1 dnl find a binary in the path
2 AC_DEFUN([QT_FIND_PATH],
4 AC_MSG_CHECKING([for $1])
5 AC_CACHE_VAL(qt_cv_path_$1,
20 if test -x "$dir/$1"; then
22 evalstr="$dir/$1 $5 2>&1 "
23 if eval $evalstr; then
24 qt_cv_path_$1="$dir/$1"
28 qt_cv_path_$1="$dir/$1"
36 if test -z "$qt_cv_path_$1" || test "$qt_cv_path_$1" = "NONE"; then
37 AC_MSG_RESULT(not found)
40 AC_MSG_RESULT($qt_cv_path_$1)
45 dnl Find the uic compiler on the path or in qt_cv_dir
46 AC_DEFUN([QT_FIND_UIC],
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 !])
52 AC_MSG_CHECKING([whether uic supports -nounload])
53 if $ac_uic --help 2>&1 | grep nounload >/dev/null ; then
55 ac_uic="$ac_uic -nounload"
61 dnl Find the right moc in path/qt_cv_dir
62 AC_DEFUN([QT_FIND_MOC],
64 QT_FIND_PATH(moc2, ac_moc2, $qt_cv_dir/bin)
65 QT_FIND_PATH(moc, ac_moc1, $qt_cv_dir/bin)
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
76 if test -n "$ac_moc1"; then
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 !])
88 dnl check a particular libname
89 AC_DEFUN([QT_TRY_LINK],
98 QString s("mangle_failure");
99 #if (QT_VERSION < 0x030000)
108 dnl check we can do a compile
109 AC_DEFUN([QT_CHECK_COMPILE],
111 AC_MSG_CHECKING([for Qt library name])
113 AC_CACHE_VAL(qt_cv_libname,
116 SAVE_CXXFLAGS=$CXXFLAGS
117 CXXFLAGS="$CXXFLAGS $QT_INCLUDES $QT_LDFLAGS"
119 for libname in -lqt-mt -lqt-mt3 -lqt3 -lqt2 -lqt;
121 QT_TRY_LINK($libname)
122 if test -n "$qt_cv_libname"; then
127 CXXFLAGS=$SAVE_CXXFLAGS
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 !])
136 AC_MSG_RESULT([$qt_cv_libname])
140 dnl get Qt version we're using
141 AC_DEFUN([QT_GET_VERSION],
143 AC_CACHE_CHECK([Qt version],lyx_cv_qtversion,
146 SAVE_CPPFLAGS=$CPPFLAGS
147 CPPFLAGS="$CPPFLAGS $QT_INCLUDES"
149 cat > conftest.$ac_ext <<EOF
150 #line __oline__ "configure"
151 #include "confdefs.h"
153 "%%%"QT_VERSION_STR"%%%"
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
162 QT_VERSION=$lyx_cv_qtversion
166 dnl Ascertain whether the Qt libraries are multi-threaded or not
167 AC_DEFUN([QT_CHECK_IS_MULTITHREADED],
169 AC_CACHE_CHECK([whether the Qt library is multi-threaded],
170 qt_cv_is_multithreaded,
173 SAVE_CXXFLAGS=$CXXFLAGS
175 CXXFLAGS="$CXXFLAGS $QT_INCLUDES $QT_LDFLAGS"
180 #define QT_THREAD_SUPPORT
181 #include <qapplication.h>
187 qt_cv_is_multithreaded=yes,
188 qt_cv_is_multithreaded=no
192 CXXFLAGS=$SAVE_CXXFLAGS
195 if test x"$qt_cv_is_multithreaded" = xyes; then
196 QT_CPPFLAGS="$QT_CPPFLAGS -DQT_THREAD_SUPPORT"
201 AC_DEFUN([QT_DO_IT_ALL],
203 dnl this variable is precious
204 AC_ARG_VAR(QTDIR, [the place where the Qt files are, e.g. /usr/lib/qt])
206 dnl Please leave this alone. I use this file in
210 AC_ARG_WITH(qt-dir, [ --with-qt-dir where the root of Qt is installed ],
211 [ qt_cv_dir=`eval echo "$withval"/` ])
213 AC_ARG_WITH(qt-includes, [ --with-qt-includes where the Qt includes are. ],
214 [ qt_cv_includes=`eval echo "$withval"` ])
216 AC_ARG_WITH(qt-libraries, [ --with-qt-libraries where the Qt library is installed.],
217 [ qt_cv_libraries=`eval echo "$withval"` ])
219 dnl pay attention to $QTDIR unless overridden
220 if test -z "$qt_cv_dir"; then
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
229 if test -z "$qt_cv_libraries"; then
230 qt_cv_libraries=$qt_cv_dir/lib
234 dnl flags for compilation
237 if test -n "$qt_cv_includes"; then
238 QT_INCLUDES="-I$qt_cv_includes"
240 if test -n "$qt_cv_libraries"; then
241 QT_LDFLAGS="-L$qt_cv_libraries"
243 AC_SUBST(QT_INCLUDES)
246 dnl Preprocessor flags
247 QT_CPPFLAGS="-DQT_CLEAN_NAMESPACE -DQT_GENUINE_STR -DQT_NO_STL"
249 *mingw*) QT_CPPFLAGS="-DQT_DLL $QT_CPPFLAGS";;
254 if test "x$with_x" = xno ; then
255 QT_CPPFLAGS="$QT_CPPFLAGS -DQ_CYGWIN_WIN"
259 AC_SUBST(QT_CPPFLAGS)
261 if test -z "$MOC"; then
266 if test -z "$UIC"; then
274 QT_LIB=$qt_cv_libname;
277 QT_CHECK_IS_MULTITHREADED
279 if test -n "$qt_cv_libname"; then
284 dnl find a binary in the path
285 AC_DEFUN([QT4_FIND_PATH],
287 AC_MSG_CHECKING([for $1])
288 AC_CACHE_VAL(qt4_cv_path_$1,
290 qt4_cv_path_$1="NONE"
291 if test -n "$$2"; then
292 qt4_cv_path_$1="$$2";
303 if test -x "$dir/$1"; then
304 if test -n "$5"; then
305 evalstr="$dir/$1 $5 2>&1 "
306 if eval $evalstr; then
307 qt4_cv_path_$1="$dir/$1"
311 qt4_cv_path_$1="$dir/$1"
319 if test -z "$qt4_cv_path_$1" || test "$qt4_cv_path_$1" = "NONE"; then
320 AC_MSG_RESULT(not found)
323 AC_MSG_RESULT($qt4_cv_path_$1)
328 dnl Find the uic compiler on the path or in qt_cv_dir
329 AC_DEFUN([QT_FIND_UIC4],
331 QT4_FIND_PATH(uic, ac_uic4, $qt4_cv_dir/bin)
333 if test -z "$ac_uic4" -a "$FATAL" = 1; then
334 AC_MSG_ERROR([uic 4 binary not found in \$PATH or $qt4_cv_dir/bin !])
338 dnl Find the right moc in path/qt_cv_dir
339 AC_DEFUN([QT_FIND_MOC4],
341 QT4_FIND_PATH(moc, ac_moc4, $qt4_cv_dir/bin)
343 if test -z "$ac_moc4" -a "$FATAL" = 1; then
344 AC_MSG_ERROR([moc 4 binary not found in \$PATH or $qt4_cv_dir/bin !])
348 dnl check a particular libname
349 AC_DEFUN([QT4_TRY_LINK],
358 QString s("mangle_failure");
359 #if (QT_VERSION < 400)
368 dnl check we can do a compile
369 AC_DEFUN([QT4_CHECK_COMPILE],
371 AC_MSG_CHECKING([for Qt 4 library name])
373 AC_CACHE_VAL(qt4_cv_libname,
376 SAVE_CXXFLAGS=$CXXFLAGS
377 CXXFLAGS="$CXXFLAGS $QT4_INCLUDES $QT4_LDFLAGS"
378 for libname in '-lQtCore -lQtGui' \
381 QT4_TRY_LINK($libname)
382 if test -n "$qt4_cv_libname"; then
386 CXXFLAGS=$SAVE_CXXFLAGS
389 if test -z "$qt4_cv_libname"; then
390 AC_MSG_RESULT([failed])
391 if test "$FATAL" = 1 ; then
392 AC_MSG_ERROR([Cannot compile a simple Qt 4 executable. Check you have the right \$QT4DIR !])
395 AC_MSG_RESULT([$qt4_cv_libname])
399 dnl get Qt version we're using
400 AC_DEFUN([QT4_GET_VERSION],
402 AC_CACHE_CHECK([Qt 4 version],lyx_cv_qt4version,
405 SAVE_CPPFLAGS=$CPPFLAGS
406 CPPFLAGS="$CPPFLAGS $QT4_INCLUDES"
408 cat > conftest.$ac_ext <<EOF
409 #line __oline__ "configure"
410 #include "confdefs.h"
412 "%%%"QT_VERSION_STR"%%%"
414 lyx_cv_qt4version=`(eval "$ac_cpp conftest.$ac_ext") 2>&5 | \
415 grep '^"%%%"' 2>/dev/null | \
416 sed -e 's/"%%%"//g' -e 's/"//g'`
417 rm -f conftest.$ac_ext
418 CPPFLAGS=$SAVE_CPPFLAGS
421 QT4_VERSION=$lyx_cv_qt4version
422 AC_SUBST(QT4_VERSION)
426 AC_DEFUN([QT4_DO_IT_ALL],
428 dnl this variable is precious
429 AC_ARG_VAR(QT4DIR, [the place where the Qt 4 files are, e.g. /usr/lib/qt4])
431 dnl Please leave this alone. I use this file in
435 AC_ARG_WITH(qt4-dir, [ --with-qt4-dir where the root of Qt 4 is installed ],
436 [ qt4_cv_dir=`eval echo "$withval"/` ])
438 AC_ARG_WITH(qt4-includes, [ --with-qt4-includes where the Qt 4 includes are. ],
439 [ qt4_cv_includes=`eval echo "$withval"` ])
441 AC_ARG_WITH(qt4-libraries, [ --with-qt4-libraries where the Qt 4 library is installed.],
442 [ qt4_cv_libraries=`eval echo "$withval"` ])
444 dnl pay attention to $QT4DIR unless overridden
445 if test -z "$qt4_cv_dir"; then
449 dnl derive inc/lib if needed
450 if test -n "$qt4_cv_dir"; then
451 if test -z "$qt4_cv_includes"; then
452 qt4_cv_includes=$qt4_cv_dir/include
454 if test -z "$qt4_cv_libraries"; then
455 qt4_cv_libraries=$qt4_cv_dir/lib
459 dnl flags for compilation
462 if test -n "$qt4_cv_includes"; then
463 QT4_INCLUDES="-I$qt4_cv_includes"
464 for i in Qt QtCore QtGui; do
465 QT4_INCLUDES="$QT4_INCLUDES -I$qt4_cv_includes/$i"
468 if test -n "$qt4_cv_libraries"; then
469 QT4_LDFLAGS="-L$qt4_cv_libraries"
471 AC_SUBST(QT4_INCLUDES)
472 AC_SUBST(QT4_LDFLAGS)
474 dnl Preprocessor flags
475 QT4_CPPFLAGS="-DQT_CLEAN_NAMESPACE -DQT_GENUINE_STR -DQT_NO_STL -DQT3_SUPPORT"
477 *mingw*) QT4_CPPFLAGS="-DQT_DLL $QT4_CPPFLAGS";;
479 AC_SUBST(QT4_CPPFLAGS)
481 if test -z "$MOC4"; then
486 if test -z "$UIC4"; then
494 QT4_LIB=$qt4_cv_libname;
497 if test -n "$qt4_cv_libname"; then