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 -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
74 if test -n "$qt_cv_bin" ; then
75 AC_PATH_PROGS($1, [$2], [], $qt_cv_bin)
77 if test -z "$$1"; then
78 AC_PATH_PROGS($1, [$2-$qt_ext $2],[],$PATH)
80 if test -z "$$1"; then
81 AC_MSG_ERROR([cannot find $2 binary.])
86 dnl get Qt version we're using
87 AC_DEFUN([QT_GET_VERSION],
89 AC_CACHE_CHECK([Qt version],lyx_cv_qtversion,
92 SAVE_CPPFLAGS=$CPPFLAGS
93 CPPFLAGS="$CPPFLAGS $QT_INCLUDES"
95 cat > conftest.$ac_ext <<EOF
96 #line __oline__ "configure"
99 "%%%"QT_VERSION_STR"%%%"
101 lyx_cv_qtversion=`(eval "$ac_cpp conftest.$ac_ext") 2>&5 | \
102 grep '^"%%%"' 2>/dev/null | \
103 sed -e 's/"%%%"//g' -e 's/"//g'`
104 rm -f conftest.$ac_ext
105 CPPFLAGS=$SAVE_CPPFLAGS
108 QTLIB_VERSION=$lyx_cv_qtversion
109 AC_SUBST(QTLIB_VERSION)
113 AC_DEFUN([QT_DO_IT_ALL],
115 dnl this variable is precious
116 AC_ARG_VAR(QTDIR, [the place where the Qt files are, e.g. /usr/lib/qt4])
118 AC_ARG_WITH(qt-dir, [AC_HELP_STRING([--with-qt-dir], [where the root of Qt is installed])],
119 [ qt_cv_dir=`eval echo "$withval"/` ])
121 AC_ARG_WITH(qt-includes, [AC_HELP_STRING([--with-qt-includes], [where the Qt includes are])],
122 [ qt_cv_includes=`eval echo "$withval"` ])
124 AC_ARG_WITH(qt-libraries, [AC_HELP_STRING([--with-qt-libraries], [where the Qt library is installed])],
125 [ qt_cv_libraries=`eval echo "$withval"` ])
127 dnl pay attention to $QTDIR unless overridden
128 if test -z "$qt_cv_dir"; then
132 dnl derive inc/lib if needed
133 if test -n "$qt_cv_dir"; then
134 if test -z "$qt_cv_includes"; then
135 qt_cv_includes=$qt_cv_dir/include
137 if test -z "$qt_cv_libraries"; then
138 qt_cv_libraries=$qt_cv_dir/lib
142 dnl compute the binary dir too
143 if test -n "$qt_cv_dir"; then
144 qt_cv_bin=$qt_cv_dir/bin
147 dnl Preprocessor flags
148 QT_CPPFLAGS="-DQT_NO_STL -DQT_NO_KEYWORDS"
150 *mingw*) QT_CPPFLAGS="-DQT_DLL $QT_CPPFLAGS";;
152 AC_SUBST(QT_CPPFLAGS)
154 dnl Check if it possible to do a pkg-config
156 if test -n "$PKG_CONFIG" ; then
159 if test "$pkg_failed" != "no" ; then
163 if test -z "$QT_LIB"; then
164 AC_MSG_ERROR([cannot find qt libraries.])
168 AS_VERSION_COMPARE($QTLIB_VERSION, $1,
169 [AC_MSG_ERROR([LyX requires at least version $1 of Qt. Only version $QTLIB_VERSION has been found.])
172 if test x$USE_QT5 = xyes ; then
173 save_CPPFLAGS=$CPPFLAGS
174 AC_MSG_CHECKING([whether Qt uses the X Window system])
175 CPPFLAGS="$save_CPPFLAGS $QT_CORE_INCLUDES"
177 [#include <qconfig.h>
178 QT_QPA_DEFAULT_PLATFORM_NAME],
180 AC_DEFINE(QPA_XCB, 1, [Define if Qt uses the X Window System])],
182 CPPFLAGS=$save_CPPFLAGS
185 QT_FIND_TOOL([QT_MOC], [moc])
186 QT_FIND_TOOL([QT_UIC], [uic])
187 QT_FIND_TOOL([QT_RCC], [rcc])
190 mocqtver=`$QT_MOC -v 2>&1 | sed -e 's/.*\([[0-9]]\.[[0-9]]\.[[0-9]]\).*/\1/'`
191 if test "x$mocqtver" != "x$QTLIB_VERSION"; then
192 LYX_WARNING([The found moc compiler is for Qt $mocqtver but the Qt library version is $QTLIB_VERSION.])
196 AC_DEFUN([QT_DO_PKG_CONFIG],
198 dnl tell pkg-config to look also in $qt_cv_dir/lib.
199 save_PKG_CONFIG_PATH=$PKG_CONFIG_PATH
200 if test -n "$qt_cv_dir" ; then
201 PKG_CONFIG_PATH=$qt_cv_dir/lib:$qt_cv_dir/lib/pkgconfig:$PKG_CONFIG_PATH
202 export PKG_CONFIG_PATH
205 qt_guilibs="QtCore QtGui"
206 if test "x$USE_QT5" != "xno" ; then
207 qt_corelibs="Qt5Core"
208 qt_guilibs="Qt5Core Qt5Concurrent Qt5Gui Qt5Widgets"
209 lyx_use_winextras=false
210 PKG_CHECK_EXISTS(Qt5WinExtras, [lyx_use_winextras=true], [])
211 if $lyx_use_winextras; then
212 qt_guilibs="$qt_guilibs Qt5WinExtras"
214 lyx_use_macextras=false
215 PKG_CHECK_EXISTS(Qt5MacExtras, [lyx_use_macextras=true], [])
216 if $lyx_use_macextras; then
217 qt_guilibs="$qt_guilibs Qt5MacExtras"
220 PKG_CHECK_MODULES(QT_CORE, $qt_corelibs,,[:])
221 if test "$pkg_failed" = "no" ; then
222 QT_CORE_INCLUDES=$QT_CORE_CFLAGS
223 AC_SUBST(QT_CORE_INCLUDES)
224 QT_CORE_LDFLAGS=`$PKG_CONFIG --libs-only-L $qt_corelibs`
225 AC_SUBST(QT_CORE_LDFLAGS)
226 QT_CORE_LIB=`$PKG_CONFIG --libs-only-l $qt_corelibs`
227 AC_SUBST(QT_CORE_LIB)
229 PKG_CHECK_MODULES(QT_FRONTEND, $qt_guilibs,,[:])
230 if test "$pkg_failed" = "no" ; then
231 QT_INCLUDES=$QT_FRONTEND_CFLAGS
232 dnl QT_LDFLAGS=$QT_FRONTEND_LIBS
233 QT_LDFLAGS=`$PKG_CONFIG --libs-only-L $qt_guilibs`
234 AC_SUBST(QT_INCLUDES)
236 QTLIB_VERSION=`$PKG_CONFIG --modversion $qt_corelibs`
237 AC_SUBST(QTLIB_VERSION)
238 QT_LIB=`$PKG_CONFIG --libs-only-l $qt_guilibs`
240 dnl LIBS="$LIBS `$PKG_CONFIG --libs-only-other $qt_guilibs`"
242 PKG_CONFIG_PATH=$save_PKG_CONFIG_PATH
243 dnl Actually, the values of QT_LIB and QT_CORE_LIB can be completely
244 dnl wrong on OS X, where everything goes to --libs-only-other.
245 dnl As a quick workaround, let us assign better values. A better patch
246 dnl exists for next cycle.
247 QT_CORE_LIB=$QT_CORE_LIBS
249 QT_LIB=$QT_FRONTEND_LIBS
253 AC_DEFUN([QT_DO_MANUAL_CONFIG],
255 dnl Check for X libraries
259 yes) LIBS="$X_PRE_LIBS $LIBS $X_LIBS -lX11 $X_EXTRA_LIBS"
260 CPPFLAGS="$CPPFLAGS $X_CFLAGS";;
261 no) AC_MSG_ERROR([cannot find X window libraries and/or headers.]);;
265 dnl flags for compilation
270 if test -n "$qt_cv_includes"; then
271 QT_INCLUDES="-I$qt_cv_includes"
272 for i in Qt QtCore QtGui QtWidgets QtSvg QtConcurrent QtMacExtras; do
273 QT_INCLUDES="$QT_INCLUDES -I$qt_cv_includes/$i"
275 QT_CORE_INCLUDES="-I$qt_cv_includes -I$qt_cv_includes/QtCore"
277 case "$qt_cv_libraries" in
279 QT_LDFLAGS="-F$qt_cv_libraries"
280 QT_CORE_LDFLAGS="-F$qt_cv_libraries"
285 QT_LDFLAGS="-L$qt_cv_libraries"
286 QT_CORE_LDFLAGS="-L$qt_cv_libraries"
289 AC_SUBST(QT_INCLUDES)
290 AC_SUBST(QT_CORE_INCLUDES)
292 AC_SUBST(QT_CORE_LDFLAGS)
296 QT_LIB=$qt_cv_libname;
298 AC_SUBST(QT_CORE_LIB)
300 if test -n "$qt_cv_libname"; then