]> git.lyx.org Git - lyx.git/blobdiff - config/qt4.m4
Math.lyx: fix a package loading logic mistake
[lyx.git] / config / qt4.m4
index 79fbbc17ca322af17c0a75477281a9f097f7f237..58edd85198cedc9db8477b83ec3df636fd2f1d07 100644 (file)
@@ -28,7 +28,7 @@ AC_DEFUN([QT4_CHECK_COMPILE],
                AC_LANG_CPLUSPLUS
                SAVE_CXXFLAGS=$CXXFLAGS
                CXXFLAGS="$CXXFLAGS $QT4_INCLUDES $QT4_LDFLAGS"
-               for libname in -lQtCore -lQtCore4
+               for libname in -lQtCore -lQtCore4 '-framework QtCore'
                do
                        QT4_TRY_LINK($libname)
                        if test -n "$qt4_cv_libname"; then
@@ -38,7 +38,9 @@ AC_DEFUN([QT4_CHECK_COMPILE],
                done
                qt4_cv_libname=
                for libname in '-lQtCore -lQtGui' \
-                              '-lQtCore4 -lQtGui4'
+                              '-lQtCore4 -lQtGui4' \
+                              '-framework QtCore -framework QtConcurrent -framework QtWidgets -framework QtGui'\
+                              '-framework QtCore -framework QtGui'
                do
                        QT4_TRY_LINK($libname)
                        if test -n "$qt4_cv_libname"; then
@@ -50,14 +52,28 @@ AC_DEFUN([QT4_CHECK_COMPILE],
 
        if test -z "$qt4_cv_libname"; then
                AC_MSG_RESULT([failed])
-               if test "$FATAL" = 1 ; then
-                       AC_MSG_ERROR([Cannot compile a simple Qt 4 executable. Check you have the right \$QT4DIR !])
-               fi
+               AC_MSG_ERROR([cannot compile a simple Qt 4 executable. Check you have the right \$QT4DIR.])
        else
                AC_MSG_RESULT([$qt4_cv_libname])
        fi
 ])
 
+
+AC_DEFUN([QT4_FIND_TOOL],
+[
+       $1=
+       if test -n "$qt4_cv_bin" ; then
+               AC_PATH_PROGS($1, [$2], [], $qt4_cv_bin)
+       fi
+       if test -z "$$1"; then
+               AC_PATH_PROGS($1, [$2-qt4 $2],[],$PATH)
+       fi
+       if test -z "$$1"; then
+               AC_MSG_ERROR([cannot find $2 binary.])
+       fi
+])
+
+
 dnl get Qt version we're using
 AC_DEFUN([QT4_GET_VERSION],
 [
@@ -90,17 +106,13 @@ AC_DEFUN([QT4_DO_IT_ALL],
        dnl this variable is precious
        AC_ARG_VAR(QT4DIR, [the place where the Qt 4 files are, e.g. /usr/lib/qt4])
 
-       dnl Please leave this alone. I use this file in
-       dnl oprofile.
-       FATAL=0
-
-       AC_ARG_WITH(qt4-dir, [  --with-qt4-dir           where the root of Qt 4 is installed ],
+       AC_ARG_WITH(qt4-dir, [AC_HELP_STRING([--with-qt4-dir], [where the root of Qt 4 is installed])],
                [ qt4_cv_dir=`eval echo "$withval"/` ])
 
-       AC_ARG_WITH(qt4-includes, [  --with-qt4-includes      where the Qt 4 includes are. ],
+       AC_ARG_WITH(qt4-includes, [AC_HELP_STRING([--with-qt4-includes], [where the Qt 4 includes are])],
                [ qt4_cv_includes=`eval echo "$withval"` ])
 
-       AC_ARG_WITH(qt4-libraries, [  --with-qt4-libraries     where the Qt 4 library is installed.],
+       AC_ARG_WITH(qt4-libraries, [AC_HELP_STRING([--with-qt4-libraries], [where the Qt 4 library is installed])],
                [  qt4_cv_libraries=`eval echo "$withval"` ])
 
        dnl pay attention to $QT4DIR unless overridden
@@ -138,9 +150,19 @@ AC_DEFUN([QT4_DO_IT_ALL],
        if test "$pkg_failed" != "no" ; then
                QT4_DO_MANUAL_CONFIG
        fi
-       AC_PATH_PROGS(MOC4, [moc-qt4 moc],[],$qt4_cv_bin:$PATH)
-       AC_PATH_PROGS(UIC4, [uic-qt4 uic],[],$qt4_cv_bin:$PATH)
-       AC_PATH_PROGS(RCC4, [rcc-qt4 rcc],[],$qt4_cv_bin:$PATH)
+
+       if test -z "$QT4_LIB"; then
+         AC_MSG_ERROR([cannot find qt4 library.])
+       fi
+
+       dnl Check qt version
+       AS_VERSION_COMPARE($QT4_VERSION, $1,
+       [AC_MSG_ERROR([LyX requires at least version $1 of Qt. Only version $QT4_VERSION has been found.])
+       ])
+
+       QT4_FIND_TOOL([MOC4], [moc])
+       QT4_FIND_TOOL([UIC4], [uic])
+       QT4_FIND_TOOL([RCC4], [rcc])
 ])
 
 AC_DEFUN([QT4_DO_PKG_CONFIG],
@@ -171,9 +193,17 @@ AC_DEFUN([QT4_DO_PKG_CONFIG],
                AC_SUBST(QT4_VERSION)
                QT4_LIB=`$PKG_CONFIG --libs-only-l QtCore QtGui`
                AC_SUBST(QT4_LIB)
-               LIBS="$LIBS `$PKG_CONFIG --libs-only-other QtCore QtGui`"
+               dnl LIBS="$LIBS `$PKG_CONFIG --libs-only-other QtCore QtGui`"
        fi
        PKG_CONFIG_PATH=$save_PKG_CONFIG_PATH
+       dnl Actually, the values of QT4_LIB and QT4_CORE_LIB can be completely
+       dnl wrong on OS X, where everything goes to --libs-only-other.
+       dnl As a quick workaround, let us assign better values. A better patch
+       dnl exists for next cycle.
+       QT4_CORE_LIB=$QT4_CORE_LIBS
+       QT4_CORE_LDFLAGS=
+       QT4_LIB=$QT4_FRONTEND_LIBS
+       QT4_LDFLAGS=
 ])
 
 AC_DEFUN([QT4_DO_MANUAL_CONFIG],
@@ -184,7 +214,7 @@ AC_DEFUN([QT4_DO_MANUAL_CONFIG],
        case $have_x in
            yes) LIBS="$X_PRE_LIBS $LIBS $X_LIBS -lX11 $X_EXTRA_LIBS"
                 CPPFLAGS="$CPPFLAGS $X_CFLAGS";;
-            no) LYX_ERROR([Cannot find X window libraries and/or headers.]);;
+            no) AC_MSG_ERROR([cannot find X window libraries and/or headers.]);;
        disable) ;;
        esac
 
@@ -195,15 +225,23 @@ AC_DEFUN([QT4_DO_MANUAL_CONFIG],
        QT4_CORE_LDFLAGS=
        if test -n "$qt4_cv_includes"; then
                QT4_INCLUDES="-I$qt4_cv_includes"
-               for i in Qt QtCore QtGui; do
+               for i in Qt QtCore QtGui QtWidgets QtConcurrent; do
                        QT4_INCLUDES="$QT4_INCLUDES -I$qt4_cv_includes/$i"
                done
                QT4_CORE_INCLUDES="-I$qt4_cv_includes -I$qt4_cv_includes/QtCore"
        fi
-       if test -n "$qt4_cv_libraries"; then
+       case "$qt4_cv_libraries" in
+       *framework*)
+               QT4_LDFLAGS="-F$qt4_cv_libraries"
+               QT4_CORE_LDFLAGS="-F$qt4_cv_libraries"
+               ;;
+       "")
+               ;;
+       *)
                QT4_LDFLAGS="-L$qt4_cv_libraries"
                QT4_CORE_LDFLAGS="-L$qt4_cv_libraries"
-       fi
+               ;;
+       esac
        AC_SUBST(QT4_INCLUDES)
        AC_SUBST(QT4_CORE_INCLUDES)
        AC_SUBST(QT4_LDFLAGS)