comparison acinclude.m4 @ 651:5ada98fb61cf

* Hugely simplify Qt search -- all we need is qmake...
author Chris Cannam
date Thu, 07 Oct 2010 17:54:08 +0100
parents ba986753c3dd
children 3270c92deacd
comparison
equal deleted inserted replaced
650:f6ed1a7a920f 651:5ada98fb61cf
45 fi 45 fi
46 fi 46 fi
47 fi 47 fi
48 ]) 48 ])
49 49
50 # Check for Qt compiler flags, linker flags, and binary packages 50 # Check for Qt. The only part of Qt we use directly is qmake.
51
51 AC_DEFUN([SV_CHECK_QT], 52 AC_DEFUN([SV_CHECK_QT],
52 [ 53 [
53 AC_REQUIRE([AC_PROG_CXX]) 54 AC_REQUIRE([AC_PROG_CXX])
54 55
55 AC_MSG_CHECKING([QTDIR]) 56 if test x$QMAKE = x ; then
56 AC_ARG_WITH([qtdir], [ --with-qtdir=DIR Qt installation directory [default=$QTDIR]], QTDIR=$withval) 57 AC_CHECK_PROG(QMAKE, qmake-qt4, $QTDIR/bin/qmake-qt4,,$QTDIR/bin/)
57 # Check that QTDIR is defined or that --with-qtdir given 58 fi
58 if test x"$QTDIR" = x ; then 59 if test x$QMAKE = x ; then
59 # some usual Qt locations 60 AC_CHECK_PROG(QMAKE, qmake, $QTDIR/bin/qmake,,$QTDIR/bin/)
60 QT_SEARCH="/usr /opt /usr/lib/qt" 61 fi
61 else 62 if test x$QMAKE = x ; then
62 case "$QTDIR" in *3*) 63 AC_CHECK_PROG(QMAKE, qmake.exe, $QTDIR/bin/qmake.exe,,$QTDIR/bin/)
63 AC_MSG_WARN([ 64 fi
64 *** The QTDIR environment variable is set to "$QTDIR". 65 if test x$QMAKE = x ; then
65 This looks like it could be the location of a Qt3 installation 66 AC_CHECK_PROG(QMAKE, qmake-qt4, qmake-qt4,,$PATH)
66 instead of the Qt4 installation we require. If configure fails, 67 fi
67 please ensure QTDIR is either set correctly or not set at all. 68 if test x$QMAKE = x ; then
69 AC_CHECK_PROG(QMAKE, qmake, qmake,,$PATH)
70 fi
71 if test x$QMAKE = x ; then
72 AC_MSG_ERROR([
73 Failed to find the required qmake-qt4 or qmake program. Please
74 ensure you have the necessary Qt4 development files installed, and
75 if necessary set QTDIR to the location of your Qt4 installation.
68 ]) 76 ])
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 77 fi
118 78
119 # Suitable versions of qmake should print out something like: 79 # Suitable versions of qmake should print out something like:
120 # 80 #
121 # QMake version 2.01a 81 # QMake version 2.01a
132 from the wrong version of Qt (Qt4 is required). Please check 92 from the wrong version of Qt (Qt4 is required). Please check
133 that this is the correct version of qmake for Qt4 builds. 93 that this is the correct version of qmake for Qt4 builds.
134 ]) 94 ])
135 esac 95 esac
136 96
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 ]) 97 ])
278 98