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 -lQtGui' \
34 QT4_TRY_LINK($libname)
35 if test -n "$qt4_cv_libname"; then
39 CXXFLAGS=$SAVE_CXXFLAGS
42 if test -z "$qt4_cv_libname"; then
43 AC_MSG_RESULT([failed])
44 if test "$FATAL" = 1 ; then
45 AC_MSG_ERROR([Cannot compile a simple Qt 4 executable. Check you have the right \$QT4DIR !])
48 AC_MSG_RESULT([$qt4_cv_libname])
52 dnl get Qt version we're using
53 AC_DEFUN([QT4_GET_VERSION],
55 AC_CACHE_CHECK([Qt 4 version],lyx_cv_qt4version,
58 SAVE_CPPFLAGS=$CPPFLAGS
59 CPPFLAGS="$CPPFLAGS $QT4_INCLUDES"
61 cat > conftest.$ac_ext <<EOF
62 #line __oline__ "configure"
65 "%%%"QT_VERSION_STR"%%%"
67 lyx_cv_qt4version=`(eval "$ac_cpp conftest.$ac_ext") 2>&5 | \
68 grep '^"%%%"' 2>/dev/null | \
69 sed -e 's/"%%%"//g' -e 's/"//g'`
70 rm -f conftest.$ac_ext
71 CPPFLAGS=$SAVE_CPPFLAGS
74 QT4_VERSION=$lyx_cv_qt4version
79 AC_DEFUN([QT4_DO_IT_ALL],
81 dnl this variable is precious
82 AC_ARG_VAR(QT4DIR, [the place where the Qt 4 files are, e.g. /usr/lib/qt4])
84 dnl Please leave this alone. I use this file in
88 AC_ARG_WITH(qt4-dir, [ --with-qt4-dir where the root of Qt 4 is installed ],
89 [ qt4_cv_dir=`eval echo "$withval"/` ])
91 AC_ARG_WITH(qt4-includes, [ --with-qt4-includes where the Qt 4 includes are. ],
92 [ qt4_cv_includes=`eval echo "$withval"` ])
94 AC_ARG_WITH(qt4-libraries, [ --with-qt4-libraries where the Qt 4 library is installed.],
95 [ qt4_cv_libraries=`eval echo "$withval"` ])
97 dnl pay attention to $QT4DIR unless overridden
98 if test -z "$qt4_cv_dir"; then
102 dnl derive inc/lib if needed
103 if test -n "$qt4_cv_dir"; then
104 if test -z "$qt4_cv_includes"; then
105 qt4_cv_includes=$qt4_cv_dir/include
107 if test -z "$qt4_cv_libraries"; then
108 qt4_cv_libraries=$qt4_cv_dir/lib
112 dnl compute the binary dir too
113 if test -n "$qt4_cv_dir"; then
114 qt4_cv_bin=$qt4_cv_dir/bin
117 dnl Preprocessor flags
118 QT4_CPPFLAGS="-DQT_CLEAN_NAMESPACE -DQT_GENUINE_STR -DQT_NO_STL -DQT_NO_KEYWORDS"
120 *mingw*) QT4_CPPFLAGS="-DQT_DLL $QT4_CPPFLAGS";;
122 if test "x$with_x" = xno ; then
123 QT4_CPPFLAGS="$QT4_CPPFLAGS -DQ_CYGWIN_WIN"
126 AC_SUBST(QT4_CPPFLAGS)
128 dnl Check if it possible to do a pkg-config
130 if test "$pkg_failed" != "no" ; then
133 AC_PATH_PROGS(MOC4, [moc-qt4 moc],[],$qt4_cv_bin:$PATH)
134 AC_PATH_PROGS(UIC4, [uic-qt4 uic],[],$qt4_cv_bin:$PATH)
137 AC_DEFUN([QT4_DO_PKG_CONFIG],
140 save_PKG_CONFIG_PATH=$PKG_CONFIG_PATH
141 if test -n "$qt4_cv_dir" ; then
142 PKG_CONFIG_PATH=$qt4_cv_dir/lib:$PKG_CONFIG_PATH
143 export PKG_CONFIG_PATH
145 PKG_CHECK_MODULES(QT4_FRONTEND, QtCore QtGui)
146 if test "$pkg_failed" == "no" ; then
147 QT4_INCLUDES=$QT4_FRONTEND_CFLAGS
148 dnl QT4_LDFLAGS=$QT4_FRONTEND_LIBS
149 QT4_LDFLAGS=`$PKG_CONFIG --libs-only-L QtCore QtGui`
150 AC_SUBST(QT4_INCLUDES)
151 AC_SUBST(QT4_LDFLAGS)
152 QT4_VERSION=`$PKG_CONFIG --modversion QtCore`
153 AC_SUBST(QT4_VERSION)
154 QT4_LIB=`$PKG_CONFIG --libs-only-l QtCore QtGui`
159 PKG_CONFIG_PATH=$save_PKG_CONFIG_PATH
162 AC_DEFUN([QT4_DO_MANUAL_CONFIG],
164 dnl flags for compilation
167 if test -n "$qt4_cv_includes"; then
168 QT4_INCLUDES="-I$qt4_cv_includes"
169 for i in Qt QtCore QtGui; do
170 QT4_INCLUDES="$QT4_INCLUDES -I$qt4_cv_includes/$i"
173 if test -n "$qt4_cv_libraries"; then
174 QT4_LDFLAGS="-L$qt4_cv_libraries"
176 AC_SUBST(QT4_INCLUDES)
177 AC_SUBST(QT4_LDFLAGS)
181 QT4_LIB=$qt4_cv_libname;
184 if test -n "$qt4_cv_libname"; then