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