1# $Id$
2# (c) 2002 Martin Preuss<martin@libchipcard.de>
3# These functions search for QT 2-3
4
5
6AC_DEFUN([AQ_CHECK_QT],[
7dnl $1 = operating system name ("linux", "freebsd", "windows")
8dnl $2 = subdirs to include when QT is available
9dnl searches a dir for some files
10dnl You may preset the return variables.
11dnl All variables which already have a value will not be altered
12dnl returns some variables:
13dnl  qt_generation either 1,2 or 3
14dnl  qt_includes path to includes
15dnl  qt_libs path to libraries
16dnl  qt_moc path to moc
17dnl  qt_uic path to uic
18
19ops="$1"
20lsd="$2"
21
22dnl check if qt apps are desired
23AC_MSG_CHECKING(if QT applications should be compiled)
24AC_ARG_ENABLE(qtapps,
25  [  --enable-qtapps         enable compilation of qt applications (default=yes)],
26  enable_qtapps="$enableval",
27  enable_qtapps="yes")
28AC_MSG_RESULT($enable_qtapps)
29
30if test "$enable_qtapps" = "no"; then
31   qt_libs=""
32   qt_includes=""
33   qt_app=""
34   qt_moc=""
35   qt_uic=""
36else
37
38dnl paths for qt
39AC_ARG_WITH(qt-dir,
40  [  --with-qt-dir=DIR      uses qt from given dir],
41  [local_qt_paths="$withval"],
42  [local_qt_paths="\
43  	$QTDIR \
44      	/usr/local/lib/qt3 \
45        /usr/lib/qt3 \
46        /lib/qt3 \
47        /usr/local/lib/qt2 \
48        /usr/lib/qt2 \
49        /lib/qt2 \
50        /usr/local/lib/qt1 \
51        /usr/lib/qt1 \
52        /lib/qt1 \
53        /usr/local/lib/qt \
54        /usr/lib/qt \
55        /lib/qt \
56        /usr/local \
57        /usr \
58        /usr/X11R6 \
59        / \
60        "])
61
62AC_MSG_CHECKING(if threaded qt may be used)
63AC_ARG_ENABLE(qt-threads,
64  [  --enable-qt-threads         enable qt-mt library (default=yes)],
65  enable_qt_threads="$enableval",
66  enable_qt_threads="yes")
67AC_MSG_RESULT($enable_qt_threads)
68
69dnl check for library
70AC_MSG_CHECKING(for qt libraries)
71dnl check for 3
72if test -z "$qt_libs" && test "$enable_qt_threads" != "no"; then
73	AQ_SEARCH_FOR_PATH([lib/libqt-mt.so.3],[$local_qt_paths])
74	if test -n "$found_dir" ; then
75        	qt_dir="$found_dir"
76    		qt_libs="-L$found_dir/lib -lqt-mt"
77                qt_generation="3"
78	fi
79fi
80if test -z "$qt_libs"; then
81	AQ_SEARCH_FOR_PATH([lib/libqt.so.3],[$local_qt_paths])
82	if test -n "$found_dir" ; then
83        	qt_dir="$found_dir"
84    		qt_libs="-L$found_dir/lib -lqt"
85                qt_generation="3"
86	fi
87fi
88
89dnl check for 2
90if test -z "$qt_libs" && test "$enable_qt_threads" != "no"; then
91	AQ_SEARCH_FOR_PATH([lib/libqt-mt.so.2],[$local_qt_paths])
92	if test -n "$found_dir" ; then
93        	qt_dir="$found_dir"
94    		qt_libs="-L$found_dir/lib -lqt-mt"
95                qt_generation="2"
96	fi
97fi
98if test -z "$qt_libs"; then
99	AQ_SEARCH_FOR_PATH([lib/libqt.so.2],[$local_qt_paths])
100	if test -n "$found_dir" ; then
101        	qt_dir="$found_dir"
102    		qt_libs="-L$found_dir/lib -lqt"
103                qt_generation="2"
104	fi
105fi
106
107dnl check for 1
108if test -z "$qt_libs" && test "$enable_qt_threads" != "no"; then
109	AQ_SEARCH_FOR_PATH([lib/libqt-mt.so.1],[$local_qt_paths])
110	if test -n "$found_dir" ; then
111        	qt_dir="$found_dir"
112    		qt_libs="-L$found_dir/lib -lqt-mt"
113                qt_generation="1"
114	fi
115fi
116if test -z "$qt_libs"; then
117	AQ_SEARCH_FOR_PATH([lib/libqt.so.1],[$local_qt_paths])
118	if test -n "$found_dir" ; then
119        	qt_dir="$found_dir"
120    		qt_libs="-L$found_dir/lib -lqt"
121                qt_generation="1"
122	fi
123fi
124if test -z "$qt_libs"; then
125	AC_MSG_RESULT(not found)
126else
127	AC_MSG_RESULT($qt_libs)
128fi
129
130dnl check for includes
131AC_MSG_CHECKING(for qt includes)
132if test -z "$qt_includes"; then
133       	AQ_SEARCH_FOR_PATH([include/qt.h],[$qt_dir $local_qt_paths])
134       	if test -n "$found_dir" ; then
135       		qt_includes="-I$found_dir/include"
136       	fi
137fi
138if test -z "$qt_includes"; then
139       	AQ_SEARCH_FOR_PATH([include/qt3/qt.h],[$qt_dir $local_qt_paths])
140       	if test -n "$found_dir" ; then
141       		qt_includes="-I$found_dir/include/qt3"
142       	fi
143fi
144if test -z "$qt_includes"; then
145       	AQ_SEARCH_FOR_PATH([include/qt2/qt.h],[$qt_dir $local_qt_paths])
146       	if test -n "$found_dir" ; then
147       		qt_includes="-I$found_dir/include/qt2"
148       	fi
149fi
150if test -z "$qt_includes"; then
151       	AQ_SEARCH_FOR_PATH([include/qt1/qt.h],[$qt_dir $local_qt_paths])
152       	if test -n "$found_dir" ; then
153       		qt_includes="-I$found_dir/include/qt1"
154       	fi
155fi
156if test -z "$qt_includes"; then
157       	AQ_SEARCH_FOR_PATH([include/qt/qt.h],[$qt_dir $local_qt_paths])
158       	if test -n "$found_dir" ; then
159       		qt_includes="-I$found_dir/include/qt"
160       	fi
161fi
162if test -z "$qt_includes"; then
163	AC_MSG_RESULT(not found)
164else
165	AC_MSG_RESULT($qt_includes)
166fi
167
168dnl check for moc
169AC_MSG_CHECKING(for qt moc)
170if test -z "$qt_moc"; then
171       	AQ_SEARCH_FOR_PATH([bin/moc],[$qt_dir $local_qt_paths])
172       	if test -n "$found_dir" ; then
173       		qt_moc="$found_dir/bin/moc"
174       	fi
175fi
176if test -z "$qt_moc"; then
177       	AQ_SEARCH_FOR_PATH([bin/moc2],[$qt_dir $local_qt_paths])
178       	if test -n "$found_dir" ; then
179       		qt_moc="$found_dir/bin/moc2"
180       	fi
181fi
182if test -z "$qt_moc"; then
183	AC_MSG_RESULT(not found)
184else
185	AC_MSG_RESULT($qt_moc)
186fi
187
188dnl check for uic
189AC_MSG_CHECKING(for qt uic)
190if test -z "$qt_uic"; then
191       	AQ_SEARCH_FOR_PATH([bin/uic],[$qt_dir $local_qt_paths])
192       	if test -n "$found_dir" ; then
193       		qt_uic="$found_dir/bin/uic"
194       	fi
195fi
196if test -z "$qt_uic"; then
197	AC_MSG_RESULT(not found)
198else
199	AC_MSG_RESULT($qt_uic)
200fi
201
202# check if all necessary qt components where found
203if test -n "$qt_includes" && \
204   test -n "$qt_libs" && \
205   test -n "$qt_moc" && \
206   test -n "$qt_uic"; then
207   qt_app="$lsd"
208   AC_DEFINE_UNQUOTED(QT_GENERATION,$qt_generation, [QT generation])
209else
210   qt_libs=""
211   qt_includes=""
212   qt_app=""
213   qt_moc=""
214   qt_uic=""
215   if test "$enable_qtapps" = "yes"; then
216        AC_MSG_ERROR([
217 Compilation of QT applications is enabled but I could not find some QT
218 components (see which are missing in messages above).
219 If you don't want to compile QT applications please use "--disable-qtapps".
220 ])
221   fi
222fi
223
224dnl end of if "$enable_qtapps"
225fi
226
227AC_SUBST(qt_dir)
228AC_SUBST(qt_app)
229AC_SUBST(qt_libs)
230AC_SUBST(qt_includes)
231AC_SUBST(qt_moc)
232AC_SUBST(qt_uic)
233AC_SUBST(qt_generation)
234])
235
236