comparison acinclude.m4 @ 638:e03a7d1e90b9

* Add acinclude file. Gah. This is probably the most important bit of the build system...
author Chris Cannam
date Fri, 17 Sep 2010 12:51:56 +0100
parents
children ba986753c3dd
comparison
equal deleted inserted replaced
637:465f769ccad0 638:e03a7d1e90b9
1
2 AC_DEFUN([SV_MODULE_REQUIRED],
3 [
4 SV_MODULE_MODULE=$1
5 SV_MODULE_VERSION_TEST="$2"
6 SV_MODULE_HEADER=$3
7 SV_MODULE_LIB=$4
8 SV_MODULE_FUNC=$5
9 SV_MODULE_HAVE=HAVE_$(echo $1 | tr '[a-z]' '[A-Z]')
10 SV_MODULE_FAILED=1
11 if test -z "$SV_MODULE_VERSION_TEST" ; then
12 SV_MODULE_VERSION_TEST=$SV_MODULE_MODULE
13 fi
14 if test -n "$PKG_CONFIG"; then
15 PKG_CHECK_MODULES($1,[$SV_MODULE_VERSION_TEST],[HAVES="$HAVES $SV_MODULE_HAVE";CXXFLAGS="$CXXFLAGS $$1_CFLAGS";LIBS="$LIBS $$1_LIBS";SV_MODULE_FAILED=""],[AC_MSG_NOTICE([Failed to find required module $SV_MODULE_MODULE using pkg-config, trying again by old-fashioned means])])
16 fi
17 if test -n "$SV_MODULE_FAILED"; then
18 AC_CHECK_HEADER([$SV_MODULE_HEADER],[HAVES="$HAVES $SV_MODULE_HAVE"],[AC_MSG_ERROR([Failed to find header $SV_MODULE_HEADER for required module $SV_MODULE_MODULE])])
19 if test -n "$SV_MODULE_LIB"; then
20 AC_CHECK_LIB([$SV_MODULE_LIB],[$SV_MODULE_FUNC],[LIBS="$LIBS -l$SV_MODULE_LIB"],[AC_MSG_ERROR([Failed to find library $SV_MODULE_LIB for required module $SV_MODULE_MODULE])])
21 fi
22 fi
23 ])
24
25 AC_DEFUN([SV_MODULE_OPTIONAL],
26 [
27 SV_MODULE_MODULE=$1
28 SV_MODULE_VERSION_TEST="$2"
29 SV_MODULE_HEADER=$3
30 SV_MODULE_LIB=$4
31 SV_MODULE_FUNC=$5
32 SV_MODULE_HAVE=HAVE_$(echo $1 | tr '[a-z]' '[A-Z]')
33 SV_MODULE_FAILED=1
34 if test -z "$SV_MODULE_VERSION_TEST" ; then
35 SV_MODULE_VERSION_TEST=$SV_MODULE_MODULE
36 fi
37 if test -n "$PKG_CONFIG"; then
38 PKG_CHECK_MODULES($1,[$SV_MODULE_VERSION_TEST],[HAVES="$HAVES $SV_MODULE_HAVE";SV_MODULE_FAILED=""],[AC_MSG_NOTICE([Failed to find optional module $SV_MODULE_MODULE using pkg-config, trying again by old-fashioned means])])
39 fi
40 if test -n "$SV_MODULE_FAILED"; then
41 AC_CHECK_HEADER([$SV_MODULE_HEADER],[HAVES="$HAVES $SV_MODULE_HAVE";SV_MODULE_FAILED=""],[AC_MSG_NOTICE([Failed to find header $SV_MODULE_HEADER for optional module $SV_MODULE_MODULE])])
42 if test -z "$SV_MODULE_FAILED"; then
43 if test -n "$SV_MODULE_LIB"; then
44 AC_CHECK_LIB([$SV_MODULE_LIB],[$SV_MODULE_FUNC],[LIBS="$LIBS -l$SV_MODULE_LIB"],[AC_MSG_NOTICE([Failed to find library $SV_MODULE_LIB for optional module $SV_MODULE_MODULE])])
45 fi
46 fi
47 fi
48 ])
49
50 # Check for Qt compiler flags, linker flags, and binary packages
51 AC_DEFUN([SV_CHECK_QT],
52 [
53 AC_REQUIRE([AC_PROG_CXX])
54
55 AC_MSG_CHECKING([QTDIR])
56 AC_ARG_WITH([qtdir], [ --with-qtdir=DIR Qt installation directory [default=$QTDIR]], QTDIR=$withval)
57 # Check that QTDIR is defined or that --with-qtdir given
58 if test x"$QTDIR" = x ; then
59 # some usual Qt locations
60 QT_SEARCH="/usr /opt /usr/lib/qt"
61 else
62 case "$QTDIR" in *3*)
63 AC_MSG_WARN([
64 *** The QTDIR environment variable is set to "$QTDIR".
65 This looks like it could be the location of a Qt3 installation
66 instead of the Qt4 installation we require. If configure fails,
67 please ensure QTDIR is either set correctly or not set at all.
68 ])
69 ;;
70 esac
71 QT_SEARCH=$QTDIR
72 QTDIR=""
73 fi
74 for i in $QT_SEARCH ; do
75 QT_INCLUDE_SEARCH="include/qt4 include"
76 for j in $QT_INCLUDE_SEARCH ; do
77 if test -f $i/$j/Qt/qglobal.h && test x$QTDIR = x ; then
78 QTDIR=$i
79 QT_INCLUDES=$i/$j
80 fi
81 done
82 done
83 if test x"$QTDIR" = x ; then
84 AC_MSG_ERROR([*** Failed to find Qt4 installation. QTDIR must be defined, or --with-qtdir option given])
85 fi
86 AC_MSG_RESULT([$QTDIR])
87
88 # Change backslashes in QTDIR to forward slashes to prevent escaping
89 # problems later on in the build process, mainly for Cygwin build
90 # environment using MSVC as the compiler
91 QTDIR=`echo $QTDIR | sed 's/\\\\/\\//g'`
92
93 AC_MSG_CHECKING([Qt includes])
94 # Check where includes are located
95 if test x"$QT_INCLUDES" = x ; then
96 AC_MSG_ERROR([
97 Failed to find required Qt4 headers.
98 Please ensure you have the Qt4 development files installed,
99 and if necessary set QTDIR to the location of your Qt4 installation.
100 ])
101 fi
102 AC_MSG_RESULT([$QT_INCLUDES])
103
104 # Check that qmake is in path
105 AC_CHECK_PROG(QMAKE, qmake-qt4, $QTDIR/bin/qmake-qt4,,$QTDIR/bin/)
106 if test x$QMAKE = x ; then
107 AC_CHECK_PROG(QMAKE, qmake, $QTDIR/bin/qmake,,$QTDIR/bin/)
108 if test x$QMAKE = x ; then
109 AC_CHECK_PROG(QMAKE, qmake.exe, $QTDIR/bin/qmake.exe,,$QTDIR/bin/)
110 if test x$QMAKE = x ; then
111 AC_MSG_ERROR([
112 Failed to find the required qmake-qt4 or qmake program. Please
113 ensure you have the necessary Qt4 development files installed.
114 ])
115 fi
116 fi
117 fi
118
119 # Suitable versions of qmake should print out something like:
120 #
121 # QMake version 2.01a
122 # Using Qt version 4.6.3 in /usr/lib
123 #
124 # This may be translated, so we check only for the numbers (2.x and 4.x
125 # in that order).
126 #
127 QMAKE_VERSION_OUTPUT=`$QMAKE -v`
128 case "$QMAKE_VERSION_OUTPUT" in
129 *2.*4.*) ;;
130 *) AC_MSG_WARN([
131 *** The version of qmake found in "$QMAKE" looks like it might be
132 from the wrong version of Qt (Qt4 is required). Please check
133 that this is the correct version of qmake for Qt4 builds.
134 ])
135 esac
136
137 # Check that moc is in path
138 AC_CHECK_PROG(MOC, moc-qt4, $QTDIR/bin/moc-qt4,,$QTDIR/bin/)
139 if test x$MOC = x ; then
140 AC_CHECK_PROG(MOC, moc, $QTDIR/bin/moc,,$QTDIR/bin/)
141 if test x$MOC = x ; then
142 AC_CHECK_PROG(MOC, moc.exe, $QTDIR/bin/moc.exe,,$QTDIR/bin/)
143 if test x$MOC = x ; then
144 AC_MSG_ERROR([
145 Failed to find required moc-qt4 or moc program.
146 Please ensure you have the Qt4 development files installed,
147 and if necessary set QTDIR to the location of your Qt4 installation.
148 ])
149 fi
150 fi
151 fi
152
153 # Check that uic is in path
154 AC_CHECK_PROG(UIC, uic-qt4, $QTDIR/bin/uic-qt4,,$QTDIR/bin/)
155 if test x$UIC = x ; then
156 AC_CHECK_PROG(UIC, uic, $QTDIR/bin/uic,,$QTDIR/bin/)
157 if test x$UIC = x ; then
158 AC_CHECK_PROG(UIC, uic.exe, $QTDIR/bin/uic.exe,,$QTDIR/bin/)
159 if test x$UIC = x ; then
160 AC_MSG_ERROR([
161 Failed to find required uic-qt4 or uic program.
162 Please ensure you have the Qt4 development files installed,
163 and if necessary set QTDIR to the location of your Qt4 installation.
164 ])
165 fi
166 fi
167 fi
168
169 # Check that rcc is in path
170 AC_CHECK_PROG(RCC, rcc-qt4, $QTDIR/bin/rcc-qt4,,$QTDIR/bin/)
171 if test x$RCC = x ; then
172 AC_CHECK_PROG(RCC, rcc, $QTDIR/bin/rcc,,$QTDIR/bin/)
173 if test x$RCC = x ; then
174 AC_CHECK_PROG(RCC, rcc.exe, $QTDIR/bin/rcc.exe,,$QTDIR/bin/)
175 if test x$RCC = x ; then
176 AC_MSG_ERROR([
177 Failed to find required rcc-qt4 or rcc program.
178 Please ensure you have the Qt4 development files installed,
179 and if necessary set QTDIR to the location of your Qt4 installation.
180 ])
181 fi
182 fi
183 fi
184
185 # lupdate is the Qt translation-update utility.
186 AC_CHECK_PROG(LUPDATE, lupdate-qt4, $QTDIR/bin/lupdate-qt4,,$QTDIR/bin/)
187 if test x$LUPDATE = x ; then
188 AC_CHECK_PROG(LUPDATE, lupdate, $QTDIR/bin/lupdate,,$QTDIR/bin/)
189 if test x$LUPDATE = x ; then
190 AC_CHECK_PROG(LUPDATE, lupdate.exe, $QTDIR/bin/lupdate.exe,,$QTDIR/bin/)
191 if test x$LUPDATE = x ; then
192 AC_MSG_WARN([
193 Failed to find lupdate-qt4 or lupdate program.
194 This program is not needed for a simple build,
195 but it should be part of a Qt4 development installation
196 and its absence is troubling.
197 ])
198 fi
199 fi
200 fi
201
202 # lrelease is the Qt translation-release utility.
203 AC_CHECK_PROG(LRELEASE, lrelease-qt4, $QTDIR/bin/lrelease-qt4,,$QTDIR/bin/)
204 if test x$LRELEASE = x ; then
205 AC_CHECK_PROG(LRELEASE, lrelease, $QTDIR/bin/lrelease,,$QTDIR/bin/)
206 if test x$LRELEASE = x ; then
207 AC_CHECK_PROG(LRELEASE, lrelease.exe, $QTDIR/bin/lrelease.exe,,$QTDIR/bin/)
208 if test x$LRELEASE = x ; then
209 AC_MSG_WARN([
210 Failed to find lrelease-qt4 or lrelease program.
211 This program is not needed for a simple build,
212 but it should be part of a Qt4 development installation
213 and its absence is troubling.
214 ])
215 fi
216 fi
217 fi
218
219 QT_CXXFLAGS="-I$QT_INCLUDES/QtGui -I$QT_INCLUDES/QtXml -I$QT_INCLUDES/QtNetwork -I$QT_INCLUDES/QtCore -I$QT_INCLUDES"
220
221 AC_MSG_CHECKING([QTLIBDIR])
222 AC_ARG_WITH([qtlibdir], [ --with-qtlibdir=DIR Qt library directory [default=$QTLIBDIR]], QTLIBDIR=$withval)
223 if test x"$QTLIBDIR" = x ; then
224 # bin is included because that's where Qt DLLs hide on Windows
225 # On Mandriva Qt libraries are in /usr/lib or /usr/lib64 although
226 # QTDIR is /usr/lib/qt4
227 QTLIB_SEARCH="$QTDIR/lib $QTDIR/lib64 $QTDIR/lib32 $QTDIR/bin /usr/lib /usr/lib64"
228 else
229 case "$QTLIBDIR" in *3*)
230 AC_MSG_WARN([
231 The QTLIBDIR environment variable is set to "$QTLIBDIR".
232 This looks suspiciously like the location for Qt3 libraries
233 instead of the Qt4 libraries we require. If configure fails,
234 please ensure QTLIBDIR is either set correctly or not set at all.
235 ])
236 ;;
237 esac
238 QTLIB_SEARCH="$QTLIBDIR"
239 QTDIR=""
240 fi
241 QTLIB_EXTS=".so .a .dylib 4.dll"
242 QTLIB_NEED_4=""
243 for i in $QTLIB_SEARCH ; do
244 for j in $QTLIB_EXTS ; do
245 if test -f $i/libQtGui$j && test x$QTLIBDIR = x ; then
246 QTLIBDIR=$i
247 elif test -f $i/QtGui$j && test x$QTLIBDIR = x ; then
248 QTLIBDIR=$i
249 if test x$j = x4.dll ; then
250 QTLIB_NEED_4=1
251 fi
252 fi
253 done
254 done
255 if test x"$QTLIBDIR" = x ; then
256 AC_MSG_ERROR([
257 Failed to find required Qt4 GUI link entry point (libQtGui.so or equivalent).
258 Define QTLIBDIR or use --with-qtlibdir to specify the library location.
259 ])
260 fi
261 AC_MSG_RESULT([$QTLIBDIR])
262
263 if test x$QTLIB_NEED_4 = x ; then
264 QT_LIBS="-L$QTLIBDIR -lQtGui -lQtXml -lQtNetwork -lQtCore"
265 else
266 QT_LIBS="-L$QTLIBDIR -lQtGui4 -lQtXml4 -lQtNetwork4 -lQtCore4"
267 fi
268
269 AC_MSG_CHECKING([QT_CXXFLAGS])
270 AC_MSG_RESULT([$QT_CXXFLAGS])
271 AC_MSG_CHECKING([QT_LIBS])
272 AC_MSG_RESULT([$QT_LIBS])
273
274 AC_SUBST(QT_CXXFLAGS)
275 AC_SUBST(QT_LIBS)
276
277 ])
278