1 dnl check a particular libname
2 AC_DEFUN([QT_TRY_LINK],
11 QString s("mangle_failure");
12 #if (QT_VERSION < 400)
21 dnl check we can do a compile
22 AC_DEFUN([QT_CHECK_COMPILE],
24 AC_MSG_CHECKING([for Qt library name])
26 AC_CACHE_VAL(qt_cv_libname,
29 SAVE_CXXFLAGS=$CXXFLAGS
30 CXXFLAGS="$CXXFLAGS $QT_INCLUDES $QT_LDFLAGS"
31 qt_corelibs="-lQtCore -lQtCore4"
32 qt_guilibs="'-lQtCore -lQtGui' '-lQtCore4 -lQtGui4'"
33 if test $USE_QT5 = "yes" ; then
34 qt_corelibs="-lQt5Core"
35 qt_guilibs="-lQt5Core -lQt5Concurrent -lQt5Gui -lQt5Svg -lQt5Widgets"
37 for libname in $qt_corelibs '-framework QtCore'
40 if test -n "$qt_cv_libname"; then
41 QT_CORE_LIB="$qt_cv_libname"
46 for libname in $qt_guilibs \
47 '-framework QtCore -framework QtConcurrent -framework QtSvg -framework QtWidgets -framework QtMacExtras -framework QtGui'\
48 '-framework QtCore -framework QtGui'
51 if test -n "$qt_cv_libname"; then
55 CXXFLAGS=$SAVE_CXXFLAGS
58 if test -z "$qt_cv_libname"; then
59 AC_MSG_RESULT([failed])
60 AC_MSG_ERROR([cannot compile a simple Qt executable. Check you have the right \$QTDIR.])
62 AC_MSG_RESULT([$qt_cv_libname])
67 AC_DEFUN([QT_FIND_TOOL],
71 if test "x$USE_QT5" != "xno" ; then
75 if test -n "$qt_cv_bin" ; then
76 AC_PATH_PROGS($1, [$2], [], $qt_cv_bin)
77 elif qtchooser -l 2>/dev/null | grep -q ^$qt_ext\$ >/dev/null ; then
78 AC_PATH_PROG(qtc_path, qtchooser, [], [$PATH])
79 AC_PATH_PROG($2_path, $2, [], [$PATH])
80 qtc_path=`dirname "$qtc_path"`
81 $2_path=`dirname "$$2_path"`
82 if test "$qtc_path" = "$$2_path" ; then
83 AC_CHECK_PROG($1, $2, [$2 -qt=$qt_ext],, [$PATH])
86 if test -z "$$1"; then
87 AC_CHECK_PROGS($1, [$2-$qt_ext $2],[],$PATH)
89 if test -z "$$1"; then
90 AC_MSG_ERROR([cannot find $2 binary.])
95 dnl get Qt version we're using
96 AC_DEFUN([QT_GET_VERSION],
98 AC_CACHE_CHECK([Qt version],lyx_cv_qtversion,
101 SAVE_CPPFLAGS=$CPPFLAGS
102 CPPFLAGS="$CPPFLAGS $QT_INCLUDES"
104 cat > conftest.$ac_ext <<EOF
105 #line __oline__ "configure"
106 #include "confdefs.h"
108 "%%%"QT_VERSION_STR"%%%"
110 lyx_cv_qtversion=`(eval "$ac_cpp conftest.$ac_ext") 2>&5 | \
111 grep '^"%%%"' 2>/dev/null | \
112 sed -e 's/"%%%"//g' -e 's/"//g'`
113 rm -f conftest.$ac_ext
114 CPPFLAGS=$SAVE_CPPFLAGS
117 QTLIB_VERSION=$lyx_cv_qtversion
118 AC_SUBST(QTLIB_VERSION)
122 AC_DEFUN([QT_DO_IT_ALL],
124 dnl this variable is precious
125 AC_ARG_VAR(QTDIR, [the place where the Qt files are, e.g. /usr/lib/qt4])
127 AC_ARG_WITH(qt-dir, [AC_HELP_STRING([--with-qt-dir], [where the root of Qt is installed])],
128 [ qt_cv_dir=`eval echo "$withval"/` ])
130 AC_ARG_WITH(qt-includes, [AC_HELP_STRING([--with-qt-includes], [where the Qt includes are])],
131 [ qt_cv_includes=`eval echo "$withval"` ])
133 AC_ARG_WITH(qt-libraries, [AC_HELP_STRING([--with-qt-libraries], [where the Qt library is installed])],
134 [ qt_cv_libraries=`eval echo "$withval"` ])
136 dnl pay attention to $QTDIR unless overridden
137 if test -z "$qt_cv_dir"; then
141 dnl derive inc/lib if needed
142 if test -n "$qt_cv_dir"; then
143 if test -z "$qt_cv_includes"; then
144 qt_cv_includes=$qt_cv_dir/include
146 if test -z "$qt_cv_libraries"; then
147 qt_cv_libraries=$qt_cv_dir/lib
151 dnl compute the binary dir too
152 if test -n "$qt_cv_dir"; then
153 qt_cv_bin=$qt_cv_dir/bin
156 dnl Preprocessor flags
157 QT_CPPFLAGS="-DQT_NO_STL -DQT_NO_KEYWORDS"
159 *mingw*) QT_CPPFLAGS="-DQT_DLL $QT_CPPFLAGS";;
161 AC_SUBST(QT_CPPFLAGS)
163 dnl Check if it possible to do a pkg-config
165 if test -n "$PKG_CONFIG" ; then
168 if test "$pkg_failed" != "no" ; then
172 if test -z "$QT_LIB"; then
173 AC_MSG_ERROR([cannot find qt libraries.])
177 AS_VERSION_COMPARE($QTLIB_VERSION, $1,
178 [AC_MSG_ERROR([LyX requires at least version $1 of Qt. Only version $QTLIB_VERSION has been found.])
181 save_CPPFLAGS=$CPPFLAGS
182 CPPFLAGS="$save_CPPFLAGS $QT_CORE_INCLUDES"
183 AC_CHECK_HEADER(QtGui/qtgui-config.h,
184 [lyx_qt5_config=QtGui/qtgui-config.h],
185 [lyx_qt5_config=qconfig.h],[-])
186 AC_MSG_CHECKING([whether Qt uses the X Window system])
187 if test x$USE_QT5 = xyes ; then
189 [#include <$lyx_qt5_config>
190 QT_QPA_DEFAULT_PLATFORM_NAME],
192 AC_DEFINE(QPA_XCB, 1, [Define if Qt uses the X Window System])],
195 AC_PREPROC_IFELSE([AC_LANG_SOURCE([
196 [#include <qglobal.h>],
202 AC_MSG_RESULT($qt_use_x11)
203 if test "x$qt_use_x11" = "xyes"; then
204 QT_LIB="$QT_LIB -lX11"
207 CPPFLAGS=$save_CPPFLAGS
209 QT_FIND_TOOL([QT_MOC], [moc])
210 QT_FIND_TOOL([QT_UIC], [uic])
211 QT_FIND_TOOL([QT_RCC], [rcc])
214 mocqtver=`$QT_MOC -v 2>&1 | sed -e 's/.*\([[0-9]]\.[[0-9]]\.[[0-9]]\).*/\1/'`
215 if test "x$mocqtver" != "x$QTLIB_VERSION"; then
216 LYX_WARNING([The found moc compiler is for Qt $mocqtver but the Qt library version is $QTLIB_VERSION.])
220 AC_DEFUN([QT_DO_PKG_CONFIG],
222 dnl tell pkg-config to look also in $qt_cv_dir/lib.
223 save_PKG_CONFIG_PATH=$PKG_CONFIG_PATH
224 if test -n "$qt_cv_dir" ; then
225 PKG_CONFIG_PATH=$qt_cv_dir/lib:$qt_cv_dir/lib/pkgconfig:$PKG_CONFIG_PATH
226 export PKG_CONFIG_PATH
229 qt_guilibs="QtCore QtGui QtSvg"
230 if test "x$USE_QT5" != "xno" ; then
231 qt_corelibs="Qt5Core"
232 qt_guilibs="Qt5Core Qt5Concurrent Qt5Gui Qt5Svg Qt5Widgets"
233 lyx_use_x11extras=false
234 PKG_CHECK_EXISTS(Qt5X11Extras, [lyx_use_x11extras=true], [])
235 if $lyx_use_x11extras; then
236 qt_guilibs="$qt_guilibs Qt5X11Extras xcb"
237 AC_DEFINE(HAVE_QT5_X11_EXTRAS, 1,
238 [Define if you have the Qt5X11Extras module])
240 lyx_use_winextras=false
241 PKG_CHECK_EXISTS(Qt5WinExtras, [lyx_use_winextras=true], [])
242 if $lyx_use_winextras; then
243 qt_guilibs="$qt_guilibs Qt5WinExtras"
245 lyx_use_macextras=false
246 PKG_CHECK_EXISTS(Qt5MacExtras, [lyx_use_macextras=true], [])
247 if $lyx_use_macextras; then
248 qt_guilibs="$qt_guilibs Qt5MacExtras"
251 PKG_CHECK_MODULES(QT_CORE, $qt_corelibs,,[:])
252 if test "$pkg_failed" = "no" ; then
253 QT_CORE_INCLUDES=$QT_CORE_CFLAGS
254 AC_SUBST(QT_CORE_INCLUDES)
255 QT_CORE_LDFLAGS=`$PKG_CONFIG --libs-only-L $qt_corelibs`
256 AC_SUBST(QT_CORE_LDFLAGS)
257 QT_CORE_LIB=`$PKG_CONFIG --libs-only-l $qt_corelibs`
258 AC_SUBST(QT_CORE_LIB)
260 PKG_CHECK_MODULES(QT_FRONTEND, $qt_guilibs,,[:])
261 if test "$pkg_failed" = "no" ; then
262 QT_INCLUDES=$QT_FRONTEND_CFLAGS
263 dnl QT_LDFLAGS=$QT_FRONTEND_LIBS
264 QT_LDFLAGS=`$PKG_CONFIG --libs-only-L $qt_guilibs`
265 AC_SUBST(QT_INCLUDES)
267 QTLIB_VERSION=`$PKG_CONFIG --modversion $qt_corelibs`
268 AC_SUBST(QTLIB_VERSION)
269 QT_LIB=`$PKG_CONFIG --libs-only-l $qt_guilibs`
271 dnl LIBS="$LIBS `$PKG_CONFIG --libs-only-other $qt_guilibs`"
273 PKG_CONFIG_PATH=$save_PKG_CONFIG_PATH
274 dnl Actually, the values of QT_LIB and QT_CORE_LIB can be completely
275 dnl wrong on OS X, where everything goes to --libs-only-other.
276 dnl As a quick workaround, let us assign better values. A better patch
277 dnl exists for next cycle.
278 QT_CORE_LIB=$QT_CORE_LIBS
280 QT_LIB=$QT_FRONTEND_LIBS
284 AC_DEFUN([QT_DO_MANUAL_CONFIG],
286 dnl Check for X libraries
295 yes) LIBS="$X_PRE_LIBS $LIBS $X_LIBS -lX11 $X_EXTRA_LIBS"
296 CPPFLAGS="$CPPFLAGS $X_CFLAGS";;
297 no) AC_MSG_ERROR([cannot find X window libraries and/or headers.]);;
301 dnl flags for compilation
306 if test -n "$qt_cv_includes"; then
307 QT_INCLUDES="-I$qt_cv_includes"
308 for i in Qt QtCore QtGui QtWidgets QtSvg QtConcurrent QtMacExtras; do
309 QT_INCLUDES="$QT_INCLUDES -I$qt_cv_includes/$i"
311 QT_CORE_INCLUDES="-I$qt_cv_includes -I$qt_cv_includes/QtCore"
313 case "$qt_cv_libraries" in
315 QT_LDFLAGS="-F$qt_cv_libraries"
316 QT_CORE_LDFLAGS="-F$qt_cv_libraries"
321 QT_LDFLAGS="-L$qt_cv_libraries"
322 QT_CORE_LDFLAGS="-L$qt_cv_libraries"
325 AC_SUBST(QT_INCLUDES)
326 AC_SUBST(QT_CORE_INCLUDES)
328 AC_SUBST(QT_CORE_LDFLAGS)
332 QT_LIB=$qt_cv_libname;
334 AC_SUBST(QT_CORE_LIB)
336 if test -n "$qt_cv_libname"; then