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