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 ## ------------------------------------------------------------------------
24 ## Find a file (or one of more files in a list of dirs)
25 ## ------------------------------------------------------------------------
28 AC_DEFUN(QT2_MOC_ERROR_MESSAGE,
30 AC_MSG_ERROR([No Qt meta object compiler (moc) found!
31 Please check whether you installed Qt correctly.
32 You need to have a running moc binary.
33 configure tried to run $ac_cv_path_qt2moc and the test didn't
34 succeed. If configure shouldn't have tried this one, set
35 the environment variable MOC to the right one before running
40 AC_DEFUN(QT2_FIND_PATH,
42 AC_MSG_CHECKING([for $1])
43 AC_CACHE_VAL(qt2_cv_path_$1,
46 if test -n "$$2"; then
58 if test -x "$dir/$1"; then
61 evalstr="$dir/$1 $5 2>&1 "
62 if eval $evalstr; then
63 qt2_cv_path_$1="$dir/$1"
67 qt2_cv_path_$1="$dir/$1"
77 if test -z "$qt2_cv_path_$1" || test "$qt2_cv_path_$1" = "NONE"; then
78 AC_MSG_RESULT(not found)
81 AC_MSG_RESULT($qt2_cv_path_$1)
86 dnl ------------------------------------------------------------------------
87 dnl Find the UIC compiler if available
88 dnl ------------------------------------------------------------------------
89 AC_DEFUN(QT2_AC_PATH_UIC,
91 QT2_FIND_PATH(uic, UIC, [$ac_qt2_bindir $QTDIR/bin \
92 /usr/bin /usr/X11R6/bin /usr/lib/qt2/bin \
93 /usr/local/qt2/bin /usr/local/qt/bin /usr/lib/qt/bin], )
97 dnl ------------------------------------------------------------------------
98 dnl Find the meta object compiler in the PATH, in $QTDIR/bin, and some
100 dnl ------------------------------------------------------------------------
102 AC_DEFUN(QT2_AC_PATH_MOC,
104 QT2_FIND_PATH(moc, MOC, [$ac_qt2_bindir $QTDIR/bin \
105 /usr/bin /usr/X11R6/bin /usr/lib/qt2/bin \
106 /usr/local/qt2/bin /usr/local/qt/bin /usr/lib/qt/bin], [QT2_MOC_ERROR_MESSAGE])
108 if test -z "$MOC"; then
109 if test -n "$ac_cv_path_qt2moc"; then
110 output=`eval "$ac_cv_path_qt2moc --help 2>&1 | sed -e '1q' | grep Qt"`
112 echo "configure:__oline__: tried to call $ac_cv_path_qt2moc --help 2>&1 | sed -e '1q' | grep Qt" >&AC_FD_CC
113 echo "configure:__oline__: moc output: $output" >&AC_FD_CC
115 if test -z "$output"; then
123 AC_DEFUN(QT2_PRINT_PROGRAM,
126 cat > conftest.$ac_ext <<EOF
127 #include "confdefs.h"
129 #include <qapplication.h>
138 AC_DEFUN(QT2_CHECK_DIRECT,
140 AC_MSG_CHECKING([if Qt2 compiles without flags])
141 AC_CACHE_VAL(cv_qt2_direct,
143 ac_LD_LIBRARY_PATH_safe=$LD_LIBRARY_PATH
144 ac_LIBRARY_PATH="$LIBRARY_PATH"
145 ac_cxxflags_safe="$CXXFLAGS"
146 ac_ldflags_safe="$LDFLAGS"
149 CXXFLAGS="$CXXFLAGS -I$qt2_includes"
151 LIBS="-lqt -lXext -lX11 $LIBSOCKET"
153 export LD_LIBRARY_PATH
159 if AC_TRY_EVAL(ac_link) && test -s conftest; then
163 echo "configure: failed program was:" >&AC_FD_CC
164 cat conftest.$ac_ext >&AC_FD_CC
167 CXXFLAGS="$ac_cxxflags_safe"
168 LDFLAGS="$ac_ldflags_safe"
171 LD_LIBRARY_PATH="$ac_LD_LIBRARY_PATH_safe"
172 export LD_LIBRARY_PATH
173 LIBRARY_PATH="$ac_LIBRARY_PATH"
177 if test "$cv_qt2_direct" = "yes"; then
186 ## ------------------------------------------------------------------------
187 ## Try to find the Qt2 headers and libraries.
188 ## $(QT2_LDFLAGS) will be -Lqt2liblocation (if needed)
189 ## and $(QT2_INCLUDES) will be -Iqt2hdrlocation (if needed)
190 ## ------------------------------------------------------------------------
192 AC_DEFUN(QT2_AC_PATH,
194 AC_MSG_CHECKING([for Qt 2])
195 ac_qt2_includes=NO ac_qt2_libraries=NO ac_qt2_bindir=NO
200 [ --with-qt2-dir where the root of Qt2 is installed ],
201 [ ac_qt2_includes="$withval"/include
202 ac_qt2_libraries="$withval"/lib
203 ac_qt2_bindir="$withval"/bin
206 AC_ARG_WITH(qt2-includes,
207 [ --with-qt2-includes where the Qt2 includes are. ],
209 ac_qt2_includes="$withval"
214 AC_ARG_WITH(qt2-libraries,
215 [ --with-qt2-libraries where the Qt2 library is installed.],
216 [ ac_qt2_libraries="$withval"
220 if test "$ac_qt2_includes" = NO || test "$ac_qt2_libraries" = NO; then
222 AC_CACHE_VAL(ac_cv_have_qt2,
223 [#try to guess Qt2 locations
225 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"
226 test -n "$QTDIR" && qt2_incdirs="$QTDIR/include/qt2 $QTDIR/include/qt $QTDIR/include $QTDIR $qt2_incdirs"
227 AC_FIND_FILE(qmovie.h, $qt2_incdirs, qt2_incdir)
228 ac_qt2_includes="$qt2_incdir"
230 if test ! "$ac_qt2_libraries" = "NO"; then
231 qt2_libdirs="$ac_qt2_libraries"
234 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"
235 test -n "$QTDIR" && qt2_libdirs="$QTDIR/lib $QTDIR $qt2_libdirs"
239 for dir in $qt2_libdirs; do
240 try="ls -1 $dir/libqt*"
241 if test=`eval $try 2> /dev/null`; then qt2_libdir=$dir; break; else echo "tried $dir" >&AC_FD_CC ; fi
244 dnl 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)
245 ac_qt2_libraries="$qt2_libdir"
247 ac_cxxflags_safe="$CXXFLAGS"
248 ac_ldflags_safe="$LDFLAGS"
251 CXXFLAGS="$CXXFLAGS -I$qt2_incdir"
252 LDFLAGS="-L$qt2_libdir $X_LDFLAGS"
253 LIBS="$LIBS -lqt -lXext -lX11 $LIBSOCKET"
257 if AC_TRY_EVAL(ac_link) && test -s conftest; then
260 echo "configure: failed program was:" >&AC_FD_CC
261 cat conftest.$ac_ext >&AC_FD_CC
262 ac_qt2_libraries="NO"
265 CXXFLAGS="$ac_cxxflags_safe"
266 LDFLAGS="$ac_ldflags_safe"
269 if test "$ac_qt2_includes" = NO || test "$ac_qt2_libraries" = NO; then
270 ac_cv_have_qt2="have_qt2=no"
272 if test "$ac_qt2_includes" = NO; then
273 if test "$ac_qt2_libraries" = NO; then
274 ac_qt2_notfound="(headers and libraries)";
276 ac_qt2_notfound="(headers)";
279 ac_qt2_notfound="(libraries)";
282 AC_MSG_ERROR([Qt2 $ac_qt2_notfound not found. Please check your installation! ]);
291 eval "$ac_cv_have_qt2"
293 if test "$have_qt2" != yes; then
294 AC_MSG_RESULT([$have_qt2]);
296 ac_cv_have_qt2="have_qt2=yes \
297 ac_qt2_includes=$ac_qt2_includes ac_qt2_libraries=$ac_qt2_libraries"
298 AC_MSG_RESULT([libraries $ac_qt2_libraries, headers $ac_qt2_includes])
300 qt2_libraries="$ac_qt2_libraries"
301 qt2_includes="$ac_qt2_includes"
304 if test ! "$qt2_libs_given" = "yes"; then
305 QT2_CHECK_DIRECT(qt2_libraries= ,[])
310 SAVE_CXXFLAGS="$CXXFLAGS"
311 CXXFLAGS="$CXXFLAGS -I$qt2_includes -L$qt2_libraries"
312 dnl specify we are definitely C++ compiling first
318 #if (QT_VERSION < 221)
325 test "$ac_qt2_ok" = no && AC_MSG_ERROR([Found an earlier version of Qt - you must specify the path to Qt2])
326 CXXFLAGS="$SAVE_CXXFLAGS"
328 AC_SUBST(qt2_libraries)
329 AC_SUBST(qt2_includes)
331 if test "$qt2_includes" = "$x_includes" || test -z "$qt2_includes"; then
334 QT2_INCLUDES="-I$qt2_includes"
335 all_includes="$QT2_INCLUDES $all_includes"
338 if test "$qt2_libraries" = "$x_libraries" || test -z "$qt2_libraries"; then
341 QT2_LDFLAGS="-L$qt2_libraries"
342 all_libraries="$QT2_LDFLAGS $all_libraries"
347 AC_SUBST(QT2_INCLUDES)
348 AC_SUBST(QT2_LDFLAGS)
354 AC_DEFUN(QT2_DO_IT_ALL,
356 if test "$QT2DIR" != ""; then