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 < 221)
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";;
251 AC_SUBST(QT_CPPFLAGS)
253 if test -z "$MOC"; then
258 if test -z "$UIC"; then
266 QT_LIB=$qt_cv_libname;
269 QT_CHECK_IS_MULTITHREADED
271 if test -n "$qt_cv_libname"; then
276 dnl find a binary in the path
277 AC_DEFUN([QT4_FIND_PATH],
279 AC_MSG_CHECKING([for $1])
280 AC_CACHE_VAL(qt4_cv_path_$1,
282 qt4_cv_path_$1="NONE"
283 if test -n "$$2"; then
284 qt4_cv_path_$1="$$2";
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"
303 qt4_cv_path_$1="$dir/$1"
311 if test -z "$qt4_cv_path_$1" || test "$qt4_cv_path_$1" = "NONE"; then
312 AC_MSG_RESULT(not found)
315 AC_MSG_RESULT($qt4_cv_path_$1)
320 dnl Find the uic compiler on the path or in qt_cv_dir
321 AC_DEFUN([QT_FIND_UIC4],
323 QT4_FIND_PATH(uic, ac_uic4, $qt4_cv_dir/bin)
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 !])
330 dnl Find the right moc in path/qt_cv_dir
331 AC_DEFUN([QT_FIND_MOC4],
333 QT4_FIND_PATH(moc, ac_moc4, $qt4_cv_dir/bin)
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 !])
340 dnl check a particular libname
341 AC_DEFUN([QT4_TRY_LINK],
350 QString s("mangle_failure");
351 #if (QT_VERSION < 400)
360 dnl check we can do a compile
361 AC_DEFUN([QT4_CHECK_COMPILE],
363 AC_MSG_CHECKING([for Qt 4 library name])
365 AC_CACHE_VAL(qt4_cv_libname,
368 SAVE_CXXFLAGS=$CXXFLAGS
369 CXXFLAGS="$CXXFLAGS $QT4_INCLUDES $QT4_LDFLAGS"
370 for libname in '-lQtCore -lQtGui -lQt3Support' \
371 '-lQtCore4 -lQtGui4 -lQt3Support4'
373 QT4_TRY_LINK($libname)
374 if test -n "$qt4_cv_libname"; then
378 CXXFLAGS=$SAVE_CXXFLAGS
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 !])
387 AC_MSG_RESULT([$qt4_cv_libname])
391 dnl get Qt version we're using
392 AC_DEFUN([QT4_GET_VERSION],
394 AC_CACHE_CHECK([Qt 4 version],lyx_cv_qt4version,
397 SAVE_CPPFLAGS=$CPPFLAGS
398 CPPFLAGS="$CPPFLAGS $QT4_INCLUDES"
400 cat > conftest.$ac_ext <<EOF
401 #line __oline__ "configure"
402 #include "confdefs.h"
404 "%%%"QT_VERSION_STR"%%%"
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
413 QT4_VERSION=$lyx_cv_qt4version
414 AC_SUBST(QT4_VERSION)
418 AC_DEFUN([QT4_DO_IT_ALL],
420 dnl this variable is precious
421 AC_ARG_VAR(QT4DIR, [the place where the Qt 4 files are, e.g. /usr/lib/qt4])
423 dnl Please leave this alone. I use this file in
427 AC_ARG_WITH(qt4-dir, [ --with-qt4-dir where the root of Qt 4 is installed ],
428 [ qt4_cv_dir=`eval echo "$withval"/` ])
430 AC_ARG_WITH(qt4-includes, [ --with-qt4-includes where the Qt 4 includes are. ],
431 [ qt4_cv_includes=`eval echo "$withval"` ])
433 AC_ARG_WITH(qt4-libraries, [ --with-qt4-libraries where the Qt 4 library is installed.],
434 [ qt4_cv_libraries=`eval echo "$withval"` ])
436 dnl pay attention to $QT4DIR unless overridden
437 if test -z "$qt4_cv_dir"; then
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
446 if test -z "$qt4_cv_libraries"; then
447 qt4_cv_libraries=$qt4_cv_dir/lib
451 dnl flags for compilation
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"
460 if test -n "$qt4_cv_libraries"; then
461 QT4_LDFLAGS="-L$qt4_cv_libraries"
463 AC_SUBST(QT4_INCLUDES)
464 AC_SUBST(QT4_LDFLAGS)
466 dnl Preprocessor flags
467 QT4_CPPFLAGS="-DQT_CLEAN_NAMESPACE -DQT_GENUINE_STR -DQT_NO_STL -DQT3_SUPPORT"
469 *mingw*) QT4_CPPFLAGS="-DQT_DLL $QT4_CPPFLAGS";;
471 AC_SUBST(QT4_CPPFLAGS)
473 if test -z "$MOC4"; then
478 if test -z "$UIC4"; then
486 QT4_LIB=$qt4_cv_libname;
489 if test -n "$qt4_cv_libname"; then