source: trunk/FACT++/.macro_dir/qt4_do_it_all.m4@ 18795

Last change on this file since 18795 was 12833, checked in by tbretz, 13 years ago
Added QtSql
File size: 5.3 KB
Line 
1dnl check a particular libname
2AC_DEFUN([QT4_TRY_LINK],
3[
4 SAVE_LIBS="$LIBS"
5 LIBS="$LIBS $1"
6 AC_TRY_LINK([
7 #include <qglobal.h>
8 #include <qstring.h>
9 ],
10 [
11 QString s("mangle_failure");
12 #if (QT_VERSION < 400)
13 break_me_(\\\);
14 #endif
15 ],
16 qt4_cv_libname=$1,
17 )
18 LIBS="$SAVE_LIBS"
19])
20
21dnl check we can do a compile
22AC_DEFUN([QT4_CHECK_COMPILE],
23[
24 AC_MSG_CHECKING([for Qt 4 library name])
25
26 AC_CACHE_VAL(qt4_cv_libname,
27 [
28 AC_LANG_CPLUSPLUS
29 SAVE_CXXFLAGS=$CXXFLAGS
30 CXXFLAGS="$CXXFLAGS $QT4_INCLUDES $QT4_LDFLAGS"
31 for libname in -lQtCore -lQtCore4 '-framework QtCore'
32 do
33 QT4_TRY_LINK($libname)
34 if test -n "$qt4_cv_libname"; then
35 QT4_CORE_LIB="$qt4_cv_libname"
36 break;
37 fi
38 done
39 qt4_cv_libname=
40 for libname in '-lQtCore -lQtGui -lQtSql' \
41 '-lQtCore4 -lQtGui4 -lQtSql4' \
42 '-framework QtCore -framework QtGui -framework QtSql'
43 do
44 QT4_TRY_LINK($libname)
45 if test -n "$qt4_cv_libname"; then
46 break;
47 fi
48 done
49 CXXFLAGS=$SAVE_CXXFLAGS
50 ])
51
52 if test -z "$qt4_cv_libname"; then
53 AC_MSG_RESULT([failed])
54 if test "$FATAL" = 1 ; then
55 AC_MSG_ERROR([Cannot compile a simple Qt 4 executable. Check you have the right \$QT4DIR !])
56 fi
57 else
58 AC_MSG_RESULT([$qt4_cv_libname])
59 fi
60])
61
62dnl get Qt version we're using
63AC_DEFUN([QT4_GET_VERSION],
64[
65 AC_CACHE_CHECK([Qt 4 version],lyx_cv_qt4version,
66 [
67 AC_LANG_CPLUSPLUS
68 SAVE_CPPFLAGS=$CPPFLAGS
69 CPPFLAGS="$CPPFLAGS $QT4_INCLUDES"
70
71 cat > conftest.$ac_ext <<EOF
72#line __oline__ "configure"
73#include "confdefs.h"
74#include <qglobal.h>
75"%%%"QT_VERSION_STR"%%%"
76EOF
77 lyx_cv_qt4version=`(eval "$ac_cpp conftest.$ac_ext") 2>&5 | \
78 grep '^"%%%"' 2>/dev/null | \
79 sed -e 's/"%%%"//g' -e 's/"//g'`
80 rm -f conftest.$ac_ext
81 CPPFLAGS=$SAVE_CPPFLAGS
82 ])
83
84 QT4_VERSION=$lyx_cv_qt4version
85 AC_SUBST(QT4_VERSION)
86])
87
88dnl start here
89AC_DEFUN([QT4_DO_IT_ALL],
90[
91 dnl this variable is precious
92 AC_ARG_VAR(QT4DIR, [the place where the Qt 4 files are, e.g. /usr/lib/qt4])
93
94 dnl Please leave this alone. I use this file in
95 dnl oprofile.
96 FATAL=0
97
98 AC_ARG_WITH(qt4-dir, [AC_HELP_STRING([--with-qt4-dir], [where the root of Qt 4 is installed])],
99 [ qt4_cv_dir=`eval echo "$withval"/` ])
100
101 AC_ARG_WITH(qt4-includes, [AC_HELP_STRING([--with-qt4-includes], [where the Qt 4 includes are])],
102 [ qt4_cv_includes=`eval echo "$withval"` ])
103
104 AC_ARG_WITH(qt4-libraries, [AC_HELP_STRING([--with-qt4-libraries], [where the Qt 4 library is installed])],
105 [ qt4_cv_libraries=`eval echo "$withval"` ])
106
107 dnl pay attention to $QT4DIR unless overridden
108 if test -z "$qt4_cv_dir"; then
109 qt4_cv_dir=$QT4DIR
110 fi
111
112 dnl derive inc/lib if needed
113 if test -n "$qt4_cv_dir"; then
114 if test -z "$qt4_cv_includes"; then
115 qt4_cv_includes=$qt4_cv_dir/include
116 fi
117 if test -z "$qt4_cv_libraries"; then
118 qt4_cv_libraries=$qt4_cv_dir/lib
119 fi
120 fi
121
122 dnl compute the binary dir too
123 if test -n "$qt4_cv_dir"; then
124 qt4_cv_bin=$qt4_cv_dir/bin
125 fi
126
127 dnl Check if it possible to do a pkg-config
128 PKG_PROG_PKG_CONFIG
129 if test -n "$PKG_CONFIG" ; then
130 QT4_DO_PKG_CONFIG
131 fi
132 if test "$pkg_failed" != "no" ; then
133 QT4_DO_MANUAL_CONFIG
134 fi
135 AC_PATH_PROGS(MOC4, [moc-qt4 moc],[],$qt4_cv_bin:$PATH)
136 AC_PATH_PROGS(UIC4, [uic-qt4 uic],[],$qt4_cv_bin:$PATH)
137 AC_PATH_PROGS(RCC4, [rcc-qt4 rcc],[],$qt4_cv_bin:$PATH)
138])
139
140AC_DEFUN([QT4_DO_PKG_CONFIG],
141[
142 dnl tell pkg-config to look also in $qt4_cv_dir/lib.
143 save_PKG_CONFIG_PATH=$PKG_CONFIG_PATH
144 if test -n "$qt4_cv_dir" ; then
145 PKG_CONFIG_PATH=$qt4_cv_dir/lib:$qt4_cv_dir/lib/pkgconfig:$PKG_CONFIG_PATH
146 export PKG_CONFIG_PATH
147 fi
148 PKG_CHECK_MODULES(QT4_CORE, QtCore,,[:])
149 if test "$pkg_failed" = "no" ; then
150 QT4_CORE_INCLUDES=$QT4_CORE_CFLAGS
151 AC_SUBST(QT4_CORE_INCLUDES)
152 QT4_CORE_LDFLAGS=`$PKG_CONFIG --libs-only-L QtCore`
153 AC_SUBST(QT4_CORE_LDFLAGS)
154 QT4_CORE_LIB=`$PKG_CONFIG --libs-only-l QtCore`
155 AC_SUBST(QT4_CORE_LIB)
156 fi
157 PKG_CHECK_MODULES(QT4_FRONTEND, QtCore QtGui QtSql,,[:])
158 if test "$pkg_failed" = "no" ; then
159 QT4_INCLUDES=$QT4_FRONTEND_CFLAGS
160 dnl QT4_LDFLAGS=$QT4_FRONTEND_LIBS
161 QT4_LDFLAGS=`$PKG_CONFIG --libs-only-L QtCore QtGui QtSql`
162 AC_SUBST(QT4_INCLUDES)
163 AC_SUBST(QT4_LDFLAGS)
164 QT4_VERSION=`$PKG_CONFIG --modversion QtCore`
165 AC_SUBST(QT4_VERSION)
166 QT4_LIB=`$PKG_CONFIG --libs-only-l QtCore QtGui QtSql`
167 AC_SUBST(QT4_LIB)
168 LIBS="$LIBS `$PKG_CONFIG --libs-only-other QtCore QtGui QtSql`"
169 fi
170])
171
172AC_DEFUN([QT4_DO_MANUAL_CONFIG],
173[
174 dnl Check for X libraries
175 AC_PATH_X
176 AC_PATH_XTRA
177 case $have_x in
178 yes) LIBS="$X_PRE_LIBS $LIBS $X_LIBS -lX11 $X_EXTRA_LIBS"
179 CPPFLAGS="$CPPFLAGS $X_CFLAGS";;
180 no) AC_MSG_ERROR([Cannot find X window libraries and/or headers.]);;
181 disable) ;;
182 esac
183
184 dnl flags for compilation
185 QT4_INCLUDES=
186 QT4_LDFLAGS=
187 QT4_CORE_INCLUDES=
188 QT4_CORE_LDFLAGS=
189 if test -n "$qt4_cv_includes"; then
190 QT4_INCLUDES="-I$qt4_cv_includes"
191 for i in Qt QtCore QtGui QtSql; do
192 QT4_INCLUDES="$QT4_INCLUDES -I$qt4_cv_includes/$i"
193 done
194 QT4_CORE_INCLUDES="-I$qt4_cv_includes -I$qt4_cv_includes/QtCore"
195 fi
196 if test -n "$qt4_cv_libraries"; then
197 QT4_LDFLAGS="-L$qt4_cv_libraries"
198 QT4_CORE_LDFLAGS="-L$qt4_cv_libraries"
199 fi
200 AC_SUBST(QT4_INCLUDES)
201 AC_SUBST(QT4_CORE_INCLUDES)
202 AC_SUBST(QT4_LDFLAGS)
203 AC_SUBST(QT4_CORE_LDFLAGS)
204
205 QT4_CHECK_COMPILE
206
207 QT4_LIB=$qt4_cv_libname;
208 AC_SUBST(QT4_LIB)
209 AC_SUBST(QT4_CORE_LIB)
210
211 if test -n "$qt4_cv_libname"; then
212 QT4_GET_VERSION
213 fi
214])
Note: See TracBrowser for help on using the repository browser.