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 Check if it possible to do a pgk-config
147 if test -n "$PKG_CONFIG" ; then
154 AC_DEFUN([QT4_DO_PKG_CONFIG],
156 PKG_CHECK_MODULES(QT4_FRONTEND, QtCore QtGui)
157 if test "$pkg_failed" == "no" ; then
158 QT4_INCLUDES=$QT4_FRONTEND_CFLAGS
159 dnl QT4_LDFLAGS=$QT4_FRONTEND_LIBS
160 QT4_LDFLAGS=`$PKG_CONFIG --libs-only-L QtCore QtGui`
161 AC_SUBST(QT4_INCLUDES)
162 AC_SUBST(QT4_LDFLAGS)
163 QT4_VERSION=`$PKG_CONFIG --modversion QtCore`
164 AC_SUBST(QT4_VERSION)
165 QT4_LIB=`$PKG_CONFIG --libs-only-l QtCore QtGui`
167 QT4_CPPFLAGS="-DQT_CLEAN_NAMESPACE -DQT_GENUINE_STR -DQT_NO_STL -DQT3_SUPPORT -DQT_NO_KEYWORDS"
169 *mingw*) QT4_CPPFLAGS="-DQT_DLL $QT4_CPPFLAGS";;
171 AC_SUBST(QT4_CPPFLAGS)
172 AC_CHECK_PROGS(MOC4, moc-qt4 moc)
173 AC_CHECK_PROGS(UIC4, uic-qt4 uic)
179 AC_DEFUN([QT4_DO_MANUAL_CONFIG],
181 dnl this variable is precious
182 AC_ARG_VAR(QT4DIR, [the place where the Qt 4 files are, e.g. /usr/lib/qt4])
184 dnl Please leave this alone. I use this file in
188 AC_ARG_WITH(qt4-dir, [ --with-qt4-dir where the root of Qt 4 is installed ],
189 [ qt4_cv_dir=`eval echo "$withval"/` ])
191 AC_ARG_WITH(qt4-includes, [ --with-qt4-includes where the Qt 4 includes are. ],
192 [ qt4_cv_includes=`eval echo "$withval"` ])
194 AC_ARG_WITH(qt4-libraries, [ --with-qt4-libraries where the Qt 4 library is installed.],
195 [ qt4_cv_libraries=`eval echo "$withval"` ])
197 dnl pay attention to $QT4DIR unless overridden
198 if test -z "$qt4_cv_dir"; then
202 dnl derive inc/lib if needed
203 if test -n "$qt4_cv_dir"; then
204 if test -z "$qt4_cv_includes"; then
205 qt4_cv_includes=$qt4_cv_dir/include
207 if test -z "$qt4_cv_libraries"; then
208 qt4_cv_libraries=$qt4_cv_dir/lib
212 dnl flags for compilation
215 if test -n "$qt4_cv_includes"; then
216 QT4_INCLUDES="-I$qt4_cv_includes"
217 for i in Qt QtCore QtGui; do
218 QT4_INCLUDES="$QT4_INCLUDES -I$qt4_cv_includes/$i"
221 if test -n "$qt4_cv_libraries"; then
222 QT4_LDFLAGS="-L$qt4_cv_libraries"
224 AC_SUBST(QT4_INCLUDES)
225 AC_SUBST(QT4_LDFLAGS)
227 dnl Preprocessor flags
228 QT4_CPPFLAGS="-DQT_CLEAN_NAMESPACE -DQT_GENUINE_STR -DQT_NO_STL -DQT3_SUPPORT -DQT_NO_KEYWORDS"
230 *mingw*) QT4_CPPFLAGS="-DQT_DLL $QT4_CPPFLAGS";;
232 AC_SUBST(QT4_CPPFLAGS)
234 if test -z "$MOC4"; then
239 if test -z "$UIC4"; then
247 QT4_LIB=$qt4_cv_libname;
250 if test -n "$qt4_cv_libname"; then