]> git.lyx.org Git - lyx.git/blob - config/kde.m4
f79a9fed8d97754e8f2bdfa07fbe1d25b9e26158
[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 AC_DEFUN(KDE_MOC_ERROR_MESSAGE,
98 [
99     AC_MSG_ERROR([No Qt meta object compiler (moc) found!
100 Please check whether you installed Qt correctly.
101 You need to have a running moc binary.
102 configure tried to run $ac_cv_path_moc and the test didn't
103 succeed. If configure shouldn't have tried this one, set
104 the environment variable MOC to the right one before running
105 configure.
106 ])
107 ])
108
109 dnl ------------------------------------------------------------------------
110 dnl Find the meta object compiler in the PATH, in $QTDIR/bin, and some
111 dnl more usual places
112 dnl ------------------------------------------------------------------------
113 dnl
114 AC_DEFUN(AC_PATH_QT_MOC,
115 [
116    KDE_FIND_PATH(moc, MOC, [$ac_qt_bindir $QTDIR/bin \
117             /usr/bin /usr/X11R6/bin /usr/lib/qt/bin \
118             /usr/local/qt/bin], [KDE_MOC_ERROR_MESSAGE])
119  
120    if test -z "$MOC"; then
121      if test -n "$ac_cv_path_moc"; then
122        output=`eval "$ac_cv_path_moc --help 2>&1 | sed -e '1q' | grep Qt"`
123      fi
124      echo "configure:__oline__: tried to call $ac_cv_path_moc --help 2>&1 | sed -e '1q' | grep Qt" >&AC_FD_CC
125      echo "configure:__oline__: moc output: $output" >&AC_FD_CC
126  
127      if test -z "$output"; then
128        KDE_MOC_ERROR_MESSAGE
129     fi
130    fi
131  
132    AC_SUBST(MOC)
133 ])
134
135 AC_DEFUN(KDE_REPLACE_ROOT,
136   $1=`echo "$$1" | sed -e "s#^/#\$\{install_root\}/#"`
137 )
138
139 AC_DEFUN(AC_CREATE_KFSSTND,
140 [
141 AC_REQUIRE([AC_CHECK_RPATH])
142
143 if test "$1" = "default"; then
144
145   AC_MSG_CHECKING(for KDE paths)
146
147   if test -z "$kde_htmldir"; then
148     kde_htmldir="\$(prefix)/share/doc/HTML"
149   fi
150   if test -z "$kde_appsdir"; then
151     kde_appsdir="\$(prefix)/share/applnk"
152   fi
153   if test -z "$kde_icondir"; then
154     kde_icondir="\$(prefix)/share/icons"
155   fi
156   if test -z "$kde_sounddir"; then
157     kde_sounddir="\$(prefix)/share/sounds"
158   fi
159   if test -z "$kde_datadir"; then
160     kde_datadir="\$(prefix)/share/apps"
161   fi
162   if test -z "$kde_locale"; then
163     kde_locale="\$(prefix)/share/locale"
164   fi
165   if test -z "$kde_cgidir"; then
166     kde_cgidir="\$(exec_prefix)/cgi-bin"
167   fi
168   if test -z "$kde_confdir"; then
169     kde_confdir="\$(prefix)/share/config"
170   fi
171   if test -z "$kde_mimedir"; then
172     kde_mimedir="\$(prefix)/share/mimelnk"
173   fi
174   if test -z "$kde_toolbardir"; then
175     kde_toolbardir="\$(prefix)/share/toolbar"
176   fi
177   if test -z "$kde_wallpaperdir"; then
178     kde_wallpaperdir="\$(prefix)/share/wallpapers"
179   fi
180   if test -z "$kde_bindir"; then
181     kde_bindir="\$(exec_prefix)/bin"
182   fi
183   if test -z "$kde_partsdir"; then
184     kde_partsdir="\$(exec_prefix)/parts"
185   fi
186   AC_MSG_RESULT(defaults)       
187
188 else 
189
190 AC_CACHE_VAL(kde_cv_all_paths,
191 [
192 AC_MSG_CHECKING([for kde headers installed])
193 AC_LANG_CPLUSPLUS
194 cat > conftest.$ac_ext <<EOF
195 #include <stdio.h>
196 #include "confdefs.h"
197 #include <kapp.h>
198
199 int main() {
200 printf("kde_htmldir=\\"%s\\"\n", KApplication::kde_htmldir().data());
201 printf("kde_appsdir=\\"%s\\"\n", KApplication::kde_appsdir().data());
202 printf("kde_icondir=\\"%s\\"\n", KApplication::kde_icondir().data());
203 printf("kde_sounddir=\\"%s\\"\n", KApplication::kde_sounddir().data());
204 printf("kde_datadir=\\"%s\\"\n", KApplication::kde_datadir().data());
205 printf("kde_locale=\\"%s\\"\n", KApplication::kde_localedir().data());
206 printf("kde_cgidir=\\"%s\\"\n", KApplication::kde_cgidir().data());
207 printf("kde_confdir=\\"%s\\"\n", KApplication::kde_configdir().data());
208 printf("kde_mimedir=\\"%s\\"\n", KApplication::kde_mimedir().data());
209 printf("kde_toolbardir=\\"%s\\"\n", KApplication::kde_toolbardir().data());
210 printf("kde_wallpaperdir=\\"%s\\"\n", KApplication::kde_wallpaperdir().data());
211 printf("kde_bindir=\\"%s\\"\n", KApplication::kde_bindir().data());
212 printf("kde_partsdir=\\"%s\\"\n", KApplication::kde_partsdir().data());
213 return 0;
214 }
215 EOF
216
217 if test -n "$kde_libraries"; then
218   KDE_TEST_RPATH="-rpath $kde_libraries"
219 fi
220
221 if test -n "$qt_libraries"; then
222   KDE_TEST_RPATH="$KDE_TEST_RPATH -rpath $qt_libraries"
223 fi
224
225 if test -n "$x_libraries"; then
226   KDE_TEST_RPATH="$KDE_TEST_RPATH -rpath $x_libraries"
227 fi
228
229 KDE_TEST_RPATH="$KDE_TEST_RPATH $KDE_EXTRA_RPATH"
230
231 ac_compile='${CXX-g++} -c $CXXFLAGS $all_includes $CPPFLAGS conftest.$ac_ext'
232 if AC_TRY_EVAL(ac_compile); then
233   AC_MSG_RESULT(yes)
234 else
235   AC_MSG_ERROR([your system is not able to compile a small KDE application!
236 Check, if you installed the KDE header files correctly.])
237 fi
238
239 AC_MSG_CHECKING([for kde libraries installed])
240 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'
241
242 if AC_TRY_EVAL(ac_link) && test -s conftest; then 
243   AC_MSG_RESULT(yes)
244 else
245   AC_MSG_ERROR([your system fails at linking a small KDE application!
246 Check, if your compiler is installed correctly and if you have used the
247 same compiler to compile Qt and kdelibs as you did use now])
248 fi
249
250 AC_MSG_CHECKING([for KDE paths])
251 if eval `./conftest 2>&5`; then
252   AC_MSG_RESULT(done)
253 else
254   AC_MSG_RESULT(problems)
255 fi
256
257 ./conftest 2> /dev/null >&5 # make an echo for config.log
258 kde_have_all_paths=yes
259 AC_LANG_CPLUSPLUS
260
261 if test "$kde_have_all_paths" = "yes"; then
262 kde_cv_all_paths="kde_have_all_paths=\"yes\" \
263         kde_htmldir=\"$kde_htmldir\" \
264         kde_appsdir=\"$kde_appsdir\" \
265         kde_icondir=\"$kde_icondir\" \
266         kde_sounddir=\"$kde_sounddir\" \
267         kde_datadir=\"$kde_datadir\" \
268         kde_locale=\"$kde_locale\" \
269         kde_cgidir=\"$kde_cgidir\" \
270         kde_confdir=\"$kde_confdir\" \
271         kde_mimedir=\"$kde_mimedir\" \
272         kde_toolbardir=\"$kde_toolbardir\" \
273         kde_wallpaperdir=\"$kde_wallpaperdir\" \
274         kde_bindir=\"$kde_bindir\" \
275         kde_partsdir=\"$kde_partsdir\""
276 fi
277 rm -fr conftest*
278
279 ])
280
281 eval "$kde_cv_all_paths"
282
283 if test -z "$kde_htmldir" || test -z "$kde_appsdir" ||
284    test -z "$kde_icondir" || test -z "$kde_sounddir" ||
285    test -z "$kde_datadir" || test -z "$kde_locale"  ||
286    test -z "$kde_cgidir"  || test -z "$kde_confdir" ||
287    test -z "$kde_mimedir" || test -z "$kde_toolbardir" ||
288    test -z "$kde_wallpaperdir" || test -z "$kde_bindir" ||
289    test -z "$kde_partsdir" || test "$kde_have_all_paths" != "yes"; then
290   kde_have_all_paths=no
291   AC_MSG_ERROR([configure could not run a little KDE program to test the environment. 
292 Since it had compiled and linked before, it must be a strange problem on your system.
293 Look at config.log for details. If you are not able to fix this, please contact Stephan Kulow <coolo@kde.org>.])
294 fi
295
296 if test -n "$install_root"; then
297   KDE_REPLACE_ROOT(kde_htmldir)
298   KDE_REPLACE_ROOT(kde_appsdir)
299   KDE_REPLACE_ROOT(kde_icondir)
300   KDE_REPLACE_ROOT(kde_sounddir)
301   KDE_REPLACE_ROOT(kde_datadir)
302   KDE_REPLACE_ROOT(kde_locale)
303   KDE_REPLACE_ROOT(kde_cgidir)
304   KDE_REPLACE_ROOT(kde_confdir)
305   KDE_REPLACE_ROOT(kde_mimedir)
306   KDE_REPLACE_ROOT(kde_toolbardir)
307   KDE_REPLACE_ROOT(kde_wallpaperdir)
308   KDE_REPLACE_ROOT(kde_bindir)
309   KDE_REPLACE_ROOT(kde_partsdir)
310   AC_SUBST(install_root)
311 fi
312
313 fi
314
315 bindir=$kde_bindir
316
317 ])
318
319 AC_DEFUN(AC_SUBST_KFSSTND,
320 [
321 AC_SUBST(kde_htmldir)
322 AC_SUBST(kde_appsdir)
323 AC_SUBST(kde_icondir)
324 AC_SUBST(kde_sounddir)
325 kde_minidir="$kde_icondir/mini"
326 AC_SUBST(kde_minidir)
327 AC_SUBST(kde_datadir)
328 AC_SUBST(kde_locale)
329 AC_SUBST(kde_cgidir)
330 AC_SUBST(kde_confdir)
331 AC_SUBST(kde_mimedir)
332 AC_SUBST(kde_toolbardir)
333 AC_SUBST(kde_wallpaperdir)
334 AC_SUBST(kde_bindir)
335 AC_SUBST(kde_partsdir)
336 ])
337
338 AC_DEFUN(KDE_MISC_TESTS,
339 [
340    AC_LANG_C
341    dnl Checks for libraries. 
342    AC_CHECK_LIB(compat, main, [LIBCOMPAT="-lcompat"]) dnl for FreeBSD
343    AC_SUBST(LIBCOMPAT)
344    AC_CHECK_LIB(crypt, main, [LIBCRYPT="-lcrypt"]) dnl for BSD
345    AC_SUBST(LIBCRYPT)
346    AC_CHECK_LIB(dnet, dnet_ntoa, [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet"])
347    if test $ac_cv_lib_dnet_dnet_ntoa = no; then
348       AC_CHECK_LIB(dnet_stub, dnet_ntoa,
349         [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet_stub"])
350    fi
351    AC_CHECK_FUNC(gethostbyname)
352    if test $ac_cv_func_gethostbyname = no; then
353      AC_CHECK_LIB(nsl, gethostbyname, X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl")
354    fi
355    AC_CHECK_FUNC(connect)
356    if test $ac_cv_func_connect = no; then
357       AC_CHECK_LIB(socket, connect, X_EXTRA_LIBS="-lsocket $X_EXTRA_LIBS", ,
358         $X_EXTRA_LIBS)
359    fi
360
361    AC_CHECK_FUNC(remove)
362    if test $ac_cv_func_remove = no; then
363       AC_CHECK_LIB(posix, remove, X_EXTRA_LIBS="$X_EXTRA_LIBS -lposix")
364    fi
365  
366    # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay.
367    AC_CHECK_FUNC(shmat)
368    if test $ac_cv_func_shmat = no; then
369      AC_CHECK_LIB(ipc, shmat, X_EXTRA_LIBS="$X_EXTRA_LIBS -lipc")
370    fi
371
372    LIBSOCKET=$X_EXTRA_LIBS
373    AC_SUBST(LIBSOCKET)
374    AC_SUBST(X_EXTRA_LIBS)
375    AC_CHECK_LIB(ucb, killpg, [LIBUCB="-lucb"]) dnl for Solaris2.4
376    AC_SUBST(LIBUCB)
377
378    case $host in  dnl this *is* LynxOS specific
379    *-*-lynxos* )
380         AC_MSG_CHECKING([LynxOS header file wrappers])
381         [CFLAGS="$CFLAGS -D__NO_INCLUDE_WARN__"]
382         AC_MSG_RESULT(disabled)
383         AC_CHECK_LIB(bsd, gethostbyname, [LIBSOCKET="-lbsd"]) dnl for LynxOS
384          ;;
385     esac
386
387 ])
388
389 ## ------------------------------------------------------------------------
390 ## Find the header files and libraries for X-Windows. Extended the 
391 ## macro AC_PATH_X
392 ## ------------------------------------------------------------------------
393 ##
394 AC_DEFUN(K_PATH_X,
395 [
396 AC_MSG_CHECKING(for X)
397 AC_CACHE_VAL(ac_cv_have_x,
398 [# One or both of the vars are not set, and there is no cached value.
399 ac_x_includes=NO ac_x_libraries=NO
400 AC_PATH_X_DIRECT
401 AC_PATH_X_XMKMF
402 if test "$ac_x_includes" = NO || test "$ac_x_libraries" = NO; then
403   AC_MSG_ERROR([Can't find X includes. Please check your installation and add the correct paths!])
404 else
405   # Record where we found X for the cache.
406   ac_cv_have_x="have_x=yes \
407                 ac_x_includes=$ac_x_includes ac_x_libraries=$ac_x_libraries"
408 fi])dnl
409 eval "$ac_cv_have_x"
410  
411 if test "$have_x" != yes; then
412   AC_MSG_RESULT($have_x)
413   no_x=yes
414 else
415   # If each of the values was on the command line, it overrides each guess.
416   test "x$x_includes" = xNONE && x_includes=$ac_x_includes
417   test "x$x_libraries" = xNONE && x_libraries=$ac_x_libraries
418   # Update the cache value to reflect the command line values.
419   ac_cv_have_x="have_x=yes \
420                 ac_x_includes=$x_includes ac_x_libraries=$x_libraries"
421   AC_MSG_RESULT([libraries $x_libraries, headers $x_includes])
422 fi
423
424 if test -z "$x_includes" || test "x$x_includes" = xNONE; then
425   X_INCLUDES=""
426   x_includes="."; dnl better than nothing :-
427  else
428   X_INCLUDES="-I$x_includes"
429 fi
430
431 if test -z "$x_libraries" || test "x$x_libraries" = xNONE; then
432   X_LDFLAGS=""
433   x_libraries="/usr/lib"; dnl better than nothing :-
434  else
435   X_LDFLAGS="-L$x_libraries"
436 fi
437 all_includes="$all_includes $X_INCLUDES"  
438 all_libraries="$all_libraries $X_LDFLAGS"  
439
440 AC_SUBST(X_INCLUDES)
441 AC_SUBST(X_LDFLAGS)
442 AC_SUBST(x_libraries)
443 AC_SUBST(x_includes)
444 ])
445
446 AC_DEFUN(KDE_PRINT_QT_PROGRAM,
447 [
448 AC_LANG_CPLUSPLUS
449 cat > conftest.$ac_ext <<EOF
450 #include "confdefs.h"
451 #include <qmovie.h>
452 #include <qapplication.h>
453 int main() {
454   QMovie m;
455   m.setSpeed(20);
456   return 0;
457 }
458 EOF
459 ])
460
461 AC_DEFUN(KDE_CHECK_QT_DIRECT,
462 [
463 AC_MSG_CHECKING([if Qt compiles without flags])
464 AC_CACHE_VAL(kde_cv_qt_direct,
465 [
466 ac_LD_LIBRARY_PATH_safe=$LD_LIBRARY_PATH
467 ac_LIBRARY_PATH="$LIBRARY_PATH"
468 ac_cxxflags_safe="$CXXFLAGS"
469 ac_ldflags_safe="$LDFLAGS"
470 ac_libs_safe="$LIBS"
471
472 CXXFLAGS="$CXXFLAGS -I$qt_includes"
473 LDFLAGS="$X_LDFLAGS"
474 LIBS="-lqt -lXext -lX11 $LIBSOCKET"
475 LD_LIBRARY_PATH=
476 export LD_LIBRARY_PATH
477 LIBRARY_PATH=
478 export LIBRARY_PATH
479
480 KDE_PRINT_QT_PROGRAM
481
482 if AC_TRY_EVAL(ac_link) && test -s conftest; then
483   kde_cv_qt_direct="yes"
484 else
485   kde_cv_qt_direct="no"
486   echo "configure: failed program was:" >&AC_FD_CC
487   cat conftest.$ac_ext >&AC_FD_CC
488 fi
489 rm -f conftest*
490 CXXFLAGS="$ac_cxxflags_safe"
491 LDFLAGS="$ac_ldflags_safe"
492 LIBS="$ac_libs_safe"
493
494 LD_LIBRARY_PATH="$ac_LD_LIBRARY_PATH_safe"
495 export LD_LIBRARY_PATH
496 LIBRARY_PATH="$ac_LIBRARY_PATH"
497 export LIBRARY_PATH
498 ])
499
500 if test "$kde_cv_qt_direct" = "yes"; then
501   AC_MSG_RESULT(yes)
502   $1
503 else
504   AC_MSG_RESULT(no)
505   $2
506 fi
507 ])
508
509 ## ------------------------------------------------------------------------
510 ## Try to find the Qt headers and libraries.
511 ## $(QT_LDFLAGS) will be -Lqtliblocation (if needed)
512 ## and $(QT_INCLUDES) will be -Iqthdrlocation (if needed)
513 ## ------------------------------------------------------------------------
514 ##
515 AC_DEFUN(AC_PATH_QT_1_3,
516 [
517 AC_REQUIRE([K_PATH_X])
518
519 AC_MSG_CHECKING([for Qt])
520 ac_qt_includes=NO ac_qt_libraries=NO ac_qt_bindir=NO
521 qt_libraries=""
522 qt_includes=""
523 AC_ARG_WITH(qt-dir,
524     [  --with-qt-dir           where the root of qt is installed ],
525     [  ac_qt_includes="$withval"/include
526        ac_qt_libraries="$withval"/lib
527        ac_qt_bindir="$withval"/bin
528     ])
529
530 AC_ARG_WITH(qt-includes,
531     [  --with-qt-includes      where the Qt includes are. ],
532     [  
533        ac_qt_includes="$withval"
534     ])
535     
536 kde_qt_libs_given=no
537
538 AC_ARG_WITH(qt-libraries,
539     [  --with-qt-libraries     where the Qt library is installed.],
540     [  ac_qt_libraries="$withval"
541        kde_qt_libs_given=yes
542     ])
543
544 if test "$ac_qt_includes" = NO || test "$ac_qt_libraries" = NO; then
545
546 AC_CACHE_VAL(ac_cv_have_qt,
547 [#try to guess Qt locations
548
549 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"
550 test -n "$QTDIR" && qt_incdirs="$QTDIR/include $QTDIR $qt_incdirs"
551 AC_FIND_FILE(qmovie.h, $qt_incdirs, qt_incdir)
552 ac_qt_includes="$qt_incdir"
553
554 if test ! "$ac_qt_libraries" = "NO"; then
555   qt_libdirs="$ac_qt_libraries"
556 fi
557
558 qt_libdirs="$qt_libdirs /usr/lib/qt/lib /usr/X11R6/lib /usr/lib /usr/local/qt/lib /usr/lib/qt $x_libraries $QTLIB"
559 test -n "$QTDIR" && qt_libdirs="$QTDIR/lib $QTDIR $qt_libdirs"
560
561 test=NONE
562 qt_libdir=NONE
563 for dir in $qt_libdirs; do
564   try="ls -1 $dir/libqt*"
565   if test=`eval $try 2> /dev/null`; then qt_libdir=$dir; break; else echo "tried $dir" >&AC_FD_CC ; fi
566 done
567
568 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)
569 ac_qt_libraries="$qt_libdir"
570
571 ac_cxxflags_safe="$CXXFLAGS"
572 ac_ldflags_safe="$LDFLAGS"
573 ac_libs_safe="$LIBS"
574
575 CXXFLAGS="$CXXFLAGS -I$qt_incdir"
576 LDFLAGS="-L$qt_libdir $X_LDFLAGS"
577 LIBS="$LIBS -lqt -lXext -lX11 $LIBSOCKET"
578
579 KDE_PRINT_QT_PROGRAM
580
581 if AC_TRY_EVAL(ac_link) && test -s conftest; then
582   rm -f conftest*
583 else
584   echo "configure: failed program was:" >&AC_FD_CC
585   cat conftest.$ac_ext >&AC_FD_CC
586   ac_qt_libraries="NO"
587 fi
588 rm -f conftest*
589 CXXFLAGS="$ac_cxxflags_safe"
590 LDFLAGS="$ac_ldflags_safe"
591 LIBS="$ac_libs_safe"
592
593 if test "$ac_qt_includes" = NO || test "$ac_qt_libraries" = NO; then
594   ac_cv_have_qt="have_qt=no"
595   ac_qt_notfound=""
596   if test "$ac_qt_includes" = NO; then
597     if test "$ac_qt_libraries" = NO; then
598       ac_qt_notfound="(headers and libraries)";
599     else
600       ac_qt_notfound="(headers)";
601     fi
602   else
603     ac_qt_notfound="(libraries)";
604   fi
605
606   AC_MSG_ERROR([Qt-1.4 $ac_qt_notfound not found. Please check your installation! ]);
607 else
608   have_qt="yes"
609 fi
610 ])
611 else
612   have_qt="yes"
613 fi
614
615 eval "$ac_cv_have_qt"
616
617 if test "$have_qt" != yes; then
618   AC_MSG_RESULT([$have_qt]);
619 else
620   ac_cv_have_qt="have_qt=yes \
621     ac_qt_includes=$ac_qt_includes ac_qt_libraries=$ac_qt_libraries"
622   AC_MSG_RESULT([libraries $ac_qt_libraries, headers $ac_qt_includes])
623   
624   qt_libraries="$ac_qt_libraries"
625   qt_includes="$ac_qt_includes"
626 fi
627
628 if test ! "$kde_qt_libs_given" = "yes"; then
629 KDE_CHECK_QT_DIRECT(qt_libraries= ,[])
630 fi
631
632 dnl should check it's not Qt2, so it will fail now, rather than in KDE check
633
634 SAVE_CXXFLAGS="$CXXFLAGS"
635 CXXFLAGS="$CXXFLAGS -I$qt_includes -L$qt_libraries"
636 AC_TRY_COMPILE([
637 #include <qglobal.h>
638 ],
639 [
640 #if (QT_VERSION >= 200)
641 break_me_(\\\);
642 #endif
643 ],
644 ac_qt_ok=yes,
645 ac_qt_ok=no
646
647 test "$ac_qt_ok" = no && AC_MSG_ERROR([Found Qt 2 - you must specify the path to the Qt 1 headers and libraries])
648 CXXFLAGS="$SAVE_CXXFLAGS"
649
650 AC_SUBST(qt_libraries)
651 AC_SUBST(qt_includes)
652
653 if test "$qt_includes" = "$x_includes" || test -z "$qt_includes"; then
654  QT_INCLUDES="";
655 else
656  QT_INCLUDES="-I$qt_includes"
657  all_includes="$QT_INCLUDES $all_includes"
658 fi
659
660 if test "$qt_libraries" = "$x_libraries" || test -z "$qt_libraries"; then
661  QT_LDFLAGS=""
662 else
663  QT_LDFLAGS="-L$qt_libraries"
664  all_libraries="$QT_LDFLAGS $all_libraries"
665 fi
666
667 AC_SUBST(QT_INCLUDES)
668 AC_SUBST(QT_LDFLAGS)
669 AC_PATH_QT_MOC
670 ])
671
672 AC_DEFUN(AC_PATH_QT,
673 [
674 AC_PATH_QT_1_3
675 ])
676
677 ## ------------------------------------------------------------------------
678 ## Now, the same with KDE
679 ## $(KDE_LDFLAGS) will be the kdeliblocation (if needed)
680 ## and $(kde_includes) will be the kdehdrlocation (if needed)
681 ## ------------------------------------------------------------------------
682 ##
683 AC_DEFUN(AC_BASE_PATH_KDE,
684 [
685 AC_REQUIRE([KDE_MISC_TESTS])
686 AC_REQUIRE([AC_PATH_QT])dnl
687 AC_MSG_CHECKING([for KDE])
688
689 if test "${prefix}" != NONE; then
690   kde_includes=${prefix}/include
691   ac_kde_includes=$prefix/include
692
693   if test "${exec_prefix}" != NONE; then
694     kde_libraries=${exec_prefix}/lib
695     ac_kde_libraries=$exec_prefix/lib
696   else
697     kde_libraries=${prefix}/lib
698     ac_kde_libraries=$prefix/lib
699   fi
700 else
701   ac_kde_includes=
702   ac_kde_libraries=
703   kde_libraries=""
704   kde_includes=""
705 fi
706
707 AC_ARG_WITH(kde-dir,
708     [  --with-kde-dir          where the KDE root is ],
709     [
710        ac_kde_includes="$withval"/include
711        ac_kde_libraries="$withval"/lib
712     ])
713  
714 AC_ARG_WITH(kde-includes,
715     [  --with-kde-includes     where the KDE includes are. ],
716     [
717        ac_kde_includes="$withval"
718     ])
719  
720 AC_ARG_WITH(kde-libraries,
721     [  --with-kde-libraries    where the KDE library is installed.],
722     [
723        ac_kde_libraries="$withval"
724     ])
725  
726 AC_CACHE_VAL(ac_cv_have_kde,
727 [#try to guess kde locations
728
729 if test -z "$1"; then
730
731 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"
732 test -n "$KDEDIR" && kde_incdirs="$KDEDIR/include $KDEDIR $kde_incdirs"
733 kde_incdirs="$ac_kde_includes $kde_incdirs"
734 AC_FIND_FILE(ksock.h, $kde_incdirs, kde_incdir)
735 ac_kde_includes="$kde_incdir"
736
737 if test -n "$ac_kde_includes" && test ! -r "$ac_kde_includes/ksock.h"; then
738   AC_MSG_ERROR([
739 in the prefix, you've chosen, are no kde headers installed. This will fail.
740 So, check this please and use another prefix!])
741 fi
742
743 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"
744 test -n "$KDEDIR" && kde_libdirs="$KDEDIR/lib $KDEDIR $kde_libdirs"
745 kde_libdirs="$ac_kde_libraries $kde_libdirs"
746 AC_FIND_FILE(libkdecore.la, $kde_libdirs, kde_libdir)
747 ac_kde_libraries="$kde_libdir"
748
749 if test -n "$ac_kde_libraries" && test ! -r "$ac_kde_libraries/libkdecore.la"; then
750 AC_MSG_ERROR([
751 in the prefix, you've chosen $ac_kde_libraries, are no kde libraries installed. This will fail.
752 So, check this please and use another prefix!])
753 fi
754
755 if test "$ac_kde_includes" = NO || test "$ac_kde_libraries" = NO; then
756   ac_cv_have_kde="have_kde=no"
757 else
758   ac_cv_have_kde="have_kde=yes \
759     ac_kde_includes=$ac_kde_includes ac_kde_libraries=$ac_kde_libraries"
760 fi
761
762 else dnl test -z $1 
763   
764   ac_cv_have_kde="have_kde=no"
765
766 fi
767 ])dnl
768
769 eval "$ac_cv_have_kde"
770
771 if test "$have_kde" != "yes"; then
772  if test "${prefix}" = NONE; then
773   ac_kde_prefix="$ac_default_prefix"
774  else
775   ac_kde_prefix="$prefix"
776  fi
777  if test "$exec_prefix" = NONE; then
778   ac_kde_exec_prefix="$ac_kde_prefix"
779   AC_MSG_RESULT([will be installed in $ac_kde_prefix])
780  else
781   ac_kde_exec_prefix="$exec_prefix"
782   AC_MSG_RESULT([will be installed in $ac_kde_prefix and $ac_kde_exec_prefix])
783  fi
784
785  kde_libraries="${ac_kde_exec_prefix}/lib"
786  kde_includes=${ac_kde_prefix}/include
787
788 else
789   ac_cv_have_kde="have_kde=yes \
790     ac_kde_includes=$ac_kde_includes ac_kde_libraries=$ac_kde_libraries"
791   AC_MSG_RESULT([libraries $ac_kde_libraries, headers $ac_kde_includes])
792   
793   kde_libraries="$ac_kde_libraries"
794   kde_includes="$ac_kde_includes"
795 fi
796 AC_SUBST(kde_libraries)
797 AC_SUBST(kde_includes)
798
799 if test "$kde_includes" = "$x_includes" || test "$kde_includes" = "$qt_includes" ; then
800  KDE_INCLUDES=""
801 else
802  KDE_INCLUDES="-I$kde_includes"
803  all_includes="$KDE_INCLUDES $all_includes"
804 fi
805
806 if test "$kde_libraries" = "$x_libraries" || test "$kde_libraries" = "$qt_libraries" ; then
807  KDE_LDFLAGS=""
808 else
809  KDE_LDFLAGS="-L$kde_libraries"
810  all_libraries="$KDE_LDFLAGS $all_libraries"
811 fi
812
813 AC_SUBST(KDE_LDFLAGS)
814 AC_SUBST(KDE_INCLUDES)
815
816 AC_SUBST(all_includes)
817 AC_SUBST(all_libraries)
818
819 ])
820
821 AC_DEFUN(KDE_CHECK_KIMGIO,
822 [
823    AC_REQUIRE([AC_FIND_TIFF])
824    AC_REQUIRE([AC_FIND_JPEG]) 
825    AC_REQUIRE([AC_FIND_PNG]) 
826
827    LIB_KIMGIO='-lkimgio $(LIBJPEG) $(LIBTIFF) $(LIBPNG) -lm'
828    AC_SUBST(LIB_KIMGIO)
829    LIB_KHTMLW='-lkhtmlw $(LIB_KIMGIO) -ljscript'
830    AC_SUBST(LIB_KHTMLW)
831    LIB_KHTML='-lkhtml $(LIB_KIMGIO) -ljscript'
832    AC_SUBST(LIB_KHTML)
833 ])
834
835 AC_DEFUN(KDE_CREATE_LIBS_ALIASES,
836 [
837    AC_REQUIRE([KDE_MISC_TESTS])
838
839    KDE_LIBS='-lqt -lkdecore -lkdeui -lkfm -lkfile'
840    AC_SUBST(KDE_LIBS)
841 #   LIB_X11='-lX11 $(LIBSOCKET)'
842 #   AC_SUBST(LIB_X11)
843 #   LIB_QT='-lqt $(LIB_X11)'
844 #   AC_SUBST(LIB_QT)
845 #   LIB_KDECORE='-lkdecore -lXext $(LIB_QT)'
846 #   AC_SUBST(LIB_KDECORE)
847 #   LIB_KDEUI='-lkdeui $(LIB_KDECORE)'
848 #   AC_SUBST(LIB_KDEUI)
849 #   LIB_KFM='-lkfm $(LIB_KDECORE)'
850 #   AC_SUBST(LIB_KFM)
851 #   LIB_KFILE='-lkfile $(LIB_KFM) $(LIB_KDEUI)'
852 #   AC_SUBST(LIB_KFILE)
853 ])
854
855 AC_DEFUN(AC_PATH_KDE,
856 [
857   AC_BASE_PATH_KDE
858   AC_ARG_ENABLE(path-check, [  --disable-path-check    don't try to find out, where to install],
859   [
860   if test "$enableval" = "no"; 
861     then ac_use_path_checking="default"
862     else ac_use_path_checking=""
863   fi
864   ], [ac_use_path_checking=""]
865   )
866
867   AC_ARG_WITH(install-root, [  --with-install-root     the root, where to install to [default=/]],
868   [
869   if test "$withval" = "no";
870     then kde_install_root="";
871     else kde_install_root=$withval;
872   fi
873   ], [kde_install_root=""]
874   )
875   
876   if test -n "$kde_install_root"; then
877      install_root="$kde_install_root"
878   else
879      install_root=
880   fi
881
882   AC_CREATE_KFSSTND($ac_use_path_checking)
883
884   AC_SUBST_KFSSTND
885   KDE_CREATE_LIBS_ALIASES
886 ])
887
888 dnl slightly changed version of AC_CHECK_FUNC(setenv)
889 AC_DEFUN(AC_CHECK_SETENV,
890 [AC_MSG_CHECKING([for setenv])
891 AC_CACHE_VAL(ac_cv_func_setenv,
892 [AC_LANG_C
893 AC_TRY_LINK(
894 dnl Don't include <ctype.h> because on OSF/1 3.0 it includes <sys/types.h>
895 dnl which includes <sys/select.h> which contains a prototype for
896 dnl select.  Similarly for bzero.
897 [#include <assert.h>
898 ]ifelse(AC_LANG, CPLUSPLUS, [#ifdef __cplusplus
899 extern "C"
900 #endif
901 ])dnl
902 [/* We use char because int might match the return type of a gcc2
903     builtin and then its argument prototype would still apply.  */
904 #include <stdlib.h>
905 ], [
906 /* The GNU C library defines this for functions which it implements
907     to always fail with ENOSYS.  Some functions are actually named
908     something starting with __ and the normal name is an alias.  */
909 #if defined (__stub_$1) || defined (__stub___$1)
910 choke me
911 #else
912 setenv("TEST", "alle", 1);
913 #endif
914 ], eval "ac_cv_func_setenv=yes", eval "ac_cv_func_setenv=no")])
915
916 if test "$ac_cv_func_setenv" = "yes"; then
917   AC_MSG_RESULT(yes)
918   AC_DEFINE_UNQUOTED(HAVE_FUNC_SETENV)
919 else
920   AC_MSG_RESULT(no)
921 fi
922 ])
923
924 AC_DEFUN(AC_CHECK_GETDOMAINNAME,
925 [
926 AC_LANG_CPLUSPLUS
927 save_CXXFLAGS="$CXXFLAGS"
928 if test "$GCC" = "yes"; then
929 CXXFLAGS="$CXXFLAGS -pedantic-errors"
930 fi
931 AC_MSG_CHECKING(for getdomainname)
932 AC_CACHE_VAL(ac_cv_func_getdomainname,
933 [
934 AC_TRY_COMPILE([
935 #include <stdlib.h>
936 #include <unistd.h>
937 ],
938 [
939 char buffer[200];
940 getdomainname(buffer, 200);
941 ],
942 ac_cv_func_getdomainname=yes,
943 ac_cv_func_getdomainname=no)
944 ])
945 AC_MSG_RESULT($ac_cv_func_getdomainname)
946 if eval "test \"`echo `$ac_cv_func_getdomainname\" = yes"; then
947   AC_DEFINE(HAVE_GETDOMAINNAME)
948 fi
949 CXXFLAGS="$save_CXXFLAGS"
950 ])
951
952 AC_DEFUN(AC_CHECK_GETHOSTNAME,
953 [
954 AC_LANG_CPLUSPLUS
955 save_CXXFLAGS="$CXXFLAGS"
956 if test "$GCC" = "yes"; then
957 CXXFLAGS="$CXXFLAGS -pedantic-errors"
958 fi
959
960 AC_MSG_CHECKING([for gethostname])
961 AC_CACHE_VAL(ac_cv_func_gethostname,
962 [
963 AC_TRY_COMPILE([
964 #include <stdlib.h>
965 #include <unistd.h>
966 ],
967 [
968 char buffer[200];
969 gethostname(buffer, 200);
970 ],
971 ac_cv_func_gethostname=yes,
972 ac_cv_func_gethostname=no)
973 ])
974 AC_MSG_RESULT($ac_cv_func_gethostname)
975 if eval "test \"`echo `$ac_cv_func_gethostname\" = yes"; then
976   AC_DEFINE(HAVE_GETHOSTNAME)
977 fi
978 CXXFLAGS="$save_CXXFLAGS"
979 ])
980
981 AC_DEFUN(AC_CHECK_USLEEP,
982 [
983 AC_LANG_CPLUSPLUS
984
985 AC_MSG_CHECKING([for usleep])
986 AC_CACHE_VAL(ac_cv_func_usleep,
987 [
988 ac_libs_safe="$LIBS"
989 LIBS="$LIBS $LIBUCB"
990 AC_TRY_LINK([
991 #include <stdlib.h>
992 #include <unistd.h>
993 ],
994 [
995 usleep(200);
996 ],
997 ac_cv_func_usleep=yes,
998 ac_cv_func_usleep=no)
999 ])
1000 AC_MSG_RESULT($ac_cv_func_usleep)
1001 if eval "test \"`echo `$ac_cv_func_usleep\" = yes"; then
1002   AC_DEFINE(HAVE_USLEEP)
1003 fi
1004 LIBS="$ac_libs_safe"
1005 ])
1006
1007 AC_DEFUN(AC_FIND_GIF,
1008    [AC_MSG_CHECKING([for giflib])
1009 AC_CACHE_VAL(ac_cv_lib_gif,
1010 [ac_save_LIBS="$LIBS"
1011 LIBS="$all_libraries -lgif -lX11 $LIBSOCKET"
1012 AC_TRY_LINK(dnl
1013 [
1014 #ifdef __cplusplus
1015 extern "C" {
1016 #endif
1017 int GifLastError(void);
1018 #ifdef __cplusplus
1019 }
1020 #endif
1021 /* We use char because int might match the return type of a gcc2
1022     builtin and then its argument prototype would still apply.  */
1023 ],
1024             [return GifLastError();],
1025             eval "ac_cv_lib_gif=yes",
1026             eval "ac_cv_lib_gif=no")
1027 LIBS="$ac_save_LIBS"
1028 ])dnl
1029 if eval "test \"`echo $ac_cv_lib_gif`\" = yes"; then
1030   AC_MSG_RESULT(yes)
1031   AC_DEFINE_UNQUOTED(HAVE_LIBGIF)
1032 else
1033   AC_MSG_ERROR(You need giflib23. Please install the kdesupport package)
1034 fi
1035 ])
1036
1037 AC_DEFUN(AC_FIND_JPEG,
1038    [AC_MSG_CHECKING([for jpeglib])
1039 AC_CACHE_VAL(ac_cv_lib_jpeg,
1040 [ac_save_LIBS="$LIBS"
1041 LIBS="$all_libraries -ljpeg -lm"
1042 AC_TRY_LINK(
1043 [/* Override any gcc2 internal prototype to avoid an error.  */
1044 struct jpeg_decompress_struct;
1045 typedef struct jpeg_decompress_struct * j_decompress_ptr;
1046 typedef int size_t;
1047 #ifdef __cplusplus
1048 extern "C" {
1049 #endif
1050     void jpeg_CreateDecompress(j_decompress_ptr cinfo,
1051                                     int version, size_t structsize);
1052 #ifdef __cplusplus
1053 }
1054 #endif
1055 /* We use char because int might match the return type of a gcc2
1056     builtin and then its argument prototype would still apply.  */
1057 ],
1058             [jpeg_CreateDecompress(0L, 0, 0);],
1059             eval "ac_cv_lib_jpeg=-ljpeg",
1060             eval "ac_cv_lib_jpeg=no")
1061 LIBS="$ac_save_LIBS"
1062
1063 dnl what to do, if the normal way fails:
1064 if eval "test \"`echo $ac_cv_lib_jpeg`\" = no"; then
1065         if test -f "$kde_libraries/libjpeg.so"; then
1066            test -f ./libjpegkde.so || $LN_S $kde_libraries/libjpeg.so ./libjpegkde.so
1067            ac_cv_lib_jpeg="-L\${topdir} -ljpegkde"
1068         else if test -f "$kde_libraries/libjpeg.sl"; then
1069            test -f ./libjpegkde.sl ||$LN_S $kde_libraries/libjpeg.sl ./libjpegkde.sl
1070            ac_cv_lib_jpeg="-L\${topdir} -ljpegkde"      
1071         else if test -f "$kde_libraries/libjpeg.a"; then
1072            test -f ./libjpegkde.a || $LN_S $kde_libraries/libjpeg.a ./libjpegkde.a
1073            ac_cv_lib_jpeg="-L\${topdir} -ljpegkde"
1074         else
1075           AC_MSG_ERROR([
1076 You need jpeglib6a. Please install the kdesupport package.
1077 If you have already installed kdesupport, you may have an
1078 old libjpeg somewhere. 
1079 In this case copy $KDEDIR/lib/libjpeg* to /usr/lib.
1080 ])
1081         fi
1082       fi
1083    fi
1084 fi
1085 ])dnl
1086 if eval "test ! \"`echo $ac_cv_lib_jpeg`\" = no"; then
1087   LIBJPEG="$ac_cv_lib_jpeg"
1088   AC_SUBST(LIBJPEG)
1089   AC_MSG_RESULT($ac_cv_lib_jpeg)
1090   AC_DEFINE_UNQUOTED(HAVE_LIBJPEG)
1091 fi
1092 ])
1093
1094 AC_DEFUN(AC_FIND_ZLIB,
1095 [
1096 AC_MSG_CHECKING([for libz])
1097 AC_CACHE_VAL(ac_cv_lib_z,
1098 [ac_save_LIBS="$LIBS"
1099 LIBS="$all_libraries -lz $LIBSOCKET"
1100 AC_TRY_LINK(dnl
1101 [
1102 #include<zlib.h>
1103 ],
1104             [return (zlibVersion() == ZLIB_VERSION); ],
1105             eval "ac_cv_lib_z='-lz'",
1106             eval "ac_cv_lib_z=no")
1107 LIBS="$ac_save_LIBS"
1108 ])dnl
1109 if eval "test ! \"`echo $ac_cv_lib_z`\" = no"; then
1110 dnl  AC_DEFINE_UNQUOTED(HAVE_LIBZ)
1111   LIBZ="$ac_cv_lib_z"
1112   AC_SUBST(LIBZ)
1113   AC_MSG_RESULT($ac_cv_lib_z)
1114 else
1115   AC_MSG_RESULT(no)
1116   LIBZ=""
1117   AC_SUBST(LIBZ)
1118 fi
1119 ])
1120
1121 AC_DEFUN(AC_FIND_TIFF,
1122 [
1123 AC_REQUIRE([AC_FIND_ZLIB])
1124 AC_REQUIRE([AC_FIND_JPEG])
1125 AC_MSG_CHECKING([for libtiff])
1126 AC_CACHE_VAL(ac_cv_lib_tiff,
1127 [ac_save_LIBS="$LIBS"
1128 LIBS="$all_libraries -ltiff $LIBJPEG $LIBZ -lX11 $LIBSOCKET"
1129 AC_TRY_LINK(dnl
1130 [
1131 #include<tiffio.h>
1132 ],
1133             [return (TIFFOpen( "", "r") == 0); ],
1134             eval "ac_cv_lib_tiff='-ltiff $LIBJPEG $LIBZ'",
1135             eval "ac_cv_lib_tiff=no")
1136 LIBS="$ac_save_LIBS"
1137 ])dnl
1138 if eval "test ! \"`echo $ac_cv_lib_tiff`\" = no"; then
1139   AC_DEFINE_UNQUOTED(HAVE_LIBTIFF)
1140   LIBTIFF="$ac_cv_lib_tiff"
1141   AC_SUBST(LIBTIFF)
1142   AC_MSG_RESULT($ac_cv_lib_tiff)
1143 else
1144   AC_MSG_RESULT(no)
1145   LIBTIFF=""
1146   AC_SUBST(LIBTIFF)
1147 fi
1148 ])
1149
1150
1151 AC_DEFUN(AC_FIND_PNG,
1152 [
1153 AC_REQUIRE([AC_FIND_ZLIB])
1154 AC_MSG_CHECKING([for libpng])
1155 AC_CACHE_VAL(ac_cv_lib_png,
1156 [ac_save_LIBS="$LIBS"
1157 LIBS="$all_libraries -lpng $LIBZ -lm -lX11 $LIBSOCKET"
1158 AC_LANG_C
1159 AC_TRY_LINK(dnl
1160     [
1161     #include<png.h>
1162     ],
1163     [
1164     png_structp png_ptr = png_create_read_struct(  // image ptr
1165                 PNG_LIBPNG_VER_STRING, 0, 0, 0 );
1166     return( png_ptr != 0 ); 
1167     ],
1168     eval "ac_cv_lib_png='-lpng $LIBZ -lm'",
1169     eval "ac_cv_lib_png=no")
1170     LIBS="$ac_save_LIBS"
1171 ])dnl
1172 if eval "test ! \"`echo $ac_cv_lib_png`\" = no"; then
1173   AC_DEFINE_UNQUOTED(HAVE_LIBPNG)
1174   LIBPNG="$ac_cv_lib_png"
1175   AC_SUBST(LIBPNG)
1176   AC_MSG_RESULT($ac_cv_lib_png)
1177 else
1178   AC_MSG_RESULT(no)
1179   LIBPNG=""
1180   AC_SUBST(LIBPNG)
1181 fi
1182 ])
1183
1184 AC_DEFUN(AC_CHECK_GNU_EXTENSIONS,
1185 [
1186 AC_MSG_CHECKING(if you need GNU extensions)
1187 AC_CACHE_VAL(ac_cv_gnu_extensions,
1188 [
1189 cat > conftest.c << EOF
1190 #include <features.h>
1191
1192 #ifdef __GNU_LIBRARY__
1193 yes
1194 #endif
1195 EOF
1196
1197 if (eval "$ac_cpp conftest.c") 2>&5 |
1198   egrep "yes" >/dev/null 2>&1; then
1199   rm -rf conftest*
1200   ac_cv_gnu_extensions=yes
1201 else
1202   ac_cv_gnu_extensions=no
1203 fi
1204 ])
1205
1206 AC_MSG_RESULT($ac_cv_gnu_extensions)
1207 if test "$ac_cv_gnu_extensions" = "yes"; then
1208   AC_DEFINE_UNQUOTED(_GNU_SOURCE)
1209 fi
1210 ])
1211
1212 dnl just a wrapper to clean up configure.in
1213 AC_DEFUN(KDE_PROG_LIBTOOL,
1214 [
1215 AC_REQUIRE([AM_ENABLE_SHARED])
1216 AC_REQUIRE([AM_ENABLE_STATIC])
1217 dnl libtool is only for C, so I must force him
1218 dnl to find the correct flags for C++
1219 ac_save_cc=$CC
1220 ac_save_cflags="$CFLAGS"
1221 CC=$CXX
1222 CFLAGS="$CXXFLAGS"
1223 AM_PROG_LIBTOOL dnl for libraries
1224 CC=$ac_save_cc
1225 CFLAGS="$ac_save_cflags"
1226 ])
1227
1228 AC_DEFUN(KDE_DO_IT_ALL,
1229 [
1230 AC_PREFIX_DEFAULT(${KDEDIR:-/usr/local/kde})
1231 KDE_PROG_LIBTOOL
1232 AC_PATH_KDE
1233 ])
1234
1235 AC_DEFUN(AC_CHECK_RPATH,
1236 [
1237 AC_MSG_CHECKING(for rpath)
1238 AC_ARG_ENABLE(rpath,
1239       [  --disable-rpath         do not use the rpath feature of ld],
1240       USE_RPATH=$enableval, USE_RPATH=yes)
1241 if test -z "$KDE_RPATH" && test "$USE_RPATH" = "yes"; then
1242
1243   KDE_RPATH="-rpath \$(kde_libraries)"
1244
1245   if test -n "$qt_libraries"; then
1246     KDE_RPATH="$KDE_RPATH -rpath \$(qt_libraries)"
1247   fi
1248   dnl $x_libraries is set to /usr/lib in case
1249   if test -n "$X_LDFLAGS"; then 
1250     KDE_RPATH="$KDE_RPATH -rpath \$(x_libraries)"
1251   fi
1252   if test -n "$KDE_EXTRA_RPATH"; then
1253     KDE_RPATH="$KDE_RPATH \$(KDE_EXTRA_RPATH)"
1254   fi
1255 fi 
1256 AC_SUBST(KDE_EXTRA_RPATH)
1257 AC_SUBST(KDE_RPATH)
1258 AC_MSG_RESULT($USE_RPATH)
1259 ])
1260
1261 # Search path for a program which passes the given test.
1262 # Ulrich Drepper <drepper@cygnus.com>, 1996.
1263
1264 # serial 1
1265 # Stephan Kulow: I appended a _KDE against name conflicts
1266
1267 dnl AM_PATH_PROG_WITH_TEST_KDE(VARIABLE, PROG-TO-CHECK-FOR,
1268 dnl   TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
1269 AC_DEFUN(AM_PATH_PROG_WITH_TEST_KDE,
1270 [# Extract the first word of "$2", so it can be a program name with args.
1271 set dummy $2; ac_word=[$]2
1272 AC_MSG_CHECKING([for $ac_word])
1273 AC_CACHE_VAL(ac_cv_path_$1,
1274 [case "[$]$1" in
1275   /*)
1276   ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
1277   ;;
1278   *)
1279   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
1280   for ac_dir in ifelse([$5], , $PATH, [$5]); do
1281     test -z "$ac_dir" && ac_dir=.
1282     if test -f $ac_dir/$ac_word; then
1283       if [$3]; then
1284         ac_cv_path_$1="$ac_dir/$ac_word"
1285         break
1286       fi
1287     fi
1288   done
1289   IFS="$ac_save_ifs"
1290 dnl If no 4th arg is given, leave the cache variable unset,
1291 dnl so AC_PATH_PROGS will keep looking.
1292 ifelse([$4], , , [  test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
1293 ])dnl
1294   ;;
1295 esac])dnl
1296 $1="$ac_cv_path_$1"
1297 if test -n "[$]$1"; then
1298   AC_MSG_RESULT([$]$1)
1299 else
1300   AC_MSG_RESULT(no)
1301 fi
1302 AC_SUBST($1)dnl
1303 ])
1304
1305
1306 dnl From Jim Meyering.
1307 dnl FIXME: migrate into libit.
1308
1309 AC_DEFUN(AM_FUNC_OBSTACK,
1310 [AC_CACHE_CHECK([for obstacks], am_cv_func_obstack,
1311  [AC_TRY_LINK([#include "obstack.h"],
1312               [struct obstack *mem;obstack_free(mem,(char *) 0)],
1313               am_cv_func_obstack=yes,
1314               am_cv_func_obstack=no)])
1315  if test $am_cv_func_obstack = yes; then
1316    AC_DEFINE(HAVE_OBSTACK)
1317  else
1318    LIBOBJS="$LIBOBJS obstack.o"
1319  fi
1320 ])
1321
1322 dnl From Jim Meyering.  Use this if you use the GNU error.[ch].
1323 dnl FIXME: Migrate into libit
1324
1325 AC_DEFUN(AM_FUNC_ERROR_AT_LINE,
1326 [AC_CACHE_CHECK([for error_at_line], am_cv_lib_error_at_line,
1327  [AC_TRY_LINK([],[error_at_line(0, 0, "", 0, "");],
1328               am_cv_lib_error_at_line=yes,
1329               am_cv_lib_error_at_line=no)])
1330  if test $am_cv_lib_error_at_line = no; then
1331    LIBOBJS="$LIBOBJS error.o"
1332  fi
1333  AC_SUBST(LIBOBJS)dnl
1334 ])
1335
1336 # Macro to add for using GNU gettext.
1337 # Ulrich Drepper <drepper@cygnus.com>, 1995.
1338
1339 # serial 1
1340 # Stephan Kulow: I put a KDE in it to avoid name conflicts
1341
1342 AC_DEFUN(AM_KDE_GNU_GETTEXT,
1343   [AC_REQUIRE([AC_PROG_MAKE_SET])dnl
1344    AC_REQUIRE([AC_PROG_RANLIB])dnl
1345    AC_REQUIRE([AC_HEADER_STDC])dnl
1346    AC_REQUIRE([AC_C_INLINE])dnl
1347    AC_REQUIRE([AC_TYPE_OFF_T])dnl
1348    AC_REQUIRE([AC_TYPE_SIZE_T])dnl
1349    AC_REQUIRE([AC_FUNC_ALLOCA])dnl
1350    AC_REQUIRE([AC_FUNC_MMAP])dnl
1351    AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h string.h \
1352 unistd.h values.h alloca.h])
1353    AC_CHECK_FUNCS([getcwd munmap putenv setenv setlocale strchr strcasecmp \
1354 __argz_count __argz_stringify __argz_next stpcpy])
1355
1356    AM_LC_MESSAGES
1357
1358    if test "x$CATOBJEXT" != "x"; then
1359      if test "x$ALL_LINGUAS" = "x"; then
1360        LINGUAS=
1361      else
1362        AC_MSG_CHECKING(for catalogs to be installed)
1363        NEW_LINGUAS=
1364        for lang in ${LINGUAS=$ALL_LINGUAS}; do
1365          case "$ALL_LINGUAS" in
1366           *$lang*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;;
1367          esac
1368        done
1369        LINGUAS=$NEW_LINGUAS
1370        AC_MSG_RESULT($LINGUAS)
1371      fi
1372
1373      dnl Construct list of names of catalog files to be constructed.
1374      if test -n "$LINGUAS"; then
1375        for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
1376      fi
1377    fi
1378
1379   ])
1380
1381 AC_DEFUN(AC_HAVE_XPM,
1382  [AC_REQUIRE_CPP()dnl
1383
1384  test -z "$XPM_LDFLAGS" && XPM_LDFLAGS=
1385  test -z "$XPM_INCLUDE" && XPM_INCLUDE=
1386
1387  AC_ARG_WITH(xpm, [  --without-xpm           disable color pixmap XPM tests],
1388         xpm_test=$withval, xpm_test="yes")
1389  if test "x$xpm_test" = xno; then
1390    ac_cv_have_xpm=no
1391  else
1392    AC_MSG_CHECKING(for XPM)
1393    AC_CACHE_VAL(ac_cv_have_xpm,
1394    [
1395     AC_LANG_C
1396     ac_save_ldflags="$LDFLAGS"
1397     ac_save_cflags="$CFLAGS"
1398     LDFLAGS="$LDFLAGS $XPM_LDFLAGS $all_libraries -lXpm -lX11 -lXext $LIBSOCKET"
1399     CFLAGS="$CFLAGS $X_INCLUDES"
1400     test ! -z "$XPM_INCLUDE" && CFLAGS="-I$XPM_INCLUDE $CFLAGS"
1401     AC_TRY_LINK([#include <X11/xpm.h>],[],
1402         ac_cv_have_xpm="yes",ac_cv_have_xpm="no")
1403     LDFLAGS="$ac_save_ldflags"
1404     CFLAGS="$ac_save_cflags"
1405    ])dnl
1406  
1407   if test "$ac_cv_have_xpm" = no; then
1408     AC_MSG_RESULT(no)
1409     XPM_LDFLAGS=""
1410     XPMINC=""
1411     $2
1412   else
1413     AC_DEFINE(HAVE_XPM)
1414     if test "$XPM_LDFLAGS" = ""; then
1415        XPMLIB="-lXpm"
1416     else
1417        XPMLIB="-L$XPM_LDFLAGS -lXpm"
1418     fi
1419     if test "$XPM_INCLUDE" = ""; then
1420        XPMINC=""
1421     else
1422        XPMINC="-I$XPM_INCLUDE"
1423     fi
1424     AC_MSG_RESULT(yes)
1425     $1
1426   fi
1427  fi
1428  AC_SUBST(XPMINC)
1429  AC_SUBST(XPMLIB)
1430 ]) 
1431
1432 AC_DEFUN(AC_HAVE_GL,
1433  [AC_REQUIRE_CPP()dnl
1434
1435  test -z "$GL_LDFLAGS" && GL_LDFLAGS=
1436  test -z "$GL_INCLUDE" && GL_INCLUDE=
1437
1438  AC_ARG_WITH(gl, [  --without-gl            disable 3D GL modes],
1439         gl_test=$withval, gl_test="yes")
1440  if test "x$gl_test" = xno; then
1441    ac_cv_have_gl=no
1442  else
1443    AC_MSG_CHECKING(for GL)
1444    AC_CACHE_VAL(ac_cv_have_gl,
1445    [
1446     AC_LANG_C
1447     ac_save_ldflags="$LDFLAGS"
1448     ac_save_cflags="$CFLAGS"
1449     LDFLAGS="$LDFLAGS $GL_LDFLAGS $all_libraries -lMesaGL -lMesaGLU -lX11 -lXext -lm $LIBSOCKET"
1450     CFLAGS="$CFLAGS $X_INCLUDES"
1451     test ! -z "$GL_INCLUDE" && CFLAGS="-I$GL_INCLUDE $CFLAGS"
1452     AC_TRY_LINK([],[],
1453         ac_cv_have_gl="yes",ac_cv_have_gl="no")
1454     LDFLAGS="$ac_save_ldflags"
1455     CFLAGS="$ac_save_cflags"
1456    ])dnl
1457  
1458   if test "$ac_cv_have_gl" = no; then
1459     AC_MSG_RESULT(no)
1460     GL_LDFLAGS=""
1461     GLINC=""
1462     $2
1463   else
1464     AC_DEFINE(HAVE_GL)
1465     if test "$GL_LDFLAGS" = ""; then
1466        GLLIB="-lMesaGL -lMesaGLU"
1467     else
1468        GLLIB="-L$GL_LDFLAGS -lMesaGL -lMesaGLU"
1469     fi
1470     if test "$GL_INCLUDE" = ""; then
1471        GLINC=""
1472     else
1473        GLINC="-I$GL_INCLUDE"
1474     fi
1475     AC_MSG_RESULT(yes)
1476     $1
1477   fi
1478  fi
1479  AC_SUBST(GLINC)
1480  AC_SUBST(GLLIB)
1481 ]) 
1482
1483  dnl PAM pam
1484  
1485  dnl Should test for PAM (Pluggable Authentication Modules)
1486  AC_DEFUN(AC_PATH_PAM_DIRECT,
1487  [
1488  test -z "$pam_direct_test_library" && pam_direct_test_library=pam
1489  test -z "$pam_direct_test_include" && pam_direct_test_include=security/pam_appl.h
1490  
1491    for ac_dir in               \
1492                                \
1493      /usr/local/include        \
1494      /usr/include              \
1495      /usr/unsupported/include  \
1496      /opt/include              \
1497      /usr/pam/include          \
1498      /usr/local/pam/include    \
1499      /usr/lib/pam/include      \
1500                               \
1501      $extra_include            \
1502      ; \
1503    do
1504      if test -r "$ac_dir/$pam_direct_test_include"; then
1505        no_pam= ac_pam_includes=$ac_dir
1506        break
1507      fi
1508    done
1509  
1510  # First see if replacing the include by lib works.
1511  for ac_dir in `echo "$ac_pam_includes" | sed s/include/lib/` \
1512                            \
1513      /lib                  \
1514      /usr/lib              \
1515      /usr/local/lib        \
1516      /usr/unsupported/lib  \
1517      /lib/security         \
1518      /usr/security/lib     \
1519      $extra_lib            \
1520      ; \
1521  do
1522    for ac_extension in a so sl; do
1523      if test -r $ac_dir/lib${pam_direct_test_library}.$ac_extension; then
1524        no_pam= ac_pam_libraries=$ac_dir
1525        break 2
1526      fi
1527    done
1528  done
1529 ])
1530
1531 AC_DEFUN(AC_PATH_PAM,
1532  [AC_REQUIRE_CPP()dnl
1533
1534   AC_CHECK_LIB(pam_misc, main, [PAM_MISC_LIB="-lpam_misc"], [], [-lpam -ldl])
1535
1536  AC_MSG_CHECKING(for PAM)
1537  AC_ARG_WITH(pam, 
1538 [  --with-pam[=ARG]        enable support for PAM: ARG=[yes|no|service name]],
1539   [
1540     if test "x$withval" = "xyes"; then
1541       no_pam=
1542       default_pam=yes
1543     elif test "x$withval" = "xno"; then
1544       no_pam=yes
1545     else
1546       no_pam=
1547       pam_service="$withval"
1548         if test -z "$pam_service"; then
1549         default_pam=yes
1550         else
1551         default_pam=
1552         fi 
1553       fi
1554   ], no_pam=yes
1555  )
1556
1557  if test ! "$no_pam" = yes; then
1558
1559  AC_CACHE_VAL(ac_cv_path_pam,
1560  [
1561  ac_pam_includes=NONE
1562  ac_pam_libraries=NONE
1563  if test -z "$pam_libraries"; then
1564    pam_libraries=NONE
1565  fi
1566  if test -z "$pam_includes"; then
1567    pam_includes=NONE
1568  fi
1569
1570  AC_PATH_PAM_DIRECT
1571  
1572  test "x$pam_includes" = xNONE && pam_includes=$ac_pam_includes
1573  test "x$pam_libraries" = xNONE && pam_libraries=$ac_pam_libraries
1574  
1575  if test ! "x$pam_includes" = xNONE && test ! "x$pam_libraries" = xNONE; then
1576    ac_pam_libs="-lpam $PAM_MISC_LIB -ldl"
1577    ac_cv_path_pam="no_pam= ac_pam_includes=$ac_pam_includes ac_pam_libraries=$ac_pam_libraries ac_pam_libs=\"$ac_pam_libs\""
1578  else
1579    ac_cv_path_pam="no_pam=yes"
1580  fi
1581  ])
1582
1583  eval "$ac_cv_path_pam"
1584  
1585  fi
1586
1587  if test "$no_pam" = yes; then
1588    AC_MSG_RESULT(no)
1589  else
1590    AC_DEFINE(HAVE_PAM)
1591    PAMLIBS="$ac_pam_libs"
1592    test "x$pam_includes" = xNONE && pam_includes=$ac_pam_includes
1593    test "x$pam_libraries" = xNONE && pam_libraries=$ac_pam_libraries
1594    AC_MSG_RESULT([libraries $pam_libraries, headers $pam_includes])
1595  if test "$default_pam" = yes; then
1596    AC_MSG_RESULT(["default pam service name will be used"])
1597  else
1598    AC_DEFINE_UNQUOTED(KDE_PAM_SERVICE,"$pam_service")
1599    AC_MSG_RESULT(["pam service name will be: " $pam_service])
1600  fi
1601 dnl test whether struct pam_message is const (Linux) or not (Sun)
1602    pam_appl_h="$ac_pam_includes/security/pam_appl.h"
1603    AC_MSG_CHECKING(for const pam_message)
1604    AC_EGREP_HEADER([struct pam_message],
1605       $pam_appl_h,
1606       [ AC_EGREP_HEADER([const struct pam_message],
1607                         $pam_appl_h,
1608                         [AC_MSG_RESULT(["const: Linux-type PAM"]) ],
1609                         [AC_MSG_RESULT(["nonconst: Sun-type PAM"])
1610                         AC_DEFINE(PAM_MESSAGE_NONCONST)] 
1611                         )],
1612        [AC_MSG_RESULT(["not found - assume const, Linux-type PAM"])]
1613        )
1614  fi
1615  
1616  if test "x$pam_libraries" != x && test "x$pam_libraries" != xNONE ; then
1617      PAMLIBPATHS="-L$pam_libraries"
1618  fi
1619  if test "x$pam_includes" != x && test "x$pam_includes" != xNONE ; then
1620      PAMINC="-I$pam_includes"
1621  fi
1622  
1623  AC_SUBST(PAMINC)
1624  AC_SUBST(PAMLIBS)
1625  AC_SUBST(PAMLIBPATHS)
1626
1627 ]) 
1628
1629 AC_DEFUN(KDE_CHECK_LIBDL,
1630 [
1631 AC_CHECK_LIB(dl, dlopen, [
1632 LIBDL="-ldl"
1633 ac_cv_have_dlfcn=yes
1634 ])
1635
1636 AC_CHECK_LIB(dld, shl_unload, [
1637 LIBDL="-ldld"
1638 ac_cv_have_shload=yes
1639 ])
1640
1641 AC_SUBST(LIBDL)
1642 ])
1643
1644 AC_DEFUN(KDE_CHECK_DLOPEN,
1645 [
1646 KDE_CHECK_LIBDL
1647 AC_CHECK_HEADERS(dlfcn.h dl.h)
1648 if test "$ac_cv_header_dlfcn_h" = "no"; then
1649   ac_cv_have_dlfcn=no
1650 fi
1651
1652 if test "$ac_cv_header_dl_h" = "no"; then
1653   ac_cv_have_shload=no
1654 fi
1655
1656 enable_dlopen=no
1657 AC_ARG_ENABLE(dlopen,
1658 [  --disable-dlopen        link staticly [default=no]] ,
1659 [if test "$enableval" = yes; then
1660   enable_dlopen=yes
1661 fi],
1662 enable_dlopen=yes)
1663
1664 # override the user's opinion, if we know it better ;)
1665 if test "$ac_cv_have_dlfcn" = "no" && test "$ac_cv_have_shload" = "no"; then
1666   enable_dlopen=no
1667 fi
1668
1669 if test "$ac_cv_have_dlfcn" = "yes"; then
1670   AC_DEFINE_UNQUOTED(HAVE_DLFCN)
1671 fi
1672
1673 if test "$ac_cv_have_shload" = "yes"; then
1674   AC_DEFINE_UNQUOTED(HAVE_SHLOAD)
1675 fi
1676
1677 if test "$enable_dlopen" = no ; then
1678   test -n "$1" && eval $1
1679 else
1680   test -n "$2" && eval $2
1681 fi
1682
1683 ])
1684
1685 AC_DEFUN(KDE_CHECK_DYNAMIC_LOADING,
1686 [
1687 KDE_CHECK_DLOPEN(libtool_enable_shared=no, libtool_enable_static=no)
1688 KDE_PROG_LIBTOOL
1689 AC_MSG_CHECKING([dynamic loading])
1690 eval "`egrep '^build_libtool_libs=' libtool`"
1691 if test "$build_libtool_libs" = "yes" && test "$enable_dlopen" = "yes"; then
1692   dynamic_loading=yes
1693   AC_DEFINE_UNQUOTED(HAVE_DYNAMIC_LOADING)
1694 else
1695   dynamic_loading=no
1696 fi
1697 AC_MSG_RESULT($dynamic_loading)
1698 if test "$dynamic_loading" = "yes"; then
1699   $1
1700 else
1701   $2
1702 fi
1703 ])
1704
1705 AC_DEFUN(KDE_ADD_INCLUDES,
1706 [
1707 if test -z "$1"; then 
1708   test_include="Pix.h"
1709 else
1710   test_include="$1"
1711 fi
1712
1713 AC_MSG_CHECKING([for libg++ ($test_include)])
1714
1715 AC_CACHE_VAL(kde_cv_libgpp_includes,
1716 [
1717 kde_cv_libgpp_includes=no
1718
1719    for ac_dir in               \
1720                                \
1721      /usr/include/g++          \
1722      /usr/include              \
1723      /usr/unsupported/include  \
1724      /opt/include              \
1725      $extra_include            \
1726      ; \
1727    do
1728      if test -r "$ac_dir/$test_include"; then
1729        kde_cv_libgpp_includes=$ac_dir
1730        break
1731      fi
1732    done
1733 ])
1734
1735 AC_MSG_RESULT($kde_cv_libgpp_includes)
1736 if test "$kde_cv_libgpp_includes" != "no"; then
1737   all_includes="-I$kde_cv_libgpp_includes $all_includes"
1738 fi
1739 ])
1740 ])
1741
1742
1743 AC_DEFUN(KDE_CHECK_MICO,
1744 [
1745 AC_REQUIRE([KDE_CHECK_LIBDL])
1746 AC_MSG_CHECKING(for MICO)
1747 AC_ARG_WITH(micodir,
1748   [  --with-micodir=micodir  where mico is installed ],
1749   kde_micodir=$withval,
1750   kde_micodir=/usr/local
1751 )
1752 AC_MSG_RESULT($kde_micodir)
1753 if test ! -r  $kde_micodir/include/CORBA.h; then
1754   AC_MSG_ERROR([No CORBA.h found, specify another micodir])
1755 fi
1756
1757 MICO_INCLUDES=-I$kde_micodir/include
1758 AC_SUBST(MICO_INCLUDES)
1759 MICO_LDFLAGS=-L$kde_micodir/lib
1760 AC_SUBST(MICO_LDFLAGS)
1761
1762 AC_MSG_CHECKING([for MICO version])
1763 AC_CACHE_VAL(kde_cv_mico_version,
1764 [
1765 AC_LANG_C
1766 cat >conftest.$ac_ext <<EOF
1767 #include <stdio.h>
1768 #include <mico/version.h>
1769 int main() { 
1770     
1771    printf("MICO_VERSION=%s\n",MICO_VERSION); 
1772    return (0); 
1773 }
1774 EOF
1775 ac_compile='${CC-gcc} $CFLAGS $MICO_INCLUDES conftest.$ac_ext -o conftest'
1776 if AC_TRY_EVAL(ac_compile); then
1777   if eval `./conftest 2>&5`; then
1778     kde_cv_mico_version=$MICO_VERSION
1779   else
1780     AC_MSG_ERROR([your system is not able to execute a small application to
1781     find MICO version! Check $kde_micodir/include/mico/version.h])
1782   fi 
1783 else
1784   AC_MSG_ERROR([your system is not able to compile a small application to
1785   find MICO version! Check $kde_micodir/include/mico/version.h])
1786 fi
1787 ])
1788
1789 dnl installed MICO version
1790 mico_v_maj=`echo $kde_cv_mico_version | sed -e 's/^\(.*\)\..*\..*$/\1/'`
1791 mico_v_mid=`echo $kde_cv_mico_version | sed -e 's/^.*\.\(.*\)\..*$/\1/'`
1792 mico_v_min=`echo $kde_cv_mico_version | sed -e 's/^.*\..*\.\(.*\)$/\1/'`
1793
1794 dnl required MICO version
1795 req_v_maj=`echo $1 | sed -e 's/^\(.*\)\..*\..*$/\1/'`
1796 req_v_mid=`echo $1 | sed -e 's/^.*\.\(.*\)\..*$/\1/'`
1797 req_v_min=`echo $1 | sed -e 's/^.*\..*\.\(.*\)$/\1/'` 
1798
1799 if test "$mico_v_maj" -lt "$req_v_maj" || \
1800    ( test "$mico_v_maj" -eq "$req_v_maj" && \
1801         test "$mico_v_mid" -lt "$req_v_mid" ) || \
1802    ( test "$mico_v_mid" -eq "$req_v_mid" && \
1803         test "$mico_v_min" -lt "$req_v_min" )
1804
1805 then
1806   AC_MSG_ERROR([found MICO version $kde_cv_mico_version but version $1 \
1807 at least is required. You should upgrade MICO.])
1808 else
1809   AC_MSG_RESULT([$kde_cv_mico_version (minimum version $1, ok)])
1810 fi
1811
1812 LIBMICO="-lmico$kde_cv_mico_version $LIBDL"
1813 AC_SUBST(LIBMICO)
1814 IDL=$kde_micodir/bin/idl
1815 AC_SUBST(IDL)
1816 ])
1817
1818
1819 AC_DEFUN(KDE_CHECK_MINI_STL,
1820 [
1821 AC_REQUIRE([KDE_CHECK_MICO])
1822
1823 AC_MSG_CHECKING(if we use mico's mini-STL)
1824 AC_CACHE_VAL(kde_cv_have_mini_stl,
1825 [
1826 AC_LANG_CPLUSPLUS
1827 kde_save_cxxflags="$CXXFLAGS"
1828 CXXFLAGS="$CXXFLAGS $MICO_INCLUDES"
1829 AC_TRY_COMPILE(
1830 [
1831 #include <mico/config.h>
1832 ],
1833 [
1834 #ifdef HAVE_MINI_STL
1835 #error "nothing"
1836 #endif
1837 ],
1838 kde_cv_have_mini_stl=no,
1839 kde_cv_have_mini_stl=yes)
1840 CXXFLAGS="$kde_save_cxxflags"
1841 ])
1842
1843
1844 AC_MSG_RESULT($kde_cv_have_mini_stl)
1845 if test "$kde_cv_have_mini_stl" = "yes"; then
1846   AC_DEFINE_UNQUOTED(HAVE_MINI_STL)
1847 fi
1848 ])
1849
1850 ])
1851
1852
1853 AC_DEFUN(KDE_CHECK_LIBPTHREAD,
1854 [
1855 AC_CHECK_LIB(pthread, pthread_create, [LIBPTHREAD="-lpthread"], LIBPTHREAD= )
1856 AC_SUBST(LIBPTHREAD)
1857 ])
1858
1859 AC_DEFUN(KDE_TRY_LINK_PYTHON,
1860 [
1861 AC_CACHE_VAL(kde_cv_try_link_python_$1,
1862 [
1863 kde_save_cxxflags="$CXXFLAGS"
1864 CXXFLAGS="$CXXFLAGS $PYTHONINC"
1865 kde_save_libs="$LIBS"
1866 LIBS="$LIBS $LIBPYTHON $2 $LIBDL $LIBSOCKET"
1867 kde_save_ldflags="$LDFLAGS"
1868 LDFLAGS="$LDFLAGS $PYTHONLIB"
1869
1870 AC_TRY_LINK(
1871 [
1872 #include <Python.h>
1873 ],[
1874         PySys_SetArgv(1, 0);
1875 ],
1876         [kde_cv_try_link_python_$1=yes],
1877         [kde_cv_try_link_python_$1=no]
1878 )
1879 CXXFLAGS="$kde_save_cxxflags"
1880 LIBS="$kde_save_libs"
1881 LDFLAGS="$kde_save_ldflags"
1882 ])
1883
1884 if test "$kde_cv_try_link_python_$1" = "yes"; then
1885   $3
1886 else
1887   $4
1888 fi
1889
1890 ])
1891
1892 AC_DEFUN(KDE_CHECK_PYTHON,
1893 [
1894 AC_REQUIRE([KDE_CHECK_LIBDL])
1895 AC_REQUIRE([KDE_CHECK_LIBPTHREAD])
1896 if test -z "$1"; then 
1897   version="1.5"
1898 else
1899   version="$1"
1900 fi
1901
1902 AC_MSG_CHECKING([for Python$version])
1903
1904 AC_ARG_WITH(pythondir, 
1905 [  --with-pythondir=pythondir   use python installed in pythondir ],
1906 [
1907   ac_python_dir=$withval
1908 ], ac_python_dir=/usr/local
1909 )
1910
1911 python_incdirs="$ac_python_dir/include/python$version /usr/include/python$version /usr/local/include/python$version /usr/local/include"
1912 AC_FIND_FILE(Python.h, $python_incdirs, python_incdir)
1913 if test ! -r $python_incdir/Python.h; then
1914   AC_MSG_ERROR(Python.h not found.)
1915 fi
1916
1917 PYTHONINC=-I$python_incdir
1918
1919 python_libdirs="$ac_python_dir/lib/python$version/config /usr/lib/python$version/config /usr/local/python$version/config"
1920 AC_FIND_FILE(libpython$version.a, $python_libdirs, python_libdir)
1921 if test ! -r $python_libdir/libpython$version.a; then
1922   AC_MSG_ERROR(libpython$version.a not found.)
1923 fi
1924
1925 PYTHONLIB=-L$python_libdir
1926 LIBPYTHON=-lpython$version
1927
1928 AC_MSG_RESULT(header $python_incdir library $python_libdir)
1929
1930 dnl Note: this test is very weak
1931 AC_MSG_CHECKING(if an Python application links)
1932 KDE_TRY_LINK_PYTHON(normal, "", AC_MSG_RESULT(yes),
1933  [
1934     AC_MSG_RESULT(no)
1935     AC_MSG_CHECKING(if Python depends on -lpthread)
1936     KDE_TRY_LINK_PYTHON(pthread, "$LIBPTHREAD",
1937     [  
1938        AC_MSG_RESULT(yes)
1939        LIBPYTHON="$LIBPYTHON $LIBPTHREAD $LIBDL"
1940     ],
1941     [
1942        AC_MSG_RESULT(no)
1943        AC_MSG_CHECKING(if Python depeds on -ltcl)
1944        KDE_TRY_LINK_PYTHON(tcl, "-ltcl",
1945        [
1946           AC_MSG_RESULT(yes)
1947           LIBPYTHON="$LIBPYTHON -ltcl"
1948        ],
1949        [
1950           AC_MSG_RESULT(no)
1951         AC_MSG_WARN([it seems, Python depends on another library. 
1952     Pleae use \"make LIBPTYHON='-lpython$version -lotherlib'\" to fix this
1953     and contact the authors to let them know about this problem])
1954         ])
1955     ])
1956  ]) 
1957
1958 AC_SUBST(PYTHONINC)
1959 AC_SUBST(PYTHONLIB)
1960 AC_SUBST(LIBPYTHON)
1961
1962 ])
1963
1964
1965 AC_DEFUN(KDE_CHECK_STL_SGI,
1966 [
1967     AC_MSG_CHECKING([if STL implementation is SGI like])
1968     AC_CACHE_VAL(kde_cv_stl_type_sgi,
1969     [
1970       AC_TRY_COMPILE([
1971 #include <string>
1972 ],[
1973   string astring="Hallo Welt.";
1974   astring.erase(0, 6); // now astring is "Welt"
1975   return 0;
1976 ], kde_cv_stl_type_sgi=yes,
1977    kde_cv_stl_type_sgi=no)
1978 ])
1979
1980    AC_MSG_RESULT($kde_cv_stl_type_sgi)
1981
1982    if test "$kde_cv_stl_type_sgi" = "yes"; then
1983         AC_DEFINE_UNQUOTED(HAVE_SGI_STL) 
1984    fi
1985 ])
1986
1987 AC_DEFUN(KDE_CHECK_STL_HP,
1988 [
1989     AC_MSG_CHECKING([if STL implementation is HP like])
1990     AC_CACHE_VAL(kde_cv_stl_type_hp,
1991     [
1992       AC_TRY_COMPILE([
1993 #include <string>
1994 ],[
1995   string astring="Hello World";
1996   astring.remove(0, 6); // now astring is "World"
1997   return 0;
1998 ], kde_cv_stl_type_hp=yes,
1999    kde_cv_stl_type_hp=no)
2000 ])
2001    AC_MSG_RESULT($kde_cv_stl_type_hp)
2002
2003    if test "$kde_cv_stl_type_hp" = "yes"; then
2004         AC_DEFINE_UNQUOTED(HAVE_HP_STL) 
2005    fi
2006 ])
2007
2008 AC_DEFUN(KDE_CHECK_STL,
2009 [
2010     KDE_CHECK_STL_SGI
2011     
2012     if test "$kde_cv_stl_type_sgi" = "no"; then
2013        KDE_CHECK_STL_HP
2014
2015        if test "$kde_cv_stl_type_hp" = "no"; then
2016          AC_MSG_ERROR("no known STL type found")
2017        fi
2018     fi
2019
2020 ])
2021
2022 AC_DEFUN(AC_FIND_QIMGIO,
2023    [AC_REQUIRE([AC_FIND_JPEG])
2024 AC_MSG_CHECKING([for qimgio])
2025 AC_CACHE_VAL(ac_cv_lib_qimgio,
2026 [ac_save_LIBS="$LIBS"
2027 LIBS="$all_libraries -lqimgio -lpng -lz -lqt $LIBJPEG -lX11 $LIBSOCKET"
2028 AC_TRY_LINK(dnl
2029 [
2030 void qInitImageIO ();
2031 ],
2032             [qInitImageIO();],
2033             eval "ac_cv_lib_qimgio=yes",
2034             eval "ac_cv_lib_qimgio=no")
2035 LIBS="$ac_save_LIBS"
2036 ])dnl
2037 if eval "test \"`echo $ac_cv_lib_qimgio`\" = yes"; then
2038   LIBQIMGIO="-lqimgio -lpng -lz $LIBJPEG"
2039   AC_MSG_RESULT(yes)
2040   AC_DEFINE_UNQUOTED(HAVE_QIMGIO)
2041   AC_SUBST(LIBQIMGIO)
2042 else
2043   AC_MSG_RESULT(not found)
2044 fi
2045 ])
2046
2047 AC_DEFUN(KDE_CHECK_ANSI,
2048 [
2049 AC_MSG_CHECKING([for strdup])
2050
2051     AC_CACHE_VAL(kde_cv_stl_type_sgi,
2052     [
2053 AC_LANG_CPLUSPLUS
2054 save_CXXFLAGS="$CXXFLAGS"
2055 if test "$GCC" = "yes"; then
2056   CXXFLAGS="$CXXFLAGS -pedantic-errors"
2057 fi
2058
2059 AC_TRY_COMPILE([
2060 #include <string.h>
2061 ],[
2062   char buffer[] = "Hallo";
2063   strdup(buffer)
2064 ], kde_cv_has_strdup=yes,
2065    kde_cv_has_strdup=no)
2066 CXXFLAGS="$save_CXXFLAGS"
2067 ])
2068 AC_MSG_RESULT($kde_cv_has_strdup)
2069
2070 if test "$kde_cv_has_strdup" = "yes"; then
2071   AC_DEFINE_UNQUOTED(HAVE_STRDUP)
2072 fi
2073
2074 ])
2075
2076 AC_DEFUN(KDE_CHECK_INSURE,
2077 [
2078   AC_ARG_ENABLE(insure, [  --enable-insure             use insure++ for debugging [default=no]],
2079   [
2080   if test $enableval = "no"; dnl
2081         then ac_use_insure="no"
2082         else ac_use_insure="yes"
2083    fi
2084   ], [ac_use_insure="no"])
2085
2086   AC_MSG_CHECKING(if we will use Insure++ to debug)
2087   AC_MSG_RESULT($ac_use_insure)
2088   if test "$ac_use_insure" = "yes"; dnl
2089        then CC="insure"; CXX="insure"; dnl CFLAGS="$CLAGS -fno-rtti -fno-exceptions "????
2090    fi
2091 ])          
2092
2093 dnl this is for kdm:
2094
2095 AC_DEFUN(AC_CHECK_KDM,
2096 [
2097 AC_CHECK_FUNCS(getsecretkey)
2098 dnl checks for X server
2099
2100 AC_PATH_PROG(X_SERVER, X)
2101 if test ! -z "$X_SERVER"; then
2102 X_SERVER=`echo $X_SERVER | sed -e 's+/X$++'`
2103 AC_DEFINE_UNQUOTED(XBINDIR,$X_SERVER)
2104 XBINDIR=$X_SERVER
2105 AC_SUBST(XBINDIR)
2106 fi
2107
2108 dnl This one tries to find XDMDIR for config files
2109 AC_ARG_WITH(xdmdir,
2110         [  --with-xdmdir                  If the xdm config dir can't be found automaticly],
2111         [ ac_xdmdir=$withval],
2112         [ ac_xdmdir="no"])
2113
2114 AC_MSG_CHECKING([for xdm configuration dir])
2115 if test "$ac_xdmdir" = "no"; then
2116     rm -fr conftestdir
2117     if mkdir conftestdir; then
2118         cd conftestdir
2119     cat > Imakefile <<'EOF'
2120 acfindxdm:
2121         @echo 'ac_xdmdir="$(XDMDIR)";'
2122 EOF
2123         if (xmkmf) > /dev/null 2> /dev/null && test -f Makefile; then
2124             eval `${MAKE-make} acfindxdm 2>/dev/null 2>/dev/null | grep -v make`
2125         fi
2126         cd ..
2127         rm -fr conftestdir
2128         dnl Check if Imake was right
2129         if test -f $ac_xdmdir/xdm-config; then
2130             AC_MSG_RESULT($ac_xdmdir)
2131         else
2132             dnl Here we must do something else
2133             dnl Maybe look for xdm-config in standard places, and
2134             dnl if that fails use a fresh copy in $KDEDIR/config/kdm/
2135             AC_FIND_FILE(xdm-config,/etc/X11/xdm /var/X11/xdm /usr/openwin/xdm /usr/X11R6/lib/X11/xdm,ac_xdmdir)
2136             if test -f $ac_xdmdir/xdm-config; then
2137                 AC_MSG_RESULT($ac_xdmdir)
2138             else                                 
2139                 if test "${prefix}" = NONE; then
2140                         ac_xdmdir=$ac_default_prefix/config/kdm
2141                 else
2142                         ac_xdmdir=$prefix/config/kdm
2143                 fi
2144                 AC_MSG_RESULT([xdm config dir not found, installing defaults in $ac_xdmdir])
2145                 xdmconfigsubdir=xdmconfig
2146                 AC_SUBST(xdmconfigsubdir)
2147             fi
2148         fi
2149     fi
2150 else
2151     if test -f $ac_xdmdir/xdm-config; then
2152         AC_MSG_RESULT($ac_xdmdir)
2153     else
2154
2155         AC_MSG_RESULT([xdm config dir not found, installing defaults in $ac_xdmdir])
2156         xdmconfigsubdir=xdmconfig
2157         AC_SUBST(xdmconfigsubdir)
2158     fi
2159 fi
2160 AC_DEFINE_UNQUOTED(XDMDIR,"$ac_xdmdir")
2161 AC_SUBST(ac_xdmdir)
2162
2163 AC_PATH_PAM
2164 if test "x$no_pam" = "xyes"; then 
2165         pam_support="no"
2166 else
2167         pam_support="yes"
2168         shadow_support="no" # if pam is installed, use it. We can't savely 
2169                             # test, if it works *sigh*
2170 fi
2171
2172 AC_ARG_WITH(shadow,
2173         [  --with-shadow                  If you want shadow password support ],
2174         [ if test "$withval" = "yes"; then
2175              shadow_support="yes"
2176           else
2177              shadow_support="no"
2178           fi
2179           if test "$pam_support" = "yes" && test "$shadow_support=yes"; then
2180                 AC_MSG_WARN("You can not define both pam AND shadow")
2181           fi
2182         ],
2183         [ if test -z "$shadow_support"; then shadow_support="no"; fi ] )
2184
2185 if test "$pam_support" = "yes"; then
2186   AC_CHECK_LIB(pam, main, [PASSWDLIB="-lpam -ldl"
2187   AC_DEFINE_UNQUOTED(HAVE_PAM_LIB)],
2188   [],-ldl)
2189 fi
2190
2191 if test -z "$PASSWDLIB" && test "$shadow_support" = "yes"; then
2192   AC_CHECK_LIB(shadow, main,
2193     [ PASSWDLIB="-lshadow"
2194       AC_DEFINE_UNQUOTED(HAVE_SHADOW_LIB)
2195     ])
2196 fi
2197 AC_SUBST(PASSWDLIB)
2198 AC_CHECK_LIB(util, main, [LIBUTIL="-lutil"]) dnl for FreeBSD
2199 AC_SUBST(LIBUTIL)
2200 AC_CHECK_LIB(s, main, [LIB_LIBS="-ls"]) dnl for AIX
2201 AC_SUBST(LIB_LIBS)
2202 AC_CHECK_LIB(Xdmcp, main, [LIBXDMCP="-lXdmcp"], , $X_LDFLAGS -lX11) dnl for Unixware
2203 AC_SUBST(LIBXDMCP)
2204
2205 if test -n "$LIBXDMCP"; then
2206   ac_cpp_safe=$ac_cpp
2207   ac_cpp='$CXXCPP $CPPFLAGS $X_INCLUDES'
2208   AC_CHECK_HEADERS(X11/Xdmcp.h)
2209   ac_cpp=$ac_cpp_safe
2210 fi
2211
2212 ])