1 dnl check a particular libname
2 AC_DEFUN([QT4_TRY_LINK],
11 QString s("mangle_failure");
12 #if (QT_VERSION < 400)
21 dnl check we can do a compile
22 AC_DEFUN([QT4_CHECK_COMPILE],
24 AC_MSG_CHECKING([for Qt 4 library name])
26 AC_CACHE_VAL(qt4_cv_libname,
29 SAVE_CXXFLAGS=$CXXFLAGS
30 CXXFLAGS="$CXXFLAGS $QT4_INCLUDES $QT4_LDFLAGS"
31 for libname in -lQtCore -lQtCore4
33 QT4_TRY_LINK($libname)
34 if test -n "$qt4_cv_libname"; then
35 QT4_CORE_LIB="$qt4_cv_libname"
40 for libname in '-lQtCore -lQtGui' \
43 QT4_TRY_LINK($libname)
44 if test -n "$qt4_cv_libname"; then
48 CXXFLAGS=$SAVE_CXXFLAGS
51 if test -z "$qt4_cv_libname"; then
52 AC_MSG_RESULT([failed])
53 if test "$FATAL" = 1 ; then
54 AC_MSG_ERROR([Cannot compile a simple Qt 4 executable. Check you have the right \$QT4DIR !])
57 AC_MSG_RESULT([$qt4_cv_libname])
61 dnl get Qt version we're using
62 AC_DEFUN([QT4_GET_VERSION],
64 AC_CACHE_CHECK([Qt 4 version],lyx_cv_qt4version,
67 SAVE_CPPFLAGS=$CPPFLAGS
68 CPPFLAGS="$CPPFLAGS $QT4_INCLUDES"
70 cat > conftest.$ac_ext <<EOF
71 #line __oline__ "configure"
74 "%%%"QT_VERSION_STR"%%%"
76 lyx_cv_qt4version=`(eval "$ac_cpp conftest.$ac_ext") 2>&5 | \
77 grep '^"%%%"' 2>/dev/null | \
78 sed -e 's/"%%%"//g' -e 's/"//g'`
79 rm -f conftest.$ac_ext
80 CPPFLAGS=$SAVE_CPPFLAGS
83 QT4_VERSION=$lyx_cv_qt4version
88 AC_DEFUN([QT4_DO_IT_ALL],
90 dnl this variable is precious
91 AC_ARG_VAR(QT4DIR, [the place where the Qt 4 files are, e.g. /usr/lib/qt4])
93 dnl Please leave this alone. I use this file in
97 AC_ARG_WITH(qt4-dir, [ --with-qt4-dir where the root of Qt 4 is installed ],
98 [ qt4_cv_dir=`eval echo "$withval"/` ])
100 AC_ARG_WITH(qt4-includes, [ --with-qt4-includes where the Qt 4 includes are. ],
101 [ qt4_cv_includes=`eval echo "$withval"` ])
103 AC_ARG_WITH(qt4-libraries, [ --with-qt4-libraries where the Qt 4 library is installed.],
104 [ qt4_cv_libraries=`eval echo "$withval"` ])
106 dnl pay attention to $QT4DIR unless overridden
107 if test -z "$qt4_cv_dir"; then
111 dnl derive inc/lib if needed
112 if test -n "$qt4_cv_dir"; then
113 if test -z "$qt4_cv_includes"; then
114 qt4_cv_includes=$qt4_cv_dir/include
116 if test -z "$qt4_cv_libraries"; then
117 qt4_cv_libraries=$qt4_cv_dir/lib
121 dnl compute the binary dir too
122 if test -n "$qt4_cv_dir"; then
123 qt4_cv_bin=$qt4_cv_dir/bin
126 dnl Preprocessor flags
127 QT4_CPPFLAGS="-DQT_NO_STL -DQT_NO_KEYWORDS"
129 *mingw*) QT4_CPPFLAGS="-DQT_DLL $QT4_CPPFLAGS";;
131 AC_SUBST(QT4_CPPFLAGS)
133 dnl Check if it possible to do a pkg-config
135 if test -n "$PKG_CONFIG" ; then
138 if test "$pkg_failed" != "no" ; then
141 AC_PATH_PROGS(MOC4, [moc-qt4 moc],[],$qt4_cv_bin:$PATH)
142 AC_PATH_PROGS(UIC4, [uic-qt4 uic],[],$qt4_cv_bin:$PATH)
143 AC_PATH_PROGS(RCC4, [rcc-qt4 rcc],[],$qt4_cv_bin:$PATH)
146 AC_DEFUN([QT4_DO_PKG_CONFIG],
148 dnl tell pkg-config to look also in $qt4_cv_dir/lib.
149 save_PKG_CONFIG_PATH=$PKG_CONFIG_PATH
150 if test -n "$qt4_cv_dir" ; then
151 PKG_CONFIG_PATH=$qt4_cv_dir/lib:$qt4_cv_dir/lib/pkgconfig:$PKG_CONFIG_PATH
152 export PKG_CONFIG_PATH
154 PKG_CHECK_MODULES(QT4_CORE, QtCore,,[:])
155 if test "$pkg_failed" = "no" ; then
156 QT4_CORE_INCLUDES=$QT4_CORE_CFLAGS
157 AC_SUBST(QT4_CORE_INCLUDES)
158 QT4_CORE_LDFLAGS=`$PKG_CONFIG --libs-only-L QtCore`
159 AC_SUBST(QT4_CORE_LDFLAGS)
160 QT4_CORE_LIB=`$PKG_CONFIG --libs-only-l QtCore`
161 AC_SUBST(QT4_CORE_LIB)
163 PKG_CHECK_MODULES(QT4_FRONTEND, QtCore QtGui,,[:])
164 if test "$pkg_failed" = "no" ; then
165 QT4_INCLUDES=$QT4_FRONTEND_CFLAGS
166 dnl QT4_LDFLAGS=$QT4_FRONTEND_LIBS
167 QT4_LDFLAGS=`$PKG_CONFIG --libs-only-L QtCore QtGui`
168 AC_SUBST(QT4_INCLUDES)
169 AC_SUBST(QT4_LDFLAGS)
170 QT4_VERSION=`$PKG_CONFIG --modversion QtCore`
171 AC_SUBST(QT4_VERSION)
172 QT4_LIB=`$PKG_CONFIG --libs-only-l QtCore QtGui`
174 LIBS="$LIBS `$PKG_CONFIG --libs-only-other QtCore QtGui`"
176 PKG_CONFIG_PATH=$save_PKG_CONFIG_PATH
179 AC_DEFUN([QT4_DO_MANUAL_CONFIG],
181 dnl Check for X libraries
185 yes) LIBS="$X_PRE_LIBS $LIBS $X_LIBS -lX11 $X_EXTRA_LIBS"
186 CPPFLAGS="$CPPFLAGS $X_CFLAGS";;
187 no) LYX_ERROR([Cannot find X window libraries and/or headers.]);;
191 dnl flags for compilation
196 if test -n "$qt4_cv_includes"; then
197 QT4_INCLUDES="-I$qt4_cv_includes"
198 for i in Qt QtCore QtGui; do
199 QT4_INCLUDES="$QT4_INCLUDES -I$qt4_cv_includes/$i"
201 QT4_CORE_INCLUDES="-I$qt4_cv_includes -I$qt4_cv_includes/QtCore"
203 if test -n "$qt4_cv_libraries"; then
204 QT4_LDFLAGS="-L$qt4_cv_libraries"
205 QT4_CORE_LDFLAGS="-L$qt4_cv_libraries"
207 AC_SUBST(QT4_INCLUDES)
208 AC_SUBST(QT4_CORE_INCLUDES)
209 AC_SUBST(QT4_LDFLAGS)
210 AC_SUBST(QT4_CORE_LDFLAGS)
214 QT4_LIB=$qt4_cv_libname;
216 AC_SUBST(QT4_CORE_LIB)
218 if test -n "$qt4_cv_libname"; then