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 !])
54 dnl Find the right moc in path/qt_cv_dir
55 AC_DEFUN([QT_FIND_MOC],
57 QT_FIND_PATH(moc2, ac_moc2, $qt_cv_dir/bin)
58 QT_FIND_PATH(moc, ac_moc1, $qt_cv_dir/bin)
60 if test -n "$ac_moc1" -a -n "$ac_moc2"; then
61 dnl found both. Prefer Qt3's if it exists else moc2
62 $ac_moc1 -v 2>&1 | grep "Qt 3" >/dev/null
63 if test "$?" = 0; then
69 if test -n "$ac_moc1"; then
76 if test -z "$ac_moc" -a "$FATAL" = 1; then
77 AC_MSG_ERROR([moc binary not found in \$PATH or $qt_cv_dir/bin !])
81 dnl check a particular libname
82 AC_DEFUN([QT_TRY_LINK],
91 QString s("mangle_failure");
92 #if (QT_VERSION < 221)
101 dnl check we can do a compile
102 AC_DEFUN([QT_CHECK_COMPILE],
104 AC_MSG_CHECKING([for Qt library name])
106 AC_CACHE_VAL(qt_cv_libname,
109 SAVE_CXXFLAGS=$CXXFLAGS
110 CXXFLAGS="$CXXFLAGS $QT_INCLUDES $QT_LDFLAGS"
112 for libname in -lqt-mt -lqt-mt3 -lqt3 -lqt2 -lqt;
114 QT_TRY_LINK($libname)
115 if test -n "$qt_cv_libname"; then
120 CXXFLAGS=$SAVE_CXXFLAGS
123 if test -z "$qt_cv_libname"; then
124 AC_MSG_RESULT([failed])
125 if test "$FATAL" = 1 ; then
126 AC_MSG_ERROR([Cannot compile a simple Qt executable. Check you have the right \$QTDIR !])
129 AC_MSG_RESULT([$qt_cv_libname])
133 dnl get Qt version we're using
134 AC_DEFUN([QT_GET_VERSION],
136 AC_CACHE_CHECK([Qt version],lyx_cv_qtversion,
139 SAVE_CPPFLAGS=$CPPFLAGS
140 CPPFLAGS="$CPPFLAGS $QT_INCLUDES"
142 cat > conftest.$ac_ext <<EOF
143 #line __oline__ "configure"
144 #include "confdefs.h"
146 "%%%"QT_VERSION_STR"%%%"
148 lyx_cv_qtversion=`(eval "$ac_cpp conftest.$ac_ext") 2>&5 | \
149 grep '^"%%%"' 2>/dev/null | \
150 sed -e 's/"%%%"//g' -e 's/"//g'`
151 rm -f conftest.$ac_ext
152 CPPFLAGS=$SAVE_CPPFLAGS
155 QT_VERSION=$lyx_cv_qtversion
159 dnl Ascertain whether the Qt libraries are multi-threaded or not
160 AC_DEFUN([QT_CHECK_IS_MULTITHREADED],
162 AC_CACHE_CHECK([whether the Qt library is multi-threaded],
163 qt_cv_is_multithreaded,
166 SAVE_CXXFLAGS=$CXXFLAGS
168 CXXFLAGS="$CXXFLAGS $QT_INCLUDES $QT_LDFLAGS"
173 #define QT_THREAD_SUPPORT
174 #include <qapplication.h>
180 qt_cv_is_multithreaded=yes,
181 qt_cv_is_multithreaded=no
185 CXXFLAGS=$SAVE_CXXFLAGS
188 if test x"$qt_cv_is_multithreaded" = xyes; then
189 QT_CPPFLAGS="$QT_CPPFLAGS -DQT_THREAD_SUPPORT"
194 AC_DEFUN([QT_DO_IT_ALL],
196 dnl this variable is precious
197 AC_ARG_VAR(QTDIR, [the place where the Qt files are, e.g. /usr/lib/qt])
199 dnl Please leave this alone. I use this file in
203 AC_ARG_WITH(qt-dir, [ --with-qt-dir where the root of Qt is installed ],
204 [ qt_cv_dir=`eval echo "$withval"/` ])
206 AC_ARG_WITH(qt-includes, [ --with-qt-includes where the Qt includes are. ],
207 [ qt_cv_includes=`eval echo "$withval"` ])
209 AC_ARG_WITH(qt-libraries, [ --with-qt-libraries where the Qt library is installed.],
210 [ qt_cv_libraries=`eval echo "$withval"` ])
212 dnl pay attention to $QTDIR unless overridden
213 if test -z "$qt_cv_dir"; then
217 dnl derive inc/lib if needed
218 if test -n "$qt_cv_dir"; then
219 if test -z "$qt_cv_includes"; then
220 qt_cv_includes=$qt_cv_dir/include
222 if test -z "$qt_cv_libraries"; then
223 qt_cv_libraries=$qt_cv_dir/lib
227 dnl flags for compilation
230 if test -n "$qt_cv_includes"; then
231 QT_INCLUDES="-I$qt_cv_includes"
233 if test -n "$qt_cv_libraries"; then
234 QT_LDFLAGS="-L$qt_cv_libraries"
236 AC_SUBST(QT_INCLUDES)
239 dnl Preprocessor flags
240 QT_CPPFLAGS="-DQT_CLEAN_NAMESPACE -DQT_GENUINE_STR -DQT_NO_STL"
242 *mingw*) QT_CPPFLAGS="-DQT_DLL $QT_CPPFLAGS";;
244 AC_SUBST(QT_CPPFLAGS)
246 if test -z "$MOC"; then
251 if test -z "$UIC"; then
259 QT_LIB=$qt_cv_libname;
262 QT_CHECK_IS_MULTITHREADED
264 if test -n "$qt_cv_libname"; then