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;
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 -DQT_NO_EMIT"
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