1##   -*- autoconf -*-
2
3dnl    This file is part of the KDE libraries/packages
4dnl    Copyright (C) 1997 Janos Farkas (chexum@shadow.banki.hu)
5dnl              (C) 1997,98,99 Stephan Kulow (coolo@kde.org)
6
7dnl    This file is free software; you can redistribute it and/or
8dnl    modify it under the terms of the GNU Library General Public
9dnl    License as published by the Free Software Foundation; either
10dnl    version 2 of the License, or (at your option) any later version.
11
12dnl    This library is distributed in the hope that it will be useful,
13dnl    but WITHOUT ANY WARRANTY; without even the implied warranty of
14dnl    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15dnl    Library General Public License for more details.
16
17dnl    You should have received a copy of the GNU Library General Public License
18dnl    along with this library; see the file COPYING.LIB.  If not, write to
19dnl    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20dnl    Boston, MA 02111-1307, USA.
21
22dnl IMPORTANT NOTE:
23dnl Please do not modify this file unless you expect your modifications to be
24dnl carried into every other module in the repository.
25dnl
26dnl Single-module modifications are best placed in configure.in for kdelibs
27dnl and kdebase or configure.in.in if present.
28
29dnl ------------------------------------------------------------------------
30dnl Forward compatibility macros (make autoconf 2.13 look like 2.50),
31dnl thanks to Raja R Harinath.
32dnl ------------------------------------------------------------------------
33dnl
34ifdef([_AC_PATH_X_XMKMF],[],
35   [AC_DEFUN([_AC_PATH_X_XMKMF],[AC_PATH_X_XMKMF])])
36ifdef([AC_OUTPUT_SUBDIRS],[],
37   [AC_DEFUN([AC_OUTPUT_SUBDIRS],[subdirs=$1; _AC_OUTPUT_SUBDIRS])])
38
39# KDE_PATH_X_DIRECT
40dnl Internal subroutine of AC_PATH_X.
41dnl Set ac_x_includes and/or ac_x_libraries.
42AC_DEFUN(KDE_PATH_X_DIRECT,
43[
44AC_REQUIRE([KDE_CHECK_LIB64])
45
46if test "$ac_x_includes" = NO; then
47  # Guess where to find include files, by looking for this one X11 .h file.
48  test -z "$x_direct_test_include" && x_direct_test_include=X11/Intrinsic.h
49
50  # First, try using that file with no special directory specified.
51AC_TRY_CPP([#include <$x_direct_test_include>],
52[# We can compile using X headers with no special include directory.
53ac_x_includes=],
54[# Look for the header file in a standard set of common directories.
55# Check X11 before X11Rn because it is often a symlink to the current release.
56  for ac_dir in               \
57    /usr/X11/include          \
58    /usr/X11R6/include        \
59    /usr/X11R5/include        \
60    /usr/X11R4/include        \
61                              \
62    /usr/include/X11          \
63    /usr/include/X11R6        \
64    /usr/include/X11R5        \
65    /usr/include/X11R4        \
66                              \
67    /usr/local/X11/include    \
68    /usr/local/X11R6/include  \
69    /usr/local/X11R5/include  \
70    /usr/local/X11R4/include  \
71                              \
72    /usr/local/include/X11    \
73    /usr/local/include/X11R6  \
74    /usr/local/include/X11R5  \
75    /usr/local/include/X11R4  \
76                              \
77    /usr/X386/include         \
78    /usr/x386/include         \
79    /usr/XFree86/include/X11  \
80                              \
81    /usr/include              \
82    /usr/local/include        \
83    /usr/unsupported/include  \
84    /usr/athena/include       \
85    /usr/local/x11r5/include  \
86    /usr/lpp/Xamples/include  \
87                              \
88    /usr/openwin/include      \
89    /usr/openwin/share/include \
90    ; \
91  do
92    if test -r "$ac_dir/$x_direct_test_include"; then
93      ac_x_includes=$ac_dir
94      break
95    fi
96  done])
97fi # $ac_x_includes = NO
98
99if test "$ac_x_libraries" = NO; then
100  # Check for the libraries.
101
102  test -z "$x_direct_test_library" && x_direct_test_library=Xt
103  test -z "$x_direct_test_function" && x_direct_test_function=XtMalloc
104
105  # See if we find them without any special options.
106  # Don't add to $LIBS permanently.
107  ac_save_LIBS="$LIBS"
108  LIBS="-l$x_direct_test_library $LIBS"
109AC_TRY_LINK(, [${x_direct_test_function}()],
110[LIBS="$ac_save_LIBS"
111# We can link X programs with no special library path.
112ac_x_libraries=],
113[LIBS="$ac_save_LIBS"
114# First see if replacing the include by lib works.
115# Check X11 before X11Rn because it is often a symlink to the current release.
116for ac_dir in `echo "$ac_x_includes" | sed s/include/lib${kdelibsuff}/` \
117    /usr/X11/lib${kdelibsuff}           \
118    /usr/X11R6/lib${kdelibsuff}         \
119    /usr/X11R5/lib${kdelibsuff}         \
120    /usr/X11R4/lib${kdelibsuff}         \
121                                        \
122    /usr/lib${kdelibsuff}/X11           \
123    /usr/lib${kdelibsuff}/X11R6         \
124    /usr/lib${kdelibsuff}/X11R5         \
125    /usr/lib${kdelibsuff}/X11R4         \
126                                        \
127    /usr/local/X11/lib${kdelibsuff}     \
128    /usr/local/X11R6/lib${kdelibsuff}   \
129    /usr/local/X11R5/lib${kdelibsuff}   \
130    /usr/local/X11R4/lib${kdelibsuff}   \
131                                        \
132    /usr/local/lib${kdelibsuff}/X11     \
133    /usr/local/lib${kdelibsuff}/X11R6   \
134    /usr/local/lib${kdelibsuff}/X11R5   \
135    /usr/local/lib${kdelibsuff}/X11R4   \
136                                        \
137    /usr/X386/lib${kdelibsuff}          \
138    /usr/x386/lib${kdelibsuff}          \
139    /usr/XFree86/lib${kdelibsuff}/X11   \
140                                        \
141    /usr/lib${kdelibsuff}               \
142    /usr/local/lib${kdelibsuff}         \
143    /usr/unsupported/lib${kdelibsuff}   \
144    /usr/athena/lib${kdelibsuff}        \
145    /usr/local/x11r5/lib${kdelibsuff}   \
146    /usr/lpp/Xamples/lib${kdelibsuff}   \
147    /lib/usr/lib${kdelibsuff}/X11       \
148                                        \
149    /usr/openwin/lib${kdelibsuff}       \
150    /usr/openwin/share/lib${kdelibsuff} \
151    ; \
152do
153dnl Don't even attempt the hair of trying to link an X program!
154  for ac_extension in a so sl; do
155    if test -r $ac_dir/lib${x_direct_test_library}.$ac_extension; then
156      ac_x_libraries=$ac_dir
157      break 2
158    fi
159  done
160done])
161fi # $ac_x_libraries = NO
162])
163
164
165dnl ------------------------------------------------------------------------
166dnl Find a file (or one of more files in a list of dirs)
167dnl ------------------------------------------------------------------------
168dnl
169AC_DEFUN(AC_FIND_FILE,
170[
171$3=NO
172for i in $2;
173do
174  for j in $1;
175  do
176    echo "configure: __oline__: $i/$j" >&AC_FD_CC
177    if test -r "$i/$j"; then
178      echo "taking that" >&AC_FD_CC
179      $3=$i
180      break 2
181    fi
182  done
183done
184])
185
186dnl KDE_FIND_PATH(programm-name, variable-name, list of directories,
187dnl	if-not-found, test-parameter)
188AC_DEFUN(KDE_FIND_PATH,
189[
190   AC_MSG_CHECKING([for $1])
191   if test -n "$$2"; then
192        kde_cv_path="$$2";
193   else
194        kde_cache=`echo $1 | sed 'y%./+-%__p_%'`
195
196        AC_CACHE_VAL(kde_cv_path_$kde_cache,
197        [
198        kde_cv_path="NONE"
199	dirs="$3"
200	kde_save_IFS=$IFS
201	IFS=':'
202	for dir in $PATH; do
203	  dirs="$dirs $dir"
204        done
205	IFS=$kde_save_IFS
206
207        for dir in $dirs; do
208	  if test -x "$dir/$1"; then
209	    if test -n "$5"
210	    then
211              evalstr="$dir/$1 $5 2>&1 "
212	      if eval $evalstr; then
213                kde_cv_path="$dir/$1"
214                break
215	      fi
216            else
217		kde_cv_path="$dir/$1"
218                break
219	    fi
220          fi
221        done
222
223        eval "kde_cv_path_$kde_cache=$kde_cv_path"
224
225        ])
226
227      eval "kde_cv_path=\"`echo '$kde_cv_path_'$kde_cache`\""
228
229   fi
230
231   if test -z "$kde_cv_path" || test "$kde_cv_path" = NONE; then
232      AC_MSG_RESULT(not found)
233      $4
234   else
235      AC_MSG_RESULT($kde_cv_path)
236      $2=$kde_cv_path
237
238   fi
239])
240
241AC_DEFUN(KDE_MOC_ERROR_MESSAGE,
242[
243    AC_MSG_ERROR([No Qt meta object compiler (moc) found!
244Please check whether you installed Qt correctly.
245You need to have a running moc binary.
246configure tried to run $ac_cv_path_moc and the test didn't
247succeed. If configure shouldn't have tried this one, set
248the environment variable MOC to the right one before running
249configure.
250])
251])
252
253AC_DEFUN(KDE_UIC_ERROR_MESSAGE,
254[
255    AC_MSG_WARN([No Qt ui compiler (uic) found!
256Please check whether you installed Qt correctly.
257You need to have a running uic binary.
258configure tried to run $ac_cv_path_uic and the test didn't
259succeed. If configure shouldn't have tried this one, set
260the environment variable UIC to the right one before running
261configure.
262])
263])
264
265
266AC_DEFUN(KDE_CHECK_UIC_FLAG,
267[
268    AC_MSG_CHECKING([whether uic supports -$1 ])
269    kde_cache=`echo $1 | sed 'y% .=/+-%____p_%'`
270    AC_CACHE_VAL(kde_cv_prog_uic_$kde_cache,
271    [
272        cat >conftest.ui <<EOT
273        <!DOCTYPE UI><UI version="3" stdsetdef="1"></UI>
274EOT
275        ac_uic_testrun="$UIC_PATH -$1 $2 conftest.ui >/dev/null"
276        if AC_TRY_EVAL(ac_uic_testrun); then
277            eval "kde_cv_prog_uic_$kde_cache=yes"
278        else
279            eval "kde_cv_prog_uic_$kde_cache=no"
280        fi
281        rm -f conftest*
282    ])
283
284    if eval "test \"`echo '$kde_cv_prog_uic_'$kde_cache`\" = yes"; then
285        AC_MSG_RESULT([yes])
286        :
287        $3
288    else
289        AC_MSG_RESULT([no])
290        :
291        $4
292    fi
293])
294
295
296dnl ------------------------------------------------------------------------
297dnl Find the meta object compiler and the ui compiler in the PATH,
298dnl in $QTDIR/bin, and some more usual places
299dnl ------------------------------------------------------------------------
300dnl
301AC_DEFUN(AC_PATH_QT_MOC_UIC,
302[
303   qt_bindirs=""
304   for dir in $kde_qt_dirs; do
305      qt_bindirs="$qt_bindirs $dir/bin $dir/src/moc"
306   done
307   qt_bindirs="$qt_bindirs /usr/bin /usr/X11R6/bin /usr/local/qt/bin"
308   if test ! "$ac_qt_bindir" = "NO"; then
309      qt_bindirs="$ac_qt_bindir $qt_bindirs"
310   fi
311
312   KDE_FIND_PATH(moc, MOC, [$qt_bindirs], [KDE_MOC_ERROR_MESSAGE])
313   if test -z "$UIC_NOT_NEEDED"; then
314     KDE_FIND_PATH(uic, UIC_PATH, [$qt_bindirs], [UIC_PATH=""])
315     if test -z "$UIC_PATH" ; then
316       KDE_UIC_ERROR_MESSAGE
317       exit 1
318     elif test $kde_qtver = 3; then
319       KDE_CHECK_UIC_FLAG(L,[/nonexistant],ac_uic_supports_libpath=yes,ac_uic_supports_libpath=no)
320       KDE_CHECK_UIC_FLAG(nounload,,ac_uic_supports_nounload=yes,ac_uic_supports_nounload=no)
321
322       UIC=$UIC_PATH
323       if test x$ac_uic_supports_libpath = xyes; then
324           UIC="$UIC -L \$(kde_widgetdir)"
325       fi
326       if test x$ac_uic_supports_nounload = xyes; then
327           UIC="$UIC -nounload"
328       fi
329     fi
330   else
331     UIC="echo uic not available: "
332   fi
333
334   AC_SUBST(MOC)
335   AC_SUBST(UIC)
336
337   UIC_TR="i18n"
338   if test $kde_qtver = 3; then
339     UIC_TR="tr2i18n"
340   fi
341
342   AC_SUBST(UIC_TR)
343])
344
345AC_DEFUN(KDE_1_CHECK_PATHS,
346[
347  KDE_1_CHECK_PATH_HEADERS
348
349  KDE_TEST_RPATH=
350
351  if test -n "$USE_RPATH"; then
352
353     if test -n "$kde_libraries"; then
354       KDE_TEST_RPATH="-R $kde_libraries"
355     fi
356
357     if test -n "$qt_libraries"; then
358       KDE_TEST_RPATH="$KDE_TEST_RPATH -R $qt_libraries"
359     fi
360
361     if test -n "$x_libraries"; then
362       KDE_TEST_RPATH="$KDE_TEST_RPATH -R $x_libraries"
363     fi
364
365     KDE_TEST_RPATH="$KDE_TEST_RPATH $KDE_EXTRA_RPATH"
366  fi
367
368AC_MSG_CHECKING([for KDE libraries installed])
369ac_link='$LIBTOOL_SHELL --silent --mode=link ${CXX-g++} -o conftest $CXXFLAGS $all_includes $CPPFLAGS $LDFLAGS $all_libraries conftest.$ac_ext $LIBS -lkdecore $LIBQT $KDE_TEST_RPATH 1>&5'
370
371if AC_TRY_EVAL(ac_link) && test -s conftest; then
372  AC_MSG_RESULT(yes)
373else
374  AC_MSG_ERROR([your system fails at linking a small KDE application!
375Check, if your compiler is installed correctly and if you have used the
376same compiler to compile Qt and kdelibs as you did use now.
377For more details about this problem, look at the end of config.log.])
378fi
379
380if eval `KDEDIR= ./conftest 2>&5`; then
381  kde_result=done
382else
383  kde_result=problems
384fi
385
386KDEDIR= ./conftest 2> /dev/null >&5 # make an echo for config.log
387kde_have_all_paths=yes
388
389KDE_SET_PATHS($kde_result)
390
391])
392
393AC_DEFUN(KDE_SET_PATHS,
394[
395  kde_cv_all_paths="kde_have_all_paths=\"yes\" \
396	kde_htmldir=\"$kde_htmldir\" \
397	kde_appsdir=\"$kde_appsdir\" \
398	kde_icondir=\"$kde_icondir\" \
399	kde_sounddir=\"$kde_sounddir\" \
400	kde_datadir=\"$kde_datadir\" \
401	kde_locale=\"$kde_locale\" \
402	kde_cgidir=\"$kde_cgidir\" \
403	kde_confdir=\"$kde_confdir\" \
404	kde_mimedir=\"$kde_mimedir\" \
405	kde_toolbardir=\"$kde_toolbardir\" \
406	kde_wallpaperdir=\"$kde_wallpaperdir\" \
407	kde_templatesdir=\"$kde_templatesdir\" \
408	kde_bindir=\"$kde_bindir\" \
409	kde_servicesdir=\"$kde_servicesdir\" \
410	kde_servicetypesdir=\"$kde_servicetypesdir\" \
411	kde_moduledir=\"$kde_moduledir\" \
412   kde_styledir=\"$kde_styledir\" \
413	kde_widgetdir=\"$kde_widgetdir\" \
414	kde_result=$1"
415])
416
417AC_DEFUN(KDE_SET_DEFAULT_PATHS,
418[
419if test "$1" = "default"; then
420
421  if test -z "$kde_htmldir"; then
422    kde_htmldir='\${prefix}/share/doc/HTML'
423  fi
424  if test -z "$kde_appsdir"; then
425    kde_appsdir='\${prefix}/share/applnk'
426  fi
427  if test -z "$kde_icondir"; then
428    kde_icondir='\${prefix}/share/icons'
429  fi
430  if test -z "$kde_sounddir"; then
431    kde_sounddir='\${prefix}/share/sounds'
432  fi
433  if test -z "$kde_datadir"; then
434    kde_datadir='\${prefix}/share/apps'
435  fi
436  if test -z "$kde_locale"; then
437    kde_locale='\${prefix}/share/locale'
438  fi
439  if test -z "$kde_cgidir"; then
440    kde_cgidir='\${exec_prefix}/cgi-bin'
441  fi
442  if test -z "$kde_confdir"; then
443    kde_confdir='\${prefix}/share/config'
444  fi
445  if test -z "$kde_mimedir"; then
446    kde_mimedir='\${prefix}/share/mimelnk'
447  fi
448  if test -z "$kde_toolbardir"; then
449    kde_toolbardir='\${prefix}/share/toolbar'
450  fi
451  if test -z "$kde_wallpaperdir"; then
452    kde_wallpaperdir='\${prefix}/share/wallpapers'
453  fi
454  if test -z "$kde_templatesdir"; then
455    kde_templatesdir='\${prefix}/share/templates'
456  fi
457  if test -z "$kde_bindir"; then
458    kde_bindir='\${exec_prefix}/bin'
459  fi
460  if test -z "$kde_servicesdir"; then
461    kde_servicesdir='\${prefix}/share/services'
462  fi
463  if test -z "$kde_servicetypesdir"; then
464    kde_servicetypesdir='\${prefix}/share/servicetypes'
465  fi
466  if test -z "$kde_moduledir"; then
467    if test "$kde_qtver" = "2"; then
468      kde_moduledir='\${libdir}/kde2'
469    else
470      kde_moduledir='\${libdir}/kde3'
471    fi
472  fi
473  if test -z "$kde_styledir"; then
474    kde_styledir='\${libdir}/kde3/plugins/styles'
475  fi
476  if test -z "$kde_widgetdir"; then
477    kde_widgetdir='\${libdir}/kde3/plugins/designer'
478  fi
479
480  KDE_SET_PATHS(defaults)
481
482else
483
484  if test $kde_qtver = 1; then
485     AC_MSG_RESULT([compiling])
486     KDE_1_CHECK_PATHS
487  else
488     AC_MSG_ERROR([path checking not yet supported for KDE 2])
489  fi
490
491fi
492])
493
494AC_DEFUN(KDE_CHECK_PATHS_FOR_COMPLETENESS,
495[ if test -z "$kde_htmldir" || test -z "$kde_appsdir" ||
496   test -z "$kde_icondir" || test -z "$kde_sounddir" ||
497   test -z "$kde_datadir" || test -z "$kde_locale"  ||
498   test -z "$kde_cgidir"  || test -z "$kde_confdir" ||
499   test -z "$kde_mimedir" || test -z "$kde_toolbardir" ||
500   test -z "$kde_wallpaperdir" || test -z "$kde_templatesdir" ||
501   test -z "$kde_bindir" || test -z "$kde_servicesdir" ||
502   test -z "$kde_servicetypesdir" || test -z "$kde_moduledir" ||
503   test -z "$kde_styledir" || test -z "kde_widgetdir"
504   test "x$kde_have_all_paths" != "xyes"; then
505     kde_have_all_paths=no
506  fi
507])
508
509AC_DEFUN(KDE_MISSING_PROG_ERROR,
510[
511    AC_MSG_ERROR([The important program $1 was not found!
512Please check whether you installed KDE correctly.
513])
514])
515
516AC_DEFUN(KDE_MISSING_ARTS_ERROR,
517[
518    AC_MSG_ERROR([The important program $1 was not found!
519Please check whether you installed aRts correctly.
520])
521])
522
523AC_DEFUN(KDE_SUBST_PROGRAMS,
524[
525
526        kde_default_bindirs="/usr/bin /usr/local/bin /opt/local/bin /usr/X11R6/bin /opt/kde/bin /opt/kde3/bin /usr/kde/bin /usr/local/kde/bin"
527        test -n "$KDEDIR" && kde_default_bindirs="$KDEDIR/bin $kde_default_bindirs"
528        if test -n "$KDEDIRS"; then
529           kde_save_IFS=$IFS
530           IFS=:
531           for dir in $KDEDIRS; do
532                kde_default_bindirs="$dir/bin $kde_default_bindirs "
533           done
534           IFS=$kde_save_IFS
535        fi
536        kde_default_bindirs="$exec_prefix/bin $prefix/bin $kde_default_bindirs"
537        KDE_FIND_PATH(dcopidl, DCOPIDL, [$kde_default_bindirs], [KDE_MISSING_PROG_ERROR(dcopidl)])
538        KDE_FIND_PATH(dcopidl2cpp, DCOPIDL2CPP, [$kde_default_bindirs], [KDE_MISSING_PROG_ERROR(dcopidl2cpp)])
539        KDE_FIND_PATH(mcopidl, MCOPIDL, [$kde_default_bindirs], [KDE_MISSING_ARTS_ERROR(mcopidl)])
540        KDE_FIND_PATH(artsc-config, ARTSCCONFIG, [$kde_default_bindirs], [KDE_MISSING_ARTS_ERROR(artsc-config)])
541        KDE_FIND_PATH(kde-config, KDECONFIG, [$kde_default_bindirs])
542        KDE_FIND_PATH(meinproc, MEINPROC, [$kde_default_bindirs])
543
544        if test -n "$MEINPROC" && test ! "$MEINPROC" = "compiled"; then
545 	    kde_sharedirs="/usr/share/kde /usr/local/share /usr/share /opt/kde3/share /opt/kde/share $prefix/share"
546            test -n "$KDEDIR" && kde_sharedirs="$KDEDIR/share $kde_sharedirs"
547            AC_FIND_FILE(apps/ksgmltools2/customization/kde-chunk.xsl, $kde_sharedirs, KDE_XSL_STYLESHEET)
548	    if test "$KDE_XSL_STYLESHEET" = "NO"; then
549		KDE_XSL_STYLESHEET=""
550	    else
551                KDE_XSL_STYLESHEET="$KDE_XSL_STYLESHEET/apps/ksgmltools2/customization/kde-chunk.xsl"
552	    fi
553        fi
554
555        DCOP_DEPENDENCIES='$(DCOPIDL)'
556        AC_SUBST(DCOPIDL)
557        AC_SUBST(DCOPIDL2CPP)
558        AC_SUBST(DCOP_DEPENDENCIES)
559        AC_SUBST(MCOPIDL)
560        AC_SUBST(ARTSCCONFIG)
561        AC_SUBST(KDECONFIG)
562	AC_SUBST(MEINPROC)
563 	AC_SUBST(KDE_XSL_STYLESHEET)
564
565        if test -x "$KDECONFIG"; then # it can be "compiled"
566          kde_libs_prefix=`$KDECONFIG --prefix`
567          if test -z "$kde_libs_prefix" || test ! -x "$kde_libs_prefix"; then
568               AC_MSG_ERROR([$KDECONFIG --prefix outputed the non existant prefix '$kde_libs_prefix' for kdelibs.
569                          This means it has been moved since you installed it.
570                          This won't work. Please recompile kdelibs for the new prefix.
571                          ])
572           fi
573           kde_libs_htmldir=`$KDECONFIG --install html --expandvars`
574        else
575           kde_libs_prefix='$(prefix)'
576           kde_libs_htmldir='$(kde_htmldir)'
577        fi
578        AC_SUBST(kde_libs_prefix)
579        AC_SUBST(kde_libs_htmldir)
580])dnl
581
582AC_DEFUN(AC_CREATE_KFSSTND,
583[
584AC_REQUIRE([AC_CHECK_RPATH])
585
586AC_MSG_CHECKING([for KDE paths])
587kde_result=""
588kde_cached_paths=yes
589AC_CACHE_VAL(kde_cv_all_paths,
590[
591  KDE_SET_DEFAULT_PATHS($1)
592  kde_cached_paths=no
593])
594eval "$kde_cv_all_paths"
595KDE_CHECK_PATHS_FOR_COMPLETENESS
596if test "$kde_have_all_paths" = "no" && test "$kde_cached_paths" = "yes"; then
597  # wrong values were cached, may be, we can set better ones
598  kde_result=
599  kde_htmldir= kde_appsdir= kde_icondir= kde_sounddir=
600  kde_datadir= kde_locale=  kde_cgidir=  kde_confdir=
601  kde_mimedir= kde_toolbardir= kde_wallpaperdir= kde_templatesdir=
602  kde_bindir= kde_servicesdir= kde_servicetypesdir= kde_moduledir=
603  kde_have_all_paths=
604  kde_styledir=
605  kde_widgetdir=
606  KDE_SET_DEFAULT_PATHS($1)
607  eval "$kde_cv_all_paths"
608  KDE_CHECK_PATHS_FOR_COMPLETENESS
609  kde_result="$kde_result (cache overridden)"
610fi
611if test "$kde_have_all_paths" = "no"; then
612  AC_MSG_ERROR([configure could not run a little KDE program to test the environment.
613Since it had compiled and linked before, it must be a strange problem on your system.
614Look at config.log for details. If you are not able to fix this, look at
615http://www.kde.org/faq/installation.html or any www.kde.org mirror.
616(If you're using an egcs version on Linux, you may update binutils!)
617])
618else
619  rm -f conftest*
620  AC_MSG_RESULT($kde_result)
621fi
622
623bindir=$kde_bindir
624
625KDE_SUBST_PROGRAMS
626
627])
628
629AC_DEFUN(AC_SUBST_KFSSTND,
630[
631AC_SUBST(kde_htmldir)
632AC_SUBST(kde_appsdir)
633AC_SUBST(kde_icondir)
634AC_SUBST(kde_sounddir)
635AC_SUBST(kde_datadir)
636AC_SUBST(kde_locale)
637AC_SUBST(kde_confdir)
638AC_SUBST(kde_mimedir)
639AC_SUBST(kde_wallpaperdir)
640AC_SUBST(kde_bindir)
641dnl for KDE 2
642AC_SUBST(kde_templatesdir)
643AC_SUBST(kde_servicesdir)
644AC_SUBST(kde_servicetypesdir)
645AC_SUBST(kde_moduledir)
646AC_SUBST(kde_styledir)
647AC_SUBST(kde_widgetdir)
648if test "$kde_qtver" = 1; then
649  kde_minidir="$kde_icondir/mini"
650else
651# for KDE 1 - this breaks KDE2 apps using minidir, but
652# that's the plan ;-/
653  kde_minidir="/dev/null"
654fi
655dnl AC_SUBST(kde_minidir)
656dnl AC_SUBST(kde_cgidir)
657dnl AC_SUBST(kde_toolbardir)
658])
659
660AC_DEFUN(KDE_MISC_TESTS,
661[
662   AC_LANG_C
663   dnl Checks for libraries.
664   AC_CHECK_LIB(util, main, [LIBUTIL="-lutil"]) dnl for *BSD
665   AC_SUBST(LIBUTIL)
666   AC_CHECK_LIB(compat, main, [LIBCOMPAT="-lcompat"]) dnl for *BSD
667   AC_SUBST(LIBCOMPAT)
668   kde_have_crypt=
669   AC_CHECK_LIB(crypt, crypt, [LIBCRYPT="-lcrypt"; kde_have_crypt=yes],
670      AC_CHECK_LIB(c, crypt, [kde_have_crypt=yes], [
671        AC_MSG_WARN([you have no crypt in either libcrypt or libc.
672You should install libcrypt from another source or configure with PAM
673support])
674	kde_have_crypt=no
675      ]))
676   AC_SUBST(LIBCRYPT)
677   if test $kde_have_crypt = yes; then
678      AC_DEFINE_UNQUOTED(HAVE_CRYPT, 1, [Defines if your system has the crypt function])
679   fi
680   AC_CHECK_SOCKLEN_T
681   AC_LANG_C
682   AC_CHECK_LIB(dnet, dnet_ntoa, [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet"])
683   if test $ac_cv_lib_dnet_dnet_ntoa = no; then
684      AC_CHECK_LIB(dnet_stub, dnet_ntoa,
685        [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet_stub"])
686   fi
687   AC_CHECK_FUNC(inet_ntoa)
688   if test $ac_cv_func_inet_ntoa = no; then
689     AC_CHECK_LIB(nsl, inet_ntoa, X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl")
690   fi
691   AC_CHECK_FUNC(connect)
692   if test $ac_cv_func_connect = no; then
693      AC_CHECK_LIB(socket, connect, X_EXTRA_LIBS="-lsocket $X_EXTRA_LIBS", ,
694        $X_EXTRA_LIBS)
695   fi
696
697   AC_CHECK_FUNC(remove)
698   if test $ac_cv_func_remove = no; then
699      AC_CHECK_LIB(posix, remove, X_EXTRA_LIBS="$X_EXTRA_LIBS -lposix")
700   fi
701
702   # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay.
703   AC_CHECK_FUNC(shmat, ,
704     AC_CHECK_LIB(ipc, shmat, X_EXTRA_LIBS="$X_EXTRA_LIBS -lipc"))
705
706   # darwin needs this to initialize the environment
707   AC_CHECK_HEADERS(crt_externs.h)
708   AC_CHECK_FUNC(_NSGetEnviron, [AC_DEFINE(HAVE_NSGETENVIRON, 1, [Define if your system needs _NSGetEnviron to set up the environment])])
709
710   # more headers that need to be explicitly included on darwin
711   AC_CHECK_HEADERS(sys/types.h stdint.h)
712
713   # darwin requires a poll emulation library
714   AC_CHECK_LIB(poll, poll, LIB_POLL="-lpoll")
715
716   # CoreAudio framework
717   AC_CHECK_HEADER(CoreAudio/CoreAudio.h, [
718     AC_DEFINE(HAVE_COREAUDIO, 1, [Define if you have the CoreAudio API])
719     FRAMEWORK_COREAUDIO="-framework CoreAudio"
720   ])
721
722   AC_CHECK_RES_INIT
723   AC_SUBST(LIB_POLL)
724   AC_SUBST(FRAMEWORK_COREAUDIO)
725   LIBSOCKET="$X_EXTRA_LIBS"
726   AC_SUBST(LIBSOCKET)
727   AC_SUBST(X_EXTRA_LIBS)
728   AC_CHECK_LIB(ucb, killpg, [LIBUCB="-lucb"]) dnl for Solaris2.4
729   AC_SUBST(LIBUCB)
730
731   case $host in  dnl this *is* LynxOS specific
732   *-*-lynxos* )
733        AC_MSG_CHECKING([LynxOS header file wrappers])
734        [CFLAGS="$CFLAGS -D__NO_INCLUDE_WARN__"]
735        AC_MSG_RESULT(disabled)
736        AC_CHECK_LIB(bsd, gethostbyname, [LIBSOCKET="-lbsd"]) dnl for LynxOS
737         ;;
738    esac
739
740   KDE_CHECK_TYPES
741   KDE_CHECK_LIBDL
742
743AH_VERBATIM(_AIX_STRINGS_H_BZERO,
744[
745/*
746 * AIX defines FD_SET in terms of bzero, but fails to include <strings.h>
747 * that defines bzero.
748 */
749
750#if defined(_AIX)
751#include <strings.h>
752#endif
753])
754
755AC_CHECK_FUNCS([vsnprintf snprintf])
756
757AH_VERBATIM(_TRU64,[
758/*
759 * On HP-UX, the declaration of vsnprintf() is needed every time !
760 */
761
762#if !defined(HAVE_VSNPRINTF) || defined(hpux)
763#if __STDC__
764#include <stdarg.h>
765#include <stdlib.h>
766#else
767#include <varargs.h>
768#endif
769#ifdef __cplusplus
770extern "C"
771#endif
772int vsnprintf(char *str, size_t n, char const *fmt, va_list ap);
773#ifdef __cplusplus
774extern "C"
775#endif
776int snprintf(char *str, size_t n, char const *fmt, ...);
777#endif
778])
779
780])
781
782dnl ------------------------------------------------------------------------
783dnl Find the header files and libraries for X-Windows. Extended the
784dnl macro AC_PATH_X
785dnl ------------------------------------------------------------------------
786dnl
787AC_DEFUN(K_PATH_X,
788[
789AC_REQUIRE([KDE_MISC_TESTS])dnl
790AC_REQUIRE([KDE_CHECK_LIB64])
791
792AC_ARG_ENABLE(
793  embedded,
794  [  --enable-embedded       link to Qt-embedded, don't use X],
795  kde_use_qt_emb=$enableval,
796  kde_use_qt_emb=no
797)
798
799AC_ARG_ENABLE(
800  qtopia,
801  [  --enable-qtopia         link to Qt-embedded, link to the Qtopia Environment],
802  kde_use_qt_emb_palm=$enableval,
803  kde_use_qt_emb_palm=no
804)
805
806if test "$kde_use_qt_emb" = "no"; then
807
808AC_MSG_CHECKING(for X)
809AC_LANG_SAVE
810AC_LANG_C
811AC_CACHE_VAL(kde_cv_have_x,
812[# One or both of the vars are not set, and there is no cached value.
813if test "{$x_includes+set}" = set || test "$x_includes" = NONE; then
814   kde_x_includes=NO
815else
816   kde_x_includes=$x_includes
817fi
818if test "{$x_libraries+set}" = set || test "$x_libraries" = NONE; then
819   kde_x_libraries=NO
820else
821   kde_x_libraries=$x_libraries
822fi
823
824# below we use the standard autoconf calls
825ac_x_libraries=$kde_x_libraries
826ac_x_includes=$kde_x_includes
827
828KDE_PATH_X_DIRECT
829dnl AC_PATH_X_XMKMF picks /usr/lib as the path for the X libraries.
830dnl Unfortunately, if compiling with the N32 ABI, this is not the correct
831dnl location. The correct location is /usr/lib32 or an undefined value
832dnl (the linker is smart enough to pick the correct default library).
833dnl Things work just fine if you use just AC_PATH_X_DIRECT.
834dnl Solaris has a similar problem. AC_PATH_X_XMKMF forces x_includes to
835dnl /usr/openwin/include, which doesn't work. /usr/include does work, so
836dnl x_includes should be left alone.
837case "$host" in
838mips-sgi-irix6*)
839  ;;
840*-*-solaris*)
841  ;;
842*)
843  _AC_PATH_X_XMKMF
844  if test -z "$ac_x_includes"; then
845    ac_x_includes="."
846  fi
847  if test -z "$ac_x_libraries"; then
848    ac_x_libraries="/usr/lib${kdelibsuff}"
849  fi
850esac
851#from now on we use our own again
852
853# when the user already gave --x-includes, we ignore
854# what the standard autoconf macros told us.
855if test "$kde_x_includes" = NO; then
856  kde_x_includes=$ac_x_includes
857fi
858
859# for --x-libraries too
860if test "$kde_x_libraries" = NO; then
861  kde_x_libraries=$ac_x_libraries
862fi
863
864if test "$kde_x_includes" = NO; then
865  AC_MSG_ERROR([Can't find X includes. Please check your installation and add the correct paths!])
866fi
867
868if test "$kde_x_libraries" = NO; then
869  AC_MSG_ERROR([Can't find X libraries. Please check your installation and add the correct paths!])
870fi
871
872# Record where we found X for the cache.
873kde_cv_have_x="have_x=yes \
874         kde_x_includes=$kde_x_includes kde_x_libraries=$kde_x_libraries"
875])dnl
876
877eval "$kde_cv_have_x"
878
879if test "$have_x" != yes; then
880  AC_MSG_RESULT($have_x)
881  no_x=yes
882else
883  AC_MSG_RESULT([libraries $kde_x_libraries, headers $kde_x_includes])
884fi
885
886if test -z "$kde_x_includes" || test "x$kde_x_includes" = xNONE; then
887  X_INCLUDES=""
888  x_includes="."; dnl better than nothing :-
889 else
890  x_includes=$kde_x_includes
891  X_INCLUDES="-I$x_includes"
892fi
893
894if test -z "$kde_x_libraries" || test "x$kde_x_libraries" = xNONE; then
895  X_LDFLAGS=""
896  x_libraries="/usr/lib"; dnl better than nothing :-
897 else
898  x_libraries=$kde_x_libraries
899  X_LDFLAGS="-L$x_libraries"
900fi
901all_includes="$X_INCLUDES"
902all_libraries="$X_LDFLAGS"
903
904AC_SUBST(X_INCLUDES)
905AC_SUBST(X_LDFLAGS)
906AC_SUBST(x_libraries)
907AC_SUBST(x_includes)
908
909# Check for libraries that X11R6 Xt/Xaw programs need.
910ac_save_LDFLAGS="$LDFLAGS"
911LDFLAGS="$LDFLAGS $X_LDFLAGS"
912# SM needs ICE to (dynamically) link under SunOS 4.x (so we have to
913# check for ICE first), but we must link in the order -lSM -lICE or
914# we get undefined symbols.  So assume we have SM if we have ICE.
915# These have to be linked with before -lX11, unlike the other
916# libraries we check for below, so use a different variable.
917#  --interran@uluru.Stanford.EDU, kb@cs.umb.edu.
918AC_CHECK_LIB(ICE, IceConnectionNumber,
919  [LIBSM="-lSM -lICE"], , $X_EXTRA_LIBS)
920AC_SUBST(LIBSM)
921LDFLAGS="$ac_save_LDFLAGS"
922
923AC_SUBST(X_PRE_LIBS)
924
925LIB_X11='-lX11 $(LIBSOCKET)'
926AC_SUBST(LIB_X11)
927
928AC_MSG_CHECKING(for libXext)
929AC_CACHE_VAL(kde_cv_have_libXext,
930[
931kde_ldflags_safe="$LDFLAGS"
932kde_libs_safe="$LIBS"
933
934LDFLAGS="$LDFLAGS $X_LDFLAGS $USER_LDFLAGS"
935LIBS="-lXext -lX11 $LIBSOCKET"
936
937AC_TRY_LINK([
938#include <stdio.h>
939#ifdef STDC_HEADERS
940# include <stdlib.h>
941#endif
942],
943[
944printf("hello Xext\n");
945],
946kde_cv_have_libXext=yes,
947kde_cv_have_libXext=no
948   )
949
950LDFLAGS=$kde_ldflags_safe
951LIBS=$kde_libs_safe
952 ])
953
954AC_MSG_RESULT($kde_cv_have_libXext)
955
956if test "$kde_cv_have_libXext" = "no"; then
957  AC_MSG_ERROR([We need a working libXext to proceed. Since configure
958can't find it itself, we stop here assuming that make wouldn't find
959them either.])
960fi
961
962AC_MSG_CHECKING(for Xinerama)
963
964 AC_ARG_WITH(xinerama,
965  [  --with-xinerama         enable support for Xinerama ],
966  [
967    no_xinerama=no
968  ], [
969    no_xinerama=yes
970  ]
971)
972
973kde_save_LDFLAGS="$LDFLAGS"
974kde_save_CFLAGS="$CFLAGS"
975kde_save_LIBS="$LIBS"
976LDFLAGS="$LDFLAGS $X_LDFLAGS $USER_LDFLAGS"
977CFLAGS="$CFLAGS -I$x_includes"
978LIBS="-lXinerama -lXext"
979
980if test "x$no_xinerama" = "xno"; then
981
982  AC_CACHE_VAL(ac_cv_have_xinerama,
983  [
984	  AC_TRY_LINK([#include <X11/Xlib.h>
985  			#include <X11/extensions/Xinerama.h>],
986	  	  [XineramaIsActive(NULL);],
987		  [ac_cv_have_xinerama="yes"],
988		  [ac_cv_have_xinerama="no"])
989  ])
990else
991  ac_cv_have_xinerama=no;
992fi
993
994AC_MSG_RESULT($ac_cv_have_xinerama)
995
996LIBXINERAMA=""
997
998if test "$ac_cv_have_xinerama" = "yes"; then
999  AC_DEFINE(HAVE_XINERAMA, 1, [Define if you want Xinerama support])
1000  LIBXINERAMA="-lXinerama"
1001fi
1002
1003AC_SUBST(LIBXINERAMA)
1004
1005LDFLAGS="$kde_save_LDFLAGS"
1006CFLAGS="$kde_save_CFLAGS"
1007LIBS="$kde_save_LIBS"
1008
1009LIB_XEXT="-lXext"
1010QTE_NORTTI=""
1011
1012else
1013  dnl We're using QT Embedded
1014  CPPFLAGS=-DQWS
1015  CXXFLAGS="$CXXFLAGS -fno-rtti"
1016  QTE_NORTTI="-fno-rtti -DQWS"
1017  X_PRE_LIBS=""
1018  LIB_X11=""
1019  LIB_XEXT=""
1020  LIBSM=""
1021  X_INCLUDES=""
1022  X_LDFLAGS=""
1023  x_includes=""
1024  x_libraries=""
1025  AC_SUBST(X_PRE_LIBS)
1026  AC_SUBST(LIB_X11)
1027  AC_SUBST(LIBSM)
1028  AC_SUBST(X_INCLUDES)
1029  AC_SUBST(X_LDFLAGS)
1030  AC_SUBST(x_includes)
1031  AC_SUBST(x_libraries)
1032fi
1033AC_SUBST(QTE_NORTTI)
1034AC_SUBST(LIB_XEXT)
1035
1036
1037AC_LANG_RESTORE
1038
1039])
1040
1041AC_DEFUN(KDE_PRINT_QT_PROGRAM,
1042[
1043AC_REQUIRE([KDE_USE_QT])
1044cat > conftest.$ac_ext <<EOF
1045#include "confdefs.h"
1046#include <qglobal.h>
1047#include <qapplication.h>
1048EOF
1049if test "$kde_qtver" = "2"; then
1050cat >> conftest.$ac_ext <<EOF
1051#include <qevent.h>
1052#include <qstring.h>
1053#include <qstyle.h>
1054EOF
1055
1056if test $kde_qtsubver -gt 0; then
1057cat >> conftest.$ac_ext <<EOF
1058#if QT_VERSION < 210
1059#error 1
1060#endif
1061EOF
1062fi
1063fi
1064
1065if test "$kde_qtver" = "3"; then
1066cat >> conftest.$ac_ext <<EOF
1067#include <qcursor.h>
1068#include <qstylefactory.h>
1069#include <private/qucomextra_p.h>
1070EOF
1071fi
1072
1073echo "#if ! ($kde_qt_verstring)" >> conftest.$ac_ext
1074cat >> conftest.$ac_ext <<EOF
1075#error 1
1076#endif
1077
1078int main() {
1079EOF
1080if test "$kde_qtver" = "2"; then
1081cat >> conftest.$ac_ext <<EOF
1082    QStringList *t = new QStringList();
1083    Q_UNUSED(t);
1084EOF
1085if test $kde_qtsubver -gt 0; then
1086cat >> conftest.$ac_ext <<EOF
1087    QString s;
1088    s.setLatin1("Elvis is alive", 14);
1089EOF
1090fi
1091fi
1092if test "$kde_qtver" = "3"; then
1093cat >> conftest.$ac_ext <<EOF
1094    (void)QStyleFactory::create(QString::null);
1095    QCursor c(Qt::WhatsThisCursor);
1096EOF
1097fi
1098cat >> conftest.$ac_ext <<EOF
1099    return 0;
1100}
1101EOF
1102])
1103
1104AC_DEFUN(KDE_USE_QT,
1105[
1106if test -z "$1"; then
1107  # Current default Qt version: 3.1
1108  kde_qtver=3
1109  kde_qtsubver=1
1110else
1111  kde_qtsubver=`echo "$1" | sed -e 's#[0-9][0-9]*\.\([0-9][0-9]*\).*#\1#'`
1112  # following is the check if subversion isnt found in passed argument
1113  if test "$kde_qtsubver" = "$1"; then
1114    kde_qtsubver=1
1115  fi
1116  kde_qtver=`echo "$1" | sed -e 's#^\([0-9][0-9]*\)\..*#\1#'`
1117  if test "$kde_qtver" = "1"; then
1118    kde_qtsubver=42
1119  fi
1120fi
1121
1122if test -z "$2"; then
1123  if test "$kde_qtver" = "2"; then
1124    if test $kde_qtsubver -gt 0; then
1125      kde_qt_minversion=">= Qt 2.2.2"
1126    else
1127      kde_qt_minversion=">= Qt 2.0.2"
1128    fi
1129  fi
1130  if test "$kde_qtver" = "3"; then
1131    if test $kde_qtsubver -gt 0; then
1132      kde_qt_minversion=">= Qt 3.1.0"
1133    else
1134      kde_qt_minversion=">= Qt 3.0"
1135    fi
1136  fi
1137  if test "$kde_qtver" = "1"; then
1138    kde_qt_minversion=">= 1.42 and < 2.0"
1139  fi
1140else
1141   kde_qt_minversion=$2
1142fi
1143
1144if test -z "$3"; then
1145   if test $kde_qtver = 3; then
1146     if test $kde_qtsubver -gt 0; then
1147       kde_qt_verstring="QT_VERSION >= 0x030100"
1148     else
1149       kde_qt_verstring="QT_VERSION >= 300"
1150     fi
1151   fi
1152   if test $kde_qtver = 2; then
1153     if test $kde_qtsubver -gt 0; then
1154       kde_qt_verstring="QT_VERSION >= 222"
1155     else
1156       kde_qt_verstring="QT_VERSION >= 200"
1157     fi
1158   fi
1159   if test $kde_qtver = 1; then
1160    kde_qt_verstring="QT_VERSION >= 142 && QT_VERSION < 200"
1161   fi
1162else
1163   kde_qt_verstring=$3
1164fi
1165
1166if test $kde_qtver = 3; then
1167  kde_qt_dirs="$QTDIR /usr/lib/qt3 /usr/lib/qt /usr/share/qt3"
1168fi
1169if test $kde_qtver = 2; then
1170   kde_qt_dirs="$QTDIR /usr/lib/qt2 /usr/lib/qt"
1171fi
1172if test $kde_qtver = 1; then
1173   kde_qt_dirs="$QTDIR /usr/lib/qt"
1174fi
1175])
1176
1177AC_DEFUN(KDE_CHECK_QT_DIRECT,
1178[
1179AC_REQUIRE([KDE_USE_QT])
1180AC_MSG_CHECKING([if Qt compiles without flags])
1181AC_CACHE_VAL(kde_cv_qt_direct,
1182[
1183AC_LANG_SAVE
1184AC_LANG_CPLUSPLUS
1185ac_LD_LIBRARY_PATH_safe=$LD_LIBRARY_PATH
1186ac_LIBRARY_PATH="$LIBRARY_PATH"
1187ac_cxxflags_safe="$CXXFLAGS"
1188ac_ldflags_safe="$LDFLAGS"
1189ac_libs_safe="$LIBS"
1190
1191CXXFLAGS="$CXXFLAGS -I$qt_includes"
1192LDFLAGS="$LDFLAGS $X_LDFLAGS"
1193if test "x$kde_use_qt_emb" != "xyes"; then
1194LIBS="$LIBQT -lXext -lX11 $LIBSOCKET"
1195else
1196LIBS="$LIBQT $LIBSOCKET"
1197fi
1198LD_LIBRARY_PATH=
1199export LD_LIBRARY_PATH
1200LIBRARY_PATH=
1201export LIBRARY_PATH
1202
1203KDE_PRINT_QT_PROGRAM
1204
1205if AC_TRY_EVAL(ac_link) && test -s conftest; then
1206  kde_cv_qt_direct="yes"
1207else
1208  kde_cv_qt_direct="no"
1209  echo "configure: failed program was:" >&AC_FD_CC
1210  cat conftest.$ac_ext >&AC_FD_CC
1211fi
1212
1213rm -f conftest*
1214CXXFLAGS="$ac_cxxflags_safe"
1215LDFLAGS="$ac_ldflags_safe"
1216LIBS="$ac_libs_safe"
1217
1218LD_LIBRARY_PATH="$ac_LD_LIBRARY_PATH_safe"
1219export LD_LIBRARY_PATH
1220LIBRARY_PATH="$ac_LIBRARY_PATH"
1221export LIBRARY_PATH
1222AC_LANG_RESTORE
1223])
1224
1225if test "$kde_cv_qt_direct" = "yes"; then
1226  AC_MSG_RESULT(yes)
1227  $1
1228else
1229  AC_MSG_RESULT(no)
1230  $2
1231fi
1232])
1233
1234dnl ------------------------------------------------------------------------
1235dnl Try to find the Qt headers and libraries.
1236dnl $(QT_LDFLAGS) will be -Lqtliblocation (if needed)
1237dnl and $(QT_INCLUDES) will be -Iqthdrlocation (if needed)
1238dnl ------------------------------------------------------------------------
1239dnl
1240AC_DEFUN(AC_PATH_QT_1_3,
1241[
1242AC_REQUIRE([K_PATH_X])
1243AC_REQUIRE([KDE_USE_QT])
1244AC_REQUIRE([KDE_CHECK_LIB64])
1245
1246dnl ------------------------------------------------------------------------
1247dnl Add configure flag to enable linking to MT version of Qt library.
1248dnl ------------------------------------------------------------------------
1249
1250AC_ARG_ENABLE(
1251  mt,
1252  [  --disable-mt            link to non-threaded Qt (deprecated)],
1253  kde_use_qt_mt=$enableval,
1254  [
1255    if test $kde_qtver = 3; then
1256      kde_use_qt_mt=yes
1257    else
1258      kde_use_qt_mt=no
1259    fi
1260  ]
1261)
1262
1263USING_QT_MT=""
1264
1265dnl ------------------------------------------------------------------------
1266dnl If we not get --disable-qt-mt then adjust some vars for the host.
1267dnl ------------------------------------------------------------------------
1268
1269KDE_MT_LDFLAGS=
1270KDE_MT_LIBS=
1271if test "x$kde_use_qt_mt" = "xyes"; then
1272  KDE_CHECK_THREADING
1273  if test "x$kde_use_threading" = "xyes"; then
1274    CPPFLAGS="$USE_THREADS -DQT_THREAD_SUPPORT $CPPFLAGS"
1275    KDE_MT_LDFLAGS="$USE_THREADS"
1276    KDE_MT_LIBS="$LIBPTHREAD"
1277  else
1278    kde_use_qt_mt=no
1279  fi
1280fi
1281AC_SUBST(KDE_MT_LDFLAGS)
1282AC_SUBST(KDE_MT_LIBS)
1283
1284kde_qt_was_given=yes
1285
1286dnl ------------------------------------------------------------------------
1287dnl If we haven't been told how to link to Qt, we work it out for ourselves.
1288dnl ------------------------------------------------------------------------
1289if test -z "$LIBQT_GLOB"; then
1290  if test "x$kde_use_qt_emb" = "xyes"; then
1291    LIBQT_GLOB="libqte.*"
1292  else
1293    LIBQT_GLOB="libqt.*"
1294  fi
1295fi
1296
1297if test -z "$LIBQT"; then
1298dnl ------------------------------------------------------------
1299dnl If we got --enable-embedded then adjust the Qt library name.
1300dnl ------------------------------------------------------------
1301  if test "x$kde_use_qt_emb" = "xyes"; then
1302    qtlib="qte"
1303  else
1304    qtlib="qt"
1305  fi
1306
1307  kde_int_qt="-l$qtlib"
1308else
1309  kde_int_qt="$LIBQT"
1310  kde_lib_qt_set=yes
1311fi
1312
1313if test -z "$LIBQPE"; then
1314dnl ------------------------------------------------------------
1315dnl If we got --enable-palmtop then add -lqpe to the link line
1316dnl ------------------------------------------------------------
1317  if test "x$kde_use_qt_emb" = "xyes"; then
1318    if test "x$kde_use_qt_emb_palm" = "xyes"; then
1319      LIB_QPE="-lqpe"
1320    else
1321      LIB_QPE=""
1322    fi
1323  else
1324    LIB_QPE=""
1325  fi
1326fi
1327
1328dnl ------------------------------------------------------------------------
1329dnl If we got --enable-qt-mt then adjust the Qt library name for the host.
1330dnl ------------------------------------------------------------------------
1331
1332if test "x$kde_use_qt_mt" = "xyes"; then
1333  if test -z "$LIBQT"; then
1334    LIBQT="-l$qtlib-mt"
1335    kde_int_qt="-l$qtlib-mt"
1336  else
1337    LIBQT="$qtlib-mt"
1338    kde_int_qt="$qtlib-mt"
1339  fi
1340  LIBQT_GLOB="lib$qtlib-mt.*"
1341  USING_QT_MT="using -mt"
1342else
1343  LIBQT="-l$qtlib"
1344fi
1345
1346if test $kde_qtver != 1; then
1347
1348  AC_REQUIRE([AC_FIND_PNG])
1349  AC_REQUIRE([AC_FIND_JPEG])
1350  LIBQT="$LIBQT $LIBPNG $LIBJPEG"
1351fi
1352
1353if test $kde_qtver = 3; then
1354  AC_REQUIRE([KDE_CHECK_LIBDL])
1355  LIBQT="$LIBQT $LIBDL"
1356fi
1357
1358AC_MSG_CHECKING([for Qt])
1359
1360if test "x$kde_use_qt_emb" != "xyes"; then
1361LIBQT="$LIBQT $X_PRE_LIBS -lXext -lX11 $LIBSM $LIBSOCKET"
1362fi
1363ac_qt_includes=NO ac_qt_libraries=NO ac_qt_bindir=NO
1364qt_libraries=""
1365qt_includes=""
1366AC_ARG_WITH(qt-dir,
1367    [  --with-qt-dir=DIR       where the root of Qt is installed ],
1368    [  ac_qt_includes="$withval"/include
1369       ac_qt_libraries="$withval"/lib${kdelibsuff}
1370       ac_qt_bindir="$withval"/bin
1371    ])
1372
1373AC_ARG_WITH(qt-includes,
1374    [  --with-qt-includes=DIR  where the Qt includes are. ],
1375    [
1376       ac_qt_includes="$withval"
1377    ])
1378
1379kde_qt_libs_given=no
1380
1381AC_ARG_WITH(qt-libraries,
1382    [  --with-qt-libraries=DIR where the Qt library is installed.],
1383    [  ac_qt_libraries="$withval"
1384       kde_qt_libs_given=yes
1385    ])
1386
1387AC_CACHE_VAL(ac_cv_have_qt,
1388[#try to guess Qt locations
1389
1390qt_incdirs=""
1391for dir in $kde_qt_dirs; do
1392   qt_incdirs="$qt_incdirs $dir/include $dir"
1393done
1394qt_incdirs="$QTINC $qt_incdirs /usr/local/qt/include /usr/include/qt /usr/include /usr/X11R6/include/X11/qt /usr/X11R6/include/qt /usr/X11R6/include/qt2 $x_includes"
1395if test ! "$ac_qt_includes" = "NO"; then
1396   qt_incdirs="$ac_qt_includes $qt_incdirs"
1397fi
1398
1399if test "$kde_qtver" != "1"; then
1400  kde_qt_header=qstyle.h
1401else
1402  kde_qt_header=qglobal.h
1403fi
1404
1405AC_FIND_FILE($kde_qt_header, $qt_incdirs, qt_incdir)
1406ac_qt_includes="$qt_incdir"
1407
1408qt_libdirs=""
1409for dir in $kde_qt_dirs; do
1410   qt_libdirs="$qt_libdirs $dir/lib${kdelibsuff} $dir"
1411done
1412qt_libdirs="$QTLIB $qt_libdirs /usr/X11R6/lib /usr/lib /usr/local/qt/lib $x_libraries"
1413if test ! "$ac_qt_libraries" = "NO"; then
1414  qt_libdir=$ac_qt_libraries
1415else
1416  qt_libdirs="$ac_qt_libraries $qt_libdirs"
1417  # if the Qt was given, the chance is too big that libqt.* doesn't exist
1418  qt_libdir=NONE
1419  for dir in $qt_libdirs; do
1420    try="ls -1 $dir/${LIBQT_GLOB}"
1421    if test -n "`$try 2> /dev/null`"; then qt_libdir=$dir; break; else echo "tried $dir" >&AC_FD_CC ; fi
1422  done
1423fi
1424
1425ac_qt_libraries="$qt_libdir"
1426
1427AC_LANG_SAVE
1428AC_LANG_CPLUSPLUS
1429
1430ac_cxxflags_safe="$CXXFLAGS"
1431ac_ldflags_safe="$LDFLAGS"
1432ac_libs_safe="$LIBS"
1433
1434CXXFLAGS="$CXXFLAGS -I$qt_incdir $all_includes"
1435LDFLAGS="$LDFLAGS -L$qt_libdir $all_libraries $USER_LDFLAGS $KDE_MT_LDFLAGS"
1436LIBS="$LIBS $LIBQT $KDE_MT_LIBS"
1437
1438KDE_PRINT_QT_PROGRAM
1439
1440if AC_TRY_EVAL(ac_link) && test -s conftest; then
1441  rm -f conftest*
1442else
1443  echo "configure: failed program was:" >&AC_FD_CC
1444  cat conftest.$ac_ext >&AC_FD_CC
1445  ac_qt_libraries="NO"
1446fi
1447rm -f conftest*
1448CXXFLAGS="$ac_cxxflags_safe"
1449LDFLAGS="$ac_ldflags_safe"
1450LIBS="$ac_libs_safe"
1451
1452AC_LANG_RESTORE
1453if test "$ac_qt_includes" = NO || test "$ac_qt_libraries" = NO; then
1454  ac_cv_have_qt="have_qt=no"
1455  ac_qt_notfound=""
1456  missing_qt_mt=""
1457  if test "$ac_qt_includes" = NO; then
1458    if test "$ac_qt_libraries" = NO; then
1459      ac_qt_notfound="(headers and libraries)";
1460    else
1461      ac_qt_notfound="(headers)";
1462    fi
1463  else
1464    if test "x$kde_use_qt_mt" = "xyes"; then
1465       missing_qt_mt="
1466Make sure that you have compiled Qt with thread support!"
1467       ac_qt_notfound="(library $qtlib-mt)";
1468    else
1469       ac_qt_notfound="(library $qtlib)";
1470    fi
1471  fi
1472
1473  AC_MSG_ERROR([Qt ($kde_qt_minversion) $ac_qt_notfound not found. Please check your installation!
1474For more details about this problem, look at the end of config.log.$missing_qt_mt])
1475else
1476  have_qt="yes"
1477fi
1478])
1479
1480eval "$ac_cv_have_qt"
1481
1482if test "$have_qt" != yes; then
1483  AC_MSG_RESULT([$have_qt]);
1484else
1485  ac_cv_have_qt="have_qt=yes \
1486    ac_qt_includes=$ac_qt_includes ac_qt_libraries=$ac_qt_libraries"
1487  AC_MSG_RESULT([libraries $ac_qt_libraries, headers $ac_qt_includes $USING_QT_MT])
1488
1489  qt_libraries="$ac_qt_libraries"
1490  qt_includes="$ac_qt_includes"
1491fi
1492
1493if test ! "$kde_qt_libs_given" = "yes"; then
1494KDE_CHECK_QT_DIRECT(qt_libraries= ,[])
1495fi
1496
1497AC_SUBST(qt_libraries)
1498AC_SUBST(qt_includes)
1499
1500if test "$qt_includes" = "$x_includes" || test -z "$qt_includes"; then
1501 QT_INCLUDES=""
1502else
1503 QT_INCLUDES="-I$qt_includes"
1504 all_includes="$QT_INCLUDES $all_includes"
1505fi
1506
1507if test "$qt_libraries" = "$x_libraries" || test -z "$qt_libraries"; then
1508 QT_LDFLAGS=""
1509else
1510 QT_LDFLAGS="-L$qt_libraries"
1511 all_libraries="$all_libraries $QT_LDFLAGS"
1512fi
1513test -z "$KDE_MT_LDFLAGS" || all_libraries="$all_libraries $KDE_MT_LDFLAGS"
1514
1515AC_SUBST(QT_INCLUDES)
1516AC_SUBST(QT_LDFLAGS)
1517AC_PATH_QT_MOC_UIC
1518
1519KDE_CHECK_QT_JPEG
1520
1521if test "x$kde_use_qt_emb" != "xyes"; then
1522LIB_QT="$kde_int_qt $LIBJPEG_QT "'$(LIBPNG) -lXext $(LIB_X11) $(LIBSM)'
1523else
1524LIB_QT="$kde_int_qt $LIBJPEG_QT "'$(LIBPNG)'
1525fi
1526test -z "$KDE_MT_LIBS" || LIB_QT="$LIB_QT $KDE_MT_LIBS"
1527
1528AC_SUBST(LIB_QT)
1529AC_SUBST(LIB_QPE)
1530
1531AC_SUBST(kde_qtver)
1532])
1533
1534AC_DEFUN(AC_PATH_QT,
1535[
1536AC_PATH_QT_1_3
1537])
1538
1539AC_DEFUN(KDE_CHECK_UIC_PLUGINS,
1540[
1541AC_REQUIRE([AC_PATH_QT_MOC_UIC])
1542
1543if test x$ac_uic_supports_libpath = xyes; then
1544
1545AC_MSG_CHECKING([if UIC has KDE plugins available])
1546AC_CACHE_VAL(kde_cv_uic_plugins,
1547[
1548cat > actest.ui << EOF
1549<!DOCTYPE UI><UI version="3.0" stdsetdef="1">
1550<class>NewConnectionDialog</class>
1551<widget class="QDialog">
1552   <widget class="KLineEdit">
1553        <property name="name">
1554           <cstring>testInput</cstring>
1555        </property>
1556   </widget>
1557</widget>
1558</UI>
1559EOF
1560
1561
1562
1563kde_cv_uic_plugins=no
1564kde_line="$UIC_PATH -L $kde_widgetdir"
1565if test x$ac_uic_supports_nounload = xyes; then
1566   kde_line="$kde_line -nounload"
1567fi
1568kde_line="$kde_line -impl actest.h actest.ui > actest.cpp"
1569if AC_TRY_EVAL(kde_line); then
1570	if test -f actest.cpp && grep klineedit actest.cpp > /dev/null; then
1571		kde_cv_uic_plugins=yes
1572	fi
1573fi
1574rm -f actest.ui actest.cpp
1575])
1576
1577if test "$kde_cv_uic_plugins" = yes; then
1578	AC_MSG_RESULT([yes])
1579else
1580	AC_MSG_ERROR([not found - you need to install kdelibs first.])
1581fi
1582fi
1583])
1584
1585AC_DEFUN(KDE_CHECK_FINAL,
1586[
1587  AC_ARG_ENABLE(final, [  --enable-final          build size optimized apps (experimental - needs lots of memory)],
1588	kde_use_final=$enableval, kde_use_final=no)
1589
1590  KDE_COMPILER_REPO
1591  if test "x$kde_use_final" = "xyes"; then
1592      KDE_USE_FINAL_TRUE=""
1593      KDE_USE_FINAL_FALSE="#"
1594   else
1595      KDE_USE_FINAL_TRUE="#"
1596      KDE_USE_FINAL_FALSE=""
1597  fi
1598  AC_SUBST(KDE_USE_FINAL_TRUE)
1599  AC_SUBST(KDE_USE_FINAL_FALSE)
1600
1601  AC_ARG_ENABLE(closure, [  --disable-closure       don't delay template instantiation],
1602  	kde_use_closure=$enableval, kde_use_closure=yes)
1603
1604  if test "x$kde_use_closure" = "xyes"; then
1605       KDE_USE_CLOSURE_TRUE=""
1606       KDE_USE_CLOSURE_FALSE="#"
1607#       CXXFLAGS="$CXXFLAGS $REPO"
1608  else
1609       KDE_USE_CLOSURE_TRUE="#"
1610       KDE_USE_CLOSURE_FALSE=""
1611  fi
1612  AC_SUBST(KDE_USE_CLOSURE_TRUE)
1613  AC_SUBST(KDE_USE_CLOSURE_FALSE)
1614])
1615
1616dnl ------------------------------------------------------------------------
1617dnl Now, the same with KDE
1618dnl $(KDE_LDFLAGS) will be the kdeliblocation (if needed)
1619dnl and $(kde_includes) will be the kdehdrlocation (if needed)
1620dnl ------------------------------------------------------------------------
1621dnl
1622AC_DEFUN(AC_BASE_PATH_KDE,
1623[
1624AC_PREREQ([2.13])
1625AC_REQUIRE([AC_PATH_QT])dnl
1626AC_REQUIRE([KDE_CHECK_LIB64])
1627
1628AC_CHECK_RPATH
1629AC_MSG_CHECKING([for KDE])
1630
1631if test "${prefix}" != NONE; then
1632  kde_includes=${prefix}/include
1633  ac_kde_includes=$prefix/include
1634
1635  if test "${exec_prefix}" != NONE; then
1636     kde_libraries=${libdir}
1637     ac_kde_libraries=$libdir
1638     if test "$ac_kde_libraries" = '${exec_prefix}/lib'${kdelibsuff}; then
1639	ac_kde_libraries=$exec_prefix/lib${kdelibsuff}
1640     fi
1641  else
1642     kde_libraries=${prefix}/lib${kdelibsuff}
1643     ac_kde_libraries=$prefix/lib${kdelibsuff}
1644  fi
1645else
1646  ac_kde_includes=
1647  ac_kde_libraries=
1648  kde_libraries=""
1649  kde_includes=""
1650fi
1651
1652AC_CACHE_VAL(ac_cv_have_kde,
1653[#try to guess kde locations
1654
1655if test "$kde_qtver" = 1; then
1656  kde_check_header="ksock.h"
1657  kde_check_lib="libkdecore.la"
1658else
1659  kde_check_header="ksharedptr.h"
1660  kde_check_lib="libkio.la"
1661fi
1662
1663if test -z "$1"; then
1664
1665kde_incdirs="/usr/lib/kde/include /usr/local/kde/include /usr/local/include /usr/kde/include /usr/include/kde /usr/include /opt/kde3/include /opt/kde/include $x_includes $qt_includes"
1666test -n "$KDEDIR" && kde_incdirs="$KDEDIR/include $KDEDIR/include/kde $KDEDIR $kde_incdirs"
1667kde_incdirs="$ac_kde_includes $kde_incdirs"
1668AC_FIND_FILE($kde_check_header, $kde_incdirs, kde_incdir)
1669ac_kde_includes="$kde_incdir"
1670
1671if test -n "$ac_kde_includes" && test ! -r "$ac_kde_includes/$kde_check_header"; then
1672  AC_MSG_ERROR([
1673in the prefix, you've chosen, are no KDE headers installed. This will fail.
1674So, check this please and use another prefix!])
1675fi
1676
1677kde_libdirs="/usr/lib/kde/lib${kdelibsuff} /usr/local/kde/lib${kdelibsuff} /usr/kde/lib${kdelibsuff} /usr/lib${kdelibsuff}/kde /usr/lib${kdelibsuff}/kde3 /usr/lib${kdelibsuff} /usr/X11R6/lib${kdelibsuff} /usr/local/lib${kdelibsuff} /opt/kde3/lib${kdelibsuff} /opt/kde/lib${kdelibsuff} /usr/X11R6/kde/lib${kdelibsuff}"
1678test -n "$KDEDIR" && kde_libdirs="$KDEDIR/lib${kdelibsuff} $KDEDIR $kde_libdirs"
1679kde_libdirs="$ac_kde_libraries $libdir $kde_libdirs"
1680AC_FIND_FILE($kde_check_lib, $kde_libdirs, kde_libdir)
1681ac_kde_libraries="$kde_libdir"
1682
1683kde_widgetdir=NO
1684dnl this might be somewhere else
1685AC_FIND_FILE("kde3/plugins/designer/kdewidgets.la", $kde_libdirs, kde_widgetdir)
1686
1687if test -n "$ac_kde_libraries" && test ! -r "$ac_kde_libraries/$kde_check_lib"; then
1688AC_MSG_ERROR([
1689in the prefix, you've chosen, are no KDE libraries installed. This will fail.
1690So, check this please and use another prefix!])
1691fi
1692
1693if test -n "$kde_widgetdir" && test ! -r "$kde_widgetdir/kde3/plugins/designer/kdewidgets.la"; then
1694AC_MSG_ERROR([
1695I can't find the designer plugins. These are required and should have been installed
1696by kdelibs])
1697fi
1698
1699if test -n "$kde_widgetdir"; then
1700    kde_widgetdir="$kde_widgetdir/kde3/plugins/designer"
1701fi
1702
1703
1704if test "$ac_kde_includes" = NO || test "$ac_kde_libraries" = NO || test "$kde_widgetdir" = NO; then
1705  ac_cv_have_kde="have_kde=no"
1706else
1707  ac_cv_have_kde="have_kde=yes \
1708    ac_kde_includes=$ac_kde_includes ac_kde_libraries=$ac_kde_libraries"
1709fi
1710
1711else dnl test -z $1
1712
1713  ac_cv_have_kde="have_kde=no"
1714
1715fi
1716])dnl
1717
1718eval "$ac_cv_have_kde"
1719
1720if test "$have_kde" != "yes"; then
1721 if test "${prefix}" = NONE; then
1722  ac_kde_prefix="$ac_default_prefix"
1723 else
1724  ac_kde_prefix="$prefix"
1725 fi
1726 if test "$exec_prefix" = NONE; then
1727  ac_kde_exec_prefix="$ac_kde_prefix"
1728  AC_MSG_RESULT([will be installed in $ac_kde_prefix])
1729 else
1730  ac_kde_exec_prefix="$exec_prefix"
1731  AC_MSG_RESULT([will be installed in $ac_kde_prefix and $ac_kde_exec_prefix])
1732 fi
1733
1734 kde_libraries="${libdir}"
1735 kde_includes=${ac_kde_prefix}/include
1736
1737else
1738  ac_cv_have_kde="have_kde=yes \
1739    ac_kde_includes=$ac_kde_includes ac_kde_libraries=$ac_kde_libraries"
1740  AC_MSG_RESULT([libraries $ac_kde_libraries, headers $ac_kde_includes])
1741
1742  kde_libraries="$ac_kde_libraries"
1743  kde_includes="$ac_kde_includes"
1744fi
1745AC_SUBST(kde_libraries)
1746AC_SUBST(kde_includes)
1747
1748if test "$kde_includes" = "$x_includes" || test "$kde_includes" = "$qt_includes"  || test "$kde_includes" = "/usr/include"; then
1749 KDE_INCLUDES=""
1750else
1751 KDE_INCLUDES="-I$kde_includes"
1752 all_includes="$KDE_INCLUDES $all_includes"
1753fi
1754
1755KDE_LDFLAGS="-L$kde_libraries"
1756if test ! "$kde_libraries" = "$x_libraries" && test ! "$kde_libraries" = "$qt_libraries" ; then
1757 all_libraries="$all_libraries $KDE_LDFLAGS"
1758fi
1759
1760AC_SUBST(KDE_LDFLAGS)
1761AC_SUBST(KDE_INCLUDES)
1762
1763AC_REQUIRE([KDE_CHECK_EXTRA_LIBS])
1764
1765all_libraries="$all_libraries $USER_LDFLAGS"
1766all_includes="$all_includes $USER_INCLUDES"
1767AC_SUBST(all_includes)
1768AC_SUBST(all_libraries)
1769
1770if test -z "$1"; then
1771KDE_CHECK_UIC_PLUGINS
1772fi
1773
1774ac_kde_libraries="$kde_libdir"
1775
1776AC_SUBST(AUTODIRS)
1777
1778
1779])
1780
1781AC_DEFUN(KDE_CHECK_EXTRA_LIBS,
1782[
1783AC_MSG_CHECKING(for extra includes)
1784AC_ARG_WITH(extra-includes, [  --with-extra-includes=DIR
1785                          adds non standard include paths],
1786  kde_use_extra_includes="$withval",
1787  kde_use_extra_includes=NONE
1788)
1789kde_extra_includes=
1790if test -n "$kde_use_extra_includes" && \
1791   test "$kde_use_extra_includes" != "NONE"; then
1792
1793   ac_save_ifs=$IFS
1794   IFS=':'
1795   for dir in $kde_use_extra_includes; do
1796     kde_extra_includes="$kde_extra_includes $dir"
1797     USER_INCLUDES="$USER_INCLUDES -I$dir"
1798   done
1799   IFS=$ac_save_ifs
1800   kde_use_extra_includes="added"
1801else
1802   kde_use_extra_includes="no"
1803fi
1804AC_SUBST(USER_INCLUDES)
1805
1806AC_MSG_RESULT($kde_use_extra_includes)
1807
1808kde_extra_libs=
1809AC_MSG_CHECKING(for extra libs)
1810AC_ARG_WITH(extra-libs, [  --with-extra-libs=DIR   adds non standard library paths],
1811  kde_use_extra_libs=$withval,
1812  kde_use_extra_libs=NONE
1813)
1814if test -n "$kde_use_extra_libs" && \
1815   test "$kde_use_extra_libs" != "NONE"; then
1816
1817   ac_save_ifs=$IFS
1818   IFS=':'
1819   for dir in $kde_use_extra_libs; do
1820     kde_extra_libs="$kde_extra_libs $dir"
1821     KDE_EXTRA_RPATH="$KDE_EXTRA_RPATH -R $dir"
1822     USER_LDFLAGS="$USER_LDFLAGS -L$dir"
1823   done
1824   IFS=$ac_save_ifs
1825   kde_use_extra_libs="added"
1826else
1827   kde_use_extra_libs="no"
1828fi
1829
1830AC_SUBST(USER_LDFLAGS)
1831
1832AC_MSG_RESULT($kde_use_extra_libs)
1833
1834])
1835
1836AC_DEFUN(KDE_1_CHECK_PATH_HEADERS,
1837[
1838    AC_MSG_CHECKING([for KDE headers installed])
1839    AC_LANG_SAVE
1840    AC_LANG_CPLUSPLUS
1841cat > conftest.$ac_ext <<EOF
1842#ifdef STDC_HEADERS
1843# include <stdlib.h>
1844#endif
1845#include <stdio.h>
1846#include "confdefs.h"
1847#include <kapp.h>
1848
1849int main() {
1850    printf("kde_htmldir=\\"%s\\"\n", KApplication::kde_htmldir().data());
1851    printf("kde_appsdir=\\"%s\\"\n", KApplication::kde_appsdir().data());
1852    printf("kde_icondir=\\"%s\\"\n", KApplication::kde_icondir().data());
1853    printf("kde_sounddir=\\"%s\\"\n", KApplication::kde_sounddir().data());
1854    printf("kde_datadir=\\"%s\\"\n", KApplication::kde_datadir().data());
1855    printf("kde_locale=\\"%s\\"\n", KApplication::kde_localedir().data());
1856    printf("kde_cgidir=\\"%s\\"\n", KApplication::kde_cgidir().data());
1857    printf("kde_confdir=\\"%s\\"\n", KApplication::kde_configdir().data());
1858    printf("kde_mimedir=\\"%s\\"\n", KApplication::kde_mimedir().data());
1859    printf("kde_toolbardir=\\"%s\\"\n", KApplication::kde_toolbardir().data());
1860    printf("kde_wallpaperdir=\\"%s\\"\n",
1861	KApplication::kde_wallpaperdir().data());
1862    printf("kde_bindir=\\"%s\\"\n", KApplication::kde_bindir().data());
1863    printf("kde_partsdir=\\"%s\\"\n", KApplication::kde_partsdir().data());
1864    printf("kde_servicesdir=\\"/tmp/dummy\\"\n");
1865    printf("kde_servicetypesdir=\\"/tmp/dummy\\"\n");
1866    printf("kde_moduledir=\\"/tmp/dummy\\"\n");
1867    printf("kde_styledir=\\"/tmp/dummy\\"\n");
1868    printf("kde_widgetdir=\\"/tmp/dummy\\"\n");
1869    return 0;
1870    }
1871EOF
1872
1873 ac_compile='${CXX-g++} -c $CXXFLAGS $all_includes $CPPFLAGS conftest.$ac_ext'
1874 if AC_TRY_EVAL(ac_compile); then
1875   AC_MSG_RESULT(yes)
1876 else
1877   AC_MSG_ERROR([your system is not able to compile a small KDE application!
1878Check, if you installed the KDE header files correctly.
1879For more details about this problem, look at the end of config.log.])
1880  fi
1881
1882  AC_LANG_RESTORE
1883])
1884
1885AC_DEFUN(KDE_CHECK_KDEQTADDON,
1886[
1887AC_MSG_CHECKING(for kde-qt-addon)
1888AC_CACHE_VAL(kde_cv_have_kdeqtaddon,
1889[
1890 kde_ldflags_safe="$LDFLAGS"
1891 kde_libs_safe="$LIBS"
1892 kde_cxxflags_safe="$CXXFLAGS"
1893
1894 LIBS="-lkde-qt-addon $LIBQT $LIBS"
1895 CXXFLAGS="$CXXFLAGS -I$prefix/include -I$prefix/include/kde $all_includes"
1896 LDFLAGS="$LDFLAGS $all_libraries $USER_LDFLAGS"
1897
1898 AC_TRY_LINK([
1899   #include <qdom.h>
1900 ],
1901 [
1902   QDomDocument doc;
1903 ],
1904  kde_cv_have_kdeqtaddon=yes,
1905  kde_cv_have_kdeqtaddon=no
1906 )
1907
1908 LDFLAGS=$kde_ldflags_safe
1909 LIBS=$kde_libs_safe
1910 CXXFLAGS=$kde_cxxflags_safe
1911])
1912
1913AC_MSG_RESULT($kde_cv_have_kdeqtaddon)
1914
1915if test "$kde_cv_have_kdeqtaddon" = "no"; then
1916  AC_MSG_ERROR([Can't find libkde-qt-addon. You need to install it first.
1917It is a separate package (and CVS module) named kde-qt-addon.])
1918fi
1919])
1920
1921AC_DEFUN(KDE_CHECK_KIMGIO,
1922[
1923   AC_REQUIRE([AC_BASE_PATH_KDE])
1924   AC_REQUIRE([KDE_CHECK_EXTRA_LIBS])
1925   AC_REQUIRE([AC_FIND_TIFF])
1926   AC_REQUIRE([AC_FIND_JPEG])
1927   AC_REQUIRE([AC_FIND_PNG])
1928   AC_REQUIRE([KDE_CREATE_LIBS_ALIASES])
1929
1930   if test "$1" = "existance"; then
1931     AC_LANG_SAVE
1932     AC_LANG_CPLUSPLUS
1933     kde_save_LIBS="$LIBS"
1934     LIBS="$LIBS $all_libraries $LIBJPEG $LIBTIFF $LIBPNG $LIBQT -lm"
1935     AC_CHECK_LIB(kimgio, kimgioRegister, [
1936      LIBKIMGIO_EXISTS=yes],LIBKIMGIO_EXISTS=no)
1937     LIBS="$kde_save_LIBS"
1938     AC_LANG_RESTORE
1939   else
1940     LIBKIMGIO_EXISTS=yes
1941   fi
1942
1943   if test "$LIBKIMGIO_EXISTS" = "yes"; then
1944     LIB_KIMGIO='-lkimgio'
1945   else
1946     LIB_KIMGIO=''
1947   fi
1948   AC_SUBST(LIB_KIMGIO)
1949])
1950
1951AC_DEFUN(KDE_CREATE_LIBS_ALIASES,
1952[
1953   AC_REQUIRE([KDE_MISC_TESTS])
1954   AC_REQUIRE([KDE_CHECK_LIBDL])
1955   AC_REQUIRE([K_PATH_X])
1956
1957if test $kde_qtver = 3; then
1958   AC_SUBST(LIB_KDECORE, "-lkdecore")
1959   AC_SUBST(LIB_KDEUI, "-lkdeui")
1960   AC_SUBST(LIB_KIO, "-lkio")
1961   AC_SUBST(LIB_SMB, "-lsmb")
1962   AC_SUBST(LIB_KAB, "-lkab")
1963   AC_SUBST(LIB_KABC, "-lkabc")
1964   AC_SUBST(LIB_KHTML, "-lkhtml")
1965   AC_SUBST(LIB_KSPELL, "-lkspell")
1966   AC_SUBST(LIB_KPARTS, "-lkparts")
1967   AC_SUBST(LIB_KDEPRINT, "-lkdeprint")
1968# these are for backward compatibility
1969   AC_SUBST(LIB_KSYCOCA, "-lkio")
1970   AC_SUBST(LIB_KFILE, "-lkio")
1971elif test $kde_qtver = 2; then
1972   AC_SUBST(LIB_KDECORE, "-lkdecore")
1973   AC_SUBST(LIB_KDEUI, "-lkdeui")
1974   AC_SUBST(LIB_KIO, "-lkio")
1975   AC_SUBST(LIB_KSYCOCA, "-lksycoca")
1976   AC_SUBST(LIB_SMB, "-lsmb")
1977   AC_SUBST(LIB_KFILE, "-lkfile")
1978   AC_SUBST(LIB_KAB, "-lkab")
1979   AC_SUBST(LIB_KHTML, "-lkhtml")
1980   AC_SUBST(LIB_KSPELL, "-lkspell")
1981   AC_SUBST(LIB_KPARTS, "-lkparts")
1982   AC_SUBST(LIB_KDEPRINT, "-lkdeprint")
1983else
1984   AC_SUBST(LIB_KDECORE, "-lkdecore -lXext $(LIB_QT)")
1985   AC_SUBST(LIB_KDEUI, "-lkdeui $(LIB_KDECORE)")
1986   AC_SUBST(LIB_KFM, "-lkfm $(LIB_KDECORE)")
1987   AC_SUBST(LIB_KFILE, "-lkfile $(LIB_KFM) $(LIB_KDEUI)")
1988   AC_SUBST(LIB_KAB, "-lkab $(LIB_KIMGIO) $(LIB_KDECORE)")
1989fi
1990])
1991
1992AC_DEFUN(AC_PATH_KDE,
1993[
1994  AC_BASE_PATH_KDE
1995  AC_ARG_ENABLE(path-check, [  --disable-path-check    don't try to find out, where to install],
1996  [
1997  if test "$enableval" = "no";
1998    then ac_use_path_checking="default"
1999    else ac_use_path_checking=""
2000  fi
2001  ],
2002  [
2003  if test "$kde_qtver" = 1;
2004    then ac_use_path_checking=""
2005    else ac_use_path_checking="default"
2006  fi
2007  ]
2008  )
2009
2010  AC_CREATE_KFSSTND($ac_use_path_checking)
2011
2012  AC_SUBST_KFSSTND
2013  KDE_CREATE_LIBS_ALIASES
2014])
2015
2016dnl KDE_CHECK_FUNC_EXT(<func>, [headers], [sample-use], [C prototype], [autoheader define], [call if found])
2017AC_DEFUN(KDE_CHECK_FUNC_EXT,
2018[
2019AC_MSG_CHECKING(for $1)
2020AC_CACHE_VAL(kde_cv_func_$1,
2021[
2022AC_LANG_SAVE
2023AC_LANG_CPLUSPLUS
2024save_CXXFLAGS="$CXXFLAGS"
2025kde_safe_LIBS="$LIBS"
2026LIBS="$LIBS $X_EXTRA_LIBS"
2027if test "$GXX" = "yes"; then
2028  CXXFLAGS="$CXXFLAGS -pedantic-errors"
2029fi
2030AC_TRY_COMPILE([
2031$2
2032],
2033[
2034$3
2035],
2036kde_cv_func_$1=yes,
2037kde_cv_func_$1=no)
2038CXXFLAGS="$save_CXXFLAGS"
2039LIBS=$kde_safe_LIBS
2040AC_LANG_RESTORE
2041])
2042
2043AC_MSG_RESULT($kde_cv_func_$1)
2044
2045AC_MSG_CHECKING([if $1 needs custom prototype])
2046AC_CACHE_VAL(kde_cv_proto_$1,
2047[
2048if test "x$kde_cv_func_$1" = xyes; then
2049  kde_cv_proto_$1=no
2050else
2051  case "$1" in
2052	setenv|unsetenv|usleep|random|srandom|seteuid|mkstemps|mkstemp|revoke|vsnprintf|strlcpy|strlcat)
2053		kde_cv_proto_$1="yes - in libkdefakes"
2054		;;
2055	*)
2056		kde_cv_proto_$1=unknown
2057		;;
2058  esac
2059fi
2060
2061if test "x$kde_cv_proto_$1" = xunknown; then
2062
2063AC_LANG_SAVE
2064AC_LANG_CPLUSPLUS
2065  kde_safe_libs=$LIBS
2066  LIBS="$LIBS $X_EXTRA_LIBS"
2067  AC_TRY_LINK([
2068$2
2069
2070extern "C" $4;
2071],
2072[
2073$3
2074],
2075[ kde_cv_func_$1=yes
2076  kde_cv_proto_$1=yes ],
2077  [kde_cv_proto_$1="$1 unavailable"]
2078)
2079LIBS=$kde_safe_libs
2080AC_LANG_RESTORE
2081fi
2082])
2083AC_MSG_RESULT($kde_cv_proto_$1)
2084
2085if test "x$kde_cv_func_$1" = xyes; then
2086  AC_DEFINE(HAVE_$5, 1, [Define if you have $1])
2087  $6
2088fi
2089if test "x$kde_cv_proto_$1" = xno; then
2090  AC_DEFINE(HAVE_$5_PROTO, 1,
2091  [Define if you have the $1 prototype])
2092fi
2093
2094AH_VERBATIM([_HAVE_$5_PROTO],
2095[
2096#if !defined(HAVE_$5_PROTO)
2097#ifdef __cplusplus
2098extern "C"
2099#endif
2100$4;
2101#endif
2102])
2103])
2104
2105AC_DEFUN(AC_CHECK_SETENV,
2106[
2107	KDE_CHECK_FUNC_EXT(setenv, [
2108#include <stdlib.h>
2109],
2110		[setenv("VAR", "VALUE", 1);],
2111	        [int setenv (const char *, const char *, int)],
2112		[SETENV])
2113])
2114
2115AC_DEFUN(AC_CHECK_UNSETENV,
2116[
2117	KDE_CHECK_FUNC_EXT(unsetenv, [
2118#include <stdlib.h>
2119],
2120		[unsetenv("VAR");],
2121	        [void unsetenv (const char *)],
2122		[UNSETENV])
2123])
2124
2125AC_DEFUN(AC_CHECK_GETDOMAINNAME,
2126[
2127	KDE_CHECK_FUNC_EXT(getdomainname, [
2128#include <stdlib.h>
2129#include <unistd.h>
2130],
2131		[
2132char buffer[200];
2133getdomainname(buffer, 200);
2134],
2135	        [int getdomainname (char *, unsigned int)],
2136		[GETDOMAINNAME])
2137])
2138
2139AC_DEFUN(AC_CHECK_GETHOSTNAME,
2140[
2141	KDE_CHECK_FUNC_EXT(gethostname, [
2142#include <stdlib.h>
2143#include <unistd.h>
2144],
2145		[
2146char buffer[200];
2147gethostname(buffer, 200);
2148],
2149	        [int gethostname (char *, unsigned int)],
2150		[GETHOSTNAME])
2151])
2152
2153AC_DEFUN(AC_CHECK_USLEEP,
2154[
2155	KDE_CHECK_FUNC_EXT(usleep, [
2156#include <unistd.h>
2157],
2158		[
2159usleep(200);
2160],
2161	        [int usleep (unsigned int)],
2162		[USLEEP])
2163])
2164
2165
2166AC_DEFUN(AC_CHECK_RANDOM,
2167[
2168	KDE_CHECK_FUNC_EXT(random, [
2169#include <stdlib.h>
2170],
2171		[
2172random();
2173],
2174	        [long int random(void)],
2175		[RANDOM])
2176
2177	KDE_CHECK_FUNC_EXT(srandom, [
2178#include <stdlib.h>
2179],
2180		[
2181srandom(27);
2182],
2183	        [void srandom(unsigned int)],
2184		[SRANDOM])
2185
2186])
2187
2188AC_DEFUN(AC_CHECK_INITGROUPS,
2189[
2190	KDE_CHECK_FUNC_EXT(initgroups, [
2191#include <sys/types.h>
2192#include <unistd.h>
2193#include <grp.h>
2194],
2195	[
2196char buffer[200];
2197initgroups(buffer, 27);
2198],
2199	[int initgroups(const char *, gid_t)],
2200	[INITGROUPS])
2201])
2202
2203AC_DEFUN(AC_CHECK_MKSTEMP,
2204[
2205	KDE_CHECK_FUNC_EXT(mkstemp, [
2206#include <stdlib.h>
2207],
2208	[
2209mkstemp("/tmp/aaaXXXXXX");
2210],
2211	[int mkstemp(char *)],
2212	[MKSTEMP])
2213])
2214
2215AC_DEFUN(AC_CHECK_MKSTEMPS,
2216[
2217	KDE_CHECK_FUNC_EXT(mkstemps, [
2218#include <stdlib.h>
2219#include <unistd.h>
2220],
2221	[
2222mkstemps("/tmp/aaaXXXXXX", 6);
2223],
2224	[int mkstemps(char *, int)],
2225	[MKSTEMPS])
2226])
2227
2228AC_DEFUN(AC_CHECK_RES_INIT,
2229[
2230  AC_MSG_CHECKING([if res_init needs -lresolv])
2231  kde_libs_safe="$LIBS"
2232  LIBS="$LIBS $X_EXTRA_LIBS -lresolv"
2233  AC_TRY_LINK(
2234    [
2235#include <sys/types.h>
2236#include <netinet/in.h>
2237#include <arpa/nameser.h>
2238#include <resolv.h>
2239    ],
2240    [
2241      res_init();
2242    ],
2243    [
2244      LIBRESOLV="-lresolv"
2245      AC_MSG_RESULT(yes)
2246      AC_DEFINE(HAVE_RES_INIT, 1, [Define if you have the res_init function])
2247    ],
2248    [ AC_MSG_RESULT(no) ]
2249  )
2250  LIBS="$kde_libs_safe"
2251  AC_SUBST(LIBRESOLV)
2252
2253  AC_MSG_CHECKING([if res_init is available])
2254  AC_TRY_COMPILE(
2255    [
2256#include <sys/types.h>
2257#include <netinet/in.h>
2258#include <arpa/nameser.h>
2259#include <resolv.h>
2260    ],
2261    [
2262      res_init();
2263    ],
2264    [
2265      AC_MSG_RESULT(yes)
2266      AC_DEFINE(HAVE_RES_INIT, 1, [Define if you have the res_init function])
2267    ],
2268    [ AC_MSG_RESULT(no) ]
2269  )
2270])
2271
2272AC_DEFUN(AC_CHECK_STRLCPY,
2273[
2274	KDE_CHECK_FUNC_EXT(strlcpy, [
2275#include <string.h>
2276],
2277[ char buf[20];
2278  strlcpy(buf, "KDE function test", sizeof(buf));
2279],
2280 	[unsigned long strlcpy(char*, const char*, unsigned long)],
2281	[STRLCPY])
2282])
2283
2284AC_DEFUN(AC_CHECK_STRLCAT,
2285[
2286	KDE_CHECK_FUNC_EXT(strlcat, [
2287#include <string.h>
2288],
2289[ char buf[20];
2290  buf[0]='\0';
2291  strlcat(buf, "KDE function test", sizeof(buf));
2292],
2293 	[unsigned long strlcat(char*, const char*, unsigned long)],
2294	[STRLCAT])
2295])
2296
2297AC_DEFUN(AC_FIND_GIF,
2298   [AC_MSG_CHECKING([for giflib])
2299AC_CACHE_VAL(ac_cv_lib_gif,
2300[ac_save_LIBS="$LIBS"
2301if test "x$kde_use_qt_emb" != "xyes"; then
2302LIBS="$all_libraries -lgif -lX11 $LIBSOCKET"
2303else
2304LIBS="$all_libraries -lgif"
2305fi
2306AC_TRY_LINK(dnl
2307[
2308#ifdef __cplusplus
2309extern "C" {
2310#endif
2311int GifLastError(void);
2312#ifdef __cplusplus
2313}
2314#endif
2315/* We use char because int might match the return type of a gcc2
2316    builtin and then its argument prototype would still apply.  */
2317],
2318            [return GifLastError();],
2319            eval "ac_cv_lib_gif=yes",
2320            eval "ac_cv_lib_gif=no")
2321LIBS="$ac_save_LIBS"
2322])dnl
2323if eval "test \"`echo $ac_cv_lib_gif`\" = yes"; then
2324  AC_MSG_RESULT(yes)
2325  AC_DEFINE_UNQUOTED(HAVE_LIBGIF, 1, [Define if you have libgif])
2326else
2327  AC_MSG_ERROR(You need giflib30. Please install the kdesupport package)
2328fi
2329])
2330
2331AC_DEFUN(KDE_FIND_JPEG_HELPER,
2332[
2333AC_MSG_CHECKING([for libjpeg$2])
2334AC_CACHE_VAL(ac_cv_lib_jpeg_$1,
2335[
2336AC_LANG_C
2337ac_save_LIBS="$LIBS"
2338LIBS="$all_libraries $USER_LDFLAGS -ljpeg$2 -lm"
2339ac_save_CFLAGS="$CFLAGS"
2340CFLAGS="$CFLAGS $all_includes $USER_INCLUDES"
2341AC_TRY_LINK(
2342[/* Override any gcc2 internal prototype to avoid an error.  */
2343struct jpeg_decompress_struct;
2344typedef struct jpeg_decompress_struct * j_decompress_ptr;
2345typedef int size_t;
2346#ifdef __cplusplus
2347extern "C" {
2348#endif
2349    void jpeg_CreateDecompress(j_decompress_ptr cinfo,
2350                                    int version, size_t structsize);
2351#ifdef __cplusplus
2352}
2353#endif
2354/* We use char because int might match the return type of a gcc2
2355    builtin and then its argument prototype would still apply.  */
2356],
2357            [jpeg_CreateDecompress(0L, 0, 0);],
2358            eval "ac_cv_lib_jpeg_$1=-ljpeg$2",
2359            eval "ac_cv_lib_jpeg_$1=no")
2360LIBS="$ac_save_LIBS"
2361CFLAGS="$ac_save_CFLAGS"
2362])
2363
2364if eval "test ! \"`echo $ac_cv_lib_jpeg_$1`\" = no"; then
2365  LIBJPEG="$ac_cv_lib_jpeg_$1"
2366  AC_MSG_RESULT($ac_cv_lib_jpeg_$1)
2367else
2368  AC_MSG_RESULT(no)
2369  $3
2370fi
2371
2372])
2373
2374AC_DEFUN(AC_FIND_JPEG,
2375[
2376dnl first look for libraries
2377KDE_FIND_JPEG_HELPER(6b, 6b,
2378   KDE_FIND_JPEG_HELPER(normal, [],
2379    [
2380       LIBJPEG=
2381    ]
2382   )
2383)
2384
2385dnl then search the headers (can't use simply AC_TRY_xxx, as jpeglib.h
2386dnl requires system dependent includes loaded before it)
2387jpeg_incdirs="$includedir /usr/include /usr/local/include $kde_extra_includes"
2388AC_FIND_FILE(jpeglib.h, $jpeg_incdirs, jpeg_incdir)
2389test "x$jpeg_incdir" = xNO && jpeg_incdir=
2390
2391dnl if headers _and_ libraries are missing, this is no error, and we
2392dnl continue with a warning (the user will get no jpeg support in khtml)
2393dnl if only one is missing, it means a configuration error, but we still
2394dnl only warn
2395if test -n "$jpeg_incdir" && test -n "$LIBJPEG" ; then
2396  AC_DEFINE_UNQUOTED(HAVE_LIBJPEG, 1, [Define if you have libjpeg])
2397else
2398  if test -n "$jpeg_incdir" || test -n "$LIBJPEG" ; then
2399    AC_MSG_WARN([
2400There is an installation error in jpeg support. You seem to have only one
2401of either the headers _or_ the libraries installed. You may need to either
2402provide correct --with-extra-... options, or the development package of
2403libjpeg6b. You can get a source package of libjpeg from http://www.ijg.org/
2404Disabling JPEG support.
2405])
2406  else
2407    AC_MSG_WARN([libjpeg not found. disable JPEG support.])
2408  fi
2409  jpeg_incdir=
2410  LIBJPEG=
2411fi
2412
2413AC_SUBST(LIBJPEG)
2414AH_VERBATIM(_AC_CHECK_JPEG,
2415[/*
2416 * jpeg.h needs HAVE_BOOLEAN, when the system uses boolean in system
2417 * headers and I'm too lazy to write a configure test as long as only
2418 * unixware is related
2419 */
2420#ifdef _UNIXWARE
2421#define HAVE_BOOLEAN
2422#endif
2423])
2424])
2425
2426AC_DEFUN(KDE_CHECK_QT_JPEG,
2427[
2428AC_MSG_CHECKING([if Qt needs $LIBJPEG])
2429AC_CACHE_VAL(kde_cv_qt_jpeg,
2430[
2431AC_LANG_SAVE
2432AC_LANG_CPLUSPLUS
2433ac_save_LIBS="$LIBS"
2434LIBS="$all_libraries $USER_LDFLAGS $LIBQT"
2435LIBS=`echo $LIBS | sed "s/$LIBJPEG//"`
2436ac_save_CXXFLAGS="$CXXFLAGS"
2437CXXFLAGS="$CXXFLAGS $all_includes $USER_INCLUDES"
2438AC_TRY_LINK(
2439[#include <qapplication.h>],
2440            [
2441            int argc;
2442            char** argv;
2443            QApplication app(argc, argv);],
2444            eval "kde_cv_qt_jpeg=no",
2445            eval "kde_cv_qt_jpeg=yes")
2446LIBS="$ac_save_LIBS"
2447CXXFLAGS="$ac_save_CXXFLAGS"
2448AC_LANG_RESTORE
2449])
2450
2451if eval "test ! \"`echo $kde_cv_qt_jpeg`\" = no"; then
2452  AC_MSG_RESULT(yes)
2453  LIBJPEG_QT='$(LIBJPEG)'
2454else
2455  AC_MSG_RESULT(no)
2456  LIBJPEG_QT=
2457fi
2458
2459])
2460
2461AC_DEFUN(AC_FIND_ZLIB,
2462[
2463AC_REQUIRE([KDE_CHECK_EXTRA_LIBS])
2464AC_MSG_CHECKING([for libz])
2465AC_CACHE_VAL(ac_cv_lib_z,
2466[
2467AC_LANG_C
2468kde_save_LIBS="$LIBS"
2469LIBS="$all_libraries $USER_LDFLAGS -lz $LIBSOCKET"
2470kde_save_CFLAGS="$CFLAGS"
2471CFLAGS="$CFLAGS $all_includes $USER_INCLUDES"
2472AC_TRY_LINK(dnl
2473[
2474#include<zlib.h>
2475],
2476            [return (zlibVersion() == ZLIB_VERSION); ],
2477            eval "ac_cv_lib_z='-lz'",
2478            eval "ac_cv_lib_z=no")
2479LIBS="$kde_save_LIBS"
2480CFLAGS="$kde_save_CFLAGS"
2481])dnl
2482if test ! "$ac_cv_lib_z" = no; then
2483  AC_DEFINE_UNQUOTED(HAVE_LIBZ, 1, [Define if you have libz])
2484  LIBZ="$ac_cv_lib_z"
2485  AC_SUBST(LIBZ)
2486  AC_MSG_RESULT($ac_cv_lib_z)
2487else
2488  AC_MSG_ERROR(not found. Check your installation and look into config.log)
2489  LIBZ=""
2490  AC_SUBST(LIBZ)
2491fi
2492])
2493
2494AC_DEFUN(KDE_TRY_TIFFLIB,
2495[
2496AC_MSG_CHECKING([for libtiff $1])
2497
2498AC_CACHE_VAL(kde_cv_libtiff_$1,
2499[
2500AC_LANG_SAVE
2501AC_LANG_CPLUSPLUS
2502kde_save_LIBS="$LIBS"
2503if test "x$kde_use_qt_emb" != "xyes"; then
2504LIBS="$all_libraries $USER_LDFLAGS -l$1 $LIBJPEG $LIBZ -lX11 $LIBSOCKET -lm"
2505else
2506LIBS="$all_libraries $USER_LDFLAGS -l$1 $LIBJPEG $LIBZ -lm"
2507fi
2508kde_save_CXXFLAGS="$CXXFLAGS"
2509CXXFLAGS="$CXXFLAGS $all_includes $USER_INCLUDES"
2510
2511AC_TRY_LINK(dnl
2512[
2513#include<tiffio.h>
2514],
2515    [return (TIFFOpen( "", "r") == 0); ],
2516[
2517    kde_cv_libtiff_$1="-l$1 $LIBJPEG $LIBZ"
2518], [
2519    kde_cv_libtiff_$1=no
2520])
2521
2522LIBS="$kde_save_LIBS"
2523CXXFLAGS="$kde_save_CXXFLAGS"
2524AC_LANG_RESTORE
2525])
2526
2527if test "$kde_cv_libtiff_$1" = "no"; then
2528    AC_MSG_RESULT(no)
2529    LIBTIFF=""
2530    $3
2531else
2532    LIBTIFF="$kde_cv_libtiff_$1"
2533    AC_MSG_RESULT(yes)
2534    AC_DEFINE_UNQUOTED(HAVE_LIBTIFF, 1, [Define if you have libtiff])
2535    $2
2536fi
2537
2538])
2539
2540AC_DEFUN(AC_FIND_TIFF,
2541[
2542AC_REQUIRE([K_PATH_X])
2543AC_REQUIRE([AC_FIND_ZLIB])
2544AC_REQUIRE([AC_FIND_JPEG])
2545AC_REQUIRE([KDE_CHECK_EXTRA_LIBS])
2546
2547KDE_TRY_TIFFLIB(tiff, [],
2548   KDE_TRY_TIFFLIB(tiff34))
2549
2550AC_SUBST(LIBTIFF)
2551])
2552
2553
2554AC_DEFUN(AC_FIND_PNG,
2555[
2556AC_REQUIRE([KDE_CHECK_EXTRA_LIBS])
2557AC_REQUIRE([AC_FIND_ZLIB])
2558AC_MSG_CHECKING([for libpng])
2559AC_CACHE_VAL(ac_cv_lib_png,
2560[
2561kde_save_LIBS="$LIBS"
2562if test "x$kde_use_qt_emb" != "xyes"; then
2563LIBS="$LIBS $all_libraries $USER_LDFLAGS -lpng $LIBZ -lm -lX11 $LIBSOCKET"
2564else
2565LIBS="$LIBS $all_libraries $USER_LDFLAGS -lpng $LIBZ -lm"
2566fi
2567kde_save_CFLAGS="$CFLAGS"
2568CFLAGS="$CFLAGS $all_includes $USER_INCLUDES"
2569AC_LANG_C
2570AC_TRY_LINK(dnl
2571    [
2572    #include<png.h>
2573    ],
2574    [
2575    png_structp png_ptr = png_create_read_struct(  /* image ptr */
2576		PNG_LIBPNG_VER_STRING, 0, 0, 0 );
2577    return( png_ptr != 0 );
2578    ],
2579    eval "ac_cv_lib_png='-lpng $LIBZ -lm'",
2580    eval "ac_cv_lib_png=no"
2581)
2582LIBS="$kde_save_LIBS"
2583CFLAGS="$kde_save_CFLAGS"
2584])dnl
2585if eval "test ! \"`echo $ac_cv_lib_png`\" = no"; then
2586  AC_DEFINE_UNQUOTED(HAVE_LIBPNG, 1, [Define if you have libpng])
2587  LIBPNG="$ac_cv_lib_png"
2588  AC_SUBST(LIBPNG)
2589  AC_MSG_RESULT($ac_cv_lib_png)
2590else
2591  AC_MSG_RESULT(no)
2592  LIBPNG=""
2593  AC_SUBST(LIBPNG)
2594fi
2595])
2596
2597AC_DEFUN(AC_CHECK_BOOL,
2598[
2599  AC_DEFINE_UNQUOTED(HAVE_BOOL, 1, [You _must_ have bool])
2600])
2601
2602AC_DEFUN(AC_CHECK_GNU_EXTENSIONS,
2603[
2604AC_MSG_CHECKING(if you need GNU extensions)
2605AC_CACHE_VAL(ac_cv_gnu_extensions,
2606[
2607cat > conftest.c << EOF
2608#include <features.h>
2609
2610#ifdef __GNU_LIBRARY__
2611yes
2612#endif
2613EOF
2614
2615if (eval "$ac_cpp conftest.c") 2>&5 |
2616  egrep "yes" >/dev/null 2>&1; then
2617  rm -rf conftest*
2618  ac_cv_gnu_extensions=yes
2619else
2620  ac_cv_gnu_extensions=no
2621fi
2622])
2623
2624AC_MSG_RESULT($ac_cv_gnu_extensions)
2625if test "$ac_cv_gnu_extensions" = "yes"; then
2626  AC_DEFINE_UNQUOTED(_GNU_SOURCE, 1, [Define if you need to use the GNU extensions])
2627fi
2628])
2629
2630AC_DEFUN(KDE_CHECK_COMPILER_FLAG,
2631[
2632AC_MSG_CHECKING(whether $CXX supports -$1)
2633kde_cache=`echo $1 | sed 'y% .=/+-%____p_%'`
2634AC_CACHE_VAL(kde_cv_prog_cxx_$kde_cache,
2635[
2636  AC_LANG_SAVE
2637  AC_LANG_CPLUSPLUS
2638  save_CXXFLAGS="$CXXFLAGS"
2639  CXXFLAGS="$CXXFLAGS -$1"
2640  AC_TRY_LINK([],[ return 0; ], [eval "kde_cv_prog_cxx_$kde_cache=yes"], [])
2641  CXXFLAGS="$save_CXXFLAGS"
2642  AC_LANG_RESTORE
2643])
2644if eval "test \"`echo '$kde_cv_prog_cxx_'$kde_cache`\" = yes"; then
2645 AC_MSG_RESULT(yes)
2646 :
2647 $2
2648else
2649 AC_MSG_RESULT(no)
2650 :
2651 $3
2652fi
2653])
2654
2655dnl AC_REMOVE_FORBIDDEN removes forbidden arguments from variables
2656dnl use: AC_REMOVE_FORBIDDEN(CC, [-forbid -bad-option whatever])
2657dnl it's all white-space separated
2658AC_DEFUN(AC_REMOVE_FORBIDDEN,
2659[ __val=$$1
2660  __forbid=" $2 "
2661  if test -n "$__val"; then
2662    __new=""
2663    ac_save_IFS=$IFS
2664    IFS=" 	"
2665    for i in $__val; do
2666      case "$__forbid" in
2667        *" $i "*) AC_MSG_WARN([found forbidden $i in $1, removing it]) ;;
2668	*) # Careful to not add spaces, where there were none, because otherwise
2669	   # libtool gets confused, if we change e.g. CXX
2670	   if test -z "$__new" ; then __new=$i ; else __new="$__new $i" ; fi ;;
2671      esac
2672    done
2673    IFS=$ac_save_IFS
2674    $1=$__new
2675  fi
2676])
2677
2678dnl AC_VALIDIFY_CXXFLAGS checks for forbidden flags the user may have given
2679AC_DEFUN(AC_VALIDIFY_CXXFLAGS,
2680[dnl
2681if test "x$kde_use_qt_emb" != "xyes"; then
2682 AC_REMOVE_FORBIDDEN(CXX, [-fno-rtti -rpath])
2683 AC_REMOVE_FORBIDDEN(CXXFLAGS, [-fno-rtti -rpath])
2684else
2685 AC_REMOVE_FORBIDDEN(CXX, [-rpath])
2686 AC_REMOVE_FORBIDDEN(CXXFLAGS, [-rpath])
2687fi
2688])
2689
2690AC_DEFUN(AC_CHECK_COMPILERS,
2691[
2692  AC_ARG_ENABLE(debug,[  --enable-debug[=ARG]    enables debug symbols (yes|no|full) [default=no]],
2693  [
2694    case $enableval in
2695      yes)
2696        kde_use_debug_code="yes"
2697        kde_use_debug_define=no
2698        ;;
2699      full)
2700        kde_use_debug_code="full"
2701        kde_use_debug_define=no
2702        ;;
2703      *)
2704        kde_use_debug_code="no"
2705        kde_use_debug_define=yes
2706        ;;
2707    esac
2708  ],
2709    [kde_use_debug_code="no"
2710      kde_use_debug_define=no
2711  ])
2712
2713  dnl Just for configure --help
2714  AC_ARG_ENABLE(dummyoption,[  --disable-debug         disables debug output and debug symbols [default=no]],[],[])
2715
2716  AC_ARG_ENABLE(strict,[  --enable-strict         compiles with strict compiler options (may not work!)],
2717   [
2718    if test $enableval = "no"; then
2719         kde_use_strict_options="no"
2720       else
2721         kde_use_strict_options="yes"
2722    fi
2723   ], [kde_use_strict_options="no"])
2724
2725  AC_ARG_ENABLE(warnings,[  --disable-warnings      disables compilation with -Wall and similiar],
2726   [
2727    if test $enableval = "no"; then
2728         kde_use_warnings="no"
2729       else
2730         kde_use_warnings="yes"
2731    fi
2732   ], [kde_use_warnings="yes"])
2733
2734  dnl enable warnings for debug build
2735  if test "$kde_use_debug_code" != "no"; then
2736    kde_use_warnings=yes
2737  fi
2738
2739  AC_ARG_ENABLE(profile,[  --enable-profile        creates profiling infos [default=no]],
2740    [kde_use_profiling=$enableval],
2741    [kde_use_profiling="no"]
2742  )
2743
2744  AC_ARG_ENABLE(gcov,[  --enable-gcov           enables gcov test coverage support [default=no]],
2745    [kde_use_gcov=$enableval],
2746    [kde_use_gcov=no]
2747  )
2748
2749  dnl this prevents stupid AC_PROG_CC to add "-g" to the default CFLAGS
2750  CFLAGS=" $CFLAGS"
2751
2752  AC_PROG_CC
2753
2754  AC_PROG_CPP
2755
2756  if test "$GCC" = "yes"; then
2757    if test "$kde_use_debug_code" != "no"; then
2758      if test $kde_use_debug_code = "full" || test $kde_use_gcov = "yes"; then
2759        CFLAGS="-g3 $CFLAGS"
2760      else
2761        CFLAGS="-g -O2 $CFLAGS"
2762      fi
2763    else
2764      CFLAGS="-O2 $CFLAGS"
2765    fi
2766  fi
2767
2768  if test "$kde_use_debug_define" = "yes"; then
2769    CFLAGS="-DNDEBUG $CFLAGS"
2770  fi
2771
2772
2773  case "$host" in
2774  *-*-sysv4.2uw*) CFLAGS="-D_UNIXWARE $CFLAGS";;
2775  *-*-sysv5uw7*) CFLAGS="-D_UNIXWARE7 $CFLAGS";;
2776  esac
2777
2778  if test -z "$LDFLAGS" && test "$kde_use_debug_code" = "no" && test "$GCC" = "yes"; then
2779     LDFLAGS=""
2780  fi
2781
2782  CXXFLAGS=" $CXXFLAGS"
2783
2784  AC_PROG_CXX
2785
2786  if test "$GXX" = "yes" || test "$CXX" = "KCC"; then
2787    if test "$kde_use_debug_code" != "no"; then
2788      if test "$CXX" = "KCC"; then
2789        CXXFLAGS="+K0 -Wall -pedantic -W -Wpointer-arith -Wwrite-strings $CXXFLAGS"
2790      else
2791        if test "$kde_use_debug_code" = "full"; then
2792          CXXFLAGS="-g3 $CXXFLAGS"
2793        else
2794          CXXFLAGS="-g -O2 $CXXFLAGS"
2795        fi
2796      fi
2797      KDE_CHECK_COMPILER_FLAG(fno-builtin,[CXXFLAGS="-fno-builtin $CXXFLAGS"])
2798
2799      dnl convenience compiler flags
2800      KDE_CHECK_COMPILER_FLAG(Woverloaded-virtual, [WOVERLOADED_VIRTUAL="-Woverloaded-virtual"], [WOVERLOADED_VRITUAL=""])
2801      AC_SUBST(WOVERLOADED_VIRTUAL)
2802    else
2803      if test "$CXX" = "KCC"; then
2804        CXXFLAGS="+K3 $CXXFLAGS"
2805      else
2806        CXXFLAGS="-O2 $CXXFLAGS"
2807      fi
2808    fi
2809  fi
2810
2811  if test "$kde_use_debug_define" = "yes"; then
2812    CXXFLAGS="-DNDEBUG -DNO_DEBUG $CXXFLAGS"
2813  fi
2814
2815  if test "$kde_use_profiling" = "yes"; then
2816    KDE_CHECK_COMPILER_FLAG(pg,
2817    [
2818      CFLAGS="-pg $CFLAGS"
2819      CXXFLAGS="-pg $CXXFLAGS"
2820    ])
2821  fi
2822
2823  if test "$kde_use_gcov" = "yes"; then
2824    KDE_CHECK_COMPILER_FLAG(fprofile-arcs,
2825    [
2826      CFLAGS="-fprofile-arcs -ftest-coverage $CFLAGS"
2827      CXXFLAGS="-fprofile-arcs -ftest-coverage $CXXFLAGS"
2828    ])
2829  fi
2830
2831  if test "$kde_use_warnings" = "yes"; then
2832      if test "$GCC" = "yes"; then
2833        case $host in
2834          *-*-linux-gnu)
2835            CFLAGS="-ansi -W -Wall -pedantic -Wshadow -Wpointer-arith -Wmissing-prototypes -Wwrite-strings -D_XOPEN_SOURCE=500 -D_BSD_SOURCE $CFLAGS"
2836            CXXFLAGS="-ansi -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -Wcast-align -Wconversion $CXXFLAGS"
2837          ;;
2838        esac
2839        CXXFLAGS="-Wall -pedantic -W -Wpointer-arith -Wwrite-strings $CXXFLAGS"
2840        KDE_CHECK_COMPILER_FLAG(Wundef,[CXXFLAGS="-Wundef $CXXFLAGS"])
2841        KDE_CHECK_COMPILER_FLAG(Wno-long-long,[CXXFLAGS="-Wno-long-long $CXXFLAGS"])
2842        KDE_CHECK_COMPILER_FLAG(Wnon-virtual-dtor,[CXXFLAGS="-Wnon-virtual-dtor $CXXFLAGS"])
2843     fi
2844  fi
2845
2846  if test "$GCC" = "yes" && test "$kde_use_strict_options" = "yes"; then
2847    CXXFLAGS="-Wcast-qual -Wshadow -Wcast-align $CXXFLAGS"
2848  fi
2849
2850  if test "$GXX" = "yes"; then
2851    KDE_CHECK_COMPILER_FLAG(fno-exceptions,[CXXFLAGS="$CXXFLAGS -fno-exceptions"])
2852    KDE_CHECK_COMPILER_FLAG(fno-check-new, [CXXFLAGS="$CXXFLAGS -fno-check-new"])
2853    KDE_CHECK_COMPILER_FLAG(fexceptions, [USE_EXCEPTIONS="-fexceptions"], USE_EXCEPTIONS=	)
2854  fi
2855  if test "$CXX" = "KCC"; then
2856    dnl unfortunately we currently cannot disable exception support in KCC
2857    dnl because doing so is binary incompatible and Qt by default links with exceptions :-(
2858    dnl KDE_CHECK_COMPILER_FLAG(-no_exceptions,[CXXFLAGS="$CXXFLAGS --no_exceptions"])
2859    dnl KDE_CHECK_COMPILER_FLAG(-exceptions, [USE_EXCEPTIONS="--exceptions"], USE_EXCEPTIONS=	)
2860
2861    AC_ARG_ENABLE(pch,[  --enable-pch            enables precompiled header support (currently only KCC) [default=no]],
2862    [
2863      kde_use_pch=$enableval
2864    ],[kde_use_pch=no])
2865
2866    if test "$kde_use_pch" = "yes"; then
2867      dnl TODO: support --pch-dir!
2868      KDE_CHECK_COMPILER_FLAG(-pch,[CXXFLAGS="$CXXFLAGS --pch"])
2869      dnl the below works (but the dir must exist), but it's
2870      dnl useless for a whole package.
2871      dnl The are precompiled headers for each source file, so when compiling
2872      dnl from scratch, it doesn't make a difference, and they take up
2873      dnl around ~5Mb _per_ sourcefile.
2874      dnl KDE_CHECK_COMPILER_FLAG(-pch_dir /tmp,
2875      dnl   [CXXFLAGS="$CXXFLAGS --pch_dir `pwd`/pcheaders"])
2876    fi
2877    dnl this flag controls inlining. by default KCC inlines in optimisation mode
2878    dnl all implementations that are defined inside the class {} declaration.
2879    dnl because of templates-compatibility with broken gcc compilers, this
2880    dnl can cause excessive inlining. This flag limits it to a sane level
2881    KDE_CHECK_COMPILER_FLAG(-inline_keyword_space_time=6,[CXXFLAGS="$CXXFLAGS --inline_keyword_space_time=6"])
2882    KDE_CHECK_COMPILER_FLAG(-inline_auto_space_time=2,[CXXFLAGS="$CXXFLAGS --inline_auto_space_time=2"])
2883    KDE_CHECK_COMPILER_FLAG(-inline_implicit_space_time=2.0,[CXXFLAGS="$CXXFLAGS --inline_implicit_space_time=2.0"])
2884    KDE_CHECK_COMPILER_FLAG(-inline_generated_space_time=2.0,[CXXFLAGS="$CXXFLAGS --inline_generated_space_time=2.0"])
2885    dnl Some source files are shared between multiple executables
2886    dnl (or libraries) and some of those need template instantiations.
2887    dnl In that case KCC needs to compile those sources with
2888    dnl --one_instantiation_per_object.  To make it easy for us we compile
2889    dnl _all_ objects with that flag (--one_per is a shorthand).
2890    KDE_CHECK_COMPILER_FLAG(-one_per, [CXXFLAGS="$CXXFLAGS --one_per"])
2891  fi
2892  AC_SUBST(USE_EXCEPTIONS)
2893  dnl obsolete macro - provided to keep things going
2894  USE_RTTI=
2895  AC_SUBST(USE_RTTI)
2896
2897  case "$host" in
2898      *-*-irix*)  test "$GXX" = yes && CXXFLAGS="-D_LANGUAGE_C_PLUS_PLUS -D__LANGUAGE_C_PLUS_PLUS $CXXFLAGS" ;;
2899      *-*-sysv4.2uw*) CXXFLAGS="-D_UNIXWARE $CXXFLAGS";;
2900      *-*-sysv5uw7*) CXXFLAGS="-D_UNIXWARE7 $CXXFLAGS";;
2901      *-*-solaris*)
2902        if test "$GXX" = yes; then
2903          libstdcpp=`$CXX -print-file-name=libstdc++.so`
2904          if test ! -f $libstdcpp; then
2905             AC_MSG_ERROR([You've compiled gcc without --enable-shared. This doesn't work with KDE. Please recompile gcc with --enable-shared to receive a libstdc++.so])
2906          fi
2907        fi
2908        ;;
2909  esac
2910
2911  AC_VALIDIFY_CXXFLAGS
2912
2913  AC_PROG_CXXCPP
2914
2915  if test "$GCC" = yes; then
2916     NOOPT_CXXFLAGS=-O0
2917     NOOPT_CFLAGS=-O0
2918  fi
2919
2920  AC_SUBST(NOOPT_CXXFLAGS)
2921  AC_SUBST(NOOPT_CFLAGS)
2922
2923  KDE_CHECK_FINAL
2924
2925  ifdef([AM_DEPENDENCIES], AC_REQUIRE([KDE_ADD_DEPENDENCIES]), [])
2926])
2927
2928AC_DEFUN(KDE_ADD_DEPENDENCIES,
2929[
2930   [A]M_DEPENDENCIES(CC)
2931   [A]M_DEPENDENCIES(CXX)
2932])
2933
2934dnl just a wrapper to clean up configure.in
2935AC_DEFUN(KDE_PROG_LIBTOOL,
2936[
2937AC_REQUIRE([AC_CHECK_COMPILERS])
2938AC_REQUIRE([AC_ENABLE_SHARED])
2939AC_REQUIRE([AC_ENABLE_STATIC])
2940
2941AC_REQUIRE([AC_LIBTOOL_DLOPEN])
2942AC_REQUIRE([KDE_CHECK_LIB64])
2943
2944AC_LANG_SAVE
2945AC_LANG_C
2946AC_OBJEXT
2947AC_EXEEXT
2948AC_LANG_RESTORE
2949
2950AM_PROG_LIBTOOL
2951AC_LIBTOOL_CXX
2952
2953LIBTOOL_SHELL="/bin/sh ./libtool"
2954#  LIBTOOL="$LIBTOOL --silent"
2955KDE_PLUGIN="-avoid-version -module -no-undefined \$(KDE_RPATH) \$(KDE_MT_LDFLAGS)"
2956AC_SUBST(KDE_PLUGIN)
2957
2958AC_ARG_ENABLE(objprelink, [  --enable-objprelink     prelink apps using objprelink (obsolete)],
2959       kde_use_objprelink=$enableval, kde_use_objprelink=no)
2960  if test "x$kde_use_objprelink" = "xyes"; then
2961        AC_MSG_WARN([
2962------------------------------------------------------------
2963Configuration option --enable-objprelink is no longer useful.
2964See http:://objprelink.sourceforge.net for details:
29651- Recent binutils are fast enough to do without objprelink.
29662- Newer versions of objprelink do not need this option.
2967------------------------------------------------------------
2968])
2969  fi
2970])
2971
2972AC_DEFUN(KDE_CHECK_LIB64,
2973[
2974    kdelibsuff=none
2975    AC_ARG_ENABLE(libsuffix,
2976        AC_HELP_STRING([--enable-libsuffix],
2977            [/lib directory suffix (64,32,none[=default])]),
2978            kdelibsuff=$enableval)
2979    # TODO: add an auto case that compiles a little C app to check
2980    # where the glibc is
2981    if test "$kdelibsuff" = "none"; then
2982       kdelibsuff=
2983    fi
2984    if test -z "$kdelibsuff"; then
2985        AC_MSG_RESULT([not using lib directory suffix])
2986        AC_DEFINE(KDELIBSUFF, [""], Suffix for lib directories)
2987    else
2988        if test "$libdir" = '${exec_prefix}/lib'; then
2989            libdir="$libdir${kdelibsuff}"
2990            AC_SUBST([libdir], ["$libdir"])  dnl ugly hack for lib64 platforms
2991        fi
2992        AC_DEFINE_UNQUOTED(KDELIBSUFF, ["\"${kdelibsuff}\""], Suffix for lib directories)
2993        AC_MSG_RESULT([using lib directory suffix $kdelibsuff])
2994    fi
2995])
2996
2997AC_DEFUN(KDE_CHECK_TYPES,
2998[  AC_CHECK_SIZEOF(int, 4)dnl
2999  AC_CHECK_SIZEOF(long, 4)dnl
3000  AC_CHECK_SIZEOF(char *, 4)dnl
3001  AC_CHECK_SIZEOF(char, 1)dnl
3002])dnl
3003
3004AC_DEFUN(KDE_DO_IT_ALL,
3005[
3006AC_CANONICAL_SYSTEM
3007AC_ARG_PROGRAM
3008AM_INIT_AUTOMAKE($1, $2)
3009AM_DISABLE_LIBRARIES
3010AC_PREFIX_DEFAULT(${KDEDIR:-/usr/local/kde})
3011AC_CHECK_COMPILERS
3012KDE_PROG_LIBTOOL
3013AM_KDE_WITH_NLS
3014AC_PATH_KDE
3015])
3016
3017AC_DEFUN(AC_CHECK_RPATH,
3018[
3019AC_MSG_CHECKING(for rpath)
3020AC_ARG_ENABLE(rpath,
3021      [  --disable-rpath         do not use the rpath feature of ld],
3022      USE_RPATH=$enableval, USE_RPATH=yes)
3023
3024if test -z "$KDE_RPATH" && test "$USE_RPATH" = "yes"; then
3025
3026  KDE_RPATH="-R \$(kde_libraries)"
3027
3028  if test -n "$qt_libraries"; then
3029    KDE_RPATH="$KDE_RPATH -R \$(qt_libraries)"
3030  fi
3031  dnl $x_libraries is set to /usr/lib in case
3032  if test -n "$X_LDFLAGS"; then
3033    X_RPATH="-R \$(x_libraries)"
3034    KDE_RPATH="$KDE_RPATH $X_RPATH"
3035  fi
3036  if test -n "$KDE_EXTRA_RPATH"; then
3037    KDE_RPATH="$KDE_RPATH \$(KDE_EXTRA_RPATH)"
3038  fi
3039fi
3040AC_SUBST(KDE_EXTRA_RPATH)
3041AC_SUBST(KDE_RPATH)
3042AC_SUBST(X_RPATH)
3043AC_MSG_RESULT($USE_RPATH)
3044])
3045
3046dnl Check for the type of the third argument of getsockname
3047AC_DEFUN(AC_CHECK_SOCKLEN_T, [
3048  AC_MSG_CHECKING(for socklen_t)
3049  AC_CACHE_VAL(ac_cv_socklen_t, [
3050    AC_LANG_SAVE
3051    AC_LANG_CPLUSPLUS
3052    AC_TRY_COMPILE([
3053#include <sys/types.h>
3054#include <sys/socket.h>
3055      ],[
3056socklen_t a=0;
3057getsockname(0,(struct sockaddr*)0, &a);
3058      ],
3059      ac_cv_socklen_t=socklen_t,
3060      AC_TRY_COMPILE([
3061#include <sys/types.h>
3062#include <sys/socket.h>
3063        ],[
3064int a=0;
3065getsockname(0,(struct sockaddr*)0, &a);
3066        ],
3067        ac_cv_socklen_t=int,
3068        ac_cv_socklen_t=size_t
3069      )
3070    )
3071    AC_LANG_RESTORE
3072  ])
3073
3074  AC_MSG_RESULT($ac_cv_socklen_t)
3075  if test "$ac_cv_socklen_t" != "socklen_t"; then
3076    AC_DEFINE_UNQUOTED(socklen_t, $ac_cv_socklen_t,
3077        [Define the real type of socklen_t])
3078  fi
3079  AC_DEFINE_UNQUOTED(ksize_t, socklen_t, [Compatibility define])
3080
3081])
3082
3083dnl This is a merge of some macros out of the gettext aclocal.m4
3084dnl since we don't need anything, I took the things we need
3085dnl the copyright for them is:
3086dnl >
3087dnl Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
3088dnl This Makefile.in is free software; the Free Software Foundation
3089dnl gives unlimited permission to copy and/or distribute it,
3090dnl with or without modifications, as long as this notice is preserved.
3091
3092dnl This program is distributed in the hope that it will be useful,
3093dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without
3094dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A
3095dnl PARTICULAR PURPOSE.
3096dnl >
3097dnl for this file it is relicensed under LGPL
3098
3099AC_DEFUN(AM_KDE_WITH_NLS,
3100  [
3101    dnl If we use NLS figure out what method
3102
3103    AM_PATH_PROG_WITH_TEST_KDE(MSGFMT, msgfmt,
3104        [test -n "`$ac_dir/$ac_word --version 2>&1 | grep 'GNU gettext'`"], msgfmt)
3105    AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
3106
3107     if test -z "`$GMSGFMT --version 2>&1 | grep 'GNU gettext'`"; then
3108        AC_MSG_RESULT([found msgfmt program is not GNU msgfmt; ignore it])
3109        GMSGFMT=":"
3110      fi
3111      MSGFMT=$GMSGFMT
3112      AC_SUBST(GMSGFMT)
3113      AC_SUBST(MSGFMT)
3114
3115      AM_PATH_PROG_WITH_TEST_KDE(XGETTEXT, xgettext,
3116	[test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
3117
3118      dnl Test whether we really found GNU xgettext.
3119      if test "$XGETTEXT" != ":"; then
3120	dnl If it is no GNU xgettext we define it as : so that the
3121	dnl Makefiles still can work.
3122	if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
3123	  : ;
3124	else
3125	  AC_MSG_RESULT(
3126	    [found xgettext programs is not GNU xgettext; ignore it])
3127	  XGETTEXT=":"
3128	fi
3129      fi
3130     AC_SUBST(XGETTEXT)
3131
3132  ])
3133
3134# Search path for a program which passes the given test.
3135# Ulrich Drepper <drepper@cygnus.com>, 1996.
3136
3137# serial 1
3138# Stephan Kulow: I appended a _KDE against name conflicts
3139
3140dnl AM_PATH_PROG_WITH_TEST_KDE(VARIABLE, PROG-TO-CHECK-FOR,
3141dnl   TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
3142AC_DEFUN(AM_PATH_PROG_WITH_TEST_KDE,
3143[# Extract the first word of "$2", so it can be a program name with args.
3144set dummy $2; ac_word=[$]2
3145AC_MSG_CHECKING([for $ac_word])
3146AC_CACHE_VAL(ac_cv_path_$1,
3147[case "[$]$1" in
3148  /*)
3149  ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
3150  ;;
3151  *)
3152  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}:"
3153  for ac_dir in ifelse([$5], , $PATH, [$5]); do
3154    test -z "$ac_dir" && ac_dir=.
3155    if test -f $ac_dir/$ac_word; then
3156      if [$3]; then
3157	ac_cv_path_$1="$ac_dir/$ac_word"
3158	break
3159      fi
3160    fi
3161  done
3162  IFS="$ac_save_ifs"
3163dnl If no 4th arg is given, leave the cache variable unset,
3164dnl so AC_PATH_PROGS will keep looking.
3165ifelse([$4], , , [  test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
3166])dnl
3167  ;;
3168esac])dnl
3169$1="$ac_cv_path_$1"
3170if test -n "[$]$1"; then
3171  AC_MSG_RESULT([$]$1)
3172else
3173  AC_MSG_RESULT(no)
3174fi
3175AC_SUBST($1)dnl
3176])
3177
3178
3179# Check whether LC_MESSAGES is available in <locale.h>.
3180# Ulrich Drepper <drepper@cygnus.com>, 1995.
3181
3182# serial 1
3183
3184AC_DEFUN(AM_LC_MESSAGES,
3185  [if test $ac_cv_header_locale_h = yes; then
3186    AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES,
3187      [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
3188       am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)])
3189    if test $am_cv_val_LC_MESSAGES = yes; then
3190      AC_DEFINE(HAVE_LC_MESSAGES, 1, [Define if your locale.h file contains LC_MESSAGES])
3191    fi
3192  fi])
3193
3194dnl From Jim Meyering.
3195dnl FIXME: migrate into libit.
3196
3197AC_DEFUN([AM_FUNC_OBSTACK],
3198[AC_CACHE_CHECK([for obstacks], am_cv_func_obstack,
3199 [AC_TRY_LINK([#include "obstack.h"],
3200	      [struct obstack *mem;obstack_free(mem,(char *) 0)],
3201	      am_cv_func_obstack=yes,
3202	      am_cv_func_obstack=no)])
3203 if test $am_cv_func_obstack = yes; then
3204   AC_DEFINE(HAVE_OBSTACK)
3205 else
3206   LIBOBJS="$LIBOBJS obstack.o"
3207 fi
3208])
3209
3210dnl From Jim Meyering.  Use this if you use the GNU error.[ch].
3211dnl FIXME: Migrate into libit
3212
3213AC_DEFUN([AM_FUNC_ERROR_AT_LINE],
3214[AC_CACHE_CHECK([for error_at_line], am_cv_lib_error_at_line,
3215 [AC_TRY_LINK([],[error_at_line(0, 0, "", 0, "");],
3216              am_cv_lib_error_at_line=yes,
3217	      am_cv_lib_error_at_line=no)])
3218 if test $am_cv_lib_error_at_line = no; then
3219   LIBOBJS="$LIBOBJS error.o"
3220 fi
3221 AC_SUBST(LIBOBJS)dnl
3222])
3223
3224# Macro to add for using GNU gettext.
3225# Ulrich Drepper <drepper@cygnus.com>, 1995.
3226
3227# serial 1
3228# Stephan Kulow: I put a KDE in it to avoid name conflicts
3229
3230AC_DEFUN(AM_KDE_GNU_GETTEXT,
3231  [AC_REQUIRE([AC_PROG_MAKE_SET])dnl
3232   AC_REQUIRE([AC_PROG_RANLIB])dnl
3233   AC_REQUIRE([AC_HEADER_STDC])dnl
3234   AC_REQUIRE([AC_TYPE_OFF_T])dnl
3235   AC_REQUIRE([AC_TYPE_SIZE_T])dnl
3236   AC_REQUIRE([AC_FUNC_ALLOCA])dnl
3237   AC_REQUIRE([AC_FUNC_MMAP])dnl
3238   AC_REQUIRE([AM_KDE_WITH_NLS])dnl
3239   AC_CHECK_HEADERS([limits.h locale.h nl_types.h string.h values.h alloca.h])
3240   AC_CHECK_FUNCS([getcwd munmap putenv setlocale strchr strcasecmp \
3241__argz_count __argz_stringify __argz_next])
3242
3243   AC_MSG_CHECKING(for stpcpy)
3244   AC_CACHE_VAL(kde_cv_func_stpcpy,
3245   [
3246   kde_safe_cxxflags=$CXXFLAGS
3247   CXXFLAGS="-Werror"
3248   AC_LANG_SAVE
3249   AC_LANG_CPLUSPLUS
3250   AC_TRY_COMPILE([
3251   #include <string.h>
3252   ],
3253   [
3254   char buffer[200];
3255   stpcpy(buffer, buffer);
3256   ],
3257   kde_cv_func_stpcpy=yes,
3258   kde_cv_func_stpcpy=no)
3259   AC_LANG_RESTORE
3260   CXXFLAGS=$kde_safe_cxxflags
3261   ])
3262   AC_MSG_RESULT($kde_cv_func_stpcpy)
3263   if eval "test \"`echo $kde_cv_func_stpcpy`\" = yes"; then
3264     AC_DEFINE(HAVE_STPCPY, 1, [Define if you have stpcpy])
3265   fi
3266
3267   AM_LC_MESSAGES
3268
3269   if test "x$CATOBJEXT" != "x"; then
3270     if test "x$ALL_LINGUAS" = "x"; then
3271       LINGUAS=
3272     else
3273       AC_MSG_CHECKING(for catalogs to be installed)
3274       NEW_LINGUAS=
3275       for lang in ${LINGUAS=$ALL_LINGUAS}; do
3276         case "$ALL_LINGUAS" in
3277          *$lang*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;;
3278         esac
3279       done
3280       LINGUAS=$NEW_LINGUAS
3281       AC_MSG_RESULT($LINGUAS)
3282     fi
3283
3284     dnl Construct list of names of catalog files to be constructed.
3285     if test -n "$LINGUAS"; then
3286       for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
3287     fi
3288   fi
3289
3290  ])
3291
3292AC_DEFUN(AC_HAVE_XPM,
3293 [AC_REQUIRE_CPP()dnl
3294  AC_REQUIRE([KDE_CHECK_EXTRA_LIBS])
3295
3296 test -z "$XPM_LDFLAGS" && XPM_LDFLAGS=
3297 test -z "$XPM_INCLUDE" && XPM_INCLUDE=
3298
3299 AC_ARG_WITH(xpm, [  --without-xpm           disable color pixmap XPM tests],
3300	xpm_test=$withval, xpm_test="yes")
3301 if test "x$xpm_test" = xno; then
3302   ac_cv_have_xpm=no
3303 else
3304   AC_MSG_CHECKING(for XPM)
3305   AC_CACHE_VAL(ac_cv_have_xpm,
3306   [
3307    AC_LANG_C
3308    ac_save_ldflags="$LDFLAGS"
3309    ac_save_cflags="$CFLAGS"
3310    if test "x$kde_use_qt_emb" != "xyes"; then
3311      LDFLAGS="$LDFLAGS $X_LDFLAGS $USER_LDFLAGS $LDFLAGS $XPM_LDFLAGS $all_libraries -lXpm -lX11 -lXext $LIBZ $LIBSOCKET"
3312    else
3313      LDFLAGS="$LDFLAGS $X_LDFLAGS $USER_LDFLAGS $LDFLAGS $XPM_LDFLAGS $all_libraries -lXpm $LIBZ $LIBSOCKET"
3314    fi
3315    CFLAGS="$CFLAGS $X_INCLUDES $USER_INCLUDES"
3316    test -n "$XPM_INCLUDE" && CFLAGS="-I$XPM_INCLUDE $CFLAGS"
3317    AC_TRY_LINK([#include <X11/xpm.h>],[],
3318	ac_cv_have_xpm="yes",ac_cv_have_xpm="no")
3319    LDFLAGS="$ac_save_ldflags"
3320    CFLAGS="$ac_save_cflags"
3321   ])dnl
3322
3323  if test "$ac_cv_have_xpm" = no; then
3324    AC_MSG_RESULT(no)
3325    XPM_LDFLAGS=""
3326    XPMINC=""
3327    $2
3328  else
3329    AC_DEFINE(HAVE_XPM, 1, [Define if you have XPM support])
3330    if test "$XPM_LDFLAGS" = ""; then
3331       XPMLIB='-lXpm $(LIB_X11)'
3332    else
3333       XPMLIB="-L$XPM_LDFLAGS -lXpm "'$(LIB_X11)'
3334    fi
3335    if test "$XPM_INCLUDE" = ""; then
3336       XPMINC=""
3337    else
3338       XPMINC="-I$XPM_INCLUDE"
3339    fi
3340    AC_MSG_RESULT(yes)
3341    $1
3342  fi
3343 fi
3344 AC_SUBST(XPMINC)
3345 AC_SUBST(XPMLIB)
3346])
3347
3348AC_DEFUN(AC_HAVE_DPMS,
3349 [AC_REQUIRE_CPP()dnl
3350  AC_REQUIRE([KDE_CHECK_EXTRA_LIBS])
3351
3352 test -z "$DPMS_LDFLAGS" && DPMS_LDFLAGS=
3353 test -z "$DPMS_INCLUDE" && DPMS_INCLUDE=
3354 DPMS_LIB=
3355
3356 AC_ARG_WITH(dpms, [  --without-dpms          disable DPMS power saving],
3357	dpms_test=$withval, dpms_test="yes")
3358 if test "x$dpms_test" = xno; then
3359   ac_cv_have_dpms=no
3360 else
3361   AC_MSG_CHECKING(for DPMS)
3362   dnl Note: ac_cv_have_dpms can be no, yes, or -lXdpms.
3363   dnl 'yes' means DPMS_LIB="", '-lXdpms' means DPMS_LIB="-lXdpms".
3364   AC_CACHE_VAL(ac_cv_have_dpms,
3365   [
3366    if test "x$kde_use_qt_emb" = "xyes"; then
3367      AC_MSG_RESULT(no)
3368      ac_cv_have_dpms="no"
3369    else
3370      AC_LANG_C
3371      ac_save_ldflags="$LDFLAGS"
3372      ac_save_cflags="$CFLAGS"
3373      ac_save_libs="$LIBS"
3374      LDFLAGS="$LDFLAGS $DPMS_LDFLAGS $all_libraries -lX11 -lXext $LIBSOCKET"
3375      CFLAGS="$CFLAGS $X_INCLUDES"
3376      test -n "$DPMS_INCLUDE" && CFLAGS="-I$DPMS_INCLUDE $CFLAGS"
3377      AC_TRY_LINK([
3378	  #include <X11/Xproto.h>
3379	  #include <X11/X.h>
3380	  #include <X11/Xlib.h>
3381	  #include <X11/extensions/dpms.h>
3382	  int foo_test_dpms()
3383	  { return DPMSSetTimeouts( 0, 0, 0, 0 ); }],[],
3384	  ac_cv_have_dpms="yes", [
3385              LDFLAGS="$ac_save_ldflags"
3386              CFLAGS="$ac_save_cflags"
3387              LDFLAGS="$LDFLAGS $DPMS_LDFLAGS $all_libraries -lX11 -lXext $LIBSOCKET"
3388              LIBS="$LIBS -lXdpms"
3389              CFLAGS="$CFLAGS $X_INCLUDES"
3390              test -n "$DPMS_INCLUDE" && CFLAGS="-I$DPMS_INCLUDE $CFLAGS"
3391              AC_TRY_LINK([
3392	          #include <X11/Xproto.h>
3393        	  #include <X11/X.h>
3394        	  #include <X11/Xlib.h>
3395        	  #include <X11/extensions/dpms.h>
3396        	  int foo_test_dpms()
3397        	  { return DPMSSetTimeouts( 0, 0, 0, 0 ); }],[],
3398        	  [
3399                  ac_cv_have_dpms="-lXdpms"
3400                  ],ac_cv_have_dpms="no")
3401              ])
3402      LDFLAGS="$ac_save_ldflags"
3403      CFLAGS="$ac_save_cflags"
3404      LIBS="$ac_save_libs"
3405    fi
3406   ])dnl
3407
3408  if test "$ac_cv_have_dpms" = no; then
3409    AC_MSG_RESULT(no)
3410    DPMS_LDFLAGS=""
3411    DPMSINC=""
3412    $2
3413  else
3414    AC_DEFINE(HAVE_DPMS, 1, [Define if you have DPMS support])
3415    if test "$ac_cv_have_dpms" = "-lXdpms"; then
3416       DPMS_LIB="-lXdpms"
3417    fi
3418    if test "$DPMS_LDFLAGS" = ""; then
3419       DPMSLIB="$DPMS_LIB "'$(LIB_X11)'
3420    else
3421       DPMSLIB="$DPMS_LDFLAGS $DPMS_LIB "'$(LIB_X11)'
3422    fi
3423    if test "$DPMS_INCLUDE" = ""; then
3424       DPMSINC=""
3425    else
3426       DPMSINC="-I$DPMS_INCLUDE"
3427    fi
3428    AC_MSG_RESULT(yes)
3429    $1
3430  fi
3431 fi
3432 AC_SUBST(DPMSINC)
3433 AC_SUBST(DPMSLIB)
3434])
3435
3436AC_DEFUN(AC_HAVE_GL,
3437 [AC_REQUIRE_CPP()dnl
3438  AC_REQUIRE([KDE_CHECK_EXTRA_LIBS])
3439
3440 test -z "$GL_LDFLAGS" && GL_LDFLAGS=
3441 test -z "$GL_INCLUDE" && GL_INCLUDE=
3442
3443 AC_ARG_WITH(gl, [  --without-gl            disable 3D GL modes],
3444	gl_test=$withval, gl_test="yes")
3445 if test "x$kde_use_qt_emb" = "xyes"; then
3446   # GL and Qt Embedded is a no-go for now.
3447   ac_cv_have_gl=no
3448 elif test "x$gl_test" = xno; then
3449   ac_cv_have_gl=no
3450 else
3451   AC_MSG_CHECKING(for GL)
3452   AC_CACHE_VAL(ac_cv_have_gl,
3453   [
3454    AC_LANG_SAVE
3455    AC_LANG_CPLUSPLUS
3456    ac_save_ldflags="$LDFLAGS"
3457    ac_save_cxxflags="$CXXFLAGS"
3458    LDFLAGS="$LDFLAGS $GL_LDFLAGS $X_LDFLAGS $all_libraries -lMesaGL -lMesaGLU"
3459    test "x$kde_use_qt_emb" != xyes && LDFLAGS="$LDFLAGS -lX11"
3460    LDFLAGS="$LDFLAGS $LIB_XEXT -lm $LIBSOCKET"
3461    CXXFLAGS="$CFLAGS $X_INCLUDES"
3462    test -n "$GL_INCLUDE" && CFLAGS="-I$GL_INCLUDE $CFLAGS"
3463    AC_TRY_LINK([#include <GL/gl.h>
3464#include <GL/glu.h>
3465], [],
3466	ac_cv_have_gl="mesa", ac_cv_have_gl="no")
3467    if test "x$ac_cv_have_gl" = "xno"; then
3468      LDFLAGS="$ac_save_ldflags $X_LDFLAGS $GL_LDFLAGS $all_libraries -lGLU -lGL"
3469      test "x$kde_use_qt_emb" != xyes && LDFLAGS="$LDFLAGS -lX11"
3470      LDFLAGS="$LDFLAGS $LIB_XEXT -lm $LIBSOCKET"
3471      CXXFLAGS="$ac_save_cflags $X_INCLUDES"
3472      test -n "$GL_INCLUDE" && CFLAGS="-I$GL_INCLUDE $CFLAGS"
3473      AC_TRY_LINK([#include <GL/gl.h>
3474#include <GL/glu.h>
3475], [],
3476	  ac_cv_have_gl="yes", ac_cv_have_gl="no")
3477    fi
3478    AC_LANG_RESTORE
3479    LDFLAGS="$ac_save_ldflags"
3480    CXXFLAGS="$ac_save_cxxflags"
3481   ])dnl
3482
3483  if test "$ac_cv_have_gl" = "no"; then
3484    AC_MSG_RESULT(no)
3485    GL_LDFLAGS=""
3486    GLINC=""
3487    $2
3488  else
3489    AC_DEFINE(HAVE_GL, 1, [Defines if you have GL (Mesa, OpenGL, ...)])
3490    if test "$GL_LDFLAGS" = ""; then
3491       if test "$ac_cv_have_gl" = "mesa"; then
3492          GLLIB='-lMesaGLU -lMesaGL $(LIB_X11)'
3493       else
3494          GLLIB='-lGLU -lGL $(LIB_X11)'
3495       fi
3496    else
3497       if test "$ac_cv_have_gl" = "mesa"; then
3498          GLLIB="$GL_LDFLAGS -lMesaGLU -lMesaGL "'$(LIB_X11)'
3499       else
3500          GLLIB="$GL_LDFLAGS -lGLU -lGL "'$(LIB_X11)'
3501       fi
3502    fi
3503    if test "$GL_INCLUDE" = ""; then
3504       GLINC=""
3505    else
3506       GLINC="-I$GL_INCLUDE"
3507    fi
3508    AC_MSG_RESULT($ac_cv_have_gl)
3509    $1
3510  fi
3511 fi
3512 AC_SUBST(GLINC)
3513 AC_SUBST(GLLIB)
3514])
3515
3516
3517 dnl shadow password and PAM magic - maintained by ossi@kde.org
3518
3519AC_DEFUN(KDE_PAM, [
3520  AC_REQUIRE([KDE_CHECK_LIBDL])
3521
3522  AC_ARG_WITH(pam,
3523    [  --with-pam[=ARG]        enable support for PAM: ARG=[yes|no|service name]],
3524    [ if test "x$withval" = "xyes"; then
3525        use_pam=yes
3526        pam_service=kde
3527      elif test "x$withval" = "xno"; then
3528        use_pam=no
3529      else
3530        use_pam=yes
3531        pam_service=$withval
3532      fi
3533      ac_cv_path_pam="use_pam=$use_pam pam_service=$pam_service"
3534    ], [
3535      AC_CACHE_VAL(ac_cv_path_pam,
3536        [ use_pam=no
3537          AC_CHECK_LIB(pam, pam_start,
3538            [ AC_CHECK_HEADER(security/pam_appl.h,
3539                [ use_pam=yes
3540                  pam_service=kde ])
3541            ], , $LIBDL)
3542          ac_cv_path_pam="use_pam=$use_pam pam_service=$pam_service"
3543        ])
3544    ])
3545  eval "$ac_cv_path_pam"
3546
3547  AC_MSG_CHECKING(for PAM)
3548  if test "x$use_pam" = xno; then
3549    AC_MSG_RESULT(no)
3550    PAMLIBS=""
3551  else
3552    AC_MSG_RESULT(yes)
3553    AC_DEFINE(HAVE_PAM, 1, [Defines if you have PAM (Pluggable Authentication Modules)])
3554    PAMLIBS="$PAM_MISC_LIB -lpam $LIBDL"
3555
3556    dnl test whether struct pam_message is const (Linux) or not (Sun)
3557    AC_MSG_CHECKING(for const pam_message)
3558    AC_EGREP_HEADER([struct pam_message], security/pam_appl.h,
3559      [ AC_EGREP_HEADER([const struct pam_message], security/pam_appl.h,
3560                        [AC_MSG_RESULT([const: Linux-type PAM])],
3561                        [AC_MSG_RESULT([nonconst: Sun-type PAM])
3562                        AC_DEFINE(PAM_MESSAGE_NONCONST, 1, [Define if your PAM support takes non-const arguments (Solaris)])]
3563                        )],
3564      [AC_MSG_RESULT([not found - assume const, Linux-type PAM])])
3565  fi
3566
3567  AC_SUBST(PAMLIBS)
3568])
3569
3570dnl DEF_PAM_SERVICE(arg name, full name, define name)
3571AC_DEFUN(DEF_PAM_SERVICE, [
3572  AC_ARG_WITH($1-pam,
3573    [  --with-$1-pam=[val]    override PAM service from --with-pam for $2],
3574    [ if test "x$use_pam" = xyes; then
3575        $3_PAM_SERVICE="$withval"
3576      else
3577        AC_MSG_ERROR([Cannot use use --with-$1-pam, as no PAM was detected.
3578You may want to enforce it by using --with-pam.])
3579      fi
3580    ],
3581    [ if test "x$use_pam" = xyes; then
3582        $3_PAM_SERVICE="$pam_service"
3583      fi
3584    ])
3585    if test -n "$$3_PAM_SERVICE"; then
3586      AC_MSG_RESULT([The PAM service used by $2 will be $$3_PAM_SERVICE])
3587      AC_DEFINE_UNQUOTED($3_PAM_SERVICE, "$$3_PAM_SERVICE", [The PAM service to be used by $2])
3588    fi
3589    AC_SUBST($3_PAM_SERVICE)
3590])
3591
3592AC_DEFUN(KDE_SHADOWPASSWD, [
3593  AC_REQUIRE([KDE_PAM])
3594
3595  AC_CHECK_LIB(shadow, getspent,
3596    [ LIBSHADOW="-lshadow"
3597      ac_use_shadow=yes
3598    ],
3599    [ dnl for UnixWare
3600      AC_CHECK_LIB(gen, getspent,
3601        [ LIBGEN="-lgen"
3602          ac_use_shadow=yes
3603        ],
3604        [ AC_CHECK_FUNC(getspent,
3605            [ ac_use_shadow=yes ],
3606            [ ac_use_shadow=no ])
3607	])
3608    ])
3609  AC_SUBST(LIBSHADOW)
3610  AC_SUBST(LIBGEN)
3611
3612  AC_MSG_CHECKING([for shadow passwords])
3613
3614  AC_ARG_WITH(shadow,
3615    [  --with-shadow		  If you want shadow password support ],
3616    [ if test "x$withval" != "xno"; then
3617        use_shadow=yes
3618      else
3619        use_shadow=no
3620      fi
3621    ], [
3622      use_shadow="$ac_use_shadow"
3623    ])
3624
3625  if test "x$use_shadow" = xyes; then
3626    AC_MSG_RESULT(yes)
3627    AC_DEFINE(HAVE_SHADOW, 1, [Define if you use shadow passwords])
3628  else
3629    AC_MSG_RESULT(no)
3630    LIBSHADOW=
3631    LIBGEN=
3632  fi
3633
3634  dnl finally make the relevant binaries setuid root, if we have shadow passwds.
3635  dnl this still applies, if we could use it indirectly through pam.
3636  if test "x$use_shadow" = xyes ||
3637     ( test "x$use_pam" = xyes && test "x$ac_use_shadow" = xyes ); then
3638      case $host in
3639      *-*-freebsd* | *-*-netbsd* | *-*-openbsd*)
3640	SETUIDFLAGS="-m 4755 -o root";;
3641      *)
3642	SETUIDFLAGS="-m 4755";;
3643      esac
3644  fi
3645  AC_SUBST(SETUIDFLAGS)
3646
3647])
3648
3649AC_DEFUN(KDE_PASSWDLIBS, [
3650  AC_REQUIRE([KDE_MISC_TESTS]) dnl for LIBCRYPT
3651  AC_REQUIRE([KDE_PAM])
3652  AC_REQUIRE([KDE_SHADOWPASSWD])
3653
3654  if test "x$use_pam" = "xyes"; then
3655    PASSWDLIBS="$PAMLIBS"
3656  else
3657    PASSWDLIBS="$LIBCRYPT $LIBSHADOW $LIBGEN"
3658  fi
3659
3660  dnl FreeBSD uses a shadow-like setup, where /etc/passwd holds the users, but
3661  dnl /etc/master.passwd holds the actual passwords.  /etc/master.passwd requires
3662  dnl root to read, so kcheckpass needs to be root (even when using pam, since pam
3663  dnl may need to read /etc/master.passwd).
3664  case $host in
3665  *-*-freebsd*)
3666    SETUIDFLAGS="-m 4755 -o root"
3667    ;;
3668  *)
3669    ;;
3670  esac
3671
3672  AC_SUBST(PASSWDLIBS)
3673])
3674
3675AC_DEFUN(KDE_CHECK_LIBDL,
3676[
3677AC_CHECK_LIB(dl, dlopen, [
3678LIBDL="-ldl"
3679ac_cv_have_dlfcn=yes
3680])
3681
3682AC_CHECK_LIB(dld, shl_unload, [
3683LIBDL="-ldld"
3684ac_cv_have_shload=yes
3685])
3686
3687AC_SUBST(LIBDL)
3688])
3689
3690AC_DEFUN(KDE_CHECK_DLOPEN,
3691[
3692KDE_CHECK_LIBDL
3693AC_CHECK_HEADERS(dlfcn.h dl.h)
3694if test "$ac_cv_header_dlfcn_h" = "no"; then
3695  ac_cv_have_dlfcn=no
3696fi
3697
3698if test "$ac_cv_header_dl_h" = "no"; then
3699  ac_cv_have_shload=no
3700fi
3701
3702dnl XXX why change enable_dlopen? its already set by autoconf's AC_ARG_ENABLE
3703dnl (MM)
3704AC_ARG_ENABLE(dlopen,
3705[  --disable-dlopen        link statically [default=no]] ,
3706enable_dlopen=$enableval,
3707enable_dlopen=yes)
3708
3709# override the user's opinion, if we know it better ;)
3710if test "$ac_cv_have_dlfcn" = "no" && test "$ac_cv_have_shload" = "no"; then
3711  enable_dlopen=no
3712fi
3713
3714if test "$ac_cv_have_dlfcn" = "yes"; then
3715  AC_DEFINE_UNQUOTED(HAVE_DLFCN, 1, [Define if you have dlfcn])
3716fi
3717
3718if test "$ac_cv_have_shload" = "yes"; then
3719  AC_DEFINE_UNQUOTED(HAVE_SHLOAD, 1, [Define if you have shload])
3720fi
3721
3722if test "$enable_dlopen" = no ; then
3723  test -n "$1" && eval $1
3724else
3725  test -n "$2" && eval $2
3726fi
3727
3728])
3729
3730AC_DEFUN(KDE_CHECK_DYNAMIC_LOADING,
3731[
3732KDE_CHECK_DLOPEN(libtool_enable_shared=yes, libtool_enable_static=no)
3733KDE_PROG_LIBTOOL
3734AC_MSG_CHECKING([dynamic loading])
3735eval "`egrep '^build_libtool_libs=' libtool`"
3736if test "$build_libtool_libs" = "yes" && test "$enable_dlopen" = "yes"; then
3737  dynamic_loading=yes
3738  AC_DEFINE_UNQUOTED(HAVE_DYNAMIC_LOADING)
3739else
3740  dynamic_loading=no
3741fi
3742AC_MSG_RESULT($dynamic_loading)
3743if test "$dynamic_loading" = "yes"; then
3744  $1
3745else
3746  $2
3747fi
3748])
3749
3750AC_DEFUN(KDE_ADD_INCLUDES,
3751[
3752if test -z "$1"; then
3753  test_include="Pix.h"
3754else
3755  test_include="$1"
3756fi
3757
3758AC_MSG_CHECKING([for libg++ ($test_include)])
3759
3760AC_CACHE_VAL(kde_cv_libgpp_includes,
3761[
3762kde_cv_libgpp_includes=no
3763
3764   for ac_dir in               \
3765                               \
3766     /usr/include/g++          \
3767     /usr/include              \
3768     /usr/unsupported/include  \
3769     /opt/include              \
3770     $extra_include            \
3771     ; \
3772   do
3773     if test -r "$ac_dir/$test_include"; then
3774       kde_cv_libgpp_includes=$ac_dir
3775       break
3776     fi
3777   done
3778])
3779
3780AC_MSG_RESULT($kde_cv_libgpp_includes)
3781if test "$kde_cv_libgpp_includes" != "no"; then
3782  all_includes="-I$kde_cv_libgpp_includes $all_includes $USER_INCLUDES"
3783fi
3784])
3785])
3786
3787
3788AC_DEFUN(KDE_CHECK_MICO,
3789[
3790AC_REQUIRE([KDE_CHECK_LIBDL])
3791AC_REQUIRE([KDE_MISC_TESTS])
3792AC_MSG_CHECKING(for MICO)
3793
3794if test -z "$MICODIR"; then
3795    kde_micodir=/usr/local
3796 else
3797    kde_micodir="$MICODIR"
3798fi
3799
3800AC_ARG_WITH(micodir,
3801  [  --with-micodir=micodir  where mico is installed ],
3802  kde_micodir=$withval,
3803  kde_micodir=$kde_micodir
3804)
3805
3806AC_CACHE_VAL(kde_cv_mico_incdir,
3807[
3808  mico_incdirs="$kde_micodir/include /usr/include /usr/local/include /usr/local/include /opt/local/include $kde_extra_includes"
3809AC_FIND_FILE(CORBA.h, $mico_incdirs, kde_cv_mico_incdir)
3810
3811])
3812kde_micodir=`echo $kde_cv_mico_incdir | sed -e 's#/include##'`
3813
3814if test ! -r  $kde_micodir/include/CORBA.h; then
3815  AC_MSG_ERROR([No CORBA.h found, specify another micodir])
3816fi
3817
3818AC_MSG_RESULT($kde_micodir)
3819
3820MICO_INCLUDES=-I$kde_micodir/include
3821AC_SUBST(MICO_INCLUDES)
3822MICO_LDFLAGS=-L$kde_micodir/lib
3823AC_SUBST(MICO_LDFLAGS)
3824micodir=$kde_micodir
3825AC_SUBST(micodir)
3826
3827AC_MSG_CHECKING([for MICO version])
3828AC_CACHE_VAL(kde_cv_mico_version,
3829[
3830AC_LANG_C
3831cat >conftest.$ac_ext <<EOF
3832#include <stdio.h>
3833#include <mico/version.h>
3834int main() {
3835
3836   printf("MICO_VERSION=%s\n",MICO_VERSION);
3837   return (0);
3838}
3839EOF
3840ac_compile='${CC-gcc} $CFLAGS $MICO_INCLUDES conftest.$ac_ext -o conftest'
3841if AC_TRY_EVAL(ac_compile); then
3842  if eval `./conftest 2>&5`; then
3843    kde_cv_mico_version=$MICO_VERSION
3844  else
3845    AC_MSG_ERROR([your system is not able to execute a small application to
3846    find MICO version! Check $kde_micodir/include/mico/version.h])
3847  fi
3848else
3849  AC_MSG_ERROR([your system is not able to compile a small application to
3850  find MICO version! Check $kde_micodir/include/mico/version.h])
3851fi
3852])
3853
3854dnl installed MICO version
3855mico_v_maj=`echo $kde_cv_mico_version | sed -e 's/^\(.*\)\..*\..*$/\1/'`
3856mico_v_mid=`echo $kde_cv_mico_version | sed -e 's/^.*\.\(.*\)\..*$/\1/'`
3857mico_v_min=`echo $kde_cv_mico_version | sed -e 's/^.*\..*\.\(.*\)$/\1/'`
3858
3859if test "x$1" = "x"; then
3860 req_version="2.3.0"
3861else
3862 req_version=$1
3863fi
3864
3865dnl required MICO version
3866req_v_maj=`echo $req_version | sed -e 's/^\(.*\)\..*\..*$/\1/'`
3867req_v_mid=`echo $req_version | sed -e 's/^.*\.\(.*\)\..*$/\1/'`
3868req_v_min=`echo $req_version | sed -e 's/^.*\..*\.\(.*\)$/\1/'`
3869
3870if test "$mico_v_maj" -lt "$req_v_maj" || \
3871   ( test "$mico_v_maj" -eq "$req_v_maj" && \
3872        test "$mico_v_mid" -lt "$req_v_mid" ) || \
3873   ( test "$mico_v_mid" -eq "$req_v_mid" && \
3874        test "$mico_v_min" -lt "$req_v_min" )
3875
3876then
3877  AC_MSG_ERROR([found MICO version $kde_cv_mico_version but version $req_version \
3878at least is required. You should upgrade MICO.])
3879else
3880  AC_MSG_RESULT([$kde_cv_mico_version (minimum version $req_version, ok)])
3881fi
3882
3883LIBMICO="-lmico$kde_cv_mico_version $LIBCRYPT $LIBSOCKET $LIBDL"
3884AC_SUBST(LIBMICO)
3885if test -z "$IDL"; then
3886  IDL='$(kde_bindir)/cuteidl'
3887fi
3888AC_SUBST(IDL)
3889IDL_DEPENDENCIES='$(kde_includes)/CUTE.h'
3890AC_SUBST(IDL_DEPENDENCIES)
3891
3892idldir="\$(includedir)/idl"
3893AC_SUBST(idldir)
3894
3895])
3896
3897AC_DEFUN(KDE_CHECK_MINI_STL,
3898[
3899AC_REQUIRE([KDE_CHECK_MICO])
3900
3901AC_MSG_CHECKING(if we use mico's mini-STL)
3902AC_CACHE_VAL(kde_cv_have_mini_stl,
3903[
3904AC_LANG_SAVE
3905AC_LANG_CPLUSPLUS
3906kde_save_cxxflags="$CXXFLAGS"
3907CXXFLAGS="$CXXFLAGS $MICO_INCLUDES"
3908AC_TRY_COMPILE(
3909[
3910#include <mico/config.h>
3911],
3912[
3913#ifdef HAVE_MINI_STL
3914#error "nothing"
3915#endif
3916],
3917kde_cv_have_mini_stl=no,
3918kde_cv_have_mini_stl=yes)
3919CXXFLAGS="$kde_save_cxxflags"
3920AC_LANG_RESTORE
3921])
3922
3923if test "x$kde_cv_have_mini_stl" = "xyes"; then
3924   AC_MSG_RESULT(yes)
3925   $1
3926else
3927   AC_MSG_RESULT(no)
3928   $2
3929fi
3930])
3931
3932])
3933
3934
3935AC_DEFUN(KDE_CHECK_LIBPTHREAD,
3936[
3937AC_CHECK_LIB(pthread, pthread_create, [LIBPTHREAD="-lpthread"] )
3938AC_SUBST(LIBPTHREAD)
3939])
3940
3941AC_DEFUN(KDE_CHECK_PTHREAD_OPTION,
3942[
3943    AC_ARG_ENABLE(kernel-threads, [  --enable-kernel-threads Enable the use of the LinuxThreads port on FreeBSD/i386 only.],
3944	kde_use_kernthreads=$enableval, kde_use_kernthreads=no)
3945
3946    if test "$kde_use_kernthreads" = "yes"; then
3947      ac_save_CXXFLAGS="$CXXFLAGS"
3948      ac_save_CFLAGS="$CFLAGS"
3949      CXXFLAGS="-I/usr/local/include/pthread/linuxthreads $CXXFLAGS"
3950      CFLAGS="-I/usr/local/include/pthread/linuxthreads $CFLAGS"
3951      AC_CHECK_HEADERS(pthread/linuxthreads/pthread.h)
3952      CXXFLAGS="$ac_save_CXXFLAGS"
3953      CFLAGS="$ac_save_CFLAGS"
3954      if test "$ac_cv_header_pthread_linuxthreads_pthread_h" = "no"; then
3955        kde_use_kernthreads=no
3956      else
3957        dnl Add proper -I and -l statements
3958        AC_CHECK_LIB(lthread, pthread_join, [LIBPTHREAD="-llthread -llgcc_r"]) dnl for FreeBSD
3959        if test "x$LIBPTHREAD" = "x"; then
3960          kde_use_kernthreads=no
3961        else
3962          USE_THREADS="-D_THREAD_SAFE -I/usr/local/include/pthread/linuxthreads"
3963        fi
3964      fi
3965    else
3966      USE_THREADS=""
3967      if test -z "$LIBPTHREAD"; then
3968        KDE_CHECK_COMPILER_FLAG(pthread, [USE_THREADS="-pthread"] )
3969      fi
3970    fi
3971
3972    AH_VERBATIM(__svr_define, [
3973#if defined(__SVR4) && !defined(__svr4__)
3974#define __svr4__ 1
3975#endif
3976])
3977    case $host_os in
3978 	solaris*)
3979		KDE_CHECK_COMPILER_FLAG(mt, [USE_THREADS="-mt"])
3980                CPPFLAGS="$CPPFLAGS -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -DUSE_SOLARIS -DSVR4"
3981    		;;
3982        freebsd*)
3983                CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE"
3984                ;;
3985        aix*)
3986                CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE"
3987                LIBPTHREAD="$LIBPTHREAD -lc_r"
3988                ;;
3989        linux*) CPPFLAGS="$CPPFLAGS -D_REENTRANT"
3990                if test "$CXX" = "KCC"; then
3991                  CXXFLAGS="$CXXFLAGS --thread_safe"
3992		  NOOPT_CXXFLAGS="$NOOPT_CXXFLAGS --thread_safe"
3993                fi
3994                ;;
3995	*)
3996		;;
3997    esac
3998    AC_SUBST(USE_THREADS)
3999    AC_SUBST(LIBPTHREAD)
4000])
4001
4002AC_DEFUN(KDE_CHECK_THREADING,
4003[
4004  AC_REQUIRE([KDE_CHECK_LIBPTHREAD])
4005  AC_REQUIRE([KDE_CHECK_PTHREAD_OPTION])
4006  dnl default is yes if libpthread is found and no if no libpthread is available
4007  if test -z "$LIBPTHREAD"; then
4008    if test -z "$USE_THREADS"; then
4009      kde_check_threading_default=no
4010    else
4011      kde_check_threading_default=yes
4012    fi
4013  else
4014    kde_check_threading_default=yes
4015  fi
4016  AC_ARG_ENABLE(threading, [  --disable-threading     disables threading even if libpthread found ],
4017   kde_use_threading=$enableval, kde_use_threading=$kde_check_threading_default)
4018  if test "x$kde_use_threading" = "xyes"; then
4019    AC_DEFINE(HAVE_LIBPTHREAD, 1, [Define if you have a working libpthread (will enable threaded code)])
4020  fi
4021])
4022
4023AC_DEFUN(KDE_TRY_LINK_PYTHON,
4024[
4025if test "$kde_python_link_found" = no; then
4026
4027if test "$1" = normal; then
4028  AC_MSG_CHECKING(if a Python application links)
4029else
4030  AC_MSG_CHECKING(if Python depends on $2)
4031fi
4032
4033AC_CACHE_VAL(kde_cv_try_link_python_$1,
4034[
4035AC_LANG_SAVE
4036AC_LANG_C
4037kde_save_cflags="$CFLAGS"
4038CFLAGS="$CFLAGS $PYTHONINC"
4039kde_save_libs="$LIBS"
4040LIBS="$LIBS $LIBPYTHON $2 $LIBDL $LIBSOCKET"
4041kde_save_ldflags="$LDFLAGS"
4042LDFLAGS="$LDFLAGS $PYTHONLIB"
4043
4044AC_TRY_LINK(
4045[
4046#include <Python.h>
4047],[
4048	PySys_SetArgv(1, 0);
4049],
4050	[kde_cv_try_link_python_$1=yes],
4051	[kde_cv_try_link_python_$1=no]
4052)
4053CFLAGS="$kde_save_cflags"
4054LIBS="$kde_save_libs"
4055LDFLAGS="$kde_save_ldflags"
4056])
4057
4058if test "$kde_cv_try_link_python_$1" = "yes"; then
4059  AC_MSG_RESULT(yes)
4060  kde_python_link_found=yes
4061  if test ! "$1" = normal; then
4062    LIBPYTHON="$LIBPYTHON $2"
4063  fi
4064  $3
4065else
4066  AC_MSG_RESULT(no)
4067  $4
4068fi
4069AC_LANG_RESTORE
4070
4071fi
4072
4073])
4074
4075AC_DEFUN(KDE_CHECK_PYTHON_DIR,
4076[
4077AC_MSG_CHECKING([for Python directory])
4078
4079AC_CACHE_VAL(kde_cv_pythondir,
4080[
4081  if test -z "$PYTHONDIR"; then
4082    kde_cv_pythondir=/usr/local
4083  else
4084    kde_cv_pythondir="$PYTHONDIR"
4085  fi
4086])
4087
4088AC_ARG_WITH(pythondir,
4089[  --with-pythondir=pythondir   use python installed in pythondir ],
4090[
4091  ac_python_dir=$withval
4092], ac_python_dir=$kde_cv_pythondir
4093)
4094
4095AC_MSG_RESULT($ac_python_dir)
4096])
4097
4098AC_DEFUN(KDE_CHECK_PYTHON_INTERN,
4099[
4100AC_REQUIRE([KDE_CHECK_LIBDL])
4101AC_REQUIRE([KDE_CHECK_LIBPTHREAD])
4102AC_REQUIRE([KDE_CHECK_PYTHON_DIR])
4103
4104if test -z "$1"; then
4105  version="1.5"
4106else
4107  version="$1"
4108fi
4109
4110AC_MSG_CHECKING([for Python$version])
4111
4112python_incdirs="$ac_python_dir/include /usr/include /usr/local/include/ $kde_extra_includes"
4113AC_FIND_FILE(Python.h, $python_incdirs, python_incdir)
4114if test ! -r $python_incdir/Python.h; then
4115  AC_FIND_FILE(python$version/Python.h, $python_incdirs, python_incdir)
4116  python_incdir=$python_incdir/python$version
4117  if test ! -r $python_incdir/Python.h; then
4118    python_incdir=no
4119  fi
4120fi
4121
4122PYTHONINC=-I$python_incdir
4123
4124python_libdirs="$ac_python_dir/lib /usr/lib /usr/local /usr/lib $kde_extra_libs"
4125AC_FIND_FILE(libpython$version.a, $python_libdirs, python_libdir)
4126if test ! -r $python_libdir/libpython$version.a; then
4127  AC_FIND_FILE(python$version/config/libpython$version.a, $python_libdirs, python_libdir)
4128  python_libdir=$python_libdir/python$version/config
4129  if test ! -r $python_libdir/libpython$version.a; then
4130    python_libdir=no
4131  fi
4132fi
4133
4134PYTHONLIB=-L$python_libdir
4135kde_orig_LIBPYTHON=$LIBPYTHON
4136if test -z "$LIBPYTHON"; then
4137  LIBPYTHON=-lpython$version
4138fi
4139
4140python_libdirs="$ac_python_dir/lib /usr/lib /usr/local /usr/lib $kde_extra_libs"
4141AC_FIND_FILE(python$version/copy.py, $python_libdirs, python_moddir)
4142python_moddir=$python_moddir/python$version
4143if test ! -r $python_moddir/copy.py; then
4144  python_moddir=no
4145fi
4146
4147PYTHONMODDIR=$python_moddir
4148
4149AC_MSG_RESULT(header $python_incdir library $python_libdir modules $python_moddir)
4150
4151if test x$python_incdir = xno ||  test x$python_libdir = xno ||  test x$python_moddir = xno; then
4152   LIBPYTHON=$kde_orig_LIBPYTHON
4153   test "x$PYTHONLIB" = "x-Lno" && PYTHONLIB=""
4154   test "x$PYTHONINC" = "x-Ino" && PYTHONINC=""
4155   $2
4156else
4157  dnl Note: this test is very weak
4158  kde_python_link_found=no
4159  KDE_TRY_LINK_PYTHON(normal)
4160  KDE_TRY_LINK_PYTHON(m, -lm)
4161  KDE_TRY_LINK_PYTHON(pthread, $LIBPTHREAD)
4162  KDE_TRY_LINK_PYTHON(tcl, -ltcl)
4163  KDE_TRY_LINK_PYTHON(db2, -ldb2)
4164  KDE_TRY_LINK_PYTHON(m_and_thread, [$LIBPTHREAD -lm])
4165  KDE_TRY_LINK_PYTHON(m_and_thread_and_util, [$LIBPTHREAD -lm -lutil])
4166  KDE_TRY_LINK_PYTHON(m_and_thread_and_db3, [$LIBPTHREAD -lm -ldb-3 -lutil])
4167  KDE_TRY_LINK_PYTHON(pthread_and_db3, [$LIBPTHREAD -ldb-3])
4168  KDE_TRY_LINK_PYTHON(m_and_thread_and_db, [$LIBPTHREAD -lm -ldb -ltermcap -lutil])
4169  KDE_TRY_LINK_PYTHON(pthread_and_dl, [$LIBPTHREAD $LIBDL -lutil -lreadline -lncurses -lm])
4170  KDE_TRY_LINK_PYTHON(m_and_thread_and_db_special, [$LIBPTHREAD -lm -ldb -lutil], [],
4171	[AC_MSG_WARN([it seems, Python depends on another library.
4172    Pleae set LIBPYTHON to '-lpython$version -lotherlib' before calling configure to fix this
4173    and contact the authors to let them know about this problem])
4174	])
4175
4176  LIBPYTHON="$LIBPYTHON $LIBDL $LIBSOCKET"
4177  AC_SUBST(PYTHONINC)
4178  AC_SUBST(PYTHONLIB)
4179  AC_SUBST(LIBPYTHON)
4180  AC_SUBST(PYTHONMODDIR)
4181  AC_DEFINE(HAVE_PYTHON, 1, [Define if you have the development files for python])
4182fi
4183
4184])
4185
4186
4187AC_DEFUN(KDE_CHECK_PYTHON,
4188[
4189  KDE_CHECK_PYTHON_INTERN("2.3",
4190    [KDE_CHECK_PYTHON_INTERN("2.2",
4191      [KDE_CHECK_PYTHON_INTERN("2.1",
4192        [KDE_CHECK_PYTHON_INTERN("2.0", [ KDE_CHECK_PYTHON_INTERN($1, $2) ])
4193  ])])])
4194])
4195
4196AC_DEFUN(KDE_CHECK_STL_SGI,
4197[
4198    AC_MSG_CHECKING([if STL implementation is SGI like])
4199    AC_CACHE_VAL(kde_cv_stl_type_sgi,
4200    [
4201      AC_TRY_COMPILE([
4202#include <string>
4203using namespace std;
4204],[
4205  string astring="Hallo Welt.";
4206  astring.erase(0, 6); // now astring is "Welt"
4207  return 0;
4208], kde_cv_stl_type_sgi=yes,
4209   kde_cv_stl_type_sgi=no)
4210])
4211
4212   AC_MSG_RESULT($kde_cv_stl_type_sgi)
4213
4214   if test "$kde_cv_stl_type_sgi" = "yes"; then
4215	AC_DEFINE_UNQUOTED(HAVE_SGI_STL, 1, [Define if you have a STL implementation by SGI])
4216   fi
4217])
4218
4219AC_DEFUN(KDE_CHECK_STL_HP,
4220[
4221    AC_MSG_CHECKING([if STL implementation is HP like])
4222    AC_CACHE_VAL(kde_cv_stl_type_hp,
4223    [
4224      AC_TRY_COMPILE([
4225#include <string>
4226using namespace std;
4227],[
4228  string astring="Hello World";
4229  astring.remove(0, 6); // now astring is "World"
4230  return 0;
4231], kde_cv_stl_type_hp=yes,
4232   kde_cv_stl_type_hp=no)
4233])
4234   AC_MSG_RESULT($kde_cv_stl_type_hp)
4235
4236   if test "$kde_cv_stl_type_hp" = "yes"; then
4237	AC_DEFINE_UNQUOTED(HAVE_HP_STL, 1, [Define if you have a STL implementation by HP])
4238   fi
4239])
4240
4241AC_DEFUN(KDE_CHECK_STL,
4242[
4243    AC_LANG_SAVE
4244    AC_LANG_CPLUSPLUS
4245    ac_save_CXXFLAGS="$CXXFLAGS"
4246    CXXFLAGS="`echo $CXXFLAGS | sed s/-fno-exceptions//`"
4247    KDE_CHECK_STL_SGI
4248
4249    if test "$kde_cv_stl_type_sgi" = "no"; then
4250       KDE_CHECK_STL_HP
4251
4252       if test "$kde_cv_stl_type_hp" = "no"; then
4253         AC_MSG_ERROR("no known STL type found - did you forget to install libstdc++[-devel] ?")
4254       fi
4255    fi
4256
4257    CXXFLAGS="$ac_save_CXXFLAGS"
4258    AC_LANG_RESTORE
4259])
4260
4261AC_DEFUN(AC_FIND_QIMGIO,
4262   [AC_REQUIRE([AC_FIND_JPEG])
4263AC_REQUIRE([KDE_CHECK_EXTRA_LIBS])
4264AC_MSG_CHECKING([for qimgio])
4265AC_CACHE_VAL(ac_cv_lib_qimgio,
4266[
4267AC_LANG_SAVE
4268AC_LANG_CPLUSPLUS
4269ac_save_LIBS="$LIBS"
4270ac_save_CXXFLAGS="$CXXFLAGS"
4271LIBS="$all_libraries -lqimgio -lpng -lz $LIBJPEG $LIBQT"
4272CXXFLAGS="$CXXFLAGS -I$qt_incdir $all_includes"
4273AC_TRY_RUN(dnl
4274[
4275#include <qimageio.h>
4276#include <qstring.h>
4277int main() {
4278		QString t = "hallo";
4279		t.fill('t');
4280		qInitImageIO();
4281}
4282],
4283            ac_cv_lib_qimgio=yes,
4284            ac_cv_lib_qimgio=no,
4285	    ac_cv_lib_qimgio=no)
4286LIBS="$ac_save_LIBS"
4287CXXFLAGS="$ac_save_CXXFLAGS"
4288AC_LANG_RESTORE
4289])dnl
4290if eval "test \"`echo $ac_cv_lib_qimgio`\" = yes"; then
4291  LIBQIMGIO="-lqimgio -lpng -lz $LIBJPEG"
4292  AC_MSG_RESULT(yes)
4293  AC_DEFINE_UNQUOTED(HAVE_QIMGIO, 1, [Define if you have the Qt extension qimgio available])
4294  AC_SUBST(LIBQIMGIO)
4295else
4296  AC_MSG_RESULT(not found)
4297fi
4298])
4299
4300AC_DEFUN(KDE_CHECK_ANSI,
4301[
4302])
4303
4304AC_DEFUN(KDE_CHECK_INSURE,
4305[
4306  AC_ARG_ENABLE(insure, [  --enable-insure             use insure++ for debugging [default=no]],
4307  [
4308  if test $enableval = "no"; dnl
4309	then ac_use_insure="no"
4310	else ac_use_insure="yes"
4311   fi
4312  ], [ac_use_insure="no"])
4313
4314  AC_MSG_CHECKING(if we will use Insure++ to debug)
4315  AC_MSG_RESULT($ac_use_insure)
4316  if test "$ac_use_insure" = "yes"; dnl
4317       then CC="insure"; CXX="insure"; dnl CFLAGS="$CLAGS -fno-rtti -fno-exceptions "????
4318   fi
4319])
4320
4321AC_DEFUN(AM_DISABLE_LIBRARIES,
4322[
4323    AC_PROVIDE([AM_ENABLE_STATIC])
4324    AC_PROVIDE([AM_ENABLE_SHARED])
4325    enable_static=no
4326    enable_shared=yes
4327])
4328
4329
4330AC_DEFUN(AC_CHECK_UTMP_FILE,
4331[
4332    AC_MSG_CHECKING([for utmp file])
4333
4334    AC_CACHE_VAL(kde_cv_utmp_file,
4335    [
4336    kde_cv_utmp_file=no
4337
4338    for ac_file in    \
4339                      \
4340	/var/run/utmp \
4341	/var/adm/utmp \
4342	/etc/utmp     \
4343     ; \
4344    do
4345     if test -r "$ac_file"; then
4346       kde_cv_utmp_file=$ac_file
4347       break
4348     fi
4349    done
4350    ])
4351
4352    if test "$kde_cv_utmp_file" != "no"; then
4353	AC_DEFINE_UNQUOTED(UTMP, "$kde_cv_utmp_file", [Define the file for utmp entries])
4354	$1
4355	AC_MSG_RESULT($kde_cv_utmp_file)
4356    else
4357    	$2
4358	AC_MSG_RESULT([non found])
4359    fi
4360])
4361
4362
4363AC_DEFUN(KDE_CREATE_SUBDIRSLIST,
4364[
4365
4366DO_NOT_COMPILE="$DO_NOT_COMPILE CVS debian bsd-port admin"
4367
4368if test ! -s $srcdir/subdirs; then
4369  dnl Note: Makefile.common creates subdirs, so this is just a fallback
4370  TOPSUBDIRS=""
4371  files=`cd $srcdir && ls -1`
4372  dirs=`for i in $files; do if test -d $i; then echo $i; fi; done`
4373  for i in $dirs; do
4374    echo $i >> $srcdir/subdirs
4375  done
4376fi
4377
4378if test -s $srcdir/inst-apps; then
4379  ac_topsubdirs="`cat $srcdir/inst-apps`"
4380else
4381  ac_topsubdirs="`cat $srcdir/subdirs`"
4382fi
4383
4384for i in $ac_topsubdirs; do
4385  AC_MSG_CHECKING([if $i should be compiled])
4386  if test -d $srcdir/$i; then
4387    install_it="yes"
4388    for j in $DO_NOT_COMPILE; do
4389      if test $i = $j; then
4390        install_it="no"
4391      fi
4392    done
4393  else
4394    install_it="no"
4395  fi
4396  AC_MSG_RESULT($install_it)
4397  vari=`echo $i | sed -e 's,[[-+.]],_,g'`
4398  if test $install_it = "yes"; then
4399    TOPSUBDIRS="$TOPSUBDIRS $i"
4400    eval "$vari""_SUBDIR_included=yes"
4401  else
4402    eval "$vari""_SUBDIR_included=no"
4403  fi
4404done
4405
4406AC_SUBST(TOPSUBDIRS)
4407])
4408
4409AC_DEFUN(KDE_CHECK_NAMESPACES,
4410[
4411AC_MSG_CHECKING(whether C++ compiler supports namespaces)
4412AC_LANG_SAVE
4413AC_LANG_CPLUSPLUS
4414AC_TRY_COMPILE([
4415],
4416[
4417namespace Foo {
4418  extern int i;
4419  namespace Bar {
4420    extern int i;
4421  }
4422}
4423
4424int Foo::i = 0;
4425int Foo::Bar::i = 1;
4426],[
4427  AC_MSG_RESULT(yes)
4428  AC_DEFINE(HAVE_NAMESPACES)
4429], [
4430AC_MSG_RESULT(no)
4431])
4432AC_LANG_RESTORE
4433])
4434
4435AC_DEFUN(KDE_CHECK_NEWLIBS,
4436[
4437
4438])
4439
4440dnl ------------------------------------------------------------------------
4441dnl Check for S_ISSOCK macro. Doesn't exist on Unix SCO. faure@kde.org
4442dnl ------------------------------------------------------------------------
4443dnl
4444AC_DEFUN(AC_CHECK_S_ISSOCK,
4445[
4446AC_MSG_CHECKING(for S_ISSOCK)
4447AC_CACHE_VAL(ac_cv_have_s_issock,
4448[
4449AC_LANG_SAVE
4450AC_LANG_C
4451AC_TRY_LINK(
4452[
4453#include <sys/stat.h>
4454],
4455[
4456struct stat buff;
4457int b = S_ISSOCK( buff.st_mode );
4458],
4459ac_cv_have_s_issock=yes,
4460ac_cv_have_s_issock=no)
4461AC_LANG_RESTORE
4462])
4463AC_MSG_RESULT($ac_cv_have_s_issock)
4464if test "$ac_cv_have_s_issock" = "yes"; then
4465  AC_DEFINE_UNQUOTED(HAVE_S_ISSOCK, 1, [Define if sys/stat.h declares S_ISSOCK.])
4466fi
4467
4468AH_VERBATIM(_ISSOCK,
4469[
4470#ifndef HAVE_S_ISSOCK
4471#define HAVE_S_ISSOCK
4472#define S_ISSOCK(mode) (1==0)
4473#endif
4474])
4475
4476])
4477
4478dnl ------------------------------------------------------------------------
4479dnl Check for MAXPATHLEN macro, defines KDEMAXPATHLEN. faure@kde.org
4480dnl ------------------------------------------------------------------------
4481dnl
4482AC_DEFUN(AC_CHECK_KDEMAXPATHLEN,
4483[
4484AC_MSG_CHECKING(for MAXPATHLEN)
4485AC_CACHE_VAL(ac_cv_maxpathlen,
4486[
4487AC_LANG_C
4488cat > conftest.$ac_ext <<EOF
4489#ifdef STDC_HEADERS
4490# include <stdlib.h>
4491#endif
4492#include <stdio.h>
4493#include <sys/param.h>
4494#ifndef MAXPATHLEN
4495#define MAXPATHLEN 1024
4496#endif
4497
4498KDE_HELLO MAXPATHLEN
4499
4500EOF
4501
4502ac_try="$ac_cpp conftest.$ac_ext 2>/dev/null | grep '^KDE_HELLO' >conftest.out"
4503
4504if AC_TRY_EVAL(ac_try) && test -s conftest.out; then
4505    ac_cv_maxpathlen=`sed 's#KDE_HELLO ##' conftest.out`
4506else
4507    ac_cv_maxpathlen=1024
4508fi
4509
4510rm conftest.*
4511
4512])
4513AC_MSG_RESULT($ac_cv_maxpathlen)
4514AC_DEFINE_UNQUOTED(KDEMAXPATHLEN,$ac_cv_maxpathlen, [Define a safe value for MAXPATHLEN] )
4515])
4516
4517dnl -------------------------------------------------------------------------
4518dnl See if the compiler supports a template repository         bero@redhat.de
4519dnl -------------------------------------------------------------------------
4520AC_DEFUN(KDE_COMPILER_REPO,
4521[
4522  REPO=""
4523  NOREPO=""
4524
4525  KDE_CHECK_COMPILER_FLAG(frepo,
4526   [
4527     REPO="-frepo"
4528     NOREPO="-fno-repo"
4529   ])
4530
4531  if test -z "$REPO"; then
4532  KDE_CHECK_COMPILER_FLAG(instances=explicit,
4533  [
4534     REPO="-instances=explicit"
4535     NOREPO="-instances=extern"
4536  ])
4537  fi
4538
4539  if test -n "$REPO"; then
4540     AC_DEFINE_UNQUOTED(HAVE_TEMPLATE_REPOSITORY, 1,
4541		[C++ compiler supports template repository])
4542     $1
4543  fi
4544
4545  AC_SUBST(REPO)
4546  AC_SUBST(NOREPO)
4547])
4548
4549AC_DEFUN(KDE_CHECK_HEADER,
4550[
4551   AC_LANG_SAVE
4552   kde_safe_cppflags=$CPPFLAGS
4553   CPPFLAGS="$CPPFLAGS $all_includes"
4554   AC_LANG_CPLUSPLUS
4555   AC_CHECK_HEADER($1, $2, $3, $4)
4556   CPPFLAGS=$kde_safe_cppflags
4557   AC_LANG_RESTORE
4558])
4559
4560AC_DEFUN(KDE_CHECK_HEADERS,
4561[
4562   AH_CHECK_HEADERS([$1])
4563   AC_LANG_SAVE
4564   kde_safe_cppflags=$CPPFLAGS
4565   CPPFLAGS="$CPPFLAGS $all_includes"
4566   AC_LANG_CPLUSPLUS
4567   AC_CHECK_HEADERS([$1], [$2], [$3], [$4])
4568   CPPFLAGS=$kde_safe_cppflags
4569   AC_LANG_RESTORE
4570])
4571
4572AC_DEFUN(KDE_FAST_CONFIGURE,
4573[
4574  dnl makes configure fast (needs perl)
4575  AC_ARG_ENABLE(fast-perl, [  --disable-fast-perl     disable fast Makefile generation (needs perl)],
4576      with_fast_perl=$enableval, with_fast_perl=yes)
4577])
4578
4579AC_DEFUN(KDE_CONF_FILES,
4580[
4581  val=
4582  if test -f $srcdir/configure.files ; then
4583    val=`sed -e 's%^%\$(top_srcdir)/%' $srcdir/configure.files`
4584  fi
4585  CONF_FILES=
4586  if test -n "$val" ; then
4587    for i in $val ; do
4588      CONF_FILES="$CONF_FILES $i"
4589    done
4590  fi
4591  AC_SUBST(CONF_FILES)
4592])dnl
4593
4594AC_DEFUN(KDE_SET_PREFIX,
4595[
4596  unset CDPATH
4597  dnl make $KDEDIR the default for the installation
4598  AC_PREFIX_DEFAULT(${KDEDIR:-/usr/local/kde})
4599
4600  if test "x$prefix" = "xNONE"; then
4601    prefix=$ac_default_prefix
4602    ac_configure_args="$ac_configure_args --prefix=$prefix"
4603  fi
4604  # And delete superflous '/' to make compares easier
4605  prefix=`echo "$prefix" | sed 's,//*,/,g' | sed -e 's,/$,,'`
4606  exec_prefix=`echo "$exec_prefix" | sed 's,//*,/,g' | sed -e 's,/$,,'`
4607  KDE_FAST_CONFIGURE
4608  KDE_CONF_FILES
4609])
4610
4611pushdef([AC_PROG_INSTALL],
4612[
4613  dnl our own version, testing for a -p flag
4614  popdef([AC_PROG_INSTALL])
4615  dnl as AC_PROG_INSTALL works as it works we first have
4616  dnl to save if the user didn't specify INSTALL, as the
4617  dnl autoconf one overwrites INSTALL and we have no chance to find
4618  dnl out afterwards
4619  test -n "$INSTALL" && kde_save_INSTALL_given=$INSTALL
4620  test -n "$INSTALL_PROGRAM" && kde_save_INSTALL_PROGRAM_given=$INSTALL_PROGRAM
4621  test -n "$INSTALL_SCRIPT" && kde_save_INSTALL_SCRIPT_given=$INSTALL_SCRIPT
4622  AC_PROG_INSTALL
4623
4624  if test -z "$kde_save_INSTALL_given" ; then
4625    # OK, user hasn't given any INSTALL, autoconf found one for us
4626    # now we test, if it supports the -p flag
4627    AC_MSG_CHECKING(for -p flag to install)
4628    rm -f confinst.$$.* > /dev/null 2>&1
4629    echo "Testtest" > confinst.$$.orig
4630    ac_res=no
4631    if ${INSTALL} -p confinst.$$.orig confinst.$$.new > /dev/null 2>&1 ; then
4632      if test -f confinst.$$.new ; then
4633        # OK, -p seems to do no harm to install
4634	INSTALL="${INSTALL} -p"
4635	ac_res=yes
4636      fi
4637    fi
4638    rm -f confinst.$$.*
4639    AC_MSG_RESULT($ac_res)
4640  fi
4641  dnl the following tries to resolve some signs and wonders coming up
4642  dnl with different autoconf/automake versions
4643  dnl e.g.:
4644  dnl  *automake 1.4 install-strip sets A_M_INSTALL_PROGRAM_FLAGS to -s
4645  dnl   and has INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(A_M_INSTALL_PROGRAM_FLAGS)
4646  dnl   it header-vars.am, so there the actual INSTALL_PROGRAM gets the -s
4647  dnl  *automake 1.4a (and above) use INSTALL_STRIP_FLAG and only has
4648  dnl   INSTALL_PROGRAM = @INSTALL_PROGRAM@ there, but changes the
4649  dnl   install-@DIR@PROGRAMS targets to explicitly use that flag
4650  dnl  *autoconf 2.13 is dumb, and thinks it can use INSTALL_PROGRAM as
4651  dnl   INSTALL_SCRIPT, which breaks with automake <= 1.4
4652  dnl  *autoconf >2.13 (since 10.Apr 1999) has not that failure
4653  dnl  *sometimes KDE does not use the install-@DIR@PROGRAM targets from
4654  dnl   automake (due to broken Makefile.am or whatever) to install programs,
4655  dnl   and so does not see the -s flag in automake > 1.4
4656  dnl to clean up that mess we:
4657  dnl  +set INSTALL_PROGRAM to use INSTALL_STRIP_FLAG
4658  dnl   which cleans KDE's program with automake > 1.4;
4659  dnl  +set INSTALL_SCRIPT to only use INSTALL, to clean up autoconf's problems
4660  dnl   with automake<=1.4
4661  dnl  note that dues to this sometimes two '-s' flags are used (if KDE
4662  dnl   properly uses install-@DIR@PROGRAMS, but I don't care
4663  dnl
4664  dnl And to all this comes, that I even can't write in comments variable
4665  dnl  names used by automake, because it is so stupid to think I wanted to
4666  dnl  _use_ them, therefor I have written A_M_... instead of AM_
4667  dnl hmm, I wanted to say something ... ahh yes: Arghhh.
4668
4669  if test -z "$kde_save_INSTALL_PROGRAM_given" ; then
4670    INSTALL_PROGRAM='${INSTALL} $(INSTALL_STRIP_FLAG)'
4671  fi
4672  if test -z "$kde_save_INSTALL_SCRIPT_given" ; then
4673    INSTALL_SCRIPT='${INSTALL}'
4674  fi
4675])dnl
4676
4677AC_DEFUN(KDE_LANG_CPLUSPLUS,
4678[AC_LANG_CPLUSPLUS
4679ac_link='rm -rf SunWS_cache; ${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&AC_FD_CC'
4680pushdef([AC_LANG_CPLUSPLUS], [popdef([AC_LANG_CPLUSPLUS]) KDE_LANG_CPLUSPLUS])
4681])
4682
4683pushdef([AC_LANG_CPLUSPLUS],
4684[popdef([AC_LANG_CPLUSPLUS])
4685KDE_LANG_CPLUSPLUS
4686])
4687
4688AC_DEFUN(KDE_CHECK_LONG_LONG,
4689[
4690AC_MSG_CHECKING(for long long)
4691AC_CACHE_VAL(kde_cv_c_long_long,
4692[
4693  AC_LANG_SAVE
4694  AC_LANG_CPLUSPLUS
4695  AC_TRY_LINK([], [
4696  long long foo = 0;
4697  foo = foo+1;
4698  ],
4699  kde_cv_c_long_long=yes, kde_cv_c_long_long=no)
4700  AC_LANG_RESTORE
4701])
4702AC_MSG_RESULT($kde_cv_c_long_long)
4703if test "$kde_cv_c_long_long" = yes; then
4704   AC_DEFINE(HAVE_LONG_LONG, 1, [Define if you have long long as datatype])
4705fi
4706])
4707
4708AC_DEFUN(KDE_CHECK_LIB,
4709[
4710     kde_save_LDFLAGS="$LDFLAGS"
4711     dnl AC_CHECK_LIB modifies LIBS, so save it here
4712     kde_save_LIBS="$LIBS"
4713     LDFLAGS="$LDFLAGS $all_libraries"
4714     case $host_os in
4715      aix*) LDFLAGS="-brtl $LDFLAGS"
4716	test "$GCC" = yes && LDFLAGS="-Wl,$LDFLAGS"
4717	;;
4718     esac
4719     AC_CHECK_LIB($1, $2, $3, $4, $5)
4720     LDFLAGS="$kde_save_LDFLAGS"
4721     LIBS="$kde_save_LIBS"
4722])
4723
4724AC_DEFUN(KDE_JAVA_PREFIX,
4725[
4726	dir=`dirname "$1"`
4727	base=`basename "$1"`
4728	list=`ls -1 $dir 2> /dev/null`
4729	for entry in $list; do
4730		if test -d $dir/$entry/bin; then
4731			case $entry in
4732			   $base)
4733				javadirs="$javadirs $dir/$entry/bin"
4734				;;
4735			esac
4736		elif test -d $dir/$entry/jre/bin; then
4737			case $entry in
4738			   $base)
4739				javadirs="$javadirs $dir/$entry/jre/bin"
4740				;;
4741			esac
4742		fi
4743	done
4744])
4745
4746dnl KDE_CHEC_JAVA_DIR(onlyjre)
4747AC_DEFUN(KDE_CHECK_JAVA_DIR,
4748[
4749
4750AC_ARG_WITH(java,
4751[  --with-java=javadir     use java installed in javadir, --without-java disables ],
4752[  ac_java_dir=$withval
4753], ac_java_dir=""
4754)
4755
4756AC_MSG_CHECKING([for Java])
4757
4758dnl at this point ac_java_dir is either a dir, 'no' to disable, or '' to say look in $PATH
4759if test "x$ac_java_dir" = "xno"; then
4760   kde_java_bindir=no
4761   kde_java_includedir=no
4762   kde_java_libjvmdir=no
4763   kde_java_libhpidir=no
4764else
4765  if test "x$ac_java_dir" = "x"; then
4766
4767
4768      dnl No option set -> look in $PATH
4769      KDE_JAVA_PREFIX(/usr/j2se)
4770      KDE_JAVA_PREFIX(/usr/j*dk*)
4771      KDE_JAVA_PREFIX(/usr/lib/j*dk*)
4772      KDE_JAVA_PREFIX(/opt/j*sdk*)
4773      KDE_JAVA_PREFIX(/usr/lib/java*)
4774      KDE_JAVA_PREFIX(/usr/java*)
4775      KDE_JAVA_PREFIX(/usr/java/j*dk*)
4776      KDE_JAVA_PREFIX(/usr/java/j*re*)
4777      KDE_JAVA_PREFIX(/usr/lib/SunJava2*)
4778      KDE_JAVA_PREFIX(/usr/lib/SunJava*)
4779      KDE_JAVA_PREFIX(/usr/lib/IBMJava2*)
4780      KDE_JAVA_PREFIX(/usr/lib/IBMJava*)
4781      KDE_JAVA_PREFIX(/opt/java*)
4782
4783      kde_cv_path="NONE"
4784      kde_save_IFS=$IFS
4785      IFS=':'
4786      for dir in $PATH; do
4787	  javadirs="$javadirs $dir"
4788      done
4789      IFS=$kde_save_IFS
4790      jredirs=
4791
4792      for dir in $javadirs; do
4793	  if test ! -d $dir; then break; fi
4794          if test -x "$dir/java"; then
4795                libjvmdir=`find $dir/.. -name libjvm.so | sed 's,libjvm.so,,'|head -n 1`
4796		if test ! -f $libjvmdir/libjvm.so; then continue; fi
4797		jredirs="$jredirs $dir"
4798	  fi
4799      done
4800
4801      JAVAC=
4802      JAVA=
4803      kde_java_bindir=no
4804      for dir in $jredirs; do
4805	  JAVA="$dir/java"
4806	  kde_java_bindir=$dir
4807	  if test -x "$dir/javac"; then
4808		JAVAC="$dir/javac"
4809                break
4810	  fi
4811      done
4812
4813      if test -n "$JAVAC"; then
4814          dnl this substitution might not work - well, we test for jni.h below
4815          kde_java_includedir=`echo $JAVAC | sed -e 's,bin/javac$,include/,'`
4816      else
4817          kde_java_includedir=no
4818      fi
4819  else
4820    dnl config option set
4821    kde_java_bindir=$ac_java_dir/bin
4822    if test -x $ac_java_dir/bin/java && test ! -x $ac_java_dir/bin/javac; then
4823	kde_java_includedir=no
4824    else
4825        kde_java_includedir=$ac_java_dir/include
4826    fi
4827  fi
4828fi
4829
4830dnl At this point kde_java_bindir and kde_java_includedir are either set or "no"
4831if test "x$kde_java_bindir" != "xno"; then
4832
4833  dnl Look for libjvm.so
4834  kde_java_libjvmdir=`find $kde_java_bindir/.. -name libjvm.so | sed 's,libjvm.so,,'|head -n 1`
4835  dnl Look for libhpi.so and avoid green threads
4836  kde_java_libhpidir=`find $kde_java_bindir/.. -name libhpi.so | grep -v green | sed 's,libhpi.so,,' | head -n 1`
4837
4838  dnl Now check everything's fine under there
4839  dnl the include dir is our flag for having the JDK
4840  if test -d "$kde_java_includedir"; then
4841    if test ! -x "$kde_java_bindir/javac"; then
4842      AC_MSG_ERROR([javac not found under $kde_java_bindir - it seems you passed a wrong --with-java.])
4843    fi
4844    if test ! -x "$kde_java_bindir/javah"; then
4845      AC_MSG_ERROR([javah not found under $kde_java_bindir. javac was found though! Use --with-java or --without-java.])
4846    fi
4847    if test ! -x "$kde_java_bindir/jar"; then
4848      AC_MSG_ERROR([jar not found under $kde_java_bindir. javac was found though! Use --with-java or --without-java.])
4849    fi
4850    if test ! -r "$kde_java_includedir/jni.h"; then
4851      AC_MSG_ERROR([jni.h not found under $kde_java_includedir. Use --with-java or --without-java.])
4852    fi
4853
4854    jni_includes="-I$kde_java_includedir"
4855    dnl Strange thing, jni.h requires jni_md.h which is under genunix here..
4856    dnl and under linux here..
4857    test -d "$kde_java_includedir/linux" && jni_includes="$jni_includes -I$kde_java_includedir/linux"
4858    test -d "$kde_java_includedir/solaris" && jni_includes="$jni_includes -I$kde_java_includedir/solaris"
4859    test -d "$kde_java_includedir/genunix" && jni_includes="$jni_includes -I$kde_java_includedir/genunix"
4860
4861  else
4862    JAVAC=
4863    jni_includes=
4864  fi
4865
4866  if test ! -r "$kde_java_libjvmdir/libjvm.so"; then
4867     AC_MSG_ERROR([libjvm.so not found under $kde_java_libjvmdir. Use --without-java.])
4868  fi
4869
4870  if test ! -x "$kde_java_bindir/java"; then
4871      AC_MSG_ERROR([java not found under $kde_java_bindir. javac was found though! Use --with-java or --without-java.])
4872  fi
4873
4874  if test ! -r "$kde_java_libhpidir/libhpi.so"; then
4875    AC_MSG_ERROR([libhpi.so not found under $kde_java_libhpidir. Use --without-java.])
4876  fi
4877
4878  if test -n "$jni_includes"; then
4879    dnl Check for JNI version
4880    AC_LANG_SAVE
4881    AC_LANG_CPLUSPLUS
4882    ac_cxxflags_safe="$CXXFLAGS"
4883    CXXFLAGS="$CXXFLAGS $all_includes $jni_includes"
4884
4885    AC_TRY_COMPILE([
4886  #include <jni.h>
4887	      ],
4888	      [
4889  #ifndef JNI_VERSION_1_2
4890  Syntax Error
4891  #endif
4892	      ],[ kde_jni_works=yes ],
4893	      [ kde_jni_works=no ])
4894
4895    if test $kde_jni_works = no; then
4896      AC_MSG_ERROR([Incorrect version of $kde_java_includedir/jni.h.
4897		    You need to have Java Development Kit (JDK) version 1.2.
4898
4899		    Use --with-java to specify another location.
4900		    Use --without-java to configure without java support.
4901		    Or download a newer JDK and try again.
4902		    See e.g. http://java.sun.com/products/jdk/1.2 ])
4903    fi
4904
4905    CXXFLAGS="$ac_cxxflags_safe"
4906    AC_LANG_RESTORE
4907
4908    dnl All tests ok, inform and subst the variables
4909
4910    JAVAC=$kde_java_bindir/javac
4911    JAVAH=$kde_java_bindir/javah
4912    JAR=$kde_java_bindir/jar
4913    AC_DEFINE_UNQUOTED(PATH_JAVA, "$kde_java_bindir/java", [Define where your java executable is])
4914    JVMLIBS="-L$kde_java_libjvmdir -ljvm -L$kde_java_libhpidir -lhpi"
4915    AC_MSG_RESULT([java JDK in $kde_java_bindir])
4916
4917  else
4918      AC_DEFINE_UNQUOTED(PATH_JAVA, "$kde_java_bindir/java", [Define where your java executable is])
4919      AC_MSG_RESULT([java JRE in $kde_java_bindir])
4920  fi
4921else # no
4922  AC_MSG_RESULT([none found])
4923fi
4924
4925AC_SUBST(JAVAC)
4926AC_SUBST(JAVAH)
4927AC_SUBST(JAR)
4928AC_SUBST(JVMLIBS)
4929AC_SUBST(jni_includes)
4930
4931# for backward compat
4932kde_cv_java_includedir=$kde_java_includedir
4933kde_cv_java_bindir=$kde_java_bindir
4934])
4935
4936dnl this is a redefinition of autoconf 2.5x's INCOMPATIBLE_FOREACH.
4937dnl When the argument list becomes big, as in KDE for AC_OUTPUT in
4938dnl big packages, m4_foreach is dog-slow.  So use our own version of
4939dnl it.  (matz@kde.org)
4940m4_define([mm_foreach],
4941[m4_pushdef([$1])_mm_foreach($@)m4_popdef([$1])])
4942m4_define([mm_car], [[$1]])
4943m4_define([mm_car2], [[$@]])
4944m4_define([_mm_foreach],
4945[m4_if(m4_quote($2), [], [],
4946       [m4_define([$1], [mm_car($2)])$3[]_mm_foreach([$1],
4947                                                     mm_car2(m4_shift($2)),
4948                                                     [$3])])])
4949m4_define([INCOMPATIBLE_FOREACH],
4950[mm_foreach([$1], m4_split(m4_normalize([$2])), [$3])])
4951
4952AC_DEFUN(KDE_NEED_FLEX,
4953[
4954kde_libs_safe=$LIBS
4955LIBS="$LIBS $USER_LDFLAGS"
4956AM_PROG_LEX
4957LIBS=$kde_libs_safe
4958if test -z "$LEXLIB"; then
4959    AC_MSG_ERROR([You need to have flex installed.])
4960fi
4961AC_SUBST(LEXLIB)
4962])
4963
4964AC_DEFUN(AC_PATH_QTOPIA,
4965[
4966  dnl TODO: use AC_CACHE_VAL
4967
4968  if test -z "$1"; then
4969    qtopia_minver_maj=1
4970    qtopia_minver_min=5
4971    qtopia_minver_pat=0
4972  else
4973    qtopia_minver_maj=`echo "$1" | sed -e "s/^\(.*\)\..*\..*$/\1/"`
4974    qtopia_minver_min=`echo "$1" | sed -e "s/^.*\.\(.*\)\..*$/\1/"`
4975    qtopia_minver_pat=`echo "$1" | sed -e "s/^.*\..*\.\(.*\)$/\1/"`
4976  fi
4977
4978  qtopia_minver="$qtopia_minver_maj$qtopia_minver_min$qtopia_minver_pat"
4979  qtopia_minverstr="$qtopia_minver_maj.$qtopia_minver_min.$qtopia_minver_pat"
4980
4981  AC_REQUIRE([AC_PATH_QT])
4982
4983  AC_MSG_CHECKING([for Qtopia])
4984
4985  LIB_QTOPIA="-lqpe"
4986  AC_SUBST(LIB_QTOPIA)
4987
4988  kde_qtopia_dirs="$QPEDIR /opt/Qtopia"
4989
4990  ac_qtopia_incdir=NO
4991
4992  AC_ARG_WITH(qtopia-dir,
4993              [  --with-qtopia-dir=DIR   where the root of Qtopia is installed ],
4994              [  ac_qtopia_incdir="$withval"/include] )
4995
4996  qtopia_incdirs=""
4997  for dir in $kde_qtopia_dirs; do
4998    qtopia_incdirs="$qtopia_incdirs $dir/include"
4999  done
5000
5001  if test ! "$ac_qtopia_incdir" = "NO"; then
5002    qtopia_incdirs="$ac_qtopia_incdir $qtopia_incdirs"
5003  fi
5004
5005  qtopia_incdir=""
5006  AC_FIND_FILE(qpe/qpeapplication.h, $qtopia_incdirs, qtopia_incdir)
5007  ac_qtopia_incdir="$qtopia_incdir"
5008
5009  if test -z "$qtopia_incdir"; then
5010    AC_MSG_ERROR([Cannot find Qtopia headers. Please check your installation.])
5011  fi
5012
5013  qtopia_ver_maj=`cat $qtopia_incdir/qpe/version.h | sed -n -e 's,.*QPE_VERSION "\(.*\)\..*\..*".*,\1,p'`;
5014  qtopia_ver_min=`cat $qtopia_incdir/qpe/version.h | sed -n -e 's,.*QPE_VERSION ".*\.\(.*\)\..*".*,\1,p'`;
5015  qtopia_ver_pat=`cat $qtopia_incdir/qpe/version.h | sed -n -e 's,.*QPE_VERSION ".*\..*\.\(.*\)".*,\1,p'`;
5016
5017  qtopia_ver="$qtopia_ver_maj$qtopia_ver_min$qtopia_ver_pat"
5018  qtopia_verstr="$qtopia_ver_maj.$qtopia_ver_min.$qtopia_ver_pat"
5019  if test "$qtopia_ver" -lt "$qtopia_minver"; then
5020    AC_MSG_ERROR([found Qtopia version $qtopia_verstr but version $qtopia_minverstr
5021is required.])
5022  fi
5023
5024  AC_LANG_SAVE
5025  AC_LANG_CPLUSPLUS
5026
5027  ac_cxxflags_safe="$CXXFLAGS"
5028  ac_ldflags_safe="$LDFLAGS"
5029  ac_libs_safe="$LIBS"
5030
5031  CXXFLAGS="$CXXFLAGS -I$qtopia_incdir $all_includes"
5032  LDFLAGS="$LDFLAGS $QT_LDFLAGS $all_libraries $USER_LDFLAGS $KDE_MT_LDFLAGS"
5033  LIBS="$LIBS $LIB_QTOPIA $LIBQT"
5034
5035  cat > conftest.$ac_ext <<EOF
5036#include "confdefs.h"
5037#include <qpe/qpeapplication.h>
5038#include <qpe/version.h>
5039
5040int main( int argc, char **argv )
5041{
5042    QPEApplication app( argc, argv );
5043    return 0;
5044}
5045EOF
5046
5047  if AC_TRY_EVAL(ac_link) && test -s conftest; then
5048    rm -f conftest*
5049  else
5050    rm -f conftest*
5051    AC_MSG_ERROR([Cannot link small Qtopia Application. For more details look at
5052the end of config.log])
5053  fi
5054
5055  CXXFLAGS="$ac_cxxflags_safe"
5056  LDFLAGS="$ac_ldflags_safe"
5057  LIBS="$ac_libs_safe"
5058
5059  AC_LANG_RESTORE
5060
5061  QTOPIA_INCLUDES="-I$qtopia_incdir"
5062  AC_SUBST(QTOPIA_INCLUDES)
5063
5064  AC_MSG_RESULT([found version $qtopia_verstr with headers at $qtopia_incdir])
5065])
5066
5067
5068AC_DEFUN(KDE_INIT_DOXYGEN,
5069[
5070AC_MSG_CHECKING([for Qt docs])
5071kde_qtdir=
5072if test "${with_qt_dir+set}" = set; then
5073  kde_qtdir="$with_qt_dir"
5074fi
5075
5076AC_FIND_FILE(qsql.html, [ $kde_qtdir/doc/html $QTDIR/doc/html /usr/share/doc/packages/qt3/html /usr/lib/qt/doc /usr/lib/qt3/doc /usr/lib/qt3/doc/html /usr/doc/qt3/html /usr/doc/qt3 /usr/share/doc/qt3-doc /usr/share/qt3/doc/html ], QTDOCDIR)
5077AC_MSG_RESULT($QTDOCDIR)
5078
5079AC_SUBST(QTDOCDIR)
5080
5081KDE_FIND_PATH(dot, DOT, [], [])
5082if test -n "$DOT"; then
5083  KDE_HAVE_DOT="YES"
5084else
5085  KDE_HAVE_DOT="NO"
5086fi
5087AC_SUBST(KDE_HAVE_DOT)
5088KDE_FIND_PATH(doxygen, DOXYGEN, [], [])
5089AC_SUBST(DOXYGEN)
5090
5091DOXYGEN_PROJECT_NAME="$1"
5092DOXYGEN_PROJECT_NUMBER="$2"
5093AC_SUBST(DOXYGEN_PROJECT_NAME)
5094AC_SUBST(DOXYGEN_PROJECT_NUMBER)
5095
5096KDE_HAS_DOXYGEN=no
5097if test -n "$DOXYGEN" && test -x "$DOXYGEN" && test -f $QTDOCDIR/qsql.html; then
5098  KDE_HAS_DOXYGEN=yes
5099fi
5100AC_SUBST(KDE_HAS_DOXYGEN)
5101
5102])
5103
5104
5105AC_DEFUN(AC_FIND_BZIP2,
5106[
5107AC_MSG_CHECKING([for bzDecompress in libbz2])
5108AC_CACHE_VAL(ac_cv_lib_bzip2,
5109[
5110AC_LANG_C
5111kde_save_LIBS="$LIBS"
5112LIBS="$all_libraries $USER_LDFLAGS -lbz2 $LIBSOCKET"
5113kde_save_CFLAGS="$CFLAGS"
5114CFLAGS="$CFLAGS $all_includes $USER_INCLUDES"
5115AC_TRY_LINK(dnl
5116[
5117#define BZ_NO_STDIO
5118#include<bzlib.h>
5119],
5120            [ bz_stream s; (void) bzDecompress(&s); ],
5121            eval "ac_cv_lib_bzip2='-lbz2'",
5122            eval "ac_cv_lib_bzip2=no")
5123LIBS="$kde_save_LIBS"
5124CFLAGS="$kde_save_CFLAGS"
5125])dnl
5126AC_MSG_RESULT($ac_cv_lib_bzip2)
5127
5128if test ! "$ac_cv_lib_bzip2" = no; then
5129  BZIP2DIR=bzip2
5130
5131  LIBBZ2="$ac_cv_lib_bzip2"
5132  AC_SUBST(LIBBZ2)
5133
5134else
5135
5136   cxx_shared_flag=
5137   ld_shared_flag=
5138   KDE_CHECK_COMPILER_FLAG(shared, [
5139	ld_shared_flag="-shared"
5140   ])
5141   KDE_CHECK_COMPILER_FLAG(fPIC, [
5142        cxx_shared_flag="-fPIC"
5143   ])
5144
5145   AC_MSG_CHECKING([for BZ2_bzDecompress in (shared) libbz2])
5146   AC_CACHE_VAL(ac_cv_lib_bzip2_prefix,
5147   [
5148   AC_LANG_CPLUSPLUS
5149   kde_save_LIBS="$LIBS"
5150   LIBS="$all_libraries $USER_LDFLAGS $ld_shared_flag -lbz2 $LIBSOCKET"
5151   kde_save_CXXFLAGS="$CXXFLAGS"
5152   CXXFLAGS="$CFLAGS $cxx_shared_flag $all_includes $USER_INCLUDES"
5153
5154   AC_TRY_LINK(dnl
5155   [
5156   #define BZ_NO_STDIO
5157   #include<bzlib.h>
5158   ],
5159               [ bz_stream s; (void) BZ2_bzDecompress(&s); ],
5160               eval "ac_cv_lib_bzip2_prefix='-lbz2'",
5161               eval "ac_cv_lib_bzip2_prefix=no")
5162   LIBS="$kde_save_LIBS"
5163   CXXFLAGS="$kde_save_CXXFLAGS"
5164   ])dnl
5165
5166   AC_MSG_RESULT($ac_cv_lib_bzip2_prefix)
5167
5168
5169
5170   if test ! "$ac_cv_lib_bzip2_prefix" = no; then
5171     BZIP2DIR=bzip2
5172
5173     LIBBZ2="$ac_cv_lib_bzip2_prefix"
5174     AC_SUBST(LIBBZ2)
5175
5176     AC_DEFINE(NEED_BZ2_PREFIX, 1, [Define if the libbz2 functions need the BZ2_ prefix])
5177   dnl else, we just ignore this
5178   fi
5179
5180fi
5181AM_CONDITIONAL(include_BZIP2, test -n "$BZIP2DIR")
5182])
5183
5184dnl ------------------------------------------------------------------------
5185dnl Try to find the SSL headers and libraries.
5186dnl $(SSL_LDFLAGS) will be -Lsslliblocation (if needed)
5187dnl and $(SSL_INCLUDES) will be -Isslhdrlocation (if needed)
5188dnl ------------------------------------------------------------------------
5189dnl
5190AC_DEFUN(KDE_CHECK_SSL,
5191[
5192LIBSSL="-lssl -lcrypto"
5193AC_REQUIRE([KDE_CHECK_LIB64])
5194
5195ac_ssl_includes=NO ac_ssl_libraries=NO
5196ssl_libraries=""
5197ssl_includes=""
5198AC_ARG_WITH(ssl-dir,
5199    [  --with-ssl-dir=DIR      where the root of OpenSSL is installed],
5200    [  ac_ssl_includes="$withval"/include
5201       ac_ssl_libraries="$withval"/lib$kdelibsuff
5202    ])
5203
5204want_ssl=yes
5205AC_ARG_WITH(ssl,
5206    [  --without-ssl           disable SSL checks],
5207    [want_ssl=$withval])
5208
5209if test $want_ssl = yes; then
5210
5211AC_MSG_CHECKING(for OpenSSL)
5212
5213AC_CACHE_VAL(ac_cv_have_ssl,
5214[#try to guess OpenSSL locations
5215
5216  ssl_incdirs="/usr/include /usr/local/include /usr/ssl/include /usr/local/ssl/include $prefix/include $kde_extra_includes"
5217  ssl_incdirs="$ac_ssl_includes $ssl_incdirs"
5218  AC_FIND_FILE(openssl/ssl.h, $ssl_incdirs, ssl_incdir)
5219  ac_ssl_includes="$ssl_incdir"
5220
5221  ssl_libdirs="/usr/lib$kdelibsuff /usr/local/lib$kdelibsuff /usr/ssl/lib$kdelibsuff /usr/local/ssl/lib$kdelibsuff $libdir $prefix/lib$kdelibsuff $exec_prefix/lib$kdelibsuff $kde_extra_libs"
5222  if test ! "$ac_ssl_libraries" = "NO"; then
5223    ssl_libdirs="$ac_ssl_libraries $ssl_libdirs"
5224  fi
5225
5226  test=NONE
5227  ssl_libdir=NONE
5228  for dir in $ssl_libdirs; do
5229    try="ls -1 $dir/libssl*"
5230    if test=`eval $try 2> /dev/null`; then ssl_libdir=$dir; break; else echo "tried $dir" >&AC_FD_CC ; fi
5231  done
5232
5233  ac_ssl_libraries="$ssl_libdir"
5234
5235  AC_LANG_SAVE
5236  AC_LANG_C
5237
5238  ac_cflags_safe="$CFLAGS"
5239  ac_ldflags_safe="$LDFLAGS"
5240  ac_libs_safe="$LIBS"
5241
5242  CFLAGS="$CFLAGS -I$ssl_incdir $all_includes"
5243  LDFLAGS="$LDFLAGS -L$ssl_libdir $all_libraries"
5244  LIBS="$LIBS $LIBSSL -lRSAglue -lrsaref"
5245
5246  AC_TRY_LINK(,void RSAPrivateEncrypt(void);RSAPrivateEncrypt();,
5247  ac_ssl_rsaref="yes"
5248  ,
5249  ac_ssl_rsaref="no"
5250  )
5251
5252  CFLAGS="$ac_cflags_safe"
5253  LDFLAGS="$ac_ldflags_safe"
5254  LIBS="$ac_libs_safe"
5255
5256  AC_LANG_RESTORE
5257
5258  if test "$ac_ssl_includes" = NO || test "$ac_ssl_libraries" = NO; then
5259    have_ssl=no
5260  else
5261    have_ssl=yes;
5262  fi
5263
5264  ])
5265
5266  eval "$ac_cv_have_ssl"
5267
5268  AC_MSG_RESULT([libraries $ac_ssl_libraries, headers $ac_ssl_includes])
5269
5270  AC_MSG_CHECKING([whether OpenSSL uses rsaref])
5271  AC_MSG_RESULT($ac_ssl_rsaref)
5272
5273  AC_MSG_CHECKING([for easter eggs])
5274  AC_MSG_RESULT([none found])
5275
5276else
5277  have_ssl=no
5278fi
5279
5280if test "$have_ssl" = yes; then
5281  AC_MSG_CHECKING(for OpenSSL version)
5282  dnl Check for SSL version
5283  AC_CACHE_VAL(ac_cv_ssl_version,
5284  [
5285    AC_LANG_SAVE
5286    AC_LANG_C
5287
5288    cat >conftest.$ac_ext <<EOF
5289#include <openssl/opensslv.h>
5290#include <stdio.h>
5291    int main() {
5292
5293#ifndef OPENSSL_VERSION_NUMBER
5294      printf("ssl_version=\\"error\\"\n");
5295#else
5296      if (OPENSSL_VERSION_NUMBER < 0x00906000)
5297        printf("ssl_version=\\"old\\"\n");
5298      else
5299        printf("ssl_version=\\"ok\\"\n");
5300#endif
5301     return (0);
5302    }
5303EOF
5304
5305    ac_compile='${CC-gcc} $CFLAGS -I$ac_ssl_includes conftest.$ac_ext -o conftest'
5306    if AC_TRY_EVAL(ac_compile); then
5307
5308      if eval `./conftest 2>&5`; then
5309        if test $ssl_version = error; then
5310          AC_MSG_ERROR([$ssl_incdir/openssl/opensslv.h doesn't define OPENSSL_VERSION_NUMBER !])
5311        else
5312          if test $ssl_version = old; then
5313            AC_MSG_WARN([OpenSSL version too old. Upgrade to 0.9.6 at least, see http://www.openssl.org. SSL support disabled.])
5314            have_ssl=no
5315          fi
5316        fi
5317        ac_cv_ssl_version="ssl_version=$ssl_version"
5318      else
5319        AC_MSG_ERROR([Your system couldn't run a small SSL test program.
5320        Check config.log, and if you can't figure it out, send a mail to
5321        David Faure <faure@kde.org>, attaching your config.log])
5322      fi
5323
5324    else
5325      AC_MSG_ERROR([Your system couldn't link a small SSL test program.
5326      Check config.log, and if you can't figure it out, send a mail to
5327      David Faure <faure@kde.org>, attaching your config.log])
5328    fi
5329
5330    AC_LANG_RESTORE
5331
5332  ])
5333
5334  eval "$ac_cv_ssl_version"
5335  AC_MSG_RESULT($ssl_version)
5336fi
5337
5338if test "$have_ssl" != yes; then
5339  LIBSSL="";
5340else
5341  AC_DEFINE(HAVE_SSL, 1, [If we are going to use OpenSSL])
5342  ac_cv_have_ssl="have_ssl=yes \
5343    ac_ssl_includes=$ac_ssl_includes ac_ssl_libraries=$ac_ssl_libraries ac_ssl_rsaref=$ac_ssl_rsaref"
5344
5345
5346  ssl_libraries="$ac_ssl_libraries"
5347  ssl_includes="$ac_ssl_includes"
5348
5349  if test "$ac_ssl_rsaref" = yes; then
5350    LIBSSL="-lssl -lcrypto -lRSAglue -lrsaref"
5351  fi
5352
5353  if test $ssl_version = "old"; then
5354    AC_DEFINE(HAVE_OLD_SSL_API, 1, [Define if you have OpenSSL < 0.9.6])
5355  fi
5356fi
5357
5358if test "$ssl_includes" = "/usr/include" || test  "$ssl_includes" = "/usr/local/include" || test -z "$ssl_includes"; then
5359 SSL_INCLUDES="";
5360else
5361 SSL_INCLUDES="-I$ssl_includes"
5362fi
5363
5364if test "$ssl_libraries" = "/usr/lib" || test "$ssl_libraries" = "/usr/local/lib" || test -z "$ssl_libraries"; then
5365 SSL_LDFLAGS=""
5366else
5367 SSL_LDFLAGS="-L$ssl_libraries -R$ssl_libraries"
5368fi
5369
5370AC_SUBST(SSL_INCLUDES)
5371AC_SUBST(SSL_LDFLAGS)
5372AC_SUBST(LIBSSL)
5373])
5374
5375AC_DEFUN(KDE_CHECK_STRLCPY,
5376[
5377  AC_CHECK_STRLCPY
5378  AC_CHECK_STRLCAT
5379  AC_CHECK_SIZEOF(size_t)
5380  AC_CHECK_SIZEOF(unsigned long)
5381
5382  AC_MSG_CHECKING([sizeof(size_t) == sizeof(unsigned long)])
5383  AC_TRY_COMPILE(,[
5384    #if SIZEOF_SIZE_T != SIZEOF_UNSIGNED_LONG
5385       choke me
5386    #endif
5387    ],[AC_MSG_RESULT([yes])],[
5388      AC_MSG_RESULT([no])
5389      AC_MSG_ERROR([
5390       Apparently on your system our assumption sizeof(size_t) == sizeof(unsigned long)
5391       does not apply. Please mail kde-devel@kde.org with a description of your system!
5392      ])
5393  ])
5394])
5395
5396