]> git.lyx.org Git - lyx.git/blob - config/kde.m4
fix typo that put too many include paths for most people
[lyx.git] / config / kde.m4
1 # Configure paths and libs when using KDE GUI
2 ##    -*- shell-script -*-
3
4 ##    This file is part of the KDE libraries/packages
5 ##    Copyright (C) 1997 Janos Farkas (chexum@shadow.banki.hu)
6 ##              (C) 1997 Stephan Kulow (coolo@kde.org)
7
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.
12
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.
17
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.        
22
23 ## IMPORTANT NOTE:
24 ## Please do not modify this file unless you expect your modifications to be
25 ## carried into every other module in the repository. If you decide that you
26 ## really want to modify it, contact coolo@kde.org mentioning that you have
27 ## and that the modified file should be committed to every module.
28 ##
29 ## Single-module modifications are best placed in configure.in for kdelibs
30 ## and kdebase or configure.in.1 if present.
31
32
33 ## ------------------------------------------------------------------------
34 ## Find a file (or one of more files in a list of dirs)
35 ## ------------------------------------------------------------------------
36 ##
37 AC_DEFUN(AC_FIND_FILE,
38 [
39 $3=NO
40 for i in $2;
41 do
42   for j in $1;
43   do
44     if test -r "$i/$j"; then
45       $3=$i
46       break 2
47     fi
48   done
49 done
50 ])
51
52 AC_DEFUN(KDE_FIND_PATH,
53 [
54    AC_MSG_CHECKING([for $1])
55    AC_CACHE_VAL(kde_cv_path_$1,
56    [
57      kde_cv_path_$1="NONE"
58      if test -n "$$2"; then
59         kde_cv_path_$1="$$2";
60      else
61         dirs="$3"
62         kde_save_IFS=$IFS
63         IFS=':'
64         for dir in $PATH; do
65           dirs="$dirs $dir"
66         done
67         IFS=$kde_save_IFS
68  
69         for dir in $dirs; do
70           if test -x "$dir/$1"; then
71             if test -n "$5"
72             then
73               evalstr="$dir/$1 $5 2>&1 "
74               if eval $evalstr; then
75                 kde_cv_path_$1="$dir/$1"
76                 break
77               fi
78             else
79                 kde_cv_path_$1="$dir/$1"
80                 break
81             fi
82           fi
83         done
84  
85      fi
86  
87    ])
88  
89    if test -z "$kde_cv_path_$1" || test "$kde_cv_path_$1" = "NONE"; then
90       AC_MSG_RESULT(not found)
91       $4
92    else
93      AC_MSG_RESULT($kde_cv_path_$1)
94      $2=$kde_cv_path_$1
95    fi
96 ])
97  
98 AC_DEFUN(KDE_MOC_ERROR_MESSAGE,
99 [
100     AC_MSG_ERROR([No Qt meta object compiler (moc) found!
101 Please check whether you installed Qt correctly.
102 You need to have a running moc binary.
103 configure tried to run $ac_cv_path_moc and the test didn't
104 succeed. If configure shouldn't have tried this one, set
105 the environment variable MOC to the right one before running
106 configure.
107 ])
108 ])
109
110 dnl ------------------------------------------------------------------------
111 dnl Find the meta object compiler in the PATH, in $QTDIR/bin, and some
112 dnl more usual places
113 dnl ------------------------------------------------------------------------
114 dnl
115 AC_DEFUN(AC_PATH_QT_MOC,
116 [
117    KDE_FIND_PATH(moc, MOC, [$ac_qt_bindir $QTDIR/bin \
118             /usr/bin /usr/X11R6/bin /usr/lib/qt/bin \
119             /usr/local/qt/bin], [KDE_MOC_ERROR_MESSAGE])
120  
121    if test -z "$MOC"; then
122      if test -n "$ac_cv_path_moc"; then
123        output=`eval "$ac_cv_path_moc --help 2>&1 | sed -e '1q' | grep Qt"`
124      fi
125      echo "configure:__oline__: tried to call $ac_cv_path_moc --help 2>&1 | sed -e '1q' | grep Qt" >&AC_FD_CC
126      echo "configure:__oline__: moc output: $output" >&AC_FD_CC
127  
128      if test -z "$output"; then
129        KDE_MOC_ERROR_MESSAGE
130     fi
131    fi
132  
133    AC_SUBST(MOC)
134 ])
135
136 AC_DEFUN(KDE_REPLACE_ROOT,
137   $1=`echo "$$1" | sed -e "s#^/#\$\{install_root\}/#"`
138 )
139
140 AC_DEFUN(AC_CREATE_KFSSTND,
141 [
142 AC_REQUIRE([AC_CHECK_RPATH])
143
144 if test "$1" = "default"; then
145
146   AC_MSG_CHECKING(for KDE paths)
147
148   if test -z "$kde_htmldir"; then
149     kde_htmldir="\$(prefix)/share/doc/HTML"
150   fi
151   if test -z "$kde_appsdir"; then
152     kde_appsdir="\$(prefix)/share/applnk"
153   fi
154   if test -z "$kde_icondir"; then
155     kde_icondir="\$(prefix)/share/icons"
156   fi
157   if test -z "$kde_sounddir"; then
158     kde_sounddir="\$(prefix)/share/sounds"
159   fi
160   if test -z "$kde_datadir"; then
161     kde_datadir="\$(prefix)/share/apps"
162   fi
163   if test -z "$kde_locale"; then
164     kde_locale="\$(prefix)/share/locale"
165   fi
166   if test -z "$kde_cgidir"; then
167     kde_cgidir="\$(exec_prefix)/cgi-bin"
168   fi
169   if test -z "$kde_confdir"; then
170     kde_confdir="\$(prefix)/share/config"
171   fi
172   if test -z "$kde_mimedir"; then
173     kde_mimedir="\$(prefix)/share/mimelnk"
174   fi
175   if test -z "$kde_toolbardir"; then
176     kde_toolbardir="\$(prefix)/share/toolbar"
177   fi
178   if test -z "$kde_wallpaperdir"; then
179     kde_wallpaperdir="\$(prefix)/share/wallpapers"
180   fi
181   if test -z "$kde_bindir"; then
182     kde_bindir="\$(exec_prefix)/bin"
183   fi
184   if test -z "$kde_partsdir"; then
185     kde_partsdir="\$(exec_prefix)/parts"
186   fi
187   AC_MSG_RESULT(defaults)       
188
189 else 
190
191 AC_CACHE_VAL(kde_cv_all_paths,
192 [
193 AC_MSG_CHECKING([for kde headers installed])
194 AC_LANG_CPLUSPLUS
195 cat > conftest.$ac_ext <<EOF
196 #include <stdio.h>
197 #include "confdefs.h"
198 #include <kapp.h>
199
200 int main() {
201 printf("kde_htmldir=\\"%s\\"\n", KApplication::kde_htmldir().data());
202 printf("kde_appsdir=\\"%s\\"\n", KApplication::kde_appsdir().data());
203 printf("kde_icondir=\\"%s\\"\n", KApplication::kde_icondir().data());
204 printf("kde_sounddir=\\"%s\\"\n", KApplication::kde_sounddir().data());
205 printf("kde_datadir=\\"%s\\"\n", KApplication::kde_datadir().data());
206 printf("kde_locale=\\"%s\\"\n", KApplication::kde_localedir().data());
207 printf("kde_cgidir=\\"%s\\"\n", KApplication::kde_cgidir().data());
208 printf("kde_confdir=\\"%s\\"\n", KApplication::kde_configdir().data());
209 printf("kde_mimedir=\\"%s\\"\n", KApplication::kde_mimedir().data());
210 printf("kde_toolbardir=\\"%s\\"\n", KApplication::kde_toolbardir().data());
211 printf("kde_wallpaperdir=\\"%s\\"\n", KApplication::kde_wallpaperdir().data());
212 printf("kde_bindir=\\"%s\\"\n", KApplication::kde_bindir().data());
213 printf("kde_partsdir=\\"%s\\"\n", KApplication::kde_partsdir().data());
214 return 0;
215 }
216 EOF
217
218 if test -n "$kde_libraries"; then
219   KDE_TEST_RPATH="-rpath $kde_libraries"
220 fi
221
222 if test -n "$qt_libraries"; then
223   KDE_TEST_RPATH="$KDE_TEST_RPATH -rpath $qt_libraries"
224 fi
225
226 if test -n "$x_libraries"; then
227   KDE_TEST_RPATH="$KDE_TEST_RPATH -rpath $x_libraries"
228 fi
229
230 KDE_TEST_RPATH="$KDE_TEST_RPATH $KDE_EXTRA_RPATH"
231
232 ac_compile='${CXX-g++} -c $CXXFLAGS $all_includes $CPPFLAGS conftest.$ac_ext'
233 if AC_TRY_EVAL(ac_compile); then
234   AC_MSG_RESULT(yes)
235 else
236   AC_MSG_ERROR([your system is not able to compile a small KDE application!
237 Check, if you installed the KDE header files correctly.])
238 fi
239
240 AC_MSG_CHECKING([for kde libraries installed])
241 ac_link='/bin/sh ./libtool --mode=link ${CXX-g++} -o conftest $CXXFLAGS $all_includes $CPPFLAGS $LDFLAGS $all_libraries conftest.$ac_ext $LIBS -lkdecore -lqt -lXext -lX11 $LIBSOCKET $KDE_TEST_RPATH 1>&5'
242
243 if AC_TRY_EVAL(ac_link) && test -s conftest; then 
244   AC_MSG_RESULT(yes)
245 else
246   AC_MSG_ERROR([your system fails at linking a small KDE application!
247 Check if your compiler is installed correctly and if you have used the
248 same compiler to compile Qt and kdelibs as you did use now])
249 fi
250
251 AC_MSG_CHECKING([for KDE paths])
252 if eval `./conftest 2>&5`; then
253   AC_MSG_RESULT(done)
254 else
255   AC_MSG_RESULT(problems)
256 fi
257
258 ./conftest 2> /dev/null >&5 # make an echo for config.log
259 kde_have_all_paths=yes
260 AC_LANG_CPLUSPLUS
261
262 if test "$kde_have_all_paths" = "yes"; then
263 kde_cv_all_paths="kde_have_all_paths=\"yes\" \
264         kde_htmldir=\"$kde_htmldir\" \
265         kde_appsdir=\"$kde_appsdir\" \
266         kde_icondir=\"$kde_icondir\" \
267         kde_sounddir=\"$kde_sounddir\" \
268         kde_datadir=\"$kde_datadir\" \
269         kde_locale=\"$kde_locale\" \
270         kde_cgidir=\"$kde_cgidir\" \
271         kde_confdir=\"$kde_confdir\" \
272         kde_mimedir=\"$kde_mimedir\" \
273         kde_toolbardir=\"$kde_toolbardir\" \
274         kde_wallpaperdir=\"$kde_wallpaperdir\" \
275         kde_bindir=\"$kde_bindir\" \
276         kde_partsdir=\"$kde_partsdir\""
277 fi
278 rm -fr conftest*
279
280 ])
281
282 eval "$kde_cv_all_paths"
283
284 if test -z "$kde_htmldir" || test -z "$kde_appsdir" ||
285    test -z "$kde_icondir" || test -z "$kde_sounddir" ||
286    test -z "$kde_datadir" || test -z "$kde_locale"  ||
287    test -z "$kde_cgidir"  || test -z "$kde_confdir" ||
288    test -z "$kde_mimedir" || test -z "$kde_toolbardir" ||
289    test -z "$kde_wallpaperdir" || test -z "$kde_bindir" ||
290    test -z "$kde_partsdir" || test "$kde_have_all_paths" != "yes"; then
291   kde_have_all_paths=no
292   AC_MSG_ERROR([configure could not run a little KDE program to test the environment. 
293 Since it had compiled and linked before, it must be a strange problem on your system.
294 Look at config.log for details. If you are not able to fix this, please contact Stephan Kulow <coolo@kde.org>.])
295 fi
296
297 if test -n "$install_root"; then
298   KDE_REPLACE_ROOT(kde_htmldir)
299   KDE_REPLACE_ROOT(kde_appsdir)
300   KDE_REPLACE_ROOT(kde_icondir)
301   KDE_REPLACE_ROOT(kde_sounddir)
302   KDE_REPLACE_ROOT(kde_datadir)
303   KDE_REPLACE_ROOT(kde_locale)
304   KDE_REPLACE_ROOT(kde_cgidir)
305   KDE_REPLACE_ROOT(kde_confdir)
306   KDE_REPLACE_ROOT(kde_mimedir)
307   KDE_REPLACE_ROOT(kde_toolbardir)
308   KDE_REPLACE_ROOT(kde_wallpaperdir)
309   KDE_REPLACE_ROOT(kde_bindir)
310   KDE_REPLACE_ROOT(kde_partsdir)
311   AC_SUBST(install_root)
312 fi
313
314 fi
315
316 ])
317
318 AC_DEFUN(AC_SUBST_KFSSTND,
319 [
320 AC_SUBST(kde_htmldir)
321 AC_SUBST(kde_appsdir)
322 AC_SUBST(kde_icondir)
323 AC_SUBST(kde_sounddir)
324 kde_minidir="$kde_icondir/mini"
325 AC_SUBST(kde_minidir)
326 AC_SUBST(kde_datadir)
327 AC_SUBST(kde_locale)
328 AC_SUBST(kde_cgidir)
329 AC_SUBST(kde_confdir)
330 AC_SUBST(kde_mimedir)
331 AC_SUBST(kde_toolbardir)
332 AC_SUBST(kde_wallpaperdir)
333 AC_SUBST(kde_bindir)
334 AC_SUBST(kde_partsdir)
335 ])
336
337 AC_DEFUN(KDE_MISC_TESTS,
338 [
339    AC_LANG_C
340    dnl Checks for libraries. 
341    AC_CHECK_LIB(compat, main, [LIBCOMPAT="-lcompat"]) dnl for FreeBSD
342    AC_SUBST(LIBCOMPAT)
343    AC_CHECK_LIB(crypt, main, [LIBCRYPT="-lcrypt"]) dnl for BSD
344    AC_SUBST(LIBCRYPT)
345    AC_CHECK_LIB(dnet, dnet_ntoa, [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet"])
346    if test $ac_cv_lib_dnet_dnet_ntoa = no; then
347       AC_CHECK_LIB(dnet_stub, dnet_ntoa,
348         [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet_stub"])
349    fi
350    AC_CHECK_FUNC(gethostbyname)
351    if test $ac_cv_func_gethostbyname = no; then
352      AC_CHECK_LIB(nsl, gethostbyname, X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl")
353    fi
354    AC_CHECK_FUNC(connect)
355    if test $ac_cv_func_connect = no; then
356       AC_CHECK_LIB(socket, connect, X_EXTRA_LIBS="-lsocket $X_EXTRA_LIBS", ,
357         $X_EXTRA_LIBS)
358    fi
359
360    AC_CHECK_FUNC(remove)
361    if test $ac_cv_func_remove = no; then
362       AC_CHECK_LIB(posix, remove, X_EXTRA_LIBS="$X_EXTRA_LIBS -lposix")
363    fi
364  
365    # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay.
366    AC_CHECK_FUNC(shmat)
367    if test $ac_cv_func_shmat = no; then
368      AC_CHECK_LIB(ipc, shmat, X_EXTRA_LIBS="$X_EXTRA_LIBS -lipc")
369    fi
370
371    LIBSOCKET=$X_EXTRA_LIBS
372    AC_SUBST(LIBSOCKET)
373    AC_SUBST(X_EXTRA_LIBS)
374    AC_CHECK_LIB(ucb, killpg, [LIBUCB="-lucb"]) dnl for Solaris2.4
375    AC_SUBST(LIBUCB)
376
377    case $host in  dnl this *is* LynxOS specific
378    *-*-lynxos* )
379         AC_MSG_CHECKING([LynxOS header file wrappers])
380         [CFLAGS="$CFLAGS -D__NO_INCLUDE_WARN__"]
381         AC_MSG_RESULT(disabled)
382         AC_CHECK_LIB(bsd, gethostbyname, [LIBSOCKET="-lbsd"]) dnl for LynxOS
383          ;;
384     esac
385
386 ])
387
388 ## ------------------------------------------------------------------------
389 ## Find the header files and libraries for X-Windows. Extended the 
390 ## macro AC_PATH_X
391 ## ------------------------------------------------------------------------
392 ##
393 AC_DEFUN(K_PATH_X,
394 [
395 AC_MSG_CHECKING(for X)
396 AC_CACHE_VAL(ac_cv_have_x,
397 [# One or both of the vars are not set, and there is no cached value.
398 ac_x_includes=NO ac_x_libraries=NO
399 AC_PATH_X_DIRECT
400 AC_PATH_X_XMKMF
401 if test "$ac_x_includes" = NO || test "$ac_x_libraries" = NO; then
402   AC_MSG_ERROR([Can't find X includes. Please check your installation and add the correct paths!])
403 else
404   # Record where we found X for the cache.
405   ac_cv_have_x="have_x=yes \
406                 ac_x_includes=$ac_x_includes ac_x_libraries=$ac_x_libraries"
407 fi])dnl
408 eval "$ac_cv_have_x"
409  
410 if test "$have_x" != yes; then
411   AC_MSG_RESULT($have_x)
412   no_x=yes
413 else
414   # If each of the values was on the command line, it overrides each guess.
415   test "x$x_includes" = xNONE && x_includes=$ac_x_includes
416   test "x$x_libraries" = xNONE && x_libraries=$ac_x_libraries
417   # Update the cache value to reflect the command line values.
418   ac_cv_have_x="have_x=yes \
419                 ac_x_includes=$x_includes ac_x_libraries=$x_libraries"
420   AC_MSG_RESULT([libraries $x_libraries, headers $x_includes])
421 fi
422
423 if test -z "$x_includes" || test "x$x_includes" = xNONE; then
424   X_INCLUDES=""
425   x_includes="."; dnl better than nothing :-
426  else
427   X_INCLUDES="-I$x_includes"
428 fi
429
430 if test -z "$x_libraries" || test "x$x_libraries" = xNONE; then
431   X_LDFLAGS=""
432   x_libraries="/usr/lib"; dnl better than nothing :-
433  else
434   X_LDFLAGS="-L$x_libraries"
435 fi
436 all_includes="$all_includes $X_INCLUDES"  
437 all_libraries="$all_libraries $X_LDFLAGS"  
438
439 AC_SUBST(X_INCLUDES)
440 AC_SUBST(X_LDFLAGS)
441 AC_SUBST(x_libraries)
442 AC_SUBST(x_includes)
443 ])
444
445 AC_DEFUN(KDE_PRINT_QT_PROGRAM,
446 [
447 AC_LANG_CPLUSPLUS
448 cat > conftest.$ac_ext <<EOF
449 #include "confdefs.h"
450 #include <qmovie.h>
451 #include <qapplication.h>
452 int main() {
453   QMovie m;
454   m.setSpeed(20);
455   return 0;
456 }
457 EOF
458 ])
459
460 AC_DEFUN(KDE_CHECK_QT_DIRECT,
461 [
462 AC_MSG_CHECKING([if Qt compiles without flags])
463 AC_CACHE_VAL(kde_cv_qt_direct,
464 [
465 ac_LD_LIBRARY_PATH_safe=$LD_LIBRARY_PATH
466 ac_LIBRARY_PATH="$LIBRARY_PATH"
467 ac_cxxflags_safe="$CXXFLAGS"
468 ac_ldflags_safe="$LDFLAGS"
469 ac_libs_safe="$LIBS"
470
471 CXXFLAGS="$CXXFLAGS -I$qt_includes"
472 LDFLAGS="$X_LDFLAGS"
473 LIBS="-lqt -lXext -lX11 $LIBSOCKET"
474 LD_LIBRARY_PATH=
475 export LD_LIBRARY_PATH
476 LIBRARY_PATH=
477 export LIBRARY_PATH
478
479 KDE_PRINT_QT_PROGRAM
480
481 if AC_TRY_EVAL(ac_link) && test -s conftest; then
482   kde_cv_qt_direct="yes"
483 else
484   kde_cv_qt_direct="no"
485   echo "configure: failed program was:" >&AC_FD_CC
486   cat conftest.$ac_ext >&AC_FD_CC
487 fi
488 rm -f conftest*
489 CXXFLAGS="$ac_cxxflags_safe"
490 LDFLAGS="$ac_ldflags_safe"
491 LIBS="$ac_libs_safe"
492
493 LD_LIBRARY_PATH="$ac_LD_LIBRARY_PATH_safe"
494 export LD_LIBRARY_PATH
495 LIBRARY_PATH="$ac_LIBRARY_PATH"
496 export LIBRARY_PATH
497 ])
498
499 if test "$kde_cv_qt_direct" = "yes"; then
500   AC_MSG_RESULT(yes)
501   $1
502 else
503   AC_MSG_RESULT(no)
504   $2
505 fi
506 ])
507
508 ## ------------------------------------------------------------------------
509 ## Try to find the Qt headers and libraries.
510 ## $(QT_LDFLAGS) will be -Lqtliblocation (if needed)
511 ## and $(QT_INCLUDES) will be -Iqthdrlocation (if needed)
512 ## ------------------------------------------------------------------------
513 ##
514 AC_DEFUN(AC_PATH_QT_1_3,
515 [
516 AC_REQUIRE([K_PATH_X])
517
518 AC_MSG_CHECKING([for Qt])
519 ac_qt_includes=NO ac_qt_libraries=NO ac_qt_bindir=NO
520 qt_libraries=""
521 qt_includes=""
522 AC_ARG_WITH(qt-dir,
523     [  --with-qt-dir           where the root of qt is installed ],
524     [  ac_qt_includes="$withval"/include
525        ac_qt_libraries="$withval"/lib
526        ac_qt_bindir="$withval"/bin
527     ])
528
529 AC_ARG_WITH(qt-includes,
530     [  --with-qt-includes      where the Qt includes are. ],
531     [  
532        ac_qt_includes="$withval"
533     ])
534     
535 kde_qt_libs_given=no
536
537 AC_ARG_WITH(qt-libraries,
538     [  --with-qt-libraries     where the Qt library is installed.],
539     [  ac_qt_libraries="$withval"
540        kde_qt_libs_given=yes
541     ])
542
543 if test "$ac_qt_includes" = NO || test "$ac_qt_libraries" = NO; then
544
545 AC_CACHE_VAL(ac_cv_have_qt,
546 [#try to guess Qt locations
547
548 qt_incdirs="$ac_qt_includes /usr/lib/qt/include /usr/local/qt/include /usr/include/qt /usr/include /usr/X11R6/include/X11/qt $x_includes $QTINC"
549 test -n "$QTDIR" && qt_incdirs="$QTDIR/include/qt $QTDIR/include $QTDIR $qt_incdirs"
550 AC_FIND_FILE(qmovie.h, $qt_incdirs, qt_incdir)
551 ac_qt_includes="$qt_incdir"
552
553 if test ! "$ac_qt_libraries" = "NO"; then
554   qt_libdirs="$ac_qt_libraries"
555 fi
556
557 qt_libdirs="$qt_libdirs /usr/lib/qt/lib /usr/X11R6/lib /usr/lib /usr/local/qt/lib /usr/lib/qt $x_libraries $QTLIB"
558 test -n "$QTDIR" && qt_libdirs="$QTDIR/lib $QTDIR $qt_libdirs"
559
560 test=NONE
561 qt_libdir=NONE
562 for dir in $qt_libdirs; do
563   try="ls -1 $dir/libqt*"
564   if test=`eval $try 2> /dev/null`; then qt_libdir=$dir; break; else echo "tried $dir" >&AC_FD_CC ; fi
565 done
566
567 dnl AC_FIND_FILE(libqt.so libqt.so.1.40 libqt.so.1.41 libqt.so.1 libqt.a libqt.sl, $qt_libdirs, qt_libdir)
568 ac_qt_libraries="$qt_libdir"
569
570 ac_cxxflags_safe="$CXXFLAGS"
571 ac_ldflags_safe="$LDFLAGS"
572 ac_libs_safe="$LIBS"
573
574 CXXFLAGS="$CXXFLAGS -I$qt_incdir"
575 LDFLAGS="-L$qt_libdir $X_LDFLAGS"
576 LIBS="$LIBS -lqt -lXext -lX11 $LIBSOCKET"
577
578 KDE_PRINT_QT_PROGRAM
579
580 if AC_TRY_EVAL(ac_link) && test -s conftest; then
581   rm -f conftest*
582 else
583   echo "configure: failed program was:" >&AC_FD_CC
584   cat conftest.$ac_ext >&AC_FD_CC
585   ac_qt_libraries="NO"
586 fi
587 rm -f conftest*
588 CXXFLAGS="$ac_cxxflags_safe"
589 LDFLAGS="$ac_ldflags_safe"
590 LIBS="$ac_libs_safe"
591
592 if test "$ac_qt_includes" = NO || test "$ac_qt_libraries" = NO; then
593   ac_cv_have_qt="have_qt=no"
594   ac_qt_notfound=""
595   if test "$ac_qt_includes" = NO; then
596     if test "$ac_qt_libraries" = NO; then
597       ac_qt_notfound="(headers and libraries)";
598     else
599       ac_qt_notfound="(headers)";
600     fi
601   else
602     ac_qt_notfound="(libraries)";
603   fi
604
605   AC_MSG_ERROR([Qt-1.4 $ac_qt_notfound not found. Please check your installation! ]);
606 else
607   have_qt="yes"
608 fi
609 ])
610 else
611   have_qt="yes"
612 fi
613
614 eval "$ac_cv_have_qt"
615
616 if test "$have_qt" != yes; then
617   AC_MSG_RESULT([$have_qt]);
618 else
619   ac_cv_have_qt="have_qt=yes \
620     ac_qt_includes=$ac_qt_includes ac_qt_libraries=$ac_qt_libraries"
621   AC_MSG_RESULT([libraries $ac_qt_libraries, headers $ac_qt_includes])
622   
623   qt_libraries="$ac_qt_libraries"
624   qt_includes="$ac_qt_includes"
625 fi
626
627 if test ! "$kde_qt_libs_given" = "yes"; then
628 KDE_CHECK_QT_DIRECT(qt_libraries= ,[])
629 fi
630
631 dnl should check it's not Qt2, so it will fail now, rather than in KDE check
632
633 SAVE_CXXFLAGS="$CXXFLAGS"
634 CXXFLAGS="$CXXFLAGS -I$qt_includes -L$qt_libraries"
635 dnl specify we are definitely C++ compiling first
636 AC_LANG_CPLUSPLUS
637 AC_TRY_COMPILE([
638 #include <qglobal.h>
639 ],
640 [
641 #if (QT_VERSION >= 200)
642 break_me_(\\\);
643 #endif
644 ],
645 ac_qt_ok=yes,
646 ac_qt_ok=no
647
648 test "$ac_qt_ok" = no && AC_MSG_ERROR([Found Qt 2 - you must specify the path to the Qt 1 headers and libraries])
649 CXXFLAGS="$SAVE_CXXFLAGS"
650
651 AC_SUBST(qt_libraries)
652 AC_SUBST(qt_includes)
653
654 if test "$qt_includes" = "$x_includes" || test -z "$qt_includes"; then
655  QT_INCLUDES="";
656 else
657  QT_INCLUDES="-I$qt_includes"
658  all_includes="$QT_INCLUDES $all_includes"
659 fi
660
661 if test "$qt_libraries" = "$x_libraries" || test -z "$qt_libraries"; then
662  QT_LDFLAGS=""
663 else
664  QT_LDFLAGS="-L$qt_libraries"
665  all_libraries="$QT_LDFLAGS $all_libraries"
666 fi
667
668 AC_SUBST(QT_INCLUDES)
669 AC_SUBST(QT_LDFLAGS)
670 AC_PATH_QT_MOC
671 ])
672
673 AC_DEFUN(AC_PATH_QT,
674 [
675 AC_PATH_QT_1_3
676 ])
677
678 ## ------------------------------------------------------------------------
679 ## Now, the same with KDE
680 ## $(KDE_LDFLAGS) will be the kdeliblocation (if needed)
681 ## and $(kde_includes) will be the kdehdrlocation (if needed)
682 ## ------------------------------------------------------------------------
683 ##
684 AC_DEFUN(AC_BASE_PATH_KDE,
685 [
686 AC_REQUIRE([KDE_MISC_TESTS])
687 AC_REQUIRE([AC_PATH_QT])dnl
688 AC_MSG_CHECKING([for KDE])
689
690 AC_ARG_WITH(kde-dir,
691     [  --with-kde-dir          where the KDE root is ],
692     [ export KDEDIR="$withval" ])
693  
694 if test "${prefix}" != NONE; then
695   kde_includes=${prefix}/include
696   ac_kde_includes=$prefix/include
697
698   if test "${exec_prefix}" != NONE; then
699     kde_libraries=${exec_prefix}/lib
700     ac_kde_libraries=$exec_prefix/lib
701   else
702     kde_libraries=${prefix}/lib
703     ac_kde_libraries=$prefix/lib
704   fi
705 else
706   ac_kde_includes=
707   ac_kde_libraries=
708   kde_libraries=""
709   kde_includes=""
710 fi
711
712 if test ! -z "$KDEDIR"; then
713   ac_kde_includes="$KDEDIR/include"
714   kde_includes="$KDEDIR/include"
715   ac_kde_libraries="$KDEDIR/lib"
716   kde_libraries="$KDEDIR/lib"
717 fi
718
719 AC_ARG_WITH(kde-includes,
720     [  --with-kde-includes     where the KDE includes are installed. ],
721     [ ac_kde_includes="$withval" ])
722  
723 AC_ARG_WITH(kde-libraries,
724     [  --with-kde-libraries    where the KDE libraries are installed.],
725     [ ac_kde_libraries="$withval" ])
726  
727 AC_CACHE_VAL(ac_cv_have_kde,
728 [#try to guess kde locations
729
730 if test -z "$1"; then
731
732 kde_incdirs="/usr/lib/kde/include /usr/local/kde/include /usr/kde/include /usr/include/kde /usr/include /opt/kde/include $x_includes $qt_includes"
733 test -n "$KDEDIR" && kde_incdirs="$KDEDIR/include/kde $KDEDIR/include $KDEDIR $kde_incdirs"
734 kde_incdirs="$ac_kde_includes $kde_incdirs"
735 AC_FIND_FILE(ksock.h, $kde_incdirs, kde_incdir)
736 ac_kde_includes="$kde_incdir"
737
738 if test -n "$ac_kde_includes" && test ! -r "$ac_kde_includes/ksock.h"; then
739   AC_MSG_ERROR([
740 in the prefix, you've chosen, are no kde headers installed. This will fail.
741 So, check this please and use another prefix!])
742 fi
743
744 kde_libdirs="/usr/lib/kde/lib /usr/local/kde/lib /usr/kde/lib /usr/lib/kde /usr/lib /usr/X11R6/lib /opt/kde/lib /usr/X11R6/kde/lib"
745 test -n "$KDEDIR" && kde_libdirs="$KDEDIR/lib $KDEDIR $kde_libdirs"
746 kde_libdirs="$ac_kde_libraries $kde_libdirs"
747 AC_FIND_FILE(libkdecore.la, $kde_libdirs, kde_libdir)
748 ac_kde_libraries="$kde_libdir"
749
750 if test -n "$ac_kde_libraries" && test ! -r "$ac_kde_libraries/libkdecore.la"; then
751 AC_MSG_ERROR([
752 in the prefix, you've chosen $ac_kde_libraries, are no kde libraries installed. This will fail.
753 So, check this please and use another prefix!])
754 fi
755
756 if test "$ac_kde_includes" = NO || test "$ac_kde_libraries" = NO; then
757   ac_cv_have_kde="have_kde=no"
758 else
759   ac_cv_have_kde="have_kde=yes \
760     ac_kde_includes=$ac_kde_includes ac_kde_libraries=$ac_kde_libraries"
761 fi
762
763 else dnl test -z $1 
764   
765   ac_cv_have_kde="have_kde=no"
766
767 fi
768 ])dnl
769
770 eval "$ac_cv_have_kde"
771
772 if test "$have_kde" != "yes"; then
773  if test "${prefix}" = NONE; then
774   ac_kde_prefix="$ac_default_prefix"
775  else
776   ac_kde_prefix="$prefix"
777  fi
778  if test "$exec_prefix" = NONE; then
779   ac_kde_exec_prefix="$ac_kde_prefix"
780   AC_MSG_RESULT([will be installed in $ac_kde_prefix])
781  else
782   ac_kde_exec_prefix="$exec_prefix"
783   AC_MSG_RESULT([will be installed in $ac_kde_prefix and $ac_kde_exec_prefix])
784  fi
785
786  kde_libraries="${ac_kde_exec_prefix}/lib"
787  kde_includes=${ac_kde_prefix}/include
788
789 else
790   ac_cv_have_kde="have_kde=yes \
791     ac_kde_includes=$ac_kde_includes ac_kde_libraries=$ac_kde_libraries"
792   AC_MSG_RESULT([libraries $ac_kde_libraries, headers $ac_kde_includes])
793   
794   kde_libraries="$ac_kde_libraries"
795   kde_includes="$ac_kde_includes"
796 fi
797 AC_SUBST(kde_libraries)
798 AC_SUBST(kde_includes)
799
800 if test "$kde_includes" = "$x_includes" || test "$kde_includes" = "$qt_includes" ; then
801  KDE_INCLUDES=""
802 else
803  KDE_INCLUDES="-I$kde_includes"
804  all_includes="$KDE_INCLUDES $all_includes"
805 fi
806
807 if test "$kde_libraries" = "$x_libraries" || test "$kde_libraries" = "$qt_libraries" ; then
808  KDE_LDFLAGS=""
809 else
810  KDE_LDFLAGS="-L$kde_libraries"
811  all_libraries="$KDE_LDFLAGS $all_libraries"
812 fi
813
814 AC_SUBST(KDE_LDFLAGS)
815 AC_SUBST(KDE_INCLUDES)
816
817 AC_SUBST(all_includes)
818 AC_SUBST(all_libraries)
819
820 ])
821
822 AC_DEFUN(KDE_CHECK_KIMGIO,
823 [
824    AC_REQUIRE([AC_FIND_TIFF])
825    AC_REQUIRE([AC_FIND_JPEG]) 
826    AC_REQUIRE([AC_FIND_PNG]) 
827
828    LIB_KIMGIO='-lkimgio $(LIBJPEG) $(LIBTIFF) $(LIBPNG) -lm'
829    AC_SUBST(LIB_KIMGIO)
830    LIB_KHTMLW='-lkhtmlw $(LIB_KIMGIO) -ljscript'
831    AC_SUBST(LIB_KHTMLW)
832    LIB_KHTML='-lkhtml $(LIB_KIMGIO) -ljscript'
833    AC_SUBST(LIB_KHTML)
834 ])
835
836 AC_DEFUN(KDE_CREATE_LIBS_ALIASES,
837 [
838    AC_REQUIRE([KDE_MISC_TESTS])
839
840    KDE_LIBS='-lkfile -lkfm -lkdeui -lkdecore -lqt'
841    AC_SUBST(KDE_LIBS)
842 #   LIB_X11='-lX11 $(LIBSOCKET)'
843 #   AC_SUBST(LIB_X11)
844 #   LIB_QT='-lqt $(LIB_X11)'
845 #   AC_SUBST(LIB_QT)
846 #   LIB_KDECORE='-lkdecore -lXext $(LIB_QT)'
847 #   AC_SUBST(LIB_KDECORE)
848 #   LIB_KDEUI='-lkdeui $(LIB_KDECORE)'
849 #   AC_SUBST(LIB_KDEUI)
850 #   LIB_KFM='-lkfm $(LIB_KDECORE)'
851 #   AC_SUBST(LIB_KFM)
852 #   LIB_KFILE='-lkfile $(LIB_KFM) $(LIB_KDEUI)'
853 #   AC_SUBST(LIB_KFILE)
854 ])
855
856 AC_DEFUN(AC_PATH_KDE,
857 [
858   AC_BASE_PATH_KDE
859   ac_use_path_checking=""
860   install_root=
861
862   AC_CREATE_KFSSTND($ac_use_path_checking)
863
864   AC_SUBST_KFSSTND
865   KDE_CREATE_LIBS_ALIASES
866 ])
867
868 dnl slightly changed version of AC_CHECK_FUNC(setenv)
869 AC_DEFUN(AC_CHECK_SETENV,
870 [AC_MSG_CHECKING([for setenv])
871 AC_CACHE_VAL(ac_cv_func_setenv,
872 [AC_LANG_C
873 AC_TRY_LINK(
874 dnl Don't include <ctype.h> because on OSF/1 3.0 it includes <sys/types.h>
875 dnl which includes <sys/select.h> which contains a prototype for
876 dnl select.  Similarly for bzero.
877 [#include <assert.h>
878 ]ifelse(AC_LANG, CPLUSPLUS, [#ifdef __cplusplus
879 extern "C"
880 #endif
881 ])dnl
882 [/* We use char because int might match the return type of a gcc2
883     builtin and then its argument prototype would still apply.  */
884 #include <stdlib.h>
885 ], [
886 /* The GNU C library defines this for functions which it implements
887     to always fail with ENOSYS.  Some functions are actually named
888     something starting with __ and the normal name is an alias.  */
889 #if defined (__stub_$1) || defined (__stub___$1)
890 choke me
891 #else
892 setenv("TEST", "alle", 1);
893 #endif
894 ], eval "ac_cv_func_setenv=yes", eval "ac_cv_func_setenv=no")])
895
896 if test "$ac_cv_func_setenv" = "yes"; then
897   AC_MSG_RESULT(yes)
898   AC_DEFINE_UNQUOTED(HAVE_FUNC_SETENV)
899 else
900   AC_MSG_RESULT(no)
901 fi
902 ])
903
904 AC_DEFUN(AC_CHECK_GETDOMAINNAME,
905 [
906 AC_LANG_CPLUSPLUS
907 save_CXXFLAGS="$CXXFLAGS"
908 if test "$GCC" = "yes"; then
909 CXXFLAGS="$CXXFLAGS -pedantic-errors"
910 fi
911 AC_MSG_CHECKING(for getdomainname)
912 AC_CACHE_VAL(ac_cv_func_getdomainname,
913 [
914 AC_TRY_COMPILE([
915 #include <stdlib.h>
916 #include <unistd.h>
917 ],
918 [
919 char buffer[200];
920 getdomainname(buffer, 200);
921 ],
922 ac_cv_func_getdomainname=yes,
923 ac_cv_func_getdomainname=no)
924 ])
925 AC_MSG_RESULT($ac_cv_func_getdomainname)
926 if eval "test \"`echo `$ac_cv_func_getdomainname\" = yes"; then
927   AC_DEFINE(HAVE_GETDOMAINNAME)
928 fi
929 CXXFLAGS="$save_CXXFLAGS"
930 ])
931
932 AC_DEFUN(AC_CHECK_GETHOSTNAME,
933 [
934 AC_LANG_CPLUSPLUS
935 save_CXXFLAGS="$CXXFLAGS"
936 if test "$GCC" = "yes"; then
937 CXXFLAGS="$CXXFLAGS -pedantic-errors"
938 fi
939
940 AC_MSG_CHECKING([for gethostname])
941 AC_CACHE_VAL(ac_cv_func_gethostname,
942 [
943 AC_TRY_COMPILE([
944 #include <stdlib.h>
945 #include <unistd.h>
946 ],
947 [
948 char buffer[200];
949 gethostname(buffer, 200);
950 ],
951 ac_cv_func_gethostname=yes,
952 ac_cv_func_gethostname=no)
953 ])
954 AC_MSG_RESULT($ac_cv_func_gethostname)
955 if eval "test \"`echo `$ac_cv_func_gethostname\" = yes"; then
956   AC_DEFINE(HAVE_GETHOSTNAME)
957 fi
958 CXXFLAGS="$save_CXXFLAGS"
959 ])
960
961 AC_DEFUN(AC_CHECK_USLEEP,
962 [
963 AC_LANG_CPLUSPLUS
964
965 AC_MSG_CHECKING([for usleep])
966 AC_CACHE_VAL(ac_cv_func_usleep,
967 [
968 ac_libs_safe="$LIBS"
969 LIBS="$LIBS $LIBUCB"
970 AC_TRY_LINK([
971 #include <stdlib.h>
972 #include <unistd.h>
973 ],
974 [
975 usleep(200);
976 ],
977 ac_cv_func_usleep=yes,
978 ac_cv_func_usleep=no)
979 ])
980 AC_MSG_RESULT($ac_cv_func_usleep)
981 if eval "test \"`echo `$ac_cv_func_usleep\" = yes"; then
982   AC_DEFINE(HAVE_USLEEP)
983 fi
984 LIBS="$ac_libs_safe"
985 ])
986
987 AC_DEFUN(AC_FIND_GIF,
988    [AC_MSG_CHECKING([for giflib])
989 AC_CACHE_VAL(ac_cv_lib_gif,
990 [ac_save_LIBS="$LIBS"
991 LIBS="$all_libraries -lgif -lX11 $LIBSOCKET"
992 AC_TRY_LINK(dnl
993 [
994 #ifdef __cplusplus
995 extern "C" {
996 #endif
997 int GifLastError(void);
998 #ifdef __cplusplus
999 }
1000 #endif
1001 /* We use char because int might match the return type of a gcc2
1002     builtin and then its argument prototype would still apply.  */
1003 ],
1004             [return GifLastError();],
1005             eval "ac_cv_lib_gif=yes",
1006             eval "ac_cv_lib_gif=no")
1007 LIBS="$ac_save_LIBS"
1008 ])dnl
1009 if eval "test \"`echo $ac_cv_lib_gif`\" = yes"; then
1010   AC_MSG_RESULT(yes)
1011   AC_DEFINE_UNQUOTED(HAVE_LIBGIF)
1012 else
1013   AC_MSG_ERROR(You need giflib23. Please install the kdesupport package)
1014 fi
1015 ])
1016
1017 AC_DEFUN(AC_FIND_JPEG,
1018    [AC_MSG_CHECKING([for jpeglib])
1019 AC_CACHE_VAL(ac_cv_lib_jpeg,
1020 [ac_save_LIBS="$LIBS"
1021 LIBS="$all_libraries -ljpeg -lm"
1022 AC_TRY_LINK(
1023 [/* Override any gcc2 internal prototype to avoid an error.  */
1024 struct jpeg_decompress_struct;
1025 typedef struct jpeg_decompress_struct * j_decompress_ptr;
1026 typedef int size_t;
1027 #ifdef __cplusplus
1028 extern "C" {
1029 #endif
1030     void jpeg_CreateDecompress(j_decompress_ptr cinfo,
1031                                     int version, size_t structsize);
1032 #ifdef __cplusplus
1033 }
1034 #endif
1035 /* We use char because int might match the return type of a gcc2
1036     builtin and then its argument prototype would still apply.  */
1037 ],
1038             [jpeg_CreateDecompress(0L, 0, 0);],
1039             eval "ac_cv_lib_jpeg=-ljpeg",
1040             eval "ac_cv_lib_jpeg=no")
1041 LIBS="$ac_save_LIBS"
1042
1043 dnl what to do, if the normal way fails:
1044 if eval "test \"`echo $ac_cv_lib_jpeg`\" = no"; then
1045         if test -f "$kde_libraries/libjpeg.so"; then
1046            test -f ./libjpegkde.so || $LN_S $kde_libraries/libjpeg.so ./libjpegkde.so
1047            ac_cv_lib_jpeg="-L\${topdir} -ljpegkde"
1048         else if test -f "$kde_libraries/libjpeg.sl"; then
1049            test -f ./libjpegkde.sl ||$LN_S $kde_libraries/libjpeg.sl ./libjpegkde.sl
1050            ac_cv_lib_jpeg="-L\${topdir} -ljpegkde"      
1051         else if test -f "$kde_libraries/libjpeg.a"; then
1052            test -f ./libjpegkde.a || $LN_S $kde_libraries/libjpeg.a ./libjpegkde.a
1053            ac_cv_lib_jpeg="-L\${topdir} -ljpegkde"
1054         else
1055           AC_MSG_ERROR([
1056 You need jpeglib6a. Please install the kdesupport package.
1057 If you have already installed kdesupport, you may have an
1058 old libjpeg somewhere. 
1059 In this case copy $KDEDIR/lib/libjpeg* to /usr/lib.
1060 ])
1061         fi
1062       fi
1063    fi
1064 fi
1065 ])dnl
1066 if eval "test ! \"`echo $ac_cv_lib_jpeg`\" = no"; then
1067   LIBJPEG="$ac_cv_lib_jpeg"
1068   AC_SUBST(LIBJPEG)
1069   AC_MSG_RESULT($ac_cv_lib_jpeg)
1070   AC_DEFINE_UNQUOTED(HAVE_LIBJPEG)
1071 fi
1072 ])
1073
1074 AC_DEFUN(AC_FIND_ZLIB,
1075 [
1076 AC_MSG_CHECKING([for libz])
1077 AC_CACHE_VAL(ac_cv_lib_z,
1078 [ac_save_LIBS="$LIBS"
1079 LIBS="$all_libraries -lz $LIBSOCKET"
1080 AC_TRY_LINK(dnl
1081 [
1082 #include<zlib.h>
1083 ],
1084             [return (zlibVersion() == ZLIB_VERSION); ],
1085             eval "ac_cv_lib_z='-lz'",
1086             eval "ac_cv_lib_z=no")
1087 LIBS="$ac_save_LIBS"
1088 ])dnl
1089 if eval "test ! \"`echo $ac_cv_lib_z`\" = no"; then
1090 dnl  AC_DEFINE_UNQUOTED(HAVE_LIBZ)
1091   LIBZ="$ac_cv_lib_z"
1092   AC_SUBST(LIBZ)
1093   AC_MSG_RESULT($ac_cv_lib_z)
1094 else
1095   AC_MSG_RESULT(no)
1096   LIBZ=""
1097   AC_SUBST(LIBZ)
1098 fi
1099 ])
1100
1101 AC_DEFUN(AC_FIND_TIFF,
1102 [
1103 AC_REQUIRE([AC_FIND_ZLIB])
1104 AC_REQUIRE([AC_FIND_JPEG])
1105 AC_MSG_CHECKING([for libtiff])
1106 AC_CACHE_VAL(ac_cv_lib_tiff,
1107 [ac_save_LIBS="$LIBS"
1108 LIBS="$all_libraries -ltiff $LIBJPEG $LIBZ -lX11 $LIBSOCKET"
1109 AC_TRY_LINK(dnl
1110 [
1111 #include<tiffio.h>
1112 ],
1113             [return (TIFFOpen( "", "r") == 0); ],
1114             eval "ac_cv_lib_tiff='-ltiff $LIBJPEG $LIBZ'",
1115             eval "ac_cv_lib_tiff=no")
1116 LIBS="$ac_save_LIBS"
1117 ])dnl
1118 if eval "test ! \"`echo $ac_cv_lib_tiff`\" = no"; then
1119   AC_DEFINE_UNQUOTED(HAVE_LIBTIFF)
1120   LIBTIFF="$ac_cv_lib_tiff"
1121   AC_SUBST(LIBTIFF)
1122   AC_MSG_RESULT($ac_cv_lib_tiff)
1123 else
1124   AC_MSG_RESULT(no)
1125   LIBTIFF=""
1126   AC_SUBST(LIBTIFF)
1127 fi
1128 ])
1129
1130
1131 AC_DEFUN(AC_FIND_PNG,
1132 [
1133 AC_REQUIRE([AC_FIND_ZLIB])
1134 AC_MSG_CHECKING([for libpng])
1135 AC_CACHE_VAL(ac_cv_lib_png,
1136 [ac_save_LIBS="$LIBS"
1137 LIBS="$all_libraries -lpng $LIBZ -lm -lX11 $LIBSOCKET"
1138 AC_LANG_C
1139 AC_TRY_LINK(dnl
1140     [
1141     #include<png.h>
1142     ],
1143     [
1144     png_structp png_ptr = png_create_read_struct(  // image ptr
1145                 PNG_LIBPNG_VER_STRING, 0, 0, 0 );
1146     return( png_ptr != 0 ); 
1147     ],
1148     eval "ac_cv_lib_png='-lpng $LIBZ -lm'",
1149     eval "ac_cv_lib_png=no")
1150     LIBS="$ac_save_LIBS"
1151 ])dnl
1152 if eval "test ! \"`echo $ac_cv_lib_png`\" = no"; then
1153   AC_DEFINE_UNQUOTED(HAVE_LIBPNG)
1154   LIBPNG="$ac_cv_lib_png"
1155   AC_SUBST(LIBPNG)
1156   AC_MSG_RESULT($ac_cv_lib_png)
1157 else
1158   AC_MSG_RESULT(no)
1159   LIBPNG=""
1160   AC_SUBST(LIBPNG)
1161 fi
1162 ])
1163
1164 AC_DEFUN(AC_CHECK_GNU_EXTENSIONS,
1165 [
1166 AC_MSG_CHECKING(if you need GNU extensions)
1167 AC_CACHE_VAL(ac_cv_gnu_extensions,
1168 [
1169 cat > conftest.c << EOF
1170 #include <features.h>
1171
1172 #ifdef __GNU_LIBRARY__
1173 yes
1174 #endif
1175 EOF
1176
1177 if (eval "$ac_cpp conftest.c") 2>&5 |
1178   egrep "yes" >/dev/null 2>&1; then
1179   rm -rf conftest*
1180   ac_cv_gnu_extensions=yes
1181 else
1182   ac_cv_gnu_extensions=no
1183 fi
1184 ])
1185
1186 AC_MSG_RESULT($ac_cv_gnu_extensions)
1187 if test "$ac_cv_gnu_extensions" = "yes"; then
1188   AC_DEFINE_UNQUOTED(_GNU_SOURCE)
1189 fi
1190 ])
1191
1192 dnl just a wrapper to clean up configure.in
1193 AC_DEFUN(KDE_PROG_LIBTOOL,
1194 [
1195 AC_REQUIRE([AM_ENABLE_SHARED])
1196 AC_REQUIRE([AM_ENABLE_STATIC])
1197 dnl libtool is only for C, so I must force him
1198 dnl to find the correct flags for C++
1199 ac_save_cc=$CC
1200 ac_save_cflags="$CFLAGS"
1201 CC=$CXX
1202 CFLAGS="$CXXFLAGS"
1203 AM_PROG_LIBTOOL dnl for libraries
1204 CC=$ac_save_cc
1205 CFLAGS="$ac_save_cflags"
1206 ])
1207
1208 AC_DEFUN(KDE_DO_IT_ALL,
1209 [
1210 KDE_PROG_LIBTOOL
1211 AC_PATH_KDE
1212 AC_PATH_PROG(QTARCH, "qtarch",qtarch-notinstalled)
1213 ])
1214
1215 AC_DEFUN(AC_CHECK_RPATH,
1216 [
1217 AC_MSG_CHECKING(for rpath)
1218 AC_ARG_ENABLE(rpath,
1219       [  --disable-rpath         do not use the rpath feature of ld],
1220       USE_RPATH=$enableval, USE_RPATH=yes)
1221 if test -z "$KDE_RPATH" && test "$USE_RPATH" = "yes"; then
1222
1223   KDE_RPATH="-rpath \$(kde_libraries)"
1224
1225   if test -n "$qt_libraries"; then
1226     KDE_RPATH="$KDE_RPATH -rpath \$(qt_libraries)"
1227   fi
1228   dnl $x_libraries is set to /usr/lib in case
1229   if test -n "$X_LDFLAGS"; then 
1230     KDE_RPATH="$KDE_RPATH -rpath \$(x_libraries)"
1231   fi
1232   if test -n "$KDE_EXTRA_RPATH"; then
1233     KDE_RPATH="$KDE_RPATH \$(KDE_EXTRA_RPATH)"
1234   fi
1235 fi 
1236 AC_SUBST(KDE_EXTRA_RPATH)
1237 AC_SUBST(KDE_RPATH)
1238 AC_MSG_RESULT($USE_RPATH)
1239 ])
1240
1241 # Search path for a program which passes the given test.
1242 # Ulrich Drepper <drepper@cygnus.com>, 1996.
1243
1244 # serial 1
1245 # Stephan Kulow: I appended a _KDE against name conflicts
1246
1247 dnl AM_PATH_PROG_WITH_TEST_KDE(VARIABLE, PROG-TO-CHECK-FOR,
1248 dnl   TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
1249 AC_DEFUN(AM_PATH_PROG_WITH_TEST_KDE,
1250 [# Extract the first word of "$2", so it can be a program name with args.
1251 set dummy $2; ac_word=[$]2
1252 AC_MSG_CHECKING([for $ac_word])
1253 AC_CACHE_VAL(ac_cv_path_$1,
1254 [case "[$]$1" in
1255   /*)
1256   ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
1257   ;;
1258   *)
1259   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
1260   for ac_dir in ifelse([$5], , $PATH, [$5]); do
1261     test -z "$ac_dir" && ac_dir=.
1262     if test -f $ac_dir/$ac_word; then
1263       if [$3]; then
1264         ac_cv_path_$1="$ac_dir/$ac_word"
1265         break
1266       fi
1267     fi
1268   done
1269   IFS="$ac_save_ifs"
1270 dnl If no 4th arg is given, leave the cache variable unset,
1271 dnl so AC_PATH_PROGS will keep looking.
1272 ifelse([$4], , , [  test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
1273 ])dnl
1274   ;;
1275 esac])dnl
1276 $1="$ac_cv_path_$1"
1277 if test -n "[$]$1"; then
1278   AC_MSG_RESULT([$]$1)
1279 else
1280   AC_MSG_RESULT(no)
1281 fi
1282 AC_SUBST($1)dnl
1283 ])
1284
1285
1286 dnl From Jim Meyering.
1287 dnl FIXME: migrate into libit.
1288
1289 AC_DEFUN(AM_FUNC_OBSTACK,
1290 [AC_CACHE_CHECK([for obstacks], am_cv_func_obstack,
1291  [AC_TRY_LINK([#include "obstack.h"],
1292               [struct obstack *mem;obstack_free(mem,(char *) 0)],
1293               am_cv_func_obstack=yes,
1294               am_cv_func_obstack=no)])
1295  if test $am_cv_func_obstack = yes; then
1296    AC_DEFINE(HAVE_OBSTACK)
1297  else
1298    LIBOBJS="$LIBOBJS obstack.o"
1299  fi
1300 ])
1301
1302 dnl From Jim Meyering.  Use this if you use the GNU error.[ch].
1303 dnl FIXME: Migrate into libit
1304
1305 AC_DEFUN(AM_FUNC_ERROR_AT_LINE,
1306 [AC_CACHE_CHECK([for error_at_line], am_cv_lib_error_at_line,
1307  [AC_TRY_LINK([],[error_at_line(0, 0, "", 0, "");],
1308               am_cv_lib_error_at_line=yes,
1309               am_cv_lib_error_at_line=no)])
1310  if test $am_cv_lib_error_at_line = no; then
1311    LIBOBJS="$LIBOBJS error.o"
1312  fi
1313  AC_SUBST(LIBOBJS)dnl
1314 ])
1315
1316 # Macro to add for using GNU gettext.
1317 # Ulrich Drepper <drepper@cygnus.com>, 1995.
1318
1319 # serial 1
1320 # Stephan Kulow: I put a KDE in it to avoid name conflicts
1321
1322 AC_DEFUN(AM_KDE_GNU_GETTEXT,
1323   [AC_REQUIRE([AC_PROG_MAKE_SET])dnl
1324    AC_REQUIRE([AC_PROG_RANLIB])dnl
1325    AC_REQUIRE([AC_HEADER_STDC])dnl
1326    AC_REQUIRE([AC_C_INLINE])dnl
1327    AC_REQUIRE([AC_TYPE_OFF_T])dnl
1328    AC_REQUIRE([AC_TYPE_SIZE_T])dnl
1329    AC_REQUIRE([AC_FUNC_ALLOCA])dnl
1330    AC_REQUIRE([AC_FUNC_MMAP])dnl
1331    AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h string.h \
1332 unistd.h values.h alloca.h])
1333    AC_CHECK_FUNCS([getcwd munmap putenv setenv setlocale strchr strcasecmp \
1334 __argz_count __argz_stringify __argz_next stpcpy])
1335
1336    AM_LC_MESSAGES
1337
1338    if test "x$CATOBJEXT" != "x"; then
1339      if test "x$ALL_LINGUAS" = "x"; then
1340        LINGUAS=
1341      else
1342        AC_MSG_CHECKING(for catalogs to be installed)
1343        NEW_LINGUAS=
1344        for lang in ${LINGUAS=$ALL_LINGUAS}; do
1345          case "$ALL_LINGUAS" in
1346           *$lang*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;;
1347          esac
1348        done
1349        LINGUAS=$NEW_LINGUAS
1350        AC_MSG_RESULT($LINGUAS)
1351      fi
1352
1353      dnl Construct list of names of catalog files to be constructed.
1354      if test -n "$LINGUAS"; then
1355        for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
1356      fi
1357    fi
1358
1359   ])
1360
1361 AC_DEFUN(AC_HAVE_XPM,
1362  [AC_REQUIRE_CPP()dnl
1363
1364  test -z "$XPM_LDFLAGS" && XPM_LDFLAGS=
1365  test -z "$XPM_INCLUDE" && XPM_INCLUDE=
1366
1367  AC_ARG_WITH(xpm, [  --without-xpm           disable color pixmap XPM tests],
1368         xpm_test=$withval, xpm_test="yes")
1369  if test "x$xpm_test" = xno; then
1370    ac_cv_have_xpm=no
1371  else
1372    AC_MSG_CHECKING(for XPM)
1373    AC_CACHE_VAL(ac_cv_have_xpm,
1374    [
1375     AC_LANG_C
1376     ac_save_ldflags="$LDFLAGS"
1377     ac_save_cflags="$CFLAGS"
1378     LDFLAGS="$LDFLAGS $XPM_LDFLAGS $all_libraries -lXpm -lX11 -lXext $LIBSOCKET"
1379     CFLAGS="$CFLAGS $X_INCLUDES"
1380     test ! -z "$XPM_INCLUDE" && CFLAGS="-I$XPM_INCLUDE $CFLAGS"
1381     AC_TRY_LINK([#include <X11/xpm.h>],[],
1382         ac_cv_have_xpm="yes",ac_cv_have_xpm="no")
1383     LDFLAGS="$ac_save_ldflags"
1384     CFLAGS="$ac_save_cflags"
1385    ])dnl
1386  
1387   if test "$ac_cv_have_xpm" = no; then
1388     AC_MSG_RESULT(no)
1389     XPM_LDFLAGS=""
1390     XPMINC=""
1391     $2
1392   else
1393     AC_DEFINE(HAVE_XPM)
1394     if test "$XPM_LDFLAGS" = ""; then
1395        XPMLIB="-lXpm"
1396     else
1397        XPMLIB="-L$XPM_LDFLAGS -lXpm"
1398     fi
1399     if test "$XPM_INCLUDE" = ""; then
1400        XPMINC=""
1401     else
1402        XPMINC="-I$XPM_INCLUDE"
1403     fi
1404     AC_MSG_RESULT(yes)
1405     $1
1406   fi
1407  fi
1408  AC_SUBST(XPMINC)
1409  AC_SUBST(XPMLIB)
1410 ]) 
1411
1412 AC_DEFUN(AC_HAVE_GL,
1413  [AC_REQUIRE_CPP()dnl
1414
1415  test -z "$GL_LDFLAGS" && GL_LDFLAGS=
1416  test -z "$GL_INCLUDE" && GL_INCLUDE=
1417
1418  AC_ARG_WITH(gl, [  --without-gl            disable 3D GL modes],
1419         gl_test=$withval, gl_test="yes")
1420  if test "x$gl_test" = xno; then
1421    ac_cv_have_gl=no
1422  else
1423    AC_MSG_CHECKING(for GL)
1424    AC_CACHE_VAL(ac_cv_have_gl,
1425    [
1426     AC_LANG_C
1427     ac_save_ldflags="$LDFLAGS"
1428     ac_save_cflags="$CFLAGS"
1429     LDFLAGS="$LDFLAGS $GL_LDFLAGS $all_libraries -lMesaGL -lMesaGLU -lX11 -lXext -lm $LIBSOCKET"
1430     CFLAGS="$CFLAGS $X_INCLUDES"
1431     test ! -z "$GL_INCLUDE" && CFLAGS="-I$GL_INCLUDE $CFLAGS"
1432     AC_TRY_LINK([],[],
1433         ac_cv_have_gl="yes",ac_cv_have_gl="no")
1434     LDFLAGS="$ac_save_ldflags"
1435     CFLAGS="$ac_save_cflags"
1436    ])dnl
1437  
1438   if test "$ac_cv_have_gl" = no; then
1439     AC_MSG_RESULT(no)
1440     GL_LDFLAGS=""
1441     GLINC=""
1442     $2
1443   else
1444     AC_DEFINE(HAVE_GL)
1445     if test "$GL_LDFLAGS" = ""; then
1446        GLLIB="-lMesaGL -lMesaGLU"
1447     else
1448        GLLIB="-L$GL_LDFLAGS -lMesaGL -lMesaGLU"
1449     fi
1450     if test "$GL_INCLUDE" = ""; then
1451        GLINC=""
1452     else
1453        GLINC="-I$GL_INCLUDE"
1454     fi
1455     AC_MSG_RESULT(yes)
1456     $1
1457   fi
1458  fi
1459  AC_SUBST(GLINC)
1460  AC_SUBST(GLLIB)
1461 ]) 
1462
1463  dnl PAM pam
1464  
1465  dnl Should test for PAM (Pluggable Authentication Modules)
1466 AC_DEFUN(KDE_CHECK_LIBDL,
1467 [
1468 AC_CHECK_LIB(dl, dlopen, [
1469 LIBDL="-ldl"
1470 ac_cv_have_dlfcn=yes
1471 ])
1472
1473 AC_CHECK_LIB(dld, shl_unload, [
1474 LIBDL="-ldld"
1475 ac_cv_have_shload=yes
1476 ])
1477
1478 AC_SUBST(LIBDL)
1479 ])
1480
1481 AC_DEFUN(KDE_CHECK_DLOPEN,
1482 [
1483 KDE_CHECK_LIBDL
1484 AC_CHECK_HEADERS(dlfcn.h dl.h)
1485 if test "$ac_cv_header_dlfcn_h" = "no"; then
1486   ac_cv_have_dlfcn=no
1487 fi
1488
1489 if test "$ac_cv_header_dl_h" = "no"; then
1490   ac_cv_have_shload=no
1491 fi
1492
1493 enable_dlopen=no
1494 AC_ARG_ENABLE(dlopen,
1495 [  --disable-dlopen        link staticly [default=no]] ,
1496 [if test "$enableval" = yes; then
1497   enable_dlopen=yes
1498 fi],
1499 enable_dlopen=yes)
1500
1501 # override the user's opinion, if we know it better ;)
1502 if test "$ac_cv_have_dlfcn" = "no" && test "$ac_cv_have_shload" = "no"; then
1503   enable_dlopen=no
1504 fi
1505
1506 if test "$ac_cv_have_dlfcn" = "yes"; then
1507   AC_DEFINE_UNQUOTED(HAVE_DLFCN)
1508 fi
1509
1510 if test "$ac_cv_have_shload" = "yes"; then
1511   AC_DEFINE_UNQUOTED(HAVE_SHLOAD)
1512 fi
1513
1514 if test "$enable_dlopen" = no ; then
1515   test -n "$1" && eval $1
1516 else
1517   test -n "$2" && eval $2
1518 fi
1519
1520 ])
1521
1522 AC_DEFUN(KDE_CHECK_DYNAMIC_LOADING,
1523 [
1524 KDE_CHECK_DLOPEN(libtool_enable_shared=no, libtool_enable_static=no)
1525 KDE_PROG_LIBTOOL
1526 AC_MSG_CHECKING([dynamic loading])
1527 eval "`egrep '^build_libtool_libs=' libtool`"
1528 if test "$build_libtool_libs" = "yes" && test "$enable_dlopen" = "yes"; then
1529   dynamic_loading=yes
1530   AC_DEFINE_UNQUOTED(HAVE_DYNAMIC_LOADING)
1531 else
1532   dynamic_loading=no
1533 fi
1534 AC_MSG_RESULT($dynamic_loading)
1535 if test "$dynamic_loading" = "yes"; then
1536   $1
1537 else
1538   $2
1539 fi
1540 ])
1541
1542 AC_DEFUN(KDE_ADD_INCLUDES,
1543 [
1544 if test -z "$1"; then 
1545   test_include="Pix.h"
1546 else
1547   test_include="$1"
1548 fi
1549
1550 AC_MSG_CHECKING([for libg++ ($test_include)])
1551
1552 AC_CACHE_VAL(kde_cv_libgpp_includes,
1553 [
1554 kde_cv_libgpp_includes=no
1555
1556    for ac_dir in               \
1557                                \
1558      /usr/include/g++          \
1559      /usr/include              \
1560      /usr/unsupported/include  \
1561      /opt/include              \
1562      $extra_include            \
1563      ; \
1564    do
1565      if test -r "$ac_dir/$test_include"; then
1566        kde_cv_libgpp_includes=$ac_dir
1567        break
1568      fi
1569    done
1570 ])
1571
1572 AC_MSG_RESULT($kde_cv_libgpp_includes)
1573 if test "$kde_cv_libgpp_includes" != "no"; then
1574   all_includes="-I$kde_cv_libgpp_includes $all_includes"
1575 fi
1576 ])
1577
1578
1579 AC_DEFUN(KDE_CHECK_LIBPTHREAD,
1580 [
1581 AC_CHECK_LIB(pthread, pthread_create, [LIBPTHREAD="-lpthread"], LIBPTHREAD= )
1582 AC_SUBST(LIBPTHREAD)
1583 ])
1584
1585 AC_DEFUN(KDE_CHECK_STL_SGI,
1586 [
1587     AC_MSG_CHECKING([if STL implementation is SGI like])
1588     AC_CACHE_VAL(kde_cv_stl_type_sgi,
1589     [
1590       AC_TRY_COMPILE([
1591 #include <string>
1592 ],[
1593   string astring="Hallo Welt.";
1594   astring.erase(0, 6); // now astring is "Welt"
1595   return 0;
1596 ], kde_cv_stl_type_sgi=yes,
1597    kde_cv_stl_type_sgi=no)
1598 ])
1599
1600    AC_MSG_RESULT($kde_cv_stl_type_sgi)
1601
1602    if test "$kde_cv_stl_type_sgi" = "yes"; then
1603         AC_DEFINE_UNQUOTED(HAVE_SGI_STL) 
1604    fi
1605 ])
1606
1607 AC_DEFUN(KDE_CHECK_STL_HP,
1608 [
1609     AC_MSG_CHECKING([if STL implementation is HP like])
1610     AC_CACHE_VAL(kde_cv_stl_type_hp,
1611     [
1612       AC_TRY_COMPILE([
1613 #include <string>
1614 ],[
1615   string astring="Hello World";
1616   astring.remove(0, 6); // now astring is "World"
1617   return 0;
1618 ], kde_cv_stl_type_hp=yes,
1619    kde_cv_stl_type_hp=no)
1620 ])
1621    AC_MSG_RESULT($kde_cv_stl_type_hp)
1622
1623    if test "$kde_cv_stl_type_hp" = "yes"; then
1624         AC_DEFINE_UNQUOTED(HAVE_HP_STL) 
1625    fi
1626 ])
1627
1628 AC_DEFUN(KDE_CHECK_STL,
1629 [
1630     KDE_CHECK_STL_SGI
1631     
1632     if test "$kde_cv_stl_type_sgi" = "no"; then
1633        KDE_CHECK_STL_HP
1634
1635        if test "$kde_cv_stl_type_hp" = "no"; then
1636          AC_MSG_ERROR("no known STL type found")
1637        fi
1638     fi
1639
1640 ])
1641
1642 AC_DEFUN(AC_FIND_QIMGIO,
1643    [AC_REQUIRE([AC_FIND_JPEG])
1644 AC_MSG_CHECKING([for qimgio])
1645 AC_CACHE_VAL(ac_cv_lib_qimgio,
1646 [ac_save_LIBS="$LIBS"
1647 LIBS="$all_libraries -lqimgio -lpng -lz -lqt $LIBJPEG -lX11 $LIBSOCKET"
1648 AC_TRY_LINK(dnl
1649 [
1650 void qInitImageIO ();
1651 ],
1652             [qInitImageIO();],
1653             eval "ac_cv_lib_qimgio=yes",
1654             eval "ac_cv_lib_qimgio=no")
1655 LIBS="$ac_save_LIBS"
1656 ])dnl
1657 if eval "test \"`echo $ac_cv_lib_qimgio`\" = yes"; then
1658   LIBQIMGIO="-lqimgio -lpng -lz $LIBJPEG"
1659   AC_MSG_RESULT(yes)
1660   AC_DEFINE_UNQUOTED(HAVE_QIMGIO)
1661   AC_SUBST(LIBQIMGIO)
1662 else
1663   AC_MSG_RESULT(not found)
1664 fi
1665 ])