]> git.lyx.org Git - features.git/blob - config/qt.m4
remove unused QtXml library
[features.git] / config / qt.m4
1 dnl find a binary in the path
2 AC_DEFUN([QT_FIND_PATH],
3 [
4         AC_MSG_CHECKING([for $1])
5         AC_CACHE_VAL(qt_cv_path_$1,
6         [
7                 qt_cv_path_$1="NONE"
8                 if test -n "$$2"; then
9                         qt_cv_path_$1="$$2";
10                 else
11                         dirs="$3"
12                         qt_save_IFS=$IFS
13                         IFS=':'
14                         for dir in $PATH; do
15                                 dirs="$dirs $dir"
16                         done
17                         IFS=$qt_save_IFS
18
19                         for dir in $dirs; do
20                                 if test -x "$dir/$1"; then
21                                         if test -n "$5"; then
22                                                 evalstr="$dir/$1 $5 2>&1 "
23                                                 if eval $evalstr; then
24                                                         qt_cv_path_$1="$dir/$1"
25                                                         break
26                                                 fi
27                                         else
28                                                 qt_cv_path_$1="$dir/$1"
29                                                 break
30                                         fi
31                                 fi
32                         done
33                 fi
34         ])
35
36         if test -z "$qt_cv_path_$1" || test "$qt_cv_path_$1" = "NONE"; then
37                 AC_MSG_RESULT(not found)
38                 $4
39         else
40                 AC_MSG_RESULT($qt_cv_path_$1)
41                 $2=$qt_cv_path_$1
42         fi
43 ])
44
45 dnl Find the uic compiler on the path or in qt_cv_dir
46 AC_DEFUN([QT_FIND_UIC],
47 [
48         QT_FIND_PATH(uic, ac_uic, $qt_cv_dir/bin)
49         if test -z "$ac_uic" -a "$FATAL" = 1; then
50                 AC_MSG_ERROR([uic binary not found in \$PATH or $qt_cv_dir/bin !])
51         fi
52         AC_MSG_CHECKING([whether uic supports -nounload])
53         if $ac_uic --help 2>&1 | grep nounload >/dev/null ; then
54                 AC_MSG_RESULT([yes])
55                 ac_uic="$ac_uic -nounload"
56         else
57                 AC_MSG_RESULT([no])
58         fi
59 ])
60
61 dnl Find the right moc in path/qt_cv_dir
62 AC_DEFUN([QT_FIND_MOC],
63 [
64         QT_FIND_PATH(moc2, ac_moc2, $qt_cv_dir/bin)
65         QT_FIND_PATH(moc, ac_moc1, $qt_cv_dir/bin)
66
67         if test -n "$ac_moc1" -a -n "$ac_moc2"; then
68                 dnl found both. Prefer Qt3's if it exists else moc2
69                 $ac_moc1 -v 2>&1 | grep "Qt 3" >/dev/null
70                 if test "$?" = 0; then
71                         ac_moc=$ac_moc1;
72                 else
73                         ac_moc=$ac_moc2;
74                 fi
75         else
76                 if test -n "$ac_moc1"; then
77                         ac_moc=$ac_moc1;
78                 else
79                         ac_moc=$ac_moc2;
80                 fi
81         fi
82
83         if test -z "$ac_moc"  -a "$FATAL" = 1; then
84                 AC_MSG_ERROR([moc binary not found in \$PATH or $qt_cv_dir/bin !])
85         fi
86 ])
87
88 dnl check a particular libname
89 AC_DEFUN([QT_TRY_LINK],
90 [
91         SAVE_LIBS="$LIBS"
92         LIBS="$LIBS $1"
93         AC_TRY_LINK([
94         #include <qglobal.h>
95         #include <qstring.h>
96                 ],
97         [
98         QString s("mangle_failure");
99         #if (QT_VERSION < 221)
100         break_me_(\\\);
101         #endif
102         ],
103         qt_cv_libname=$1,
104         )
105         LIBS="$SAVE_LIBS"
106 ])
107
108 dnl check we can do a compile
109 AC_DEFUN([QT_CHECK_COMPILE],
110 [
111         AC_MSG_CHECKING([for Qt library name])
112
113         AC_CACHE_VAL(qt_cv_libname,
114         [
115                 AC_LANG_CPLUSPLUS
116                 SAVE_CXXFLAGS=$CXXFLAGS
117                 CXXFLAGS="$CXXFLAGS $QT_INCLUDES $QT_LDFLAGS"
118
119                 for libname in -lqt-mt -lqt-mt3 -lqt3 -lqt2 -lqt;
120                 do
121                         QT_TRY_LINK($libname)
122                         if test -n "$qt_cv_libname"; then
123                                 break;
124                         fi
125                 done
126
127                 CXXFLAGS=$SAVE_CXXFLAGS
128         ])
129
130         if test -z "$qt_cv_libname"; then
131                 AC_MSG_RESULT([failed])
132                 if test "$FATAL" = 1 ; then
133                         AC_MSG_ERROR([Cannot compile a simple Qt executable. Check you have the right \$QTDIR !])
134                 fi
135         else
136                 AC_MSG_RESULT([$qt_cv_libname])
137         fi
138 ])
139
140 dnl get Qt version we're using
141 AC_DEFUN([QT_GET_VERSION],
142 [
143         AC_CACHE_CHECK([Qt version],lyx_cv_qtversion,
144         [
145                 AC_LANG_CPLUSPLUS
146                 SAVE_CPPFLAGS=$CPPFLAGS
147                 CPPFLAGS="$CPPFLAGS $QT_INCLUDES"
148
149                 cat > conftest.$ac_ext <<EOF
150 #line __oline__ "configure"
151 #include "confdefs.h"
152 #include <qglobal.h>
153 "%%%"QT_VERSION_STR"%%%"
154 EOF
155                 lyx_cv_qtversion=`(eval "$ac_cpp conftest.$ac_ext") 2>&5 | \
156                         grep '^"%%%"'  2>/dev/null | \
157                         sed -e 's/"%%%"//g' -e 's/"//g'`
158                 rm -f conftest.$ac_ext
159                 CPPFLAGS=$SAVE_CPPFLAGS
160         ])
161
162         QT_VERSION=$lyx_cv_qtversion
163         AC_SUBST(QT_VERSION)
164 ])
165
166 dnl Ascertain whether the Qt libraries are multi-threaded or not
167 AC_DEFUN([QT_CHECK_IS_MULTITHREADED],
168 [
169         AC_CACHE_CHECK([whether the Qt library is multi-threaded],
170                        qt_cv_is_multithreaded,
171         [
172                 AC_LANG_CPLUSPLUS
173                 SAVE_CXXFLAGS=$CXXFLAGS
174                 SAVE_LIBS="$LIBS"
175                 CXXFLAGS="$CXXFLAGS $QT_INCLUDES $QT_LDFLAGS"
176                 LIBS="$LIBS $QT_LIB"
177
178                 AC_TRY_LINK(
179                 [
180 #define QT_THREAD_SUPPORT
181 #include <qapplication.h>
182                 ],
183                 [
184         QApplication a(0,0);
185         a.unlock();
186                 ],
187                 qt_cv_is_multithreaded=yes,
188                 qt_cv_is_multithreaded=no
189                 )
190
191                 LIBS="$SAVE_LIBS"
192                 CXXFLAGS=$SAVE_CXXFLAGS
193         ])
194
195         if test x"$qt_cv_is_multithreaded" = xyes; then
196                 QT_CPPFLAGS="$QT_CPPFLAGS -DQT_THREAD_SUPPORT"
197         fi
198 ])
199
200 dnl start here
201 AC_DEFUN([QT_DO_IT_ALL],
202 [
203         dnl this variable is precious
204         AC_ARG_VAR(QTDIR, [the place where the Qt files are, e.g. /usr/lib/qt])
205
206         dnl Please leave this alone. I use this file in
207         dnl oprofile.
208         FATAL=0
209
210         AC_ARG_WITH(qt-dir, [  --with-qt-dir           where the root of Qt is installed ],
211                 [ qt_cv_dir=`eval echo "$withval"/` ])
212
213         AC_ARG_WITH(qt-includes, [  --with-qt-includes      where the Qt includes are. ],
214                 [ qt_cv_includes=`eval echo "$withval"` ])
215
216         AC_ARG_WITH(qt-libraries, [  --with-qt-libraries     where the Qt library is installed.],
217                 [  qt_cv_libraries=`eval echo "$withval"` ])
218
219         dnl pay attention to $QTDIR unless overridden
220         if test -z "$qt_cv_dir"; then
221                 qt_cv_dir=$QTDIR
222         fi
223
224         dnl derive inc/lib if needed
225         if test -n "$qt_cv_dir"; then
226                 if test -z "$qt_cv_includes"; then
227                         qt_cv_includes=$qt_cv_dir/include
228                 fi
229                 if test -z "$qt_cv_libraries"; then
230                         qt_cv_libraries=$qt_cv_dir/lib
231                 fi
232         fi
233
234         dnl flags for compilation
235         QT_INCLUDES=
236         QT_LDFLAGS=
237         if test -n "$qt_cv_includes"; then
238                 QT_INCLUDES="-I$qt_cv_includes"
239         fi
240         if test -n "$qt_cv_libraries"; then
241                 QT_LDFLAGS="-L$qt_cv_libraries"
242         fi
243         AC_SUBST(QT_INCLUDES)
244         AC_SUBST(QT_LDFLAGS)
245
246         dnl Preprocessor flags
247         QT_CPPFLAGS="-DQT_CLEAN_NAMESPACE -DQT_GENUINE_STR -DQT_NO_STL"
248         case ${host} in
249         *mingw*) QT_CPPFLAGS="-DQT_DLL $QT_CPPFLAGS";;
250         esac
251         AC_SUBST(QT_CPPFLAGS)
252
253         if test -z "$MOC"; then
254                 QT_FIND_MOC
255                 MOC=$ac_moc
256         fi
257         AC_SUBST(MOC)
258         if test -z "$UIC"; then
259                 QT_FIND_UIC
260                 UIC=$ac_uic
261         fi
262         AC_SUBST(UIC)
263
264         QT_CHECK_COMPILE
265
266         QT_LIB=$qt_cv_libname;
267         AC_SUBST(QT_LIB)
268
269         QT_CHECK_IS_MULTITHREADED
270
271         if test -n "$qt_cv_libname"; then
272                 QT_GET_VERSION
273         fi
274 ])
275
276 dnl find a binary in the path
277 AC_DEFUN([QT4_FIND_PATH],
278 [
279         AC_MSG_CHECKING([for $1])
280         AC_CACHE_VAL(qt4_cv_path_$1,
281         [
282                 qt4_cv_path_$1="NONE"
283                 if test -n "$$2"; then
284                         qt4_cv_path_$1="$$2";
285                 else
286                         dirs="$3"
287                         qt_save_IFS=$IFS
288                         IFS=':'
289                         for dir in $PATH; do
290                                 dirs="$dirs $dir"
291                         done
292                         IFS=$qt_save_IFS
293
294                         for dir in $dirs; do
295                                 if test -x "$dir/$1"; then
296                                         if test -n "$5"; then
297                                                 evalstr="$dir/$1 $5 2>&1 "
298                                                 if eval $evalstr; then
299                                                         qt4_cv_path_$1="$dir/$1"
300                                                         break
301                                                 fi
302                                         else
303                                                 qt4_cv_path_$1="$dir/$1"
304                                                 break
305                                         fi
306                                 fi
307                         done
308                 fi
309         ])
310
311         if test -z "$qt4_cv_path_$1" || test "$qt4_cv_path_$1" = "NONE"; then
312                 AC_MSG_RESULT(not found)
313                 $4
314         else
315                 AC_MSG_RESULT($qt4_cv_path_$1)
316                 $2=$qt4_cv_path_$1
317         fi
318 ])
319
320 dnl Find the uic compiler on the path or in qt_cv_dir
321 AC_DEFUN([QT_FIND_UIC4],
322 [
323         QT4_FIND_PATH(uic, ac_uic4, $qt4_cv_dir/bin)
324
325         if test -z "$ac_uic4" -a "$FATAL" = 1; then
326                 AC_MSG_ERROR([uic 4 binary not found in \$PATH or $qt4_cv_dir/bin !])
327         fi
328 ])
329
330 dnl Find the right moc in path/qt_cv_dir
331 AC_DEFUN([QT_FIND_MOC4],
332 [
333         QT4_FIND_PATH(moc, ac_moc4, $qt4_cv_dir/bin)
334
335         if test -z "$ac_moc4"  -a "$FATAL" = 1; then
336                 AC_MSG_ERROR([moc 4 binary not found in \$PATH or $qt4_cv_dir/bin !])
337         fi
338 ])
339
340 dnl check a particular libname
341 AC_DEFUN([QT4_TRY_LINK],
342 [
343         SAVE_LIBS="$LIBS"
344         LIBS="$LIBS $1"
345         AC_TRY_LINK([
346         #include <qglobal.h>
347         #include <qstring.h>
348                 ],
349         [
350         QString s("mangle_failure");
351         #if (QT_VERSION < 400)
352         break_me_(\\\);
353         #endif
354         ],
355         qt4_cv_libname=$1,
356         )
357         LIBS="$SAVE_LIBS"
358 ])
359
360 dnl check we can do a compile
361 AC_DEFUN([QT4_CHECK_COMPILE],
362 [
363         AC_MSG_CHECKING([for Qt 4 library name])
364
365         AC_CACHE_VAL(qt4_cv_libname,
366         [
367                 AC_LANG_CPLUSPLUS
368                 SAVE_CXXFLAGS=$CXXFLAGS
369                 CXXFLAGS="$CXXFLAGS $QT4_INCLUDES $QT4_LDFLAGS"
370                 for libname in '-lQtCore -lQtGui -lQt3Support' \
371                                '-lQtCore4 -lQtGui4 -lQt3Support4'
372                 do
373                         QT4_TRY_LINK($libname)
374                         if test -n "$qt4_cv_libname"; then
375                                 break;
376                         fi
377                 done
378                 CXXFLAGS=$SAVE_CXXFLAGS
379         ])
380
381         if test -z "$qt4_cv_libname"; then
382                 AC_MSG_RESULT([failed])
383                 if test "$FATAL" = 1 ; then
384                         AC_MSG_ERROR([Cannot compile a simple Qt 4 executable. Check you have the right \$QT4DIR !])
385                 fi
386         else
387                 AC_MSG_RESULT([$qt4_cv_libname])
388         fi
389 ])
390
391 dnl get Qt version we're using
392 AC_DEFUN([QT4_GET_VERSION],
393 [
394         AC_CACHE_CHECK([Qt 4 version],lyx_cv_qt4version,
395         [
396                 AC_LANG_CPLUSPLUS
397                 SAVE_CPPFLAGS=$CPPFLAGS
398                 CPPFLAGS="$CPPFLAGS $QT4_INCLUDES"
399
400                 cat > conftest.$ac_ext <<EOF
401 #line __oline__ "configure"
402 #include "confdefs.h"
403 #include <qglobal.h>
404 "%%%"QT_VERSION_STR"%%%"
405 EOF
406                 lyx_cv_qt4version=`(eval "$ac_cpp conftest.$ac_ext") 2>&5 | \
407                         grep '^"%%%"'  2>/dev/null | \
408                         sed -e 's/"%%%"//g' -e 's/"//g'`
409                 rm -f conftest.$ac_ext
410                 CPPFLAGS=$SAVE_CPPFLAGS
411         ])
412
413         QT4_VERSION=$lyx_cv_qt4version
414         AC_SUBST(QT4_VERSION)
415 ])
416
417 dnl start here
418 AC_DEFUN([QT4_DO_IT_ALL],
419 [
420         dnl this variable is precious
421         AC_ARG_VAR(QT4DIR, [the place where the Qt 4 files are, e.g. /usr/lib/qt4])
422
423         dnl Please leave this alone. I use this file in
424         dnl oprofile.
425         FATAL=0
426
427         AC_ARG_WITH(qt4-dir, [  --with-qt4-dir           where the root of Qt 4 is installed ],
428                 [ qt4_cv_dir=`eval echo "$withval"/` ])
429
430         AC_ARG_WITH(qt4-includes, [  --with-qt4-includes      where the Qt 4 includes are. ],
431                 [ qt4_cv_includes=`eval echo "$withval"` ])
432
433         AC_ARG_WITH(qt4-libraries, [  --with-qt4-libraries     where the Qt 4 library is installed.],
434                 [  qt4_cv_libraries=`eval echo "$withval"` ])
435
436         dnl pay attention to $QT4DIR unless overridden
437         if test -z "$qt4_cv_dir"; then
438                 qt4_cv_dir=$QT4DIR
439         fi
440
441         dnl derive inc/lib if needed
442         if test -n "$qt4_cv_dir"; then
443                 if test -z "$qt4_cv_includes"; then
444                         qt4_cv_includes=$qt4_cv_dir/include
445                 fi
446                 if test -z "$qt4_cv_libraries"; then
447                         qt4_cv_libraries=$qt4_cv_dir/lib
448                 fi
449         fi
450
451         dnl flags for compilation
452         QT4_INCLUDES=
453         QT4_LDFLAGS=
454         if test -n "$qt4_cv_includes"; then
455                 QT4_INCLUDES="-I$qt4_cv_includes"
456                 for i in Qt QtCore QtGui Qt3Support; do
457                         QT4_INCLUDES="$QT4_INCLUDES -I$qt4_cv_includes/$i"
458                 done
459         fi
460         if test -n "$qt4_cv_libraries"; then
461                 QT4_LDFLAGS="-L$qt4_cv_libraries"
462         fi
463         AC_SUBST(QT4_INCLUDES)
464         AC_SUBST(QT4_LDFLAGS)
465
466         dnl Preprocessor flags
467         QT4_CPPFLAGS="-DQT_CLEAN_NAMESPACE -DQT_GENUINE_STR -DQT_NO_STL -DQT3_SUPPORT"
468         case ${host} in
469         *mingw*) QT4_CPPFLAGS="-DQT_DLL $QT4_CPPFLAGS";;
470         esac
471         AC_SUBST(QT4_CPPFLAGS)
472
473         if test -z "$MOC4"; then
474                 QT_FIND_MOC4
475                 MOC4=$ac_moc4
476         fi
477         AC_SUBST(MOC4)
478         if test -z "$UIC4"; then
479                 QT_FIND_UIC4
480                 UIC4=$ac_uic4
481         fi
482         AC_SUBST(UIC4)
483
484         QT4_CHECK_COMPILE
485
486         QT4_LIB=$qt4_cv_libname;
487         AC_SUBST(QT4_LIB)
488
489         if test -n "$qt4_cv_libname"; then
490                 QT4_GET_VERSION
491         fi
492 ])