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