]> git.lyx.org Git - lyx.git/blob - config/kde.m4
Bugfixes, de.po and sl.po updates, lyxlookup cleanup
[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/qt $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 dnl specify we are definitely C++ compiling first
637 AC_LANG_CPLUSPLUS
638 AC_TRY_COMPILE([
639 #include <qglobal.h>
640 ],
641 [
642 #if (QT_VERSION >= 200)
643 break_me_(\\\);
644 #endif
645 ],
646 ac_qt_ok=yes,
647 ac_qt_ok=no
648
649 test "$ac_qt_ok" = no && AC_MSG_ERROR([Found Qt 2 - you must specify the path to the Qt 1 headers and libraries])
650 CXXFLAGS="$SAVE_CXXFLAGS"
651
652 AC_SUBST(qt_libraries)
653 AC_SUBST(qt_includes)
654
655 if test "$qt_includes" = "$x_includes" || test -z "$qt_includes"; then
656  QT_INCLUDES="";
657 else
658  QT_INCLUDES="-I$qt_includes"
659  all_includes="$QT_INCLUDES $all_includes"
660 fi
661
662 if test "$qt_libraries" = "$x_libraries" || test -z "$qt_libraries"; then
663  QT_LDFLAGS=""
664 else
665  QT_LDFLAGS="-L$qt_libraries"
666  all_libraries="$QT_LDFLAGS $all_libraries"
667 fi
668
669 AC_SUBST(QT_INCLUDES)
670 AC_SUBST(QT_LDFLAGS)
671 AC_PATH_QT_MOC
672 ])
673
674 AC_DEFUN(AC_PATH_QT,
675 [
676 AC_PATH_QT_1_3
677 ])
678
679 ## ------------------------------------------------------------------------
680 ## Now, the same with KDE
681 ## $(KDE_LDFLAGS) will be the kdeliblocation (if needed)
682 ## and $(kde_includes) will be the kdehdrlocation (if needed)
683 ## ------------------------------------------------------------------------
684 ##
685 AC_DEFUN(AC_BASE_PATH_KDE,
686 [
687 AC_REQUIRE([KDE_MISC_TESTS])
688 AC_REQUIRE([AC_PATH_QT])dnl
689 AC_MSG_CHECKING([for KDE])
690
691 AC_ARG_WITH(kde-dir,
692     [  --with-kde-dir          where the KDE root is ],
693     [ export KDEDIR="$withval" ])
694  
695 if test "${prefix}" != NONE; then
696   kde_includes=${prefix}/include
697   ac_kde_includes=$prefix/include
698
699   if test "${exec_prefix}" != NONE; then
700     kde_libraries=${exec_prefix}/lib
701     ac_kde_libraries=$exec_prefix/lib
702   else
703     kde_libraries=${prefix}/lib
704     ac_kde_libraries=$prefix/lib
705   fi
706 else
707   ac_kde_includes=
708   ac_kde_libraries=
709   kde_libraries=""
710   kde_includes=""
711 fi
712
713 if test ! -z "$KDEDIR"; then
714   ac_kde_includes="$KDEDIR/include"
715   kde_includes="$KDEDIR/include"
716   ac_kde_libraries="$KDEDIR/lib"
717   kde_libraries="$KDEDIR/lib"
718 fi
719
720 AC_ARG_WITH(kde-includes,
721     [  --with-kde-includes     where the KDE includes are installed. ],
722     [ ac_kde_includes="$withval" ])
723  
724 AC_ARG_WITH(kde-libraries,
725     [  --with-kde-libraries    where the KDE libraries are installed.],
726     [ ac_kde_libraries="$withval" ])
727  
728 AC_CACHE_VAL(ac_cv_have_kde,
729 [#try to guess kde locations
730
731 if test -z "$1"; then
732
733 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"
734 test -n "$KDEDIR" && kde_incdirs="$KDEDIR/include/kde $KDEDIR/include $KDEDIR $kde_incdirs"
735 kde_incdirs="$ac_kde_includes $kde_incdirs"
736 AC_FIND_FILE(ksock.h, $kde_incdirs, kde_incdir)
737 ac_kde_includes="$kde_incdir"
738
739 if test -n "$ac_kde_includes" && test ! -r "$ac_kde_includes/ksock.h"; then
740   AC_MSG_ERROR([
741 in the prefix, you've chosen, are no kde headers installed. This will fail.
742 So, check this please and use another prefix!])
743 fi
744
745 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"
746 test -n "$KDEDIR" && kde_libdirs="$KDEDIR/lib $KDEDIR $kde_libdirs"
747 kde_libdirs="$ac_kde_libraries $kde_libdirs"
748 AC_FIND_FILE(libkdecore.la, $kde_libdirs, kde_libdir)
749 ac_kde_libraries="$kde_libdir"
750
751 if test -n "$ac_kde_libraries" && test ! -r "$ac_kde_libraries/libkdecore.la"; then
752 AC_MSG_ERROR([
753 in the prefix, you've chosen $ac_kde_libraries, are no kde libraries installed. This will fail.
754 So, check this please and use another prefix!])
755 fi
756
757 if test "$ac_kde_includes" = NO || test "$ac_kde_libraries" = NO; then
758   ac_cv_have_kde="have_kde=no"
759 else
760   ac_cv_have_kde="have_kde=yes \
761     ac_kde_includes=$ac_kde_includes ac_kde_libraries=$ac_kde_libraries"
762 fi
763
764 else dnl test -z $1 
765   
766   ac_cv_have_kde="have_kde=no"
767
768 fi
769 ])dnl
770
771 eval "$ac_cv_have_kde"
772
773 if test "$have_kde" != "yes"; then
774  if test "${prefix}" = NONE; then
775   ac_kde_prefix="$ac_default_prefix"
776  else
777   ac_kde_prefix="$prefix"
778  fi
779  if test "$exec_prefix" = NONE; then
780   ac_kde_exec_prefix="$ac_kde_prefix"
781   AC_MSG_RESULT([will be installed in $ac_kde_prefix])
782  else
783   ac_kde_exec_prefix="$exec_prefix"
784   AC_MSG_RESULT([will be installed in $ac_kde_prefix and $ac_kde_exec_prefix])
785  fi
786
787  kde_libraries="${ac_kde_exec_prefix}/lib"
788  kde_includes=${ac_kde_prefix}/include
789
790 else
791   ac_cv_have_kde="have_kde=yes \
792     ac_kde_includes=$ac_kde_includes ac_kde_libraries=$ac_kde_libraries"
793   AC_MSG_RESULT([libraries $ac_kde_libraries, headers $ac_kde_includes])
794   
795   kde_libraries="$ac_kde_libraries"
796   kde_includes="$ac_kde_includes"
797 fi
798 AC_SUBST(kde_libraries)
799 AC_SUBST(kde_includes)
800
801 if test "$kde_includes" = "$x_includes" || test "$kde_includes" = "$qt_includes" ; then
802  KDE_INCLUDES=""
803 else
804  KDE_INCLUDES="-I$kde_includes"
805  all_includes="$KDE_INCLUDES $all_includes"
806 fi
807
808 if test "$kde_libraries" = "$x_libraries" || test "$kde_libraries" = "$qt_libraries" ; then
809  KDE_LDFLAGS=""
810 else
811  KDE_LDFLAGS="-L$kde_libraries"
812  all_libraries="$KDE_LDFLAGS $all_libraries"
813 fi
814
815 AC_SUBST(KDE_LDFLAGS)
816 AC_SUBST(KDE_INCLUDES)
817
818 AC_SUBST(all_includes)
819 AC_SUBST(all_libraries)
820
821 ])
822
823 AC_DEFUN(KDE_CHECK_KIMGIO,
824 [
825    AC_REQUIRE([AC_FIND_TIFF])
826    AC_REQUIRE([AC_FIND_JPEG]) 
827    AC_REQUIRE([AC_FIND_PNG]) 
828
829    LIB_KIMGIO='-lkimgio $(LIBJPEG) $(LIBTIFF) $(LIBPNG) -lm'
830    AC_SUBST(LIB_KIMGIO)
831    LIB_KHTMLW='-lkhtmlw $(LIB_KIMGIO) -ljscript'
832    AC_SUBST(LIB_KHTMLW)
833    LIB_KHTML='-lkhtml $(LIB_KIMGIO) -ljscript'
834    AC_SUBST(LIB_KHTML)
835 ])
836
837 AC_DEFUN(KDE_CREATE_LIBS_ALIASES,
838 [
839    AC_REQUIRE([KDE_MISC_TESTS])
840
841    KDE_LIBS='-lkfile -lkfm -lkdeui -lkdecore -lqt'
842    AC_SUBST(KDE_LIBS)
843 #   LIB_X11='-lX11 $(LIBSOCKET)'
844 #   AC_SUBST(LIB_X11)
845 #   LIB_QT='-lqt $(LIB_X11)'
846 #   AC_SUBST(LIB_QT)
847 #   LIB_KDECORE='-lkdecore -lXext $(LIB_QT)'
848 #   AC_SUBST(LIB_KDECORE)
849 #   LIB_KDEUI='-lkdeui $(LIB_KDECORE)'
850 #   AC_SUBST(LIB_KDEUI)
851 #   LIB_KFM='-lkfm $(LIB_KDECORE)'
852 #   AC_SUBST(LIB_KFM)
853 #   LIB_KFILE='-lkfile $(LIB_KFM) $(LIB_KDEUI)'
854 #   AC_SUBST(LIB_KFILE)
855 ])
856
857 AC_DEFUN(AC_PATH_KDE,
858 [
859   AC_BASE_PATH_KDE
860   AC_ARG_ENABLE(path-check, [  --disable-path-check    don't try to find out, where to install],
861   [
862   if test "$enableval" = "no"; 
863     then ac_use_path_checking="default"
864     else ac_use_path_checking=""
865   fi
866   ], [ac_use_path_checking=""]
867   )
868
869   AC_ARG_WITH(install-root, [  --with-install-root     the root, where to install to [default=/]],
870   [
871   if test "$withval" = "no";
872     then kde_install_root="";
873     else kde_install_root=$withval;
874   fi
875   ], [kde_install_root=""]
876   )
877   
878   if test -n "$kde_install_root"; then
879      install_root="$kde_install_root"
880   else
881      install_root=
882   fi
883
884   AC_CREATE_KFSSTND($ac_use_path_checking)
885
886   AC_SUBST_KFSSTND
887   KDE_CREATE_LIBS_ALIASES
888 ])
889
890 dnl slightly changed version of AC_CHECK_FUNC(setenv)
891 AC_DEFUN(AC_CHECK_SETENV,
892 [AC_MSG_CHECKING([for setenv])
893 AC_CACHE_VAL(ac_cv_func_setenv,
894 [AC_LANG_C
895 AC_TRY_LINK(
896 dnl Don't include <ctype.h> because on OSF/1 3.0 it includes <sys/types.h>
897 dnl which includes <sys/select.h> which contains a prototype for
898 dnl select.  Similarly for bzero.
899 [#include <assert.h>
900 ]ifelse(AC_LANG, CPLUSPLUS, [#ifdef __cplusplus
901 extern "C"
902 #endif
903 ])dnl
904 [/* We use char because int might match the return type of a gcc2
905     builtin and then its argument prototype would still apply.  */
906 #include <stdlib.h>
907 ], [
908 /* The GNU C library defines this for functions which it implements
909     to always fail with ENOSYS.  Some functions are actually named
910     something starting with __ and the normal name is an alias.  */
911 #if defined (__stub_$1) || defined (__stub___$1)
912 choke me
913 #else
914 setenv("TEST", "alle", 1);
915 #endif
916 ], eval "ac_cv_func_setenv=yes", eval "ac_cv_func_setenv=no")])
917
918 if test "$ac_cv_func_setenv" = "yes"; then
919   AC_MSG_RESULT(yes)
920   AC_DEFINE_UNQUOTED(HAVE_FUNC_SETENV)
921 else
922   AC_MSG_RESULT(no)
923 fi
924 ])
925
926 AC_DEFUN(AC_CHECK_GETDOMAINNAME,
927 [
928 AC_LANG_CPLUSPLUS
929 save_CXXFLAGS="$CXXFLAGS"
930 if test "$GCC" = "yes"; then
931 CXXFLAGS="$CXXFLAGS -pedantic-errors"
932 fi
933 AC_MSG_CHECKING(for getdomainname)
934 AC_CACHE_VAL(ac_cv_func_getdomainname,
935 [
936 AC_TRY_COMPILE([
937 #include <stdlib.h>
938 #include <unistd.h>
939 ],
940 [
941 char buffer[200];
942 getdomainname(buffer, 200);
943 ],
944 ac_cv_func_getdomainname=yes,
945 ac_cv_func_getdomainname=no)
946 ])
947 AC_MSG_RESULT($ac_cv_func_getdomainname)
948 if eval "test \"`echo `$ac_cv_func_getdomainname\" = yes"; then
949   AC_DEFINE(HAVE_GETDOMAINNAME)
950 fi
951 CXXFLAGS="$save_CXXFLAGS"
952 ])
953
954 AC_DEFUN(AC_CHECK_GETHOSTNAME,
955 [
956 AC_LANG_CPLUSPLUS
957 save_CXXFLAGS="$CXXFLAGS"
958 if test "$GCC" = "yes"; then
959 CXXFLAGS="$CXXFLAGS -pedantic-errors"
960 fi
961
962 AC_MSG_CHECKING([for gethostname])
963 AC_CACHE_VAL(ac_cv_func_gethostname,
964 [
965 AC_TRY_COMPILE([
966 #include <stdlib.h>
967 #include <unistd.h>
968 ],
969 [
970 char buffer[200];
971 gethostname(buffer, 200);
972 ],
973 ac_cv_func_gethostname=yes,
974 ac_cv_func_gethostname=no)
975 ])
976 AC_MSG_RESULT($ac_cv_func_gethostname)
977 if eval "test \"`echo `$ac_cv_func_gethostname\" = yes"; then
978   AC_DEFINE(HAVE_GETHOSTNAME)
979 fi
980 CXXFLAGS="$save_CXXFLAGS"
981 ])
982
983 AC_DEFUN(AC_CHECK_USLEEP,
984 [
985 AC_LANG_CPLUSPLUS
986
987 AC_MSG_CHECKING([for usleep])
988 AC_CACHE_VAL(ac_cv_func_usleep,
989 [
990 ac_libs_safe="$LIBS"
991 LIBS="$LIBS $LIBUCB"
992 AC_TRY_LINK([
993 #include <stdlib.h>
994 #include <unistd.h>
995 ],
996 [
997 usleep(200);
998 ],
999 ac_cv_func_usleep=yes,
1000 ac_cv_func_usleep=no)
1001 ])
1002 AC_MSG_RESULT($ac_cv_func_usleep)
1003 if eval "test \"`echo `$ac_cv_func_usleep\" = yes"; then
1004   AC_DEFINE(HAVE_USLEEP)
1005 fi
1006 LIBS="$ac_libs_safe"
1007 ])
1008
1009 AC_DEFUN(AC_FIND_GIF,
1010    [AC_MSG_CHECKING([for giflib])
1011 AC_CACHE_VAL(ac_cv_lib_gif,
1012 [ac_save_LIBS="$LIBS"
1013 LIBS="$all_libraries -lgif -lX11 $LIBSOCKET"
1014 AC_TRY_LINK(dnl
1015 [
1016 #ifdef __cplusplus
1017 extern "C" {
1018 #endif
1019 int GifLastError(void);
1020 #ifdef __cplusplus
1021 }
1022 #endif
1023 /* We use char because int might match the return type of a gcc2
1024     builtin and then its argument prototype would still apply.  */
1025 ],
1026             [return GifLastError();],
1027             eval "ac_cv_lib_gif=yes",
1028             eval "ac_cv_lib_gif=no")
1029 LIBS="$ac_save_LIBS"
1030 ])dnl
1031 if eval "test \"`echo $ac_cv_lib_gif`\" = yes"; then
1032   AC_MSG_RESULT(yes)
1033   AC_DEFINE_UNQUOTED(HAVE_LIBGIF)
1034 else
1035   AC_MSG_ERROR(You need giflib23. Please install the kdesupport package)
1036 fi
1037 ])
1038
1039 AC_DEFUN(AC_FIND_JPEG,
1040    [AC_MSG_CHECKING([for jpeglib])
1041 AC_CACHE_VAL(ac_cv_lib_jpeg,
1042 [ac_save_LIBS="$LIBS"
1043 LIBS="$all_libraries -ljpeg -lm"
1044 AC_TRY_LINK(
1045 [/* Override any gcc2 internal prototype to avoid an error.  */
1046 struct jpeg_decompress_struct;
1047 typedef struct jpeg_decompress_struct * j_decompress_ptr;
1048 typedef int size_t;
1049 #ifdef __cplusplus
1050 extern "C" {
1051 #endif
1052     void jpeg_CreateDecompress(j_decompress_ptr cinfo,
1053                                     int version, size_t structsize);
1054 #ifdef __cplusplus
1055 }
1056 #endif
1057 /* We use char because int might match the return type of a gcc2
1058     builtin and then its argument prototype would still apply.  */
1059 ],
1060             [jpeg_CreateDecompress(0L, 0, 0);],
1061             eval "ac_cv_lib_jpeg=-ljpeg",
1062             eval "ac_cv_lib_jpeg=no")
1063 LIBS="$ac_save_LIBS"
1064
1065 dnl what to do, if the normal way fails:
1066 if eval "test \"`echo $ac_cv_lib_jpeg`\" = no"; then
1067         if test -f "$kde_libraries/libjpeg.so"; then
1068            test -f ./libjpegkde.so || $LN_S $kde_libraries/libjpeg.so ./libjpegkde.so
1069            ac_cv_lib_jpeg="-L\${topdir} -ljpegkde"
1070         else if test -f "$kde_libraries/libjpeg.sl"; then
1071            test -f ./libjpegkde.sl ||$LN_S $kde_libraries/libjpeg.sl ./libjpegkde.sl
1072            ac_cv_lib_jpeg="-L\${topdir} -ljpegkde"      
1073         else if test -f "$kde_libraries/libjpeg.a"; then
1074            test -f ./libjpegkde.a || $LN_S $kde_libraries/libjpeg.a ./libjpegkde.a
1075            ac_cv_lib_jpeg="-L\${topdir} -ljpegkde"
1076         else
1077           AC_MSG_ERROR([
1078 You need jpeglib6a. Please install the kdesupport package.
1079 If you have already installed kdesupport, you may have an
1080 old libjpeg somewhere. 
1081 In this case copy $KDEDIR/lib/libjpeg* to /usr/lib.
1082 ])
1083         fi
1084       fi
1085    fi
1086 fi
1087 ])dnl
1088 if eval "test ! \"`echo $ac_cv_lib_jpeg`\" = no"; then
1089   LIBJPEG="$ac_cv_lib_jpeg"
1090   AC_SUBST(LIBJPEG)
1091   AC_MSG_RESULT($ac_cv_lib_jpeg)
1092   AC_DEFINE_UNQUOTED(HAVE_LIBJPEG)
1093 fi
1094 ])
1095
1096 AC_DEFUN(AC_FIND_ZLIB,
1097 [
1098 AC_MSG_CHECKING([for libz])
1099 AC_CACHE_VAL(ac_cv_lib_z,
1100 [ac_save_LIBS="$LIBS"
1101 LIBS="$all_libraries -lz $LIBSOCKET"
1102 AC_TRY_LINK(dnl
1103 [
1104 #include<zlib.h>
1105 ],
1106             [return (zlibVersion() == ZLIB_VERSION); ],
1107             eval "ac_cv_lib_z='-lz'",
1108             eval "ac_cv_lib_z=no")
1109 LIBS="$ac_save_LIBS"
1110 ])dnl
1111 if eval "test ! \"`echo $ac_cv_lib_z`\" = no"; then
1112 dnl  AC_DEFINE_UNQUOTED(HAVE_LIBZ)
1113   LIBZ="$ac_cv_lib_z"
1114   AC_SUBST(LIBZ)
1115   AC_MSG_RESULT($ac_cv_lib_z)
1116 else
1117   AC_MSG_RESULT(no)
1118   LIBZ=""
1119   AC_SUBST(LIBZ)
1120 fi
1121 ])
1122
1123 AC_DEFUN(AC_FIND_TIFF,
1124 [
1125 AC_REQUIRE([AC_FIND_ZLIB])
1126 AC_REQUIRE([AC_FIND_JPEG])
1127 AC_MSG_CHECKING([for libtiff])
1128 AC_CACHE_VAL(ac_cv_lib_tiff,
1129 [ac_save_LIBS="$LIBS"
1130 LIBS="$all_libraries -ltiff $LIBJPEG $LIBZ -lX11 $LIBSOCKET"
1131 AC_TRY_LINK(dnl
1132 [
1133 #include<tiffio.h>
1134 ],
1135             [return (TIFFOpen( "", "r") == 0); ],
1136             eval "ac_cv_lib_tiff='-ltiff $LIBJPEG $LIBZ'",
1137             eval "ac_cv_lib_tiff=no")
1138 LIBS="$ac_save_LIBS"
1139 ])dnl
1140 if eval "test ! \"`echo $ac_cv_lib_tiff`\" = no"; then
1141   AC_DEFINE_UNQUOTED(HAVE_LIBTIFF)
1142   LIBTIFF="$ac_cv_lib_tiff"
1143   AC_SUBST(LIBTIFF)
1144   AC_MSG_RESULT($ac_cv_lib_tiff)
1145 else
1146   AC_MSG_RESULT(no)
1147   LIBTIFF=""
1148   AC_SUBST(LIBTIFF)
1149 fi
1150 ])
1151
1152
1153 AC_DEFUN(AC_FIND_PNG,
1154 [
1155 AC_REQUIRE([AC_FIND_ZLIB])
1156 AC_MSG_CHECKING([for libpng])
1157 AC_CACHE_VAL(ac_cv_lib_png,
1158 [ac_save_LIBS="$LIBS"
1159 LIBS="$all_libraries -lpng $LIBZ -lm -lX11 $LIBSOCKET"
1160 AC_LANG_C
1161 AC_TRY_LINK(dnl
1162     [
1163     #include<png.h>
1164     ],
1165     [
1166     png_structp png_ptr = png_create_read_struct(  // image ptr
1167                 PNG_LIBPNG_VER_STRING, 0, 0, 0 );
1168     return( png_ptr != 0 ); 
1169     ],
1170     eval "ac_cv_lib_png='-lpng $LIBZ -lm'",
1171     eval "ac_cv_lib_png=no")
1172     LIBS="$ac_save_LIBS"
1173 ])dnl
1174 if eval "test ! \"`echo $ac_cv_lib_png`\" = no"; then
1175   AC_DEFINE_UNQUOTED(HAVE_LIBPNG)
1176   LIBPNG="$ac_cv_lib_png"
1177   AC_SUBST(LIBPNG)
1178   AC_MSG_RESULT($ac_cv_lib_png)
1179 else
1180   AC_MSG_RESULT(no)
1181   LIBPNG=""
1182   AC_SUBST(LIBPNG)
1183 fi
1184 ])
1185
1186 AC_DEFUN(AC_CHECK_GNU_EXTENSIONS,
1187 [
1188 AC_MSG_CHECKING(if you need GNU extensions)
1189 AC_CACHE_VAL(ac_cv_gnu_extensions,
1190 [
1191 cat > conftest.c << EOF
1192 #include <features.h>
1193
1194 #ifdef __GNU_LIBRARY__
1195 yes
1196 #endif
1197 EOF
1198
1199 if (eval "$ac_cpp conftest.c") 2>&5 |
1200   egrep "yes" >/dev/null 2>&1; then
1201   rm -rf conftest*
1202   ac_cv_gnu_extensions=yes
1203 else
1204   ac_cv_gnu_extensions=no
1205 fi
1206 ])
1207
1208 AC_MSG_RESULT($ac_cv_gnu_extensions)
1209 if test "$ac_cv_gnu_extensions" = "yes"; then
1210   AC_DEFINE_UNQUOTED(_GNU_SOURCE)
1211 fi
1212 ])
1213
1214 dnl just a wrapper to clean up configure.in
1215 AC_DEFUN(KDE_PROG_LIBTOOL,
1216 [
1217 AC_REQUIRE([AM_ENABLE_SHARED])
1218 AC_REQUIRE([AM_ENABLE_STATIC])
1219 dnl libtool is only for C, so I must force him
1220 dnl to find the correct flags for C++
1221 ac_save_cc=$CC
1222 ac_save_cflags="$CFLAGS"
1223 CC=$CXX
1224 CFLAGS="$CXXFLAGS"
1225 AM_PROG_LIBTOOL dnl for libraries
1226 CC=$ac_save_cc
1227 CFLAGS="$ac_save_cflags"
1228 ])
1229
1230 AC_DEFUN(KDE_DO_IT_ALL,
1231 [
1232 AC_PREFIX_DEFAULT(${KDEDIR:-/usr/local/kde})
1233 KDE_PROG_LIBTOOL
1234 AC_PATH_KDE
1235 AC_PATH_PROG(QTARCH, "qtarch",qtarch-notinstalled)
1236 ])
1237
1238 AC_DEFUN(AC_CHECK_RPATH,
1239 [
1240 AC_MSG_CHECKING(for rpath)
1241 AC_ARG_ENABLE(rpath,
1242       [  --disable-rpath         do not use the rpath feature of ld],
1243       USE_RPATH=$enableval, USE_RPATH=yes)
1244 if test -z "$KDE_RPATH" && test "$USE_RPATH" = "yes"; then
1245
1246   KDE_RPATH="-rpath \$(kde_libraries)"
1247
1248   if test -n "$qt_libraries"; then
1249     KDE_RPATH="$KDE_RPATH -rpath \$(qt_libraries)"
1250   fi
1251   dnl $x_libraries is set to /usr/lib in case
1252   if test -n "$X_LDFLAGS"; then 
1253     KDE_RPATH="$KDE_RPATH -rpath \$(x_libraries)"
1254   fi
1255   if test -n "$KDE_EXTRA_RPATH"; then
1256     KDE_RPATH="$KDE_RPATH \$(KDE_EXTRA_RPATH)"
1257   fi
1258 fi 
1259 AC_SUBST(KDE_EXTRA_RPATH)
1260 AC_SUBST(KDE_RPATH)
1261 AC_MSG_RESULT($USE_RPATH)
1262 ])
1263
1264 # Search path for a program which passes the given test.
1265 # Ulrich Drepper <drepper@cygnus.com>, 1996.
1266
1267 # serial 1
1268 # Stephan Kulow: I appended a _KDE against name conflicts
1269
1270 dnl AM_PATH_PROG_WITH_TEST_KDE(VARIABLE, PROG-TO-CHECK-FOR,
1271 dnl   TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
1272 AC_DEFUN(AM_PATH_PROG_WITH_TEST_KDE,
1273 [# Extract the first word of "$2", so it can be a program name with args.
1274 set dummy $2; ac_word=[$]2
1275 AC_MSG_CHECKING([for $ac_word])
1276 AC_CACHE_VAL(ac_cv_path_$1,
1277 [case "[$]$1" in
1278   /*)
1279   ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
1280   ;;
1281   *)
1282   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
1283   for ac_dir in ifelse([$5], , $PATH, [$5]); do
1284     test -z "$ac_dir" && ac_dir=.
1285     if test -f $ac_dir/$ac_word; then
1286       if [$3]; then
1287         ac_cv_path_$1="$ac_dir/$ac_word"
1288         break
1289       fi
1290     fi
1291   done
1292   IFS="$ac_save_ifs"
1293 dnl If no 4th arg is given, leave the cache variable unset,
1294 dnl so AC_PATH_PROGS will keep looking.
1295 ifelse([$4], , , [  test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
1296 ])dnl
1297   ;;
1298 esac])dnl
1299 $1="$ac_cv_path_$1"
1300 if test -n "[$]$1"; then
1301   AC_MSG_RESULT([$]$1)
1302 else
1303   AC_MSG_RESULT(no)
1304 fi
1305 AC_SUBST($1)dnl
1306 ])
1307
1308
1309 dnl From Jim Meyering.
1310 dnl FIXME: migrate into libit.
1311
1312 AC_DEFUN(AM_FUNC_OBSTACK,
1313 [AC_CACHE_CHECK([for obstacks], am_cv_func_obstack,
1314  [AC_TRY_LINK([#include "obstack.h"],
1315               [struct obstack *mem;obstack_free(mem,(char *) 0)],
1316               am_cv_func_obstack=yes,
1317               am_cv_func_obstack=no)])
1318  if test $am_cv_func_obstack = yes; then
1319    AC_DEFINE(HAVE_OBSTACK)
1320  else
1321    LIBOBJS="$LIBOBJS obstack.o"
1322  fi
1323 ])
1324
1325 dnl From Jim Meyering.  Use this if you use the GNU error.[ch].
1326 dnl FIXME: Migrate into libit
1327
1328 AC_DEFUN(AM_FUNC_ERROR_AT_LINE,
1329 [AC_CACHE_CHECK([for error_at_line], am_cv_lib_error_at_line,
1330  [AC_TRY_LINK([],[error_at_line(0, 0, "", 0, "");],
1331               am_cv_lib_error_at_line=yes,
1332               am_cv_lib_error_at_line=no)])
1333  if test $am_cv_lib_error_at_line = no; then
1334    LIBOBJS="$LIBOBJS error.o"
1335  fi
1336  AC_SUBST(LIBOBJS)dnl
1337 ])
1338
1339 # Macro to add for using GNU gettext.
1340 # Ulrich Drepper <drepper@cygnus.com>, 1995.
1341
1342 # serial 1
1343 # Stephan Kulow: I put a KDE in it to avoid name conflicts
1344
1345 AC_DEFUN(AM_KDE_GNU_GETTEXT,
1346   [AC_REQUIRE([AC_PROG_MAKE_SET])dnl
1347    AC_REQUIRE([AC_PROG_RANLIB])dnl
1348    AC_REQUIRE([AC_HEADER_STDC])dnl
1349    AC_REQUIRE([AC_C_INLINE])dnl
1350    AC_REQUIRE([AC_TYPE_OFF_T])dnl
1351    AC_REQUIRE([AC_TYPE_SIZE_T])dnl
1352    AC_REQUIRE([AC_FUNC_ALLOCA])dnl
1353    AC_REQUIRE([AC_FUNC_MMAP])dnl
1354    AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h string.h \
1355 unistd.h values.h alloca.h])
1356    AC_CHECK_FUNCS([getcwd munmap putenv setenv setlocale strchr strcasecmp \
1357 __argz_count __argz_stringify __argz_next stpcpy])
1358
1359    AM_LC_MESSAGES
1360
1361    if test "x$CATOBJEXT" != "x"; then
1362      if test "x$ALL_LINGUAS" = "x"; then
1363        LINGUAS=
1364      else
1365        AC_MSG_CHECKING(for catalogs to be installed)
1366        NEW_LINGUAS=
1367        for lang in ${LINGUAS=$ALL_LINGUAS}; do
1368          case "$ALL_LINGUAS" in
1369           *$lang*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;;
1370          esac
1371        done
1372        LINGUAS=$NEW_LINGUAS
1373        AC_MSG_RESULT($LINGUAS)
1374      fi
1375
1376      dnl Construct list of names of catalog files to be constructed.
1377      if test -n "$LINGUAS"; then
1378        for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
1379      fi
1380    fi
1381
1382   ])
1383
1384 AC_DEFUN(AC_HAVE_XPM,
1385  [AC_REQUIRE_CPP()dnl
1386
1387  test -z "$XPM_LDFLAGS" && XPM_LDFLAGS=
1388  test -z "$XPM_INCLUDE" && XPM_INCLUDE=
1389
1390  AC_ARG_WITH(xpm, [  --without-xpm           disable color pixmap XPM tests],
1391         xpm_test=$withval, xpm_test="yes")
1392  if test "x$xpm_test" = xno; then
1393    ac_cv_have_xpm=no
1394  else
1395    AC_MSG_CHECKING(for XPM)
1396    AC_CACHE_VAL(ac_cv_have_xpm,
1397    [
1398     AC_LANG_C
1399     ac_save_ldflags="$LDFLAGS"
1400     ac_save_cflags="$CFLAGS"
1401     LDFLAGS="$LDFLAGS $XPM_LDFLAGS $all_libraries -lXpm -lX11 -lXext $LIBSOCKET"
1402     CFLAGS="$CFLAGS $X_INCLUDES"
1403     test ! -z "$XPM_INCLUDE" && CFLAGS="-I$XPM_INCLUDE $CFLAGS"
1404     AC_TRY_LINK([#include <X11/xpm.h>],[],
1405         ac_cv_have_xpm="yes",ac_cv_have_xpm="no")
1406     LDFLAGS="$ac_save_ldflags"
1407     CFLAGS="$ac_save_cflags"
1408    ])dnl
1409  
1410   if test "$ac_cv_have_xpm" = no; then
1411     AC_MSG_RESULT(no)
1412     XPM_LDFLAGS=""
1413     XPMINC=""
1414     $2
1415   else
1416     AC_DEFINE(HAVE_XPM)
1417     if test "$XPM_LDFLAGS" = ""; then
1418        XPMLIB="-lXpm"
1419     else
1420        XPMLIB="-L$XPM_LDFLAGS -lXpm"
1421     fi
1422     if test "$XPM_INCLUDE" = ""; then
1423        XPMINC=""
1424     else
1425        XPMINC="-I$XPM_INCLUDE"
1426     fi
1427     AC_MSG_RESULT(yes)
1428     $1
1429   fi
1430  fi
1431  AC_SUBST(XPMINC)
1432  AC_SUBST(XPMLIB)
1433 ]) 
1434
1435 AC_DEFUN(AC_HAVE_GL,
1436  [AC_REQUIRE_CPP()dnl
1437
1438  test -z "$GL_LDFLAGS" && GL_LDFLAGS=
1439  test -z "$GL_INCLUDE" && GL_INCLUDE=
1440
1441  AC_ARG_WITH(gl, [  --without-gl            disable 3D GL modes],
1442         gl_test=$withval, gl_test="yes")
1443  if test "x$gl_test" = xno; then
1444    ac_cv_have_gl=no
1445  else
1446    AC_MSG_CHECKING(for GL)
1447    AC_CACHE_VAL(ac_cv_have_gl,
1448    [
1449     AC_LANG_C
1450     ac_save_ldflags="$LDFLAGS"
1451     ac_save_cflags="$CFLAGS"
1452     LDFLAGS="$LDFLAGS $GL_LDFLAGS $all_libraries -lMesaGL -lMesaGLU -lX11 -lXext -lm $LIBSOCKET"
1453     CFLAGS="$CFLAGS $X_INCLUDES"
1454     test ! -z "$GL_INCLUDE" && CFLAGS="-I$GL_INCLUDE $CFLAGS"
1455     AC_TRY_LINK([],[],
1456         ac_cv_have_gl="yes",ac_cv_have_gl="no")
1457     LDFLAGS="$ac_save_ldflags"
1458     CFLAGS="$ac_save_cflags"
1459    ])dnl
1460  
1461   if test "$ac_cv_have_gl" = no; then
1462     AC_MSG_RESULT(no)
1463     GL_LDFLAGS=""
1464     GLINC=""
1465     $2
1466   else
1467     AC_DEFINE(HAVE_GL)
1468     if test "$GL_LDFLAGS" = ""; then
1469        GLLIB="-lMesaGL -lMesaGLU"
1470     else
1471        GLLIB="-L$GL_LDFLAGS -lMesaGL -lMesaGLU"
1472     fi
1473     if test "$GL_INCLUDE" = ""; then
1474        GLINC=""
1475     else
1476        GLINC="-I$GL_INCLUDE"
1477     fi
1478     AC_MSG_RESULT(yes)
1479     $1
1480   fi
1481  fi
1482  AC_SUBST(GLINC)
1483  AC_SUBST(GLLIB)
1484 ]) 
1485
1486  dnl PAM pam
1487  
1488  dnl Should test for PAM (Pluggable Authentication Modules)
1489  AC_DEFUN(AC_PATH_PAM_DIRECT,
1490  [
1491  test -z "$pam_direct_test_library" && pam_direct_test_library=pam
1492  test -z "$pam_direct_test_include" && pam_direct_test_include=security/pam_appl.h
1493  
1494    for ac_dir in               \
1495                                \
1496      /usr/local/include        \
1497      /usr/include              \
1498      /usr/unsupported/include  \
1499      /opt/include              \
1500      /usr/pam/include          \
1501      /usr/local/pam/include    \
1502      /usr/lib/pam/include      \
1503                               \
1504      $extra_include            \
1505      ; \
1506    do
1507      if test -r "$ac_dir/$pam_direct_test_include"; then
1508        no_pam= ac_pam_includes=$ac_dir
1509        break
1510      fi
1511    done
1512  
1513  # First see if replacing the include by lib works.
1514  for ac_dir in `echo "$ac_pam_includes" | sed s/include/lib/` \
1515                            \
1516      /lib                  \
1517      /usr/lib              \
1518      /usr/local/lib        \
1519      /usr/unsupported/lib  \
1520      /lib/security         \
1521      /usr/security/lib     \
1522      $extra_lib            \
1523      ; \
1524  do
1525    for ac_extension in a so sl; do
1526      if test -r $ac_dir/lib${pam_direct_test_library}.$ac_extension; then
1527        no_pam= ac_pam_libraries=$ac_dir
1528        break 2
1529      fi
1530    done
1531  done
1532 ])
1533
1534 AC_DEFUN(AC_PATH_PAM,
1535  [AC_REQUIRE_CPP()dnl
1536
1537   AC_CHECK_LIB(pam_misc, main, [PAM_MISC_LIB="-lpam_misc"], [], [-lpam -ldl])
1538
1539  AC_MSG_CHECKING(for PAM)
1540  AC_ARG_WITH(pam, 
1541 [  --with-pam[=ARG]        enable support for PAM: ARG=[yes|no|service name]],
1542   [
1543     if test "x$withval" = "xyes"; then
1544       no_pam=
1545       default_pam=yes
1546     elif test "x$withval" = "xno"; then
1547       no_pam=yes
1548     else
1549       no_pam=
1550       pam_service="$withval"
1551         if test -z "$pam_service"; then
1552         default_pam=yes
1553         else
1554         default_pam=
1555         fi 
1556       fi
1557   ], no_pam=yes
1558  )
1559
1560  if test ! "$no_pam" = yes; then
1561
1562  AC_CACHE_VAL(ac_cv_path_pam,
1563  [
1564  ac_pam_includes=NONE
1565  ac_pam_libraries=NONE
1566  if test -z "$pam_libraries"; then
1567    pam_libraries=NONE
1568  fi
1569  if test -z "$pam_includes"; then
1570    pam_includes=NONE
1571  fi
1572
1573  AC_PATH_PAM_DIRECT
1574  
1575  test "x$pam_includes" = xNONE && pam_includes=$ac_pam_includes
1576  test "x$pam_libraries" = xNONE && pam_libraries=$ac_pam_libraries
1577  
1578  if test ! "x$pam_includes" = xNONE && test ! "x$pam_libraries" = xNONE; then
1579    ac_pam_libs="-lpam $PAM_MISC_LIB -ldl"
1580    ac_cv_path_pam="no_pam= ac_pam_includes=$ac_pam_includes ac_pam_libraries=$ac_pam_libraries ac_pam_libs=\"$ac_pam_libs\""
1581  else
1582    ac_cv_path_pam="no_pam=yes"
1583  fi
1584  ])
1585
1586  eval "$ac_cv_path_pam"
1587  
1588  fi
1589
1590  if test "$no_pam" = yes; then
1591    AC_MSG_RESULT(no)
1592  else
1593    AC_DEFINE(HAVE_PAM)
1594    PAMLIBS="$ac_pam_libs"
1595    test "x$pam_includes" = xNONE && pam_includes=$ac_pam_includes
1596    test "x$pam_libraries" = xNONE && pam_libraries=$ac_pam_libraries
1597    AC_MSG_RESULT([libraries $pam_libraries, headers $pam_includes])
1598  if test "$default_pam" = yes; then
1599    AC_MSG_RESULT(["default pam service name will be used"])
1600  else
1601    AC_DEFINE_UNQUOTED(KDE_PAM_SERVICE,"$pam_service")
1602    AC_MSG_RESULT(["pam service name will be: " $pam_service])
1603  fi
1604 dnl test whether struct pam_message is const (Linux) or not (Sun)
1605    pam_appl_h="$ac_pam_includes/security/pam_appl.h"
1606    AC_MSG_CHECKING(for const pam_message)
1607    AC_EGREP_HEADER([struct pam_message],
1608       $pam_appl_h,
1609       [ AC_EGREP_HEADER([const struct pam_message],
1610                         $pam_appl_h,
1611                         [AC_MSG_RESULT(["const: Linux-type PAM"]) ],
1612                         [AC_MSG_RESULT(["nonconst: Sun-type PAM"])
1613                         AC_DEFINE(PAM_MESSAGE_NONCONST)] 
1614                         )],
1615        [AC_MSG_RESULT(["not found - assume const, Linux-type PAM"])]
1616        )
1617  fi
1618  
1619  if test "x$pam_libraries" != x && test "x$pam_libraries" != xNONE ; then
1620      PAMLIBPATHS="-L$pam_libraries"
1621  fi
1622  if test "x$pam_includes" != x && test "x$pam_includes" != xNONE ; then
1623      PAMINC="-I$pam_includes"
1624  fi
1625  
1626  AC_SUBST(PAMINC)
1627  AC_SUBST(PAMLIBS)
1628  AC_SUBST(PAMLIBPATHS)
1629
1630 ]) 
1631
1632 AC_DEFUN(KDE_CHECK_LIBDL,
1633 [
1634 AC_CHECK_LIB(dl, dlopen, [
1635 LIBDL="-ldl"
1636 ac_cv_have_dlfcn=yes
1637 ])
1638
1639 AC_CHECK_LIB(dld, shl_unload, [
1640 LIBDL="-ldld"
1641 ac_cv_have_shload=yes
1642 ])
1643
1644 AC_SUBST(LIBDL)
1645 ])
1646
1647 AC_DEFUN(KDE_CHECK_DLOPEN,
1648 [
1649 KDE_CHECK_LIBDL
1650 AC_CHECK_HEADERS(dlfcn.h dl.h)
1651 if test "$ac_cv_header_dlfcn_h" = "no"; then
1652   ac_cv_have_dlfcn=no
1653 fi
1654
1655 if test "$ac_cv_header_dl_h" = "no"; then
1656   ac_cv_have_shload=no
1657 fi
1658
1659 enable_dlopen=no
1660 AC_ARG_ENABLE(dlopen,
1661 [  --disable-dlopen        link staticly [default=no]] ,
1662 [if test "$enableval" = yes; then
1663   enable_dlopen=yes
1664 fi],
1665 enable_dlopen=yes)
1666
1667 # override the user's opinion, if we know it better ;)
1668 if test "$ac_cv_have_dlfcn" = "no" && test "$ac_cv_have_shload" = "no"; then
1669   enable_dlopen=no
1670 fi
1671
1672 if test "$ac_cv_have_dlfcn" = "yes"; then
1673   AC_DEFINE_UNQUOTED(HAVE_DLFCN)
1674 fi
1675
1676 if test "$ac_cv_have_shload" = "yes"; then
1677   AC_DEFINE_UNQUOTED(HAVE_SHLOAD)
1678 fi
1679
1680 if test "$enable_dlopen" = no ; then
1681   test -n "$1" && eval $1
1682 else
1683   test -n "$2" && eval $2
1684 fi
1685
1686 ])
1687
1688 AC_DEFUN(KDE_CHECK_DYNAMIC_LOADING,
1689 [
1690 KDE_CHECK_DLOPEN(libtool_enable_shared=no, libtool_enable_static=no)
1691 KDE_PROG_LIBTOOL
1692 AC_MSG_CHECKING([dynamic loading])
1693 eval "`egrep '^build_libtool_libs=' libtool`"
1694 if test "$build_libtool_libs" = "yes" && test "$enable_dlopen" = "yes"; then
1695   dynamic_loading=yes
1696   AC_DEFINE_UNQUOTED(HAVE_DYNAMIC_LOADING)
1697 else
1698   dynamic_loading=no
1699 fi
1700 AC_MSG_RESULT($dynamic_loading)
1701 if test "$dynamic_loading" = "yes"; then
1702   $1
1703 else
1704   $2
1705 fi
1706 ])
1707
1708 AC_DEFUN(KDE_ADD_INCLUDES,
1709 [
1710 if test -z "$1"; then 
1711   test_include="Pix.h"
1712 else
1713   test_include="$1"
1714 fi
1715
1716 AC_MSG_CHECKING([for libg++ ($test_include)])
1717
1718 AC_CACHE_VAL(kde_cv_libgpp_includes,
1719 [
1720 kde_cv_libgpp_includes=no
1721
1722    for ac_dir in               \
1723                                \
1724      /usr/include/g++          \
1725      /usr/include              \
1726      /usr/unsupported/include  \
1727      /opt/include              \
1728      $extra_include            \
1729      ; \
1730    do
1731      if test -r "$ac_dir/$test_include"; then
1732        kde_cv_libgpp_includes=$ac_dir
1733        break
1734      fi
1735    done
1736 ])
1737
1738 AC_MSG_RESULT($kde_cv_libgpp_includes)
1739 if test "$kde_cv_libgpp_includes" != "no"; then
1740   all_includes="-I$kde_cv_libgpp_includes $all_includes"
1741 fi
1742 ])
1743 ])
1744
1745
1746 AC_DEFUN(KDE_CHECK_MICO,
1747 [
1748 AC_REQUIRE([KDE_CHECK_LIBDL])
1749 AC_MSG_CHECKING(for MICO)
1750 AC_ARG_WITH(micodir,
1751   [  --with-micodir=micodir  where mico is installed ],
1752   kde_micodir=$withval,
1753   kde_micodir=/usr/local
1754 )
1755 AC_MSG_RESULT($kde_micodir)
1756 if test ! -r  $kde_micodir/include/CORBA.h; then
1757   AC_MSG_ERROR([No CORBA.h found, specify another micodir])
1758 fi
1759
1760 MICO_INCLUDES=-I$kde_micodir/include
1761 AC_SUBST(MICO_INCLUDES)
1762 MICO_LDFLAGS=-L$kde_micodir/lib
1763 AC_SUBST(MICO_LDFLAGS)
1764
1765 AC_MSG_CHECKING([for MICO version])
1766 AC_CACHE_VAL(kde_cv_mico_version,
1767 [
1768 AC_LANG_C
1769 cat >conftest.$ac_ext <<EOF
1770 #include <stdio.h>
1771 #include <mico/version.h>
1772 int main() { 
1773     
1774    printf("MICO_VERSION=%s\n",MICO_VERSION); 
1775    return (0); 
1776 }
1777 EOF
1778 ac_compile='${CC-gcc} $CFLAGS $MICO_INCLUDES conftest.$ac_ext -o conftest'
1779 if AC_TRY_EVAL(ac_compile); then
1780   if eval `./conftest 2>&5`; then
1781     kde_cv_mico_version=$MICO_VERSION
1782   else
1783     AC_MSG_ERROR([your system is not able to execute a small application to
1784     find MICO version! Check $kde_micodir/include/mico/version.h])
1785   fi 
1786 else
1787   AC_MSG_ERROR([your system is not able to compile a small application to
1788   find MICO version! Check $kde_micodir/include/mico/version.h])
1789 fi
1790 ])
1791
1792 dnl installed MICO version
1793 mico_v_maj=`echo $kde_cv_mico_version | sed -e 's/^\(.*\)\..*\..*$/\1/'`
1794 mico_v_mid=`echo $kde_cv_mico_version | sed -e 's/^.*\.\(.*\)\..*$/\1/'`
1795 mico_v_min=`echo $kde_cv_mico_version | sed -e 's/^.*\..*\.\(.*\)$/\1/'`
1796
1797 dnl required MICO version
1798 req_v_maj=`echo $1 | sed -e 's/^\(.*\)\..*\..*$/\1/'`
1799 req_v_mid=`echo $1 | sed -e 's/^.*\.\(.*\)\..*$/\1/'`
1800 req_v_min=`echo $1 | sed -e 's/^.*\..*\.\(.*\)$/\1/'` 
1801
1802 if test "$mico_v_maj" -lt "$req_v_maj" || \
1803    ( test "$mico_v_maj" -eq "$req_v_maj" && \
1804         test "$mico_v_mid" -lt "$req_v_mid" ) || \
1805    ( test "$mico_v_mid" -eq "$req_v_mid" && \
1806         test "$mico_v_min" -lt "$req_v_min" )
1807
1808 then
1809   AC_MSG_ERROR([found MICO version $kde_cv_mico_version but version $1 \
1810 at least is required. You should upgrade MICO.])
1811 else
1812   AC_MSG_RESULT([$kde_cv_mico_version (minimum version $1, ok)])
1813 fi
1814
1815 LIBMICO="-lmico$kde_cv_mico_version $LIBDL"
1816 AC_SUBST(LIBMICO)
1817 IDL=$kde_micodir/bin/idl
1818 AC_SUBST(IDL)
1819 ])
1820
1821
1822 AC_DEFUN(KDE_CHECK_MINI_STL,
1823 [
1824 AC_REQUIRE([KDE_CHECK_MICO])
1825
1826 AC_MSG_CHECKING(if we use mico's mini-STL)
1827 AC_CACHE_VAL(kde_cv_have_mini_stl,
1828 [
1829 AC_LANG_CPLUSPLUS
1830 kde_save_cxxflags="$CXXFLAGS"
1831 CXXFLAGS="$CXXFLAGS $MICO_INCLUDES"
1832 AC_TRY_COMPILE(
1833 [
1834 #include <mico/config.h>
1835 ],
1836 [
1837 #ifdef HAVE_MINI_STL
1838 #error "nothing"
1839 #endif
1840 ],
1841 kde_cv_have_mini_stl=no,
1842 kde_cv_have_mini_stl=yes)
1843 CXXFLAGS="$kde_save_cxxflags"
1844 ])
1845
1846
1847 AC_MSG_RESULT($kde_cv_have_mini_stl)
1848 if test "$kde_cv_have_mini_stl" = "yes"; then
1849   AC_DEFINE_UNQUOTED(HAVE_MINI_STL)
1850 fi
1851 ])
1852
1853 ])
1854
1855
1856 AC_DEFUN(KDE_CHECK_LIBPTHREAD,
1857 [
1858 AC_CHECK_LIB(pthread, pthread_create, [LIBPTHREAD="-lpthread"], LIBPTHREAD= )
1859 AC_SUBST(LIBPTHREAD)
1860 ])
1861
1862 AC_DEFUN(KDE_TRY_LINK_PYTHON,
1863 [
1864 AC_CACHE_VAL(kde_cv_try_link_python_$1,
1865 [
1866 kde_save_cxxflags="$CXXFLAGS"
1867 CXXFLAGS="$CXXFLAGS $PYTHONINC"
1868 kde_save_libs="$LIBS"
1869 LIBS="$LIBS $LIBPYTHON $2 $LIBDL $LIBSOCKET"
1870 kde_save_ldflags="$LDFLAGS"
1871 LDFLAGS="$LDFLAGS $PYTHONLIB"
1872
1873 AC_TRY_LINK(
1874 [
1875 #include <Python.h>
1876 ],[
1877         PySys_SetArgv(1, 0);
1878 ],
1879         [kde_cv_try_link_python_$1=yes],
1880         [kde_cv_try_link_python_$1=no]
1881 )
1882 CXXFLAGS="$kde_save_cxxflags"
1883 LIBS="$kde_save_libs"
1884 LDFLAGS="$kde_save_ldflags"
1885 ])
1886
1887 if test "$kde_cv_try_link_python_$1" = "yes"; then
1888   $3
1889 else
1890   $4
1891 fi
1892
1893 ])
1894
1895 AC_DEFUN(KDE_CHECK_PYTHON,
1896 [
1897 AC_REQUIRE([KDE_CHECK_LIBDL])
1898 AC_REQUIRE([KDE_CHECK_LIBPTHREAD])
1899 if test -z "$1"; then 
1900   version="1.5"
1901 else
1902   version="$1"
1903 fi
1904
1905 AC_MSG_CHECKING([for Python$version])
1906
1907 AC_ARG_WITH(pythondir, 
1908 [  --with-pythondir=pythondir   use python installed in pythondir ],
1909 [
1910   ac_python_dir=$withval
1911 ], ac_python_dir=/usr/local
1912 )
1913
1914 python_incdirs="$ac_python_dir/include/python$version /usr/include/python$version /usr/local/include/python$version /usr/local/include"
1915 AC_FIND_FILE(Python.h, $python_incdirs, python_incdir)
1916 if test ! -r $python_incdir/Python.h; then
1917   AC_MSG_ERROR(Python.h not found.)
1918 fi
1919
1920 PYTHONINC=-I$python_incdir
1921
1922 python_libdirs="$ac_python_dir/lib/python$version/config /usr/lib/python$version/config /usr/local/python$version/config"
1923 AC_FIND_FILE(libpython$version.a, $python_libdirs, python_libdir)
1924 if test ! -r $python_libdir/libpython$version.a; then
1925   AC_MSG_ERROR(libpython$version.a not found.)
1926 fi
1927
1928 PYTHONLIB=-L$python_libdir
1929 LIBPYTHON=-lpython$version
1930
1931 AC_MSG_RESULT(header $python_incdir library $python_libdir)
1932
1933 dnl Note: this test is very weak
1934 AC_MSG_CHECKING(if an Python application links)
1935 KDE_TRY_LINK_PYTHON(normal, "", AC_MSG_RESULT(yes),
1936  [
1937     AC_MSG_RESULT(no)
1938     AC_MSG_CHECKING(if Python depends on -lpthread)
1939     KDE_TRY_LINK_PYTHON(pthread, "$LIBPTHREAD",
1940     [  
1941        AC_MSG_RESULT(yes)
1942        LIBPYTHON="$LIBPYTHON $LIBPTHREAD $LIBDL"
1943     ],
1944     [
1945        AC_MSG_RESULT(no)
1946        AC_MSG_CHECKING(if Python depeds on -ltcl)
1947        KDE_TRY_LINK_PYTHON(tcl, "-ltcl",
1948        [
1949           AC_MSG_RESULT(yes)
1950           LIBPYTHON="$LIBPYTHON -ltcl"
1951        ],
1952        [
1953           AC_MSG_RESULT(no)
1954         AC_MSG_WARN([it seems, Python depends on another library. 
1955     Pleae use \"make LIBPTYHON='-lpython$version -lotherlib'\" to fix this
1956     and contact the authors to let them know about this problem])
1957         ])
1958     ])
1959  ]) 
1960
1961 AC_SUBST(PYTHONINC)
1962 AC_SUBST(PYTHONLIB)
1963 AC_SUBST(LIBPYTHON)
1964
1965 ])
1966
1967
1968 AC_DEFUN(KDE_CHECK_STL_SGI,
1969 [
1970     AC_MSG_CHECKING([if STL implementation is SGI like])
1971     AC_CACHE_VAL(kde_cv_stl_type_sgi,
1972     [
1973       AC_TRY_COMPILE([
1974 #include <string>
1975 ],[
1976   string astring="Hallo Welt.";
1977   astring.erase(0, 6); // now astring is "Welt"
1978   return 0;
1979 ], kde_cv_stl_type_sgi=yes,
1980    kde_cv_stl_type_sgi=no)
1981 ])
1982
1983    AC_MSG_RESULT($kde_cv_stl_type_sgi)
1984
1985    if test "$kde_cv_stl_type_sgi" = "yes"; then
1986         AC_DEFINE_UNQUOTED(HAVE_SGI_STL) 
1987    fi
1988 ])
1989
1990 AC_DEFUN(KDE_CHECK_STL_HP,
1991 [
1992     AC_MSG_CHECKING([if STL implementation is HP like])
1993     AC_CACHE_VAL(kde_cv_stl_type_hp,
1994     [
1995       AC_TRY_COMPILE([
1996 #include <string>
1997 ],[
1998   string astring="Hello World";
1999   astring.remove(0, 6); // now astring is "World"
2000   return 0;
2001 ], kde_cv_stl_type_hp=yes,
2002    kde_cv_stl_type_hp=no)
2003 ])
2004    AC_MSG_RESULT($kde_cv_stl_type_hp)
2005
2006    if test "$kde_cv_stl_type_hp" = "yes"; then
2007         AC_DEFINE_UNQUOTED(HAVE_HP_STL) 
2008    fi
2009 ])
2010
2011 AC_DEFUN(KDE_CHECK_STL,
2012 [
2013     KDE_CHECK_STL_SGI
2014     
2015     if test "$kde_cv_stl_type_sgi" = "no"; then
2016        KDE_CHECK_STL_HP
2017
2018        if test "$kde_cv_stl_type_hp" = "no"; then
2019          AC_MSG_ERROR("no known STL type found")
2020        fi
2021     fi
2022
2023 ])
2024
2025 AC_DEFUN(AC_FIND_QIMGIO,
2026    [AC_REQUIRE([AC_FIND_JPEG])
2027 AC_MSG_CHECKING([for qimgio])
2028 AC_CACHE_VAL(ac_cv_lib_qimgio,
2029 [ac_save_LIBS="$LIBS"
2030 LIBS="$all_libraries -lqimgio -lpng -lz -lqt $LIBJPEG -lX11 $LIBSOCKET"
2031 AC_TRY_LINK(dnl
2032 [
2033 void qInitImageIO ();
2034 ],
2035             [qInitImageIO();],
2036             eval "ac_cv_lib_qimgio=yes",
2037             eval "ac_cv_lib_qimgio=no")
2038 LIBS="$ac_save_LIBS"
2039 ])dnl
2040 if eval "test \"`echo $ac_cv_lib_qimgio`\" = yes"; then
2041   LIBQIMGIO="-lqimgio -lpng -lz $LIBJPEG"
2042   AC_MSG_RESULT(yes)
2043   AC_DEFINE_UNQUOTED(HAVE_QIMGIO)
2044   AC_SUBST(LIBQIMGIO)
2045 else
2046   AC_MSG_RESULT(not found)
2047 fi
2048 ])
2049
2050 AC_DEFUN(KDE_CHECK_ANSI,
2051 [
2052 AC_MSG_CHECKING([for strdup])
2053
2054     AC_CACHE_VAL(kde_cv_stl_type_sgi,
2055     [
2056 AC_LANG_CPLUSPLUS
2057 save_CXXFLAGS="$CXXFLAGS"
2058 if test "$GCC" = "yes"; then
2059   CXXFLAGS="$CXXFLAGS -pedantic-errors"
2060 fi
2061
2062 AC_TRY_COMPILE([
2063 #include <string.h>
2064 ],[
2065   char buffer[] = "Hallo";
2066   strdup(buffer)
2067 ], kde_cv_has_strdup=yes,
2068    kde_cv_has_strdup=no)
2069 CXXFLAGS="$save_CXXFLAGS"
2070 ])
2071 AC_MSG_RESULT($kde_cv_has_strdup)
2072
2073 if test "$kde_cv_has_strdup" = "yes"; then
2074   AC_DEFINE_UNQUOTED(HAVE_STRDUP)
2075 fi
2076
2077 ])
2078
2079 AC_DEFUN(KDE_CHECK_INSURE,
2080 [
2081   AC_ARG_ENABLE(insure, [  --enable-insure             use insure++ for debugging [default=no]],
2082   [
2083   if test $enableval = "no"; dnl
2084         then ac_use_insure="no"
2085         else ac_use_insure="yes"
2086    fi
2087   ], [ac_use_insure="no"])
2088
2089   AC_MSG_CHECKING(if we will use Insure++ to debug)
2090   AC_MSG_RESULT($ac_use_insure)
2091   if test "$ac_use_insure" = "yes"; dnl
2092        then CC="insure"; CXX="insure"; dnl CFLAGS="$CLAGS -fno-rtti -fno-exceptions "????
2093    fi
2094 ])          
2095
2096 dnl this is for kdm:
2097
2098 AC_DEFUN(AC_CHECK_KDM,
2099 [
2100 AC_CHECK_FUNCS(getsecretkey)
2101 dnl checks for X server
2102
2103 AC_PATH_PROG(X_SERVER, X)
2104 if test ! -z "$X_SERVER"; then
2105 X_SERVER=`echo $X_SERVER | sed -e 's+/X$++'`
2106 AC_DEFINE_UNQUOTED(XBINDIR,$X_SERVER)
2107 XBINDIR=$X_SERVER
2108 AC_SUBST(XBINDIR)
2109 fi
2110
2111 dnl This one tries to find XDMDIR for config files
2112 AC_ARG_WITH(xdmdir,
2113         [  --with-xdmdir                  If the xdm config dir can't be found automaticly],
2114         [ ac_xdmdir=$withval],
2115         [ ac_xdmdir="no"])
2116
2117 AC_MSG_CHECKING([for xdm configuration dir])
2118 if test "$ac_xdmdir" = "no"; then
2119     rm -fr conftestdir
2120     if mkdir conftestdir; then
2121         cd conftestdir
2122     cat > Imakefile <<'EOF'
2123 acfindxdm:
2124         @echo 'ac_xdmdir="$(XDMDIR)";'
2125 EOF
2126         if (xmkmf) > /dev/null 2> /dev/null && test -f Makefile; then
2127             eval `${MAKE-make} acfindxdm 2>/dev/null 2>/dev/null | grep -v make`
2128         fi
2129         cd ..
2130         rm -fr conftestdir
2131         dnl Check if Imake was right
2132         if test -f $ac_xdmdir/xdm-config; then
2133             AC_MSG_RESULT($ac_xdmdir)
2134         else
2135             dnl Here we must do something else
2136             dnl Maybe look for xdm-config in standard places, and
2137             dnl if that fails use a fresh copy in $KDEDIR/config/kdm/
2138             AC_FIND_FILE(xdm-config,/etc/X11/xdm /var/X11/xdm /usr/openwin/xdm /usr/X11R6/lib/X11/xdm,ac_xdmdir)
2139             if test -f $ac_xdmdir/xdm-config; then
2140                 AC_MSG_RESULT($ac_xdmdir)
2141             else                                 
2142                 if test "${prefix}" = NONE; then
2143                         ac_xdmdir=$ac_default_prefix/config/kdm
2144                 else
2145                         ac_xdmdir=$prefix/config/kdm
2146                 fi
2147                 AC_MSG_RESULT([xdm config dir not found, installing defaults in $ac_xdmdir])
2148                 xdmconfigsubdir=xdmconfig
2149                 AC_SUBST(xdmconfigsubdir)
2150             fi
2151         fi
2152     fi
2153 else
2154     if test -f $ac_xdmdir/xdm-config; then
2155         AC_MSG_RESULT($ac_xdmdir)
2156     else
2157
2158         AC_MSG_RESULT([xdm config dir not found, installing defaults in $ac_xdmdir])
2159         xdmconfigsubdir=xdmconfig
2160         AC_SUBST(xdmconfigsubdir)
2161     fi
2162 fi
2163 AC_DEFINE_UNQUOTED(XDMDIR,"$ac_xdmdir")
2164 AC_SUBST(ac_xdmdir)
2165
2166 AC_PATH_PAM
2167 if test "x$no_pam" = "xyes"; then 
2168         pam_support="no"
2169 else
2170         pam_support="yes"
2171         shadow_support="no" # if pam is installed, use it. We can't savely 
2172                             # test, if it works *sigh*
2173 fi
2174
2175 AC_ARG_WITH(shadow,
2176         [  --with-shadow                  If you want shadow password support ],
2177         [ if test "$withval" = "yes"; then
2178              shadow_support="yes"
2179           else
2180              shadow_support="no"
2181           fi
2182           if test "$pam_support" = "yes" && test "$shadow_support=yes"; then
2183                 AC_MSG_WARN("You can not define both pam AND shadow")
2184           fi
2185         ],
2186         [ if test -z "$shadow_support"; then shadow_support="no"; fi ] )
2187
2188 if test "$pam_support" = "yes"; then
2189   AC_CHECK_LIB(pam, main, [PASSWDLIB="-lpam -ldl"
2190   AC_DEFINE_UNQUOTED(HAVE_PAM_LIB)],
2191   [],-ldl)
2192 fi
2193
2194 if test -z "$PASSWDLIB" && test "$shadow_support" = "yes"; then
2195   AC_CHECK_LIB(shadow, main,
2196     [ PASSWDLIB="-lshadow"
2197       AC_DEFINE_UNQUOTED(HAVE_SHADOW_LIB)
2198     ])
2199 fi
2200 AC_SUBST(PASSWDLIB)
2201 AC_CHECK_LIB(util, main, [LIBUTIL="-lutil"]) dnl for FreeBSD
2202 AC_SUBST(LIBUTIL)
2203 AC_CHECK_LIB(s, main, [LIB_LIBS="-ls"]) dnl for AIX
2204 AC_SUBST(LIB_LIBS)
2205 AC_CHECK_LIB(Xdmcp, main, [LIBXDMCP="-lXdmcp"], , $X_LDFLAGS -lX11) dnl for Unixware
2206 AC_SUBST(LIBXDMCP)
2207
2208 if test -n "$LIBXDMCP"; then
2209   ac_cpp_safe=$ac_cpp
2210   ac_cpp='$CXXCPP $CPPFLAGS $X_INCLUDES'
2211   AC_CHECK_HEADERS(X11/Xdmcp.h)
2212   ac_cpp=$ac_cpp_safe
2213 fi
2214
2215 ])