1# $Id$
2# (c) 2010 Martin Preuss<martin@libchipcard.de>
3# These functions search for QT4
4
5
6AC_DEFUN([AQ_CHECK_QT4],[
7dnl PREREQUISITES:
8dnl   AQ_CHECK_OS must be called before this
9dnl IN:
10dnl    nothing
11dnl OUT:
12dnl   Variables:
13dnl     have_qt4 - set to "yes" if QT4 exists
14dnl     qt4_includes - path to includes
15dnl     qt4_libs - path to libraries
16dnl     qt4_uic - name and path of the uic tool
17dnl     qt4_moc - name and path of the moc tool
18dnl   Defines:
19dnl     HAVE_QT4
20
21dnl paths for qt4 includes
22AC_MSG_CHECKING(for qt4 includes)
23AC_ARG_WITH(qt4-includes,
24  [  --with-qt4-includes=DIR      uses qt4 includes from given dir],
25  [local_qt4_includes="$withval"],
26  [local_qt4_includes="\
27  	$QTDIR/include \
28        /usr/include/qt4 \
29        /usr/local/include/qt4 \
30        /usr/lib/qt4/include \
31        /usr/local/lib/qt4/include \
32        /opt/qt4/include \
33        /usr/include/qt \
34        /usr/local/include/qt \
35        /usr/lib/qt/include \
36        /usr/local/lib/qt/include \
37        /usr/include \
38        /usr/local/include \
39        /opt/qt/include \
40        /usr/X11R6/include \
41        "
42  ]
43)
44
45if test -z "$qt4_includes"; then
46    for i in $local_qt4_includes; do
47        if test -z "$qt4_includes"; then
48            qglobalh_paths="Qt QtCore"
49            for q in $qglobalh_paths; do
50                if test -f "$i/$q/qglobal.h"; then
51                    lv1=`grep -h "#define QT_VERSION_STR" $i/$q/qglobal.h`
52                    case $lv1 in
53                    *4.*)
54                        qt4_includes="-I$i -I$i/Qt -I$i/QtCore -I$i/QtGui"
55                        qt4_dir=`echo $i | ${SED} 's-/include.*--'`
56                        break;
57                        ;;
58                    esac
59                fi
60            done
61        fi
62    done
63fi
64if test -n "$qt4_includes"; then
65	AC_MSG_RESULT($qt4_includes)
66else
67	AC_MSG_RESULT(not found)
68fi
69
70
71
72# Check for x86_64 architecture; potentially set lib-directory suffix
73if test "$target_cpu" = "x86_64"; then
74  libdirsuffix="64"
75else
76  libdirsuffix=""
77fi
78
79dnl paths for qt4 libs
80AC_MSG_CHECKING(for qt4 libraries)
81AC_ARG_WITH(qt4-libs,
82  [  --with-qt4-libs=DIR      uses qt4 libs from given dir],
83  [local_qt4_libs="$withval"],
84  [local_qt4_libs="\
85        $qt4_dir/lib${libdirsuffix} \
86  	$QTDIR/lib${libdirsuffix} \
87	$DEBIAN_MULTIARCH_DIRS \
88        /usr/lib/qt4 \
89        /usr/local/lib/qt4 \
90        /usr/lib/qt4/lib${libdirsuffix} \
91        /usr/local/lib/qt4/lib${libdirsuffix} \
92        /opt/qt4/lib${libdirsuffix} \
93        /usr/lib/qt \
94        /usr/local/lib/qt \
95        /usr/lib/qt/lib${libdirsuffix} \
96        /usr/local/lib/qt/lib${libdirsuffix} \
97        /usr/lib${libdirsuffix} \
98        /usr/lib${libdirsuffix}/qt4/lib \
99        /usr/lib${libdirsuffix}/qt-4.5/lib \
100        /usr/lib${libdirsuffix}/qt-4.6/lib \
101        /usr/local/lib${libdirsuffix} \
102        /opt/qt/lib${libdirsuffix} \
103        /usr/X11R6/lib${libdirsuffix} \
104        "
105  ]
106)
107
108# Determine the extension of a shared library; the variable
109# std_shrext comes from the AC_PROG_LIBTOOL macro. Copied from
110# libtool.
111
112# Shared library suffix. On linux this was set as
113# shrext_cmds='.so'; but on darwin it is actually a text command.
114eval std_shrext=\"$shrext_cmds\"
115if test -z "${std_shrext}"; then
116   std_shrext='.so'
117fi
118
119qt_libname="QtGui"
120
121# This is the name of the qt library to search for.
122if test "x$OSYSTEM" = "xosx"; then
123   qt_searchname="lib${qt_libname}.4.dylib"
124elif test "x$host" = "xi686-w64-mingw32" || test "x$host" = "xx86_64-w64-mingw32"; then
125   qt_searchname="lib${qt_libname}4${std_shrext}.a"
126else
127   qt_searchname="lib${qt_libname}${std_shrext}.4"
128fi
129
130
131if test -z "$qt4_libs"; then
132   AQ_SEARCH_FOR_PATH([$qt_searchname],[$local_qt4_libs])
133   if test -n "$found_dir" ; then
134     if test "x$host" = "xi686-w64-mingw32" || test "x$host" = "xx86_64-w64-mingw32"; then
135       qt4_libs="-L$found_dir -l${qt_libname}4 -lQtCore4 -no-undefined"
136     else
137     qt4_libs="-L$found_dir -l${qt_libname} -lQtCore"
138   fi
139   fi
140fi
141
142if test -n "$qt4_libs"; then
143	AC_MSG_RESULT($qt4_libs)
144else
145	AC_MSG_RESULT(not found)
146fi
147
148
149dnl paths for qt4 moc
150AC_MSG_CHECKING(for qt4 moc)
151if test -z "$qt4_moc"; then
152  AC_ARG_WITH(qt4-moc,
153    [  --with-qt4-moc=FILE      uses the given qt4 moc],
154    [qt4_moc="$withval"],
155    [qt4_moc=""]
156  )
157fi
158
159if test -z "$qt4_moc"; then
160  searchdir="\
161    $qt4_dir/bin \
162    $QTDIR/bin \
163    /usr/lib/qt4/bin \
164    /usr/local/lib/qt4/bin \
165    /opt/qt4/bin \
166    /usr/lib/qt/bin \
167    /usr/local/lib/qt/bin \
168    /usr/bin \
169    /usr/local/bin \
170    /opt/qt/bin \
171    /usr/X11R6/bin \
172    "
173
174# search for "moc-qt4"
175  for f in $searchdir; do
176    if test -x $f/moc-qt4; then
177      qt4_moc="$f/moc-qt4"
178      break
179    fi
180  done
181
182# fall back to "moc"
183  if test -z "$qt4_moc"; then
184    for f in $searchdir; do
185      if test -x $f/moc; then
186        qt4_moc="$f/moc"
187        break
188      fi
189    done
190  fi
191fi
192
193if test -n "$qt4_moc"; then
194      AC_MSG_RESULT($qt4_moc)
195else
196      AC_MSG_RESULT(not found)
197fi
198
199
200
201dnl paths for qt4 uic
202AC_MSG_CHECKING(for qt4 uic)
203if test -z "$qt4_uic"; then
204  AC_ARG_WITH(qt4-uic,
205    [  --with-qt4-uic=FILE      uses the given qt4 uic],
206    [qt4_uic="$withval"],
207    [qt4_uic=""]
208  )
209
210  searchdir="\
211    $qt4_dir/bin \
212    $QTDIR/bin \
213    /usr/lib/qt4/bin \
214    /usr/local/lib/qt4/bin \
215    /opt/qt4/bin \
216    /usr/lib/qt/bin \
217    /usr/local/lib/qt/bin \
218    /usr/bin \
219    /usr/local/bin \
220    /opt/qt/bin \
221    /usr/X11R6/bin \
222    "
223
224# search for "uic-qt4"
225  for f in $searchdir; do
226    if test -x $f/uic-qt4; then
227      qt4_uic="$f/uic-qt4"
228      break
229    fi
230  done
231
232# fall back to "uic"
233  if test -z "$qt4_uic"; then
234    for f in $searchdir; do
235      if test -x $f/uic; then
236        qt4_uic="$f/uic"
237        break
238      fi
239    done
240  fi
241fi
242
243if test -n "$qt4_uic"; then
244      AC_MSG_RESULT($qt4_uic)
245else
246      AC_MSG_RESULT(not found)
247fi
248
249
250
251# check if all necessary qt4 components where found
252if test -z "$qt4_includes" || \
253   test -z "$qt4_moc" || \
254   test -z "$qt4_uic" || \
255   test -z "$qt4_libs"; then
256	qt4_libs=""
257	qt4_moc=""
258	qt4_uic=""
259   	qt4_includes=""
260   	have_qt4="no"
261        AC_MSG_ERROR([
262 Compilation of QT applications is enabled but I could not find some Qt
263 components (see which are missing in messages above).
264 If you don't want to compile Qt4 applications please explicitly specify
265 which GUIs you want to support using "--with-guis".
266 ])
267else
268dnl TODO: AC_TRY_RUN, check whether qversion.h has matching versions
269   have_qt4="yes"
270   AC_DEFINE(HAVE_QT4, 1, [whether Qt4 is available])
271fi
272
273
274AS_SCRUB_INCLUDE(qt4_includes)
275AC_SUBST(qt4_libs)
276AC_SUBST(qt4_includes)
277AC_SUBST(qt4_moc)
278AC_SUBST(qt4_uic)
279
280])
281
282
283
284
285
286
287