1 # Configure paths and libs when using Qt2 GUI
2 ## -*- shell-script -*-
4 ## Based on KDE file written by :
5 ## Copyright (C) 1997 Janos Farkas (chexum@shadow.banki.hu)
6 ## (C) 1997 Stephan Kulow (coolo@kde.org)
8 ## This file is free software; you can redistribute it and/or
9 ## modify it under the terms of the GNU Library General Public
10 ## License as published by the Free Software Foundation; either
11 ## version 2 of the License, or (at your option) any later version.
13 ## This library is distributed in the hope that it will be useful,
14 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 ## Library General Public License for more details.
18 ## You should have received a copy of the GNU Library General Public License
19 ## along with this library; see the file COPYING.LIB. If not, write to
20 ## the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 ## Boston, MA 02111-1307, USA.
23 AC_DEFUN(QT2_MOC_ERROR_MESSAGE,
25 AC_MSG_ERROR([No Qt meta object compiler (moc) found!
26 Please check whether you installed Qt correctly.
27 You need to have a running moc binary.
28 configure tried to run $ac_cv_path_qt2moc and the test didn't
29 succeed. If configure shouldn't have tried this one, set
30 the environment variable MOC to the right one before running
35 AC_DEFUN(QT2_FIND_PATH,
37 AC_MSG_CHECKING([for $1])
38 AC_CACHE_VAL(qt2_cv_path_$1,
41 if test -n "$$2"; then
53 if test -x "$dir/$1"; then
56 evalstr="$dir/$1 $5 2>&1 "
57 if eval $evalstr; then
58 qt2_cv_path_$1="$dir/$1"
62 qt2_cv_path_$1="$dir/$1"
72 if test -z "$qt2_cv_path_$1" || test "$qt2_cv_path_$1" = "NONE"; then
73 AC_MSG_RESULT(not found)
76 AC_MSG_RESULT($qt2_cv_path_$1)
81 dnl ------------------------------------------------------------------------
82 dnl Find the UIC compiler if available
83 dnl ------------------------------------------------------------------------
84 AC_DEFUN(QT2_AC_PATH_UIC,
86 QT2_FIND_PATH(uic, UIC, [$ac_qt2_bindir $QTDIR/bin \
87 /usr/bin /usr/X11R6/bin /usr/lib/qt2/bin \
88 /usr/local/qt2/bin /usr/local/qt/bin /usr/lib/qt/bin], )
92 dnl ------------------------------------------------------------------------
93 dnl Find the meta object compiler in the PATH, in $QTDIR/bin, and some
95 dnl ------------------------------------------------------------------------
97 AC_DEFUN(QT2_AC_PATH_MOC,
99 QT2_FIND_PATH(moc, MOC, [$ac_qt2_bindir $QTDIR/bin \
100 /usr/bin /usr/X11R6/bin /usr/lib/qt2/bin \
101 /usr/local/qt2/bin /usr/local/qt/bin /usr/lib/qt/bin],)
103 QT2_FIND_PATH(moc2, MOC2, [$ac_qt2_bindir $QTDIR/bin \
104 /usr/bin /usr/X11R6/bin /usr/lib/qt2/bin \
105 /usr/local/qt2/bin /usr/local/qt/bin /usr/lib/qt/bin],)
107 if ! test -z "$MOC2"; then
111 if test -z "$MOC"; then
112 if test -n "$ac_cv_path_qt2moc"; then
113 output=`eval "$ac_cv_path_qt2moc --help 2>&1 | sed -e '1q' | grep Qt"`
115 echo "configure:__oline__: tried to call $ac_cv_path_qt2moc --help 2>&1 | sed -e '1q' | grep Qt" >&AC_FD_CC
116 echo "configure:__oline__: moc output: $output" >&AC_FD_CC
118 if test -z "$output"; then
119 QT2_MOC_ERROR_MESSAGE
126 AC_DEFUN(QT2_PRINT_PROGRAM,
129 cat > conftest.$ac_ext <<EOF
130 #include "confdefs.h"
132 #include <qapplication.h>
141 dnl check for -lqt2 not -lqt
142 AC_DEFUN(QT2_CHECK_LIB_NAME,
144 ac_cxxflags_safe="$CXXFLAGS"
145 ac_ldflags_safe="$LDFLAGS"
148 CXXFLAGS="$CXXFLAGS -I$qt2_incdir"
149 LDFLAGS="-L$qt2_libdir $X_LDFLAGS"
150 LIBS="$LIBS -lqt2 -lXext -lX11 $LIBSOCKET"
154 if AC_TRY_EVAL(ac_link) && test -s conftest; then
158 echo "configure: failed program was:" >&AC_FD_CC
159 cat conftest.$ac_ext >&AC_FD_CC
162 CXXFLAGS="$ac_cxxflags_safe"
163 LDFLAGS="$ac_ldflags_safe"
167 ## ------------------------------------------------------------------------
168 ## Try to find the Qt2 headers and libraries.
169 ## $(QT2_LDFLAGS) will be -Lqt2liblocation (if needed)
170 ## and $(QT2_INCLUDES) will be -Iqt2hdrlocation (if needed)
171 ## ------------------------------------------------------------------------
173 AC_DEFUN(QT2_AC_PATH,
175 AC_MSG_CHECKING([for Qt 2])
176 ac_qt2_includes=NO ac_qt2_libraries=NO ac_qt2_bindir=NO
181 [ --with-qt2-dir where the root of Qt2 is installed ],
182 [ ac_qt2_includes=`eval echo "$withval"/include`
183 ac_qt2_libraries=`eval echo "$withval"/lib`
184 ac_qt2_bindir=`eval echo "$withval"/bin`
187 AC_ARG_WITH(qt2-includes,
188 [ --with-qt2-includes where the Qt2 includes are. ],
190 ac_qt2_includes=`eval echo "$withval"`
195 AC_ARG_WITH(qt2-libraries,
196 [ --with-qt2-libraries where the Qt2 library is installed.],
197 [ ac_qt2_libraries=`eval echo "$withval"`
201 if test "$ac_qt2_includes" = NO || test "$ac_qt2_libraries" = NO; then
203 AC_CACHE_VAL(ac_cv_have_qt2,
204 [#try to guess Qt2 locations
206 qt2_incdirs="$ac_qt2_includes /usr/lib/qt2/include /usr/local/qt2/include /usr/include/qt2 /usr/X11R6/include/X11/qt2 /usr/lib/qt/include /usr/local/qt/include /usr/include/qt /usr/include /usr/X11R6/include/X11/qt $x_includes $QTINC"
207 test -n "$QTDIR" && qt2_incdirs="$QTDIR/include/qt2 $QTDIR/include/qt $QTDIR/include $QTDIR $qt2_incdirs"
208 AC_FIND_FILE(qmovie.h, $qt2_incdirs, qt2_incdir)
209 ac_qt2_includes="$qt2_incdir"
211 if test ! "$ac_qt2_libraries" = "NO"; then
212 qt2_libdirs="$ac_qt2_libraries"
215 qt2_libdirs="$qt2_libdirs /usr/lib/qt2/lib /usr/lib/qt/lib /usr/X11R6/lib /usr/lib /usr/local/qt2/lib /usr/lib/qt2 /usr/local/qt/lib /usr/lib/qt $x_libraries $QTLIB"
216 test -n "$QTDIR" && qt2_libdirs="$QTDIR/lib $QTDIR $qt2_libdirs"
220 for dir in $qt2_libdirs; do
221 try="ls -1 $dir/libqt*"
222 if test=`eval $try 2> /dev/null`; then qt2_libdir=$dir; break; else echo "tried $dir" >&AC_FD_CC ; fi
227 AC_FIND_FILE(libqt.so.2.2.3 libqt.so.2.2 libqt.so.2 libqt2.so libqt.a libqt.sl, $qt2_libdirs, qt2_libdir)
229 ac_qt2_libraries="$qt2_libdir"
233 if test "$ac_qt2_name" = "-lqt"; then
234 ac_qt2_libraries="$qt2_libdir"
236 ac_cxxflags_safe="$CXXFLAGS"
237 ac_ldflags_safe="$LDFLAGS"
240 CXXFLAGS="$CXXFLAGS -I$qt2_incdir"
241 LDFLAGS="-L$qt2_libdir $X_LDFLAGS"
242 LIBS="$LIBS -lqt -lXext -lX11 $LIBSOCKET"
246 if AC_TRY_EVAL(ac_link) && test -s conftest; then
249 echo "configure: failed program was:" >&AC_FD_CC
250 cat conftest.$ac_ext >&AC_FD_CC
251 ac_qt2_libraries="NO"
254 CXXFLAGS="$ac_cxxflags_safe"
255 LDFLAGS="$ac_ldflags_safe"
259 if test "$ac_qt2_includes" = NO || test "$ac_qt2_libraries" = NO; then
260 ac_cv_have_qt2="have_qt2=no"
262 if test "$ac_qt2_includes" = NO; then
263 if test "$ac_qt2_libraries" = NO; then
264 ac_qt2_notfound="(headers and libraries)";
266 ac_qt2_notfound="(headers)";
269 ac_qt2_notfound="(libraries)";
272 AC_MSG_ERROR([Qt2 $ac_qt2_notfound not found. Please check your installation! ]);
278 dnl libs and headers supplied. Need to check lib name
279 qt2_incdir="$ac_qt2_includes"
280 qt2_libdir="$ac_qt2_libraries"
285 eval "$ac_cv_have_qt2"
287 if test "$have_qt2" != yes; then
288 AC_MSG_RESULT([$have_qt2]);
290 ac_cv_have_qt2="have_qt2=yes ac_qt2_name=$ac_qt2_name \
291 ac_qt2_includes=$ac_qt2_includes ac_qt2_libraries=$ac_qt2_libraries"
292 AC_MSG_RESULT([libraries $ac_qt2_libraries, headers $ac_qt2_includes])
294 qt2_libraries="$ac_qt2_libraries"
295 qt2_includes="$ac_qt2_includes"
300 SAVE_CXXFLAGS="$CXXFLAGS"
301 CXXFLAGS="$CXXFLAGS -I$qt2_includes -L$qt2_libraries"
302 dnl specify we are definitely C++ compiling first
308 #if (QT_VERSION < 221)
315 test "$ac_qt2_ok" = no && AC_MSG_ERROR([Found an earlier version of Qt - you must specify the path to Qt2])
316 CXXFLAGS="$SAVE_CXXFLAGS"
318 AC_SUBST(qt2_libraries)
319 AC_SUBST(qt2_includes)
321 if test "$qt2_includes" = "$x_includes" || test -z "$qt2_includes"; then
324 QT2_INCLUDES="-I$qt2_includes"
325 all_includes="$QT2_INCLUDES $all_includes"
328 if test "$qt2_libraries" = "$x_libraries" || test -z "$qt2_libraries"; then
331 QT2_LDFLAGS="-L$qt2_libraries"
332 all_libraries="$QT2_LDFLAGS $all_libraries"
335 QT2_LIBS="$ac_qt2_name"
337 AC_SUBST(QT2_INCLUDES)
338 AC_SUBST(QT2_LDFLAGS)
344 AC_DEFUN(QT2_DO_IT_ALL,
346 if test "$QT2DIR" != ""; then