1 dnl find a binary in the path
2 AC_DEFUN([QT4_FIND_PATH],
4 AC_MSG_CHECKING([for $1])
5 AC_CACHE_VAL(qt4_cv_path_$1,
20 if test -x "$dir/$1"; then
22 evalstr="$dir/$1 $5 2>&1 "
23 if eval $evalstr; then
24 qt4_cv_path_$1="$dir/$1"
28 qt4_cv_path_$1="$dir/$1"
36 if test -z "$qt4_cv_path_$1" || test "$qt4_cv_path_$1" = "NONE"; then
37 AC_MSG_RESULT(not found)
40 AC_MSG_RESULT($qt4_cv_path_$1)
45 dnl Find the uic compiler on the path or in qt_cv_dir
46 AC_DEFUN([QT_FIND_UIC4],
48 QT4_FIND_PATH(uic, ac_uic4, $qt4_cv_dir/bin)
50 if test -z "$ac_uic4" -a "$FATAL" = 1; then
51 AC_MSG_ERROR([uic 4 binary not found in \$PATH or $qt4_cv_dir/bin !])
55 dnl Find the right moc in path/qt_cv_dir
56 AC_DEFUN([QT_FIND_MOC4],
58 QT4_FIND_PATH(moc, ac_moc4, $qt4_cv_dir/bin)
60 if test -z "$ac_moc4" -a "$FATAL" = 1; then
61 AC_MSG_ERROR([moc 4 binary not found in \$PATH or $qt4_cv_dir/bin !])
65 dnl check a particular libname
66 AC_DEFUN([QT4_TRY_LINK],
75 QString s("mangle_failure");
76 #if (QT_VERSION < 400)
85 dnl check we can do a compile
86 AC_DEFUN([QT4_CHECK_COMPILE],
88 AC_MSG_CHECKING([for Qt 4 library name])
90 AC_CACHE_VAL(qt4_cv_libname,
93 SAVE_CXXFLAGS=$CXXFLAGS
94 CXXFLAGS="$CXXFLAGS $QT4_INCLUDES $QT4_LDFLAGS"
95 for libname in '-lQtCore -lQtGui' \
98 QT4_TRY_LINK($libname)
99 if test -n "$qt4_cv_libname"; then
103 CXXFLAGS=$SAVE_CXXFLAGS
106 if test -z "$qt4_cv_libname"; then
107 AC_MSG_RESULT([failed])
108 if test "$FATAL" = 1 ; then
109 AC_MSG_ERROR([Cannot compile a simple Qt 4 executable. Check you have the right \$QT4DIR !])
112 AC_MSG_RESULT([$qt4_cv_libname])
116 dnl get Qt version we're using
117 AC_DEFUN([QT4_GET_VERSION],
119 AC_CACHE_CHECK([Qt 4 version],lyx_cv_qt4version,
122 SAVE_CPPFLAGS=$CPPFLAGS
123 CPPFLAGS="$CPPFLAGS $QT4_INCLUDES"
125 cat > conftest.$ac_ext <<EOF
126 #line __oline__ "configure"
127 #include "confdefs.h"
129 "%%%"QT_VERSION_STR"%%%"
131 lyx_cv_qt4version=`(eval "$ac_cpp conftest.$ac_ext") 2>&5 | \
132 grep '^"%%%"' 2>/dev/null | \
133 sed -e 's/"%%%"//g' -e 's/"//g'`
134 rm -f conftest.$ac_ext
135 CPPFLAGS=$SAVE_CPPFLAGS
138 QT4_VERSION=$lyx_cv_qt4version
139 AC_SUBST(QT4_VERSION)
143 AC_DEFUN([QT4_DO_IT_ALL],
145 dnl this variable is precious
146 AC_ARG_VAR(QT4DIR, [the place where the Qt 4 files are, e.g. /usr/lib/qt4])
148 dnl Please leave this alone. I use this file in
152 AC_ARG_WITH(qt4-dir, [ --with-qt4-dir where the root of Qt 4 is installed ],
153 [ qt4_cv_dir=`eval echo "$withval"/` ])
155 AC_ARG_WITH(qt4-includes, [ --with-qt4-includes where the Qt 4 includes are. ],
156 [ qt4_cv_includes=`eval echo "$withval"` ])
158 AC_ARG_WITH(qt4-libraries, [ --with-qt4-libraries where the Qt 4 library is installed.],
159 [ qt4_cv_libraries=`eval echo "$withval"` ])
161 dnl pay attention to $QT4DIR unless overridden
162 if test -z "$qt4_cv_dir"; then
166 dnl derive inc/lib if needed
167 if test -n "$qt4_cv_dir"; then
168 if test -z "$qt4_cv_includes"; then
169 qt4_cv_includes=$qt4_cv_dir/include
171 if test -z "$qt4_cv_libraries"; then
172 qt4_cv_libraries=$qt4_cv_dir/lib
176 dnl flags for compilation
179 if test -n "$qt4_cv_includes"; then
180 QT4_INCLUDES="-I$qt4_cv_includes"
181 for i in Qt QtCore QtGui; do
182 QT4_INCLUDES="$QT4_INCLUDES -I$qt4_cv_includes/$i"
185 if test -n "$qt4_cv_libraries"; then
186 QT4_LDFLAGS="-L$qt4_cv_libraries"
188 AC_SUBST(QT4_INCLUDES)
189 AC_SUBST(QT4_LDFLAGS)
191 dnl Preprocessor flags
192 QT4_CPPFLAGS="-DQT_CLEAN_NAMESPACE -DQT_GENUINE_STR -DQT_NO_STL -DQT3_SUPPORT -DQT_NO_KEYWORDS"
194 *mingw*) QT4_CPPFLAGS="-DQT_DLL $QT4_CPPFLAGS";;
196 AC_SUBST(QT4_CPPFLAGS)
198 if test -z "$MOC4"; then
203 if test -z "$UIC4"; then
211 QT4_LIB=$qt4_cv_libname;
214 if test -n "$qt4_cv_libname"; then