2002-04-05 Marcus Brinkmann <marcus@g10code.de>
[pinentry.git] / acinclude.m4
1 dnl Autoconf macros used by PINENTRY
2 dnl
3 dnl Copyright (C) 2002 g10 Code GmbH
4 dnl
5 dnl IU_LIB_NCURSES, IU_LIB_CURSES and IU_LIB_TERMCAP are:
6 dnl Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
7 dnl Written by Miles Bader <miles@gnu.ai.mit.edu>
8 dnl
9 dnl This program is free software; you can redistribute it and/or modify
10 dnl it under the terms of the GNU General Public License as published by
11 dnl the Free Software Foundation; either version 2, or (at your option)
12 dnl any later version.
13 dnl
14 dnl This program is distributed in the hope that it will be useful,
15 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
16 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 dnl GNU General Public License for more details.
18 dnl
19 dnl You should have received a copy of the GNU General Public License
20 dnl along with this program; if not, write to the Free Software
21 dnl Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 dnl
23
24 dnl IU_LIB_NCURSES -- check for, and configure, ncurses
25 dnl
26 dnl If libncurses is found to exist on this system and the --disable-ncurses
27 dnl flag wasn't specified, defines LIBNCURSES with the appropriate linker
28 dnl specification, and possibly defines NCURSES_INCLUDE with the appropriate
29 dnl -I flag to get access to ncurses include files.
30 dnl
31 AC_DEFUN([IU_LIB_NCURSES], [
32   AC_ARG_ENABLE(ncurses,    [  --disable-ncurses       don't prefer -lncurses over -lcurses],
33               , enable_ncurses=yes)
34   if test "$enable_ncurses" = yes; then
35     AC_CHECK_LIB(ncurses, initscr, LIBNCURSES="-lncurses")
36     if test "$LIBNCURSES"; then
37       # Use ncurses header files instead of the ordinary ones, if possible;
38       # is there a better way of doing this, that avoids looking in specific
39       # directories?
40       AC_ARG_WITH(ncurses-include-dir,
41 [  --with-ncurses-include-dir=DIR
42                           Set directory containing the include files for
43                           use with -lncurses, when it isn't installed as
44                           the default curses library.  If DIR is "none",
45                           then no special ncurses include files are used.
46   --without-ncurses-include-dir
47                           Equivalent to --with-ncurses-include-dir=none])dnl
48       if test "${with_ncurses_include_dir+set}" = set; then
49         AC_MSG_CHECKING(for ncurses include dir)
50         case "$with_ncurses_include_dir" in
51           no|none)
52             inetutils_cv_includedir_ncurses=none;;
53           *)
54             inetutils_cv_includedir_ncurses="$with_ncurses_include_dir";;
55         esac
56         AC_MSG_RESULT($inetutils_cv_includedir_ncurses)
57       else
58         AC_CACHE_CHECK(for ncurses include dir,
59                        inetutils_cv_includedir_ncurses,
60           for D in $includedir $prefix/include /local/include /usr/local/include /include /usr/include; do
61             if test -d $D/ncurses; then
62               inetutils_cv_includedir_ncurses="$D/ncurses"
63               break
64             fi
65             test "$inetutils_cv_includedir_ncurses" \
66               || inetutils_cv_includedir_ncurses=none
67           done)
68       fi
69       if test "$inetutils_cv_includedir_ncurses" = none; then
70         NCURSES_INCLUDE=""
71       else
72         NCURSES_INCLUDE="-I$inetutils_cv_includedir_ncurses"
73       fi
74     fi
75   fi
76   AC_SUBST(NCURSES_INCLUDE)
77   AC_SUBST(LIBNCURSES)])dnl
78
79 dnl IU_LIB_TERMCAP -- check for various termcap libraries
80 dnl
81 dnl Checks for various common libraries implementing the termcap interface,
82 dnl including ncurses (unless --disable ncurses is specified), curses (which
83 dnl does on some systems), termcap, and termlib.  If termcap is found, then
84 dnl LIBTERMCAP is defined with the appropriate linker specification.
85 dnl 
86 AC_DEFUN([IU_LIB_TERMCAP], [
87   AC_REQUIRE([IU_LIB_NCURSES])
88   if test "$LIBNCURSES"; then
89     LIBTERMCAP="$LIBNCURSES"
90   else
91     AC_CHECK_LIB(curses, tgetent, LIBTERMCAP=-lcurses)
92     if test "$ac_cv_lib_curses_tgetent" = no; then
93       AC_CHECK_LIB(termcap, tgetent, LIBTERMCAP=-ltermcap)
94     fi
95     if test "$ac_cv_lib_termcap_tgetent" = no; then
96       AC_CHECK_LIB(termlib, tgetent, LIBTERMCAP=-ltermlib)
97     fi
98   fi
99   AC_SUBST(LIBTERMCAP)])dnl
100
101 dnl IU_LIB_CURSES -- checke for curses, and associated libraries
102 dnl
103 dnl Checks for varions libraries implementing the curses interface, and if
104 dnl found, defines LIBCURSES to be the appropriate linker specification,
105 dnl *including* any termcap libraries if needed (some versions of curses
106 dnl don't need termcap).
107 dnl
108 AC_DEFUN([IU_LIB_CURSES], [
109   AC_REQUIRE([IU_LIB_TERMCAP])
110   AC_REQUIRE([IU_LIB_NCURSES])
111   if test "$LIBNCURSES"; then
112     LIBCURSES="$LIBNCURSES"     # ncurses doesn't require termcap
113   else
114     _IU_SAVE_LIBS="$LIBS"
115     LIBS="$LIBTERMCAP"
116     AC_CHECK_LIB(curses, initscr, LIBCURSES="-lcurses")
117     if test "$LIBCURSES" -a "$LIBTERMCAP" -a "$LIBCURSES" != "$LIBTERMCAP"; then
118       AC_CACHE_CHECK(whether curses needs $LIBTERMCAP,
119                      inetutils_cv_curses_needs_termcap,
120         LIBS="$LIBCURSES"
121         AC_TRY_LINK([#include <curses.h>], [initscr ();],
122                     [inetutils_cv_curses_needs_termcap=no],
123                     [inetutils_cv_curses_needs_termcap=yes]))
124       if test $inetutils_cv_curses_needs_termcap = yes; then
125           LIBCURSES="$LIBCURSES $LIBTERMCAP"
126       fi
127     fi
128     LIBS="$_IU_SAVE_LIBS"
129   fi
130   AC_SUBST(LIBCURSES)])dnl
131 dnl additional configure macros
132
133 dnl
134 dnl GNUPG_CHECK_TYPEDEF(TYPE, HAVE_NAME)
135 dnl Check whether a typedef exists and create a #define $2 if it exists
136 dnl
137 AC_DEFUN(GNUPG_CHECK_TYPEDEF,
138   [ AC_MSG_CHECKING(for $1 typedef)
139     AC_CACHE_VAL(gnupg_cv_typedef_$1,
140     [AC_TRY_COMPILE([#define _GNU_SOURCE 1
141     #include <stdlib.h>
142     #include <sys/types.h>], [
143     #undef $1
144     int a = sizeof($1);
145     ], gnupg_cv_typedef_$1=yes, gnupg_cv_typedef_$1=no )])
146     AC_MSG_RESULT($gnupg_cv_typedef_$1)
147     if test "$gnupg_cv_typedef_$1" = yes; then
148         AC_DEFINE($2,1,[Defined if a `]$1[' is typedef'd])
149     fi
150   ])
151
152
153 ######################################################################
154 # Check whether mlock is broken (hpux 10.20 raises a SIGBUS if mlock
155 # is not called from uid 0 (not tested whether uid 0 works)
156 # For DECs Tru64 we have also to check whether mlock is in librt
157 # mlock is there a macro using memlk()
158 ######################################################################
159 dnl GNUPG_CHECK_MLOCK
160 dnl
161 define(GNUPG_CHECK_MLOCK,
162   [ AC_CHECK_FUNCS(mlock)
163     if test "$ac_cv_func_mlock" = "no"; then
164         AC_CHECK_HEADERS(sys/mman.h)
165         if test "$ac_cv_header_sys_mman_h" = "yes"; then
166             # Add librt to LIBS:
167             AC_CHECK_LIB(rt, memlk)
168             AC_CACHE_CHECK([whether mlock is in sys/mman.h],
169                             gnupg_cv_mlock_is_in_sys_mman,
170                 [AC_TRY_LINK([
171                     #include <assert.h>
172                     #ifdef HAVE_SYS_MMAN_H
173                     #include <sys/mman.h>
174                     #endif
175                 ], [
176                     int i;
177
178                     /* glibc defines this for functions which it implements
179                      * to always fail with ENOSYS.  Some functions are actually
180                      * named something starting with __ and the normal name
181                      * is an alias.  */
182                     #if defined (__stub_mlock) || defined (__stub___mlock)
183                     choke me
184                     #else
185                     mlock(&i, 4);
186                     #endif
187                     ; return 0;
188                 ],
189                 gnupg_cv_mlock_is_in_sys_mman=yes,
190                 gnupg_cv_mlock_is_in_sys_mman=no)])
191             if test "$gnupg_cv_mlock_is_in_sys_mman" = "yes"; then
192                 AC_DEFINE(HAVE_MLOCK,1,
193                           [Defined if the system supports an mlock() call])
194             fi
195         fi
196     fi
197     if test "$ac_cv_func_mlock" = "yes"; then
198         AC_MSG_CHECKING(whether mlock is broken)
199           AC_CACHE_VAL(gnupg_cv_have_broken_mlock,
200              AC_TRY_RUN([
201                 #include <stdlib.h>
202                 #include <unistd.h>
203                 #include <errno.h>
204                 #include <sys/mman.h>
205                 #include <sys/types.h>
206                 #include <fcntl.h>
207
208                 int main()
209                 {
210                     char *pool;
211                     int err;
212                     long int pgsize = getpagesize();
213
214                     pool = malloc( 4096 + pgsize );
215                     if( !pool )
216                         return 2;
217                     pool += (pgsize - ((long int)pool % pgsize));
218
219                     err = mlock( pool, 4096 );
220                     if( !err || errno == EPERM )
221                         return 0; /* okay */
222
223                     return 1;  /* hmmm */
224                 }
225
226             ],
227             gnupg_cv_have_broken_mlock="no",
228             gnupg_cv_have_broken_mlock="yes",
229             gnupg_cv_have_broken_mlock="assume-no"
230            )
231          )
232          if test "$gnupg_cv_have_broken_mlock" = "yes"; then
233              AC_DEFINE(HAVE_BROKEN_MLOCK,1,
234                        [Defined if the mlock() call does not work])
235              AC_MSG_RESULT(yes)
236              AC_CHECK_FUNCS(plock)
237          else
238             if test "$gnupg_cv_have_broken_mlock" = "no"; then
239                 AC_MSG_RESULT(no)
240             else
241                 AC_MSG_RESULT(assuming no)
242             fi
243          fi
244     fi
245   ])
246
247 # Configure paths for GLIB
248 # Owen Taylor     97-11-3
249
250 dnl AM_PATH_GLIB([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]])
251 dnl Test for GLIB, and define GLIB_CFLAGS and GLIB_LIBS, if "gmodule" or 
252 dnl gthread is specified in MODULES, pass to glib-config
253 dnl
254 AC_DEFUN(AM_PATH_GLIB,
255 [dnl 
256 dnl Get the cflags and libraries from the glib-config script
257 dnl
258 AC_ARG_WITH(glib-prefix,[  --with-glib-prefix=PFX   Prefix where GLIB is installed (optional)],
259             glib_config_prefix="$withval", glib_config_prefix="")
260 AC_ARG_WITH(glib-exec-prefix,[  --with-glib-exec-prefix=PFX Exec prefix where GLIB is installed (optional)],
261             glib_config_exec_prefix="$withval", glib_config_exec_prefix="")
262 AC_ARG_ENABLE(glibtest, [  --disable-glibtest       Do not try to compile and run a test GLIB program],
263                     , enable_glibtest=yes)
264
265   if test x$glib_config_exec_prefix != x ; then
266      glib_config_args="$glib_config_args --exec-prefix=$glib_config_exec_prefix"
267      if test x${GLIB_CONFIG+set} != xset ; then
268         GLIB_CONFIG=$glib_config_exec_prefix/bin/glib-config
269      fi
270   fi
271   if test x$glib_config_prefix != x ; then
272      glib_config_args="$glib_config_args --prefix=$glib_config_prefix"
273      if test x${GLIB_CONFIG+set} != xset ; then
274         GLIB_CONFIG=$glib_config_prefix/bin/glib-config
275      fi
276   fi
277
278   for module in . $4
279   do
280       case "$module" in
281          gmodule) 
282              glib_config_args="$glib_config_args gmodule"
283          ;;
284          gthread) 
285              glib_config_args="$glib_config_args gthread"
286          ;;
287       esac
288   done
289
290   AC_PATH_PROG(GLIB_CONFIG, glib-config, no)
291   min_glib_version=ifelse([$1], ,0.99.7,$1)
292   AC_MSG_CHECKING(for GLIB - version >= $min_glib_version)
293   no_glib=""
294   if test "$GLIB_CONFIG" = "no" ; then
295     no_glib=yes
296   else
297     GLIB_CFLAGS=`$GLIB_CONFIG $glib_config_args --cflags`
298     GLIB_LIBS=`$GLIB_CONFIG $glib_config_args --libs`
299     glib_config_major_version=`$GLIB_CONFIG $glib_config_args --version | \
300            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
301     glib_config_minor_version=`$GLIB_CONFIG $glib_config_args --version | \
302            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
303     glib_config_micro_version=`$GLIB_CONFIG $glib_config_args --version | \
304            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
305     if test "x$enable_glibtest" = "xyes" ; then
306       ac_save_CFLAGS="$CFLAGS"
307       ac_save_LIBS="$LIBS"
308       CFLAGS="$CFLAGS $GLIB_CFLAGS"
309       LIBS="$GLIB_LIBS $LIBS"
310 dnl
311 dnl Now check if the installed GLIB is sufficiently new. (Also sanity
312 dnl checks the results of glib-config to some extent
313 dnl
314       rm -f conf.glibtest
315       AC_TRY_RUN([
316 #include <glib.h>
317 #include <stdio.h>
318 #include <stdlib.h>
319
320 int 
321 main ()
322 {
323   int major, minor, micro;
324   char *tmp_version;
325
326   system ("touch conf.glibtest");
327
328   /* HP/UX 9 (%@#!) writes to sscanf strings */
329   tmp_version = g_strdup("$min_glib_version");
330   if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
331      printf("%s, bad version string\n", "$min_glib_version");
332      exit(1);
333    }
334
335   if ((glib_major_version != $glib_config_major_version) ||
336       (glib_minor_version != $glib_config_minor_version) ||
337       (glib_micro_version != $glib_config_micro_version))
338     {
339       printf("\n*** 'glib-config --version' returned %d.%d.%d, but GLIB (%d.%d.%d)\n", 
340              $glib_config_major_version, $glib_config_minor_version, $glib_config_micro_version,
341              glib_major_version, glib_minor_version, glib_micro_version);
342       printf ("*** was found! If glib-config was correct, then it is best\n");
343       printf ("*** to remove the old version of GLIB. You may also be able to fix the error\n");
344       printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
345       printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
346       printf("*** required on your system.\n");
347       printf("*** If glib-config was wrong, set the environment variable GLIB_CONFIG\n");
348       printf("*** to point to the correct copy of glib-config, and remove the file config.cache\n");
349       printf("*** before re-running configure\n");
350     } 
351   else if ((glib_major_version != GLIB_MAJOR_VERSION) ||
352            (glib_minor_version != GLIB_MINOR_VERSION) ||
353            (glib_micro_version != GLIB_MICRO_VERSION))
354     {
355       printf("*** GLIB header files (version %d.%d.%d) do not match\n",
356              GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION, GLIB_MICRO_VERSION);
357       printf("*** library (version %d.%d.%d)\n",
358              glib_major_version, glib_minor_version, glib_micro_version);
359     }
360   else
361     {
362       if ((glib_major_version > major) ||
363         ((glib_major_version == major) && (glib_minor_version > minor)) ||
364         ((glib_major_version == major) && (glib_minor_version == minor) && (glib_micro_version >= micro)))
365       {
366         return 0;
367        }
368      else
369       {
370         printf("\n*** An old version of GLIB (%d.%d.%d) was found.\n",
371                glib_major_version, glib_minor_version, glib_micro_version);
372         printf("*** You need a version of GLIB newer than %d.%d.%d. The latest version of\n",
373                major, minor, micro);
374         printf("*** GLIB is always available from ftp://ftp.gtk.org.\n");
375         printf("***\n");
376         printf("*** If you have already installed a sufficiently new version, this error\n");
377         printf("*** probably means that the wrong copy of the glib-config shell script is\n");
378         printf("*** being found. The easiest way to fix this is to remove the old version\n");
379         printf("*** of GLIB, but you can also set the GLIB_CONFIG environment to point to the\n");
380         printf("*** correct copy of glib-config. (In this case, you will have to\n");
381         printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
382         printf("*** so that the correct libraries are found at run-time))\n");
383       }
384     }
385   return 1;
386 }
387 ],, no_glib=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
388        CFLAGS="$ac_save_CFLAGS"
389        LIBS="$ac_save_LIBS"
390      fi
391   fi
392   if test "x$no_glib" = x ; then
393      AC_MSG_RESULT(yes)
394      ifelse([$2], , :, [$2])     
395   else
396      AC_MSG_RESULT(no)
397      if test "$GLIB_CONFIG" = "no" ; then
398        echo "*** The glib-config script installed by GLIB could not be found"
399        echo "*** If GLIB was installed in PREFIX, make sure PREFIX/bin is in"
400        echo "*** your path, or set the GLIB_CONFIG environment variable to the"
401        echo "*** full path to glib-config."
402      else
403        if test -f conf.glibtest ; then
404         :
405        else
406           echo "*** Could not run GLIB test program, checking why..."
407           CFLAGS="$CFLAGS $GLIB_CFLAGS"
408           LIBS="$LIBS $GLIB_LIBS"
409           AC_TRY_LINK([
410 #include <glib.h>
411 #include <stdio.h>
412 ],      [ return ((glib_major_version) || (glib_minor_version) || (glib_micro_version)); ],
413         [ echo "*** The test program compiled, but did not run. This usually means"
414           echo "*** that the run-time linker is not finding GLIB or finding the wrong"
415           echo "*** version of GLIB. If it is not finding GLIB, you'll need to set your"
416           echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
417           echo "*** to the installed location  Also, make sure you have run ldconfig if that"
418           echo "*** is required on your system"
419           echo "***"
420           echo "*** If you have an old version installed, it is best to remove it, although"
421           echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"
422           echo "***"
423           echo "*** If you have a RedHat 5.0 system, you should remove the GTK package that"
424           echo "*** came with the system with the command"
425           echo "***"
426           echo "***    rpm --erase --nodeps gtk gtk-devel" ],
427         [ echo "*** The test program failed to compile or link. See the file config.log for the"
428           echo "*** exact error that occured. This usually means GLIB was incorrectly installed"
429           echo "*** or that you have moved GLIB since it was installed. In the latter case, you"
430           echo "*** may want to edit the glib-config script: $GLIB_CONFIG" ])
431           CFLAGS="$ac_save_CFLAGS"
432           LIBS="$ac_save_LIBS"
433        fi
434      fi
435      GLIB_CFLAGS=""
436      GLIB_LIBS=""
437      ifelse([$3], , :, [$3])
438   fi
439   AC_SUBST(GLIB_CFLAGS)
440   AC_SUBST(GLIB_LIBS)
441   rm -f conf.glibtest
442 ])
443
444
445 # Configure paths for GTK+
446 # Owen Taylor     97-11-3
447
448 dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]])
449 dnl Test for GTK, and define GTK_CFLAGS and GTK_LIBS
450 dnl
451 AC_DEFUN(AM_PATH_GTK,
452 [dnl 
453 dnl Get the cflags and libraries from the gtk-config script
454 dnl
455 AC_ARG_WITH(gtk-prefix,[  --with-gtk-prefix=PFX   Prefix where GTK is installed (optional)],
456             gtk_config_prefix="$withval", gtk_config_prefix="")
457 AC_ARG_WITH(gtk-exec-prefix,[  --with-gtk-exec-prefix=PFX Exec prefix where GTK is installed (optional)],
458             gtk_config_exec_prefix="$withval", gtk_config_exec_prefix="")
459 AC_ARG_ENABLE(gtktest, [  --disable-gtktest       Do not try to compile and run a test GTK program],
460                     , enable_gtktest=yes)
461
462   for module in . $4
463   do
464       case "$module" in
465          gthread) 
466              gtk_config_args="$gtk_config_args gthread"
467          ;;
468       esac
469   done
470
471   if test x$gtk_config_exec_prefix != x ; then
472      gtk_config_args="$gtk_config_args --exec-prefix=$gtk_config_exec_prefix"
473      if test x${GTK_CONFIG+set} != xset ; then
474         GTK_CONFIG=$gtk_config_exec_prefix/bin/gtk-config
475      fi
476   fi
477   if test x$gtk_config_prefix != x ; then
478      gtk_config_args="$gtk_config_args --prefix=$gtk_config_prefix"
479      if test x${GTK_CONFIG+set} != xset ; then
480         GTK_CONFIG=$gtk_config_prefix/bin/gtk-config
481      fi
482   fi
483
484   AC_PATH_PROG(GTK_CONFIG, gtk-config, no)
485   min_gtk_version=ifelse([$1], ,0.99.7,$1)
486   AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
487   no_gtk=""
488   if test "$GTK_CONFIG" = "no" ; then
489     no_gtk=yes
490   else
491     GTK_CFLAGS=`$GTK_CONFIG $gtk_config_args --cflags`
492     GTK_LIBS=`$GTK_CONFIG $gtk_config_args --libs`
493     gtk_config_major_version=`$GTK_CONFIG $gtk_config_args --version | \
494            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
495     gtk_config_minor_version=`$GTK_CONFIG $gtk_config_args --version | \
496            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
497     gtk_config_micro_version=`$GTK_CONFIG $gtk_config_args --version | \
498            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
499     if test "x$enable_gtktest" = "xyes" ; then
500       ac_save_CFLAGS="$CFLAGS"
501       ac_save_LIBS="$LIBS"
502       CFLAGS="$CFLAGS $GTK_CFLAGS"
503       LIBS="$GTK_LIBS $LIBS"
504 dnl
505 dnl Now check if the installed GTK is sufficiently new. (Also sanity
506 dnl checks the results of gtk-config to some extent
507 dnl
508       rm -f conf.gtktest
509       AC_TRY_RUN([
510 #include <gtk/gtk.h>
511 #include <stdio.h>
512 #include <stdlib.h>
513
514 int 
515 main ()
516 {
517   int major, minor, micro;
518   char *tmp_version;
519
520   system ("touch conf.gtktest");
521
522   /* HP/UX 9 (%@#!) writes to sscanf strings */
523   tmp_version = g_strdup("$min_gtk_version");
524   if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
525      printf("%s, bad version string\n", "$min_gtk_version");
526      exit(1);
527    }
528
529   if ((gtk_major_version != $gtk_config_major_version) ||
530       (gtk_minor_version != $gtk_config_minor_version) ||
531       (gtk_micro_version != $gtk_config_micro_version))
532     {
533       printf("\n*** 'gtk-config --version' returned %d.%d.%d, but GTK+ (%d.%d.%d)\n", 
534              $gtk_config_major_version, $gtk_config_minor_version, $gtk_config_micro_version,
535              gtk_major_version, gtk_minor_version, gtk_micro_version);
536       printf ("*** was found! If gtk-config was correct, then it is best\n");
537       printf ("*** to remove the old version of GTK+. You may also be able to fix the error\n");
538       printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
539       printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
540       printf("*** required on your system.\n");
541       printf("*** If gtk-config was wrong, set the environment variable GTK_CONFIG\n");
542       printf("*** to point to the correct copy of gtk-config, and remove the file config.cache\n");
543       printf("*** before re-running configure\n");
544     } 
545 #if defined (GTK_MAJOR_VERSION) && defined (GTK_MINOR_VERSION) && defined (GTK_MICRO_VERSION)
546   else if ((gtk_major_version != GTK_MAJOR_VERSION) ||
547            (gtk_minor_version != GTK_MINOR_VERSION) ||
548            (gtk_micro_version != GTK_MICRO_VERSION))
549     {
550       printf("*** GTK+ header files (version %d.%d.%d) do not match\n",
551              GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION);
552       printf("*** library (version %d.%d.%d)\n",
553              gtk_major_version, gtk_minor_version, gtk_micro_version);
554     }
555 #endif /* defined (GTK_MAJOR_VERSION) ... */
556   else
557     {
558       if ((gtk_major_version > major) ||
559         ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
560         ((gtk_major_version == major) && (gtk_minor_version == minor) && (gtk_micro_version >= micro)))
561       {
562         return 0;
563        }
564      else
565       {
566         printf("\n*** An old version of GTK+ (%d.%d.%d) was found.\n",
567                gtk_major_version, gtk_minor_version, gtk_micro_version);
568         printf("*** You need a version of GTK+ newer than %d.%d.%d. The latest version of\n",
569                major, minor, micro);
570         printf("*** GTK+ is always available from ftp://ftp.gtk.org.\n");
571         printf("***\n");
572         printf("*** If you have already installed a sufficiently new version, this error\n");
573         printf("*** probably means that the wrong copy of the gtk-config shell script is\n");
574         printf("*** being found. The easiest way to fix this is to remove the old version\n");
575         printf("*** of GTK+, but you can also set the GTK_CONFIG environment to point to the\n");
576         printf("*** correct copy of gtk-config. (In this case, you will have to\n");
577         printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
578         printf("*** so that the correct libraries are found at run-time))\n");
579       }
580     }
581   return 1;
582 }
583 ],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
584        CFLAGS="$ac_save_CFLAGS"
585        LIBS="$ac_save_LIBS"
586      fi
587   fi
588   if test "x$no_gtk" = x ; then
589      AC_MSG_RESULT(yes)
590      ifelse([$2], , :, [$2])     
591   else
592      AC_MSG_RESULT(no)
593      if test "$GTK_CONFIG" = "no" ; then
594        echo "*** The gtk-config script installed by GTK could not be found"
595        echo "*** If GTK was installed in PREFIX, make sure PREFIX/bin is in"
596        echo "*** your path, or set the GTK_CONFIG environment variable to the"
597        echo "*** full path to gtk-config."
598      else
599        if test -f conf.gtktest ; then
600         :
601        else
602           echo "*** Could not run GTK test program, checking why..."
603           CFLAGS="$CFLAGS $GTK_CFLAGS"
604           LIBS="$LIBS $GTK_LIBS"
605           AC_TRY_LINK([
606 #include <gtk/gtk.h>
607 #include <stdio.h>
608 ],      [ return ((gtk_major_version) || (gtk_minor_version) || (gtk_micro_version)); ],
609         [ echo "*** The test program compiled, but did not run. This usually means"
610           echo "*** that the run-time linker is not finding GTK or finding the wrong"
611           echo "*** version of GTK. If it is not finding GTK, you'll need to set your"
612           echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
613           echo "*** to the installed location  Also, make sure you have run ldconfig if that"
614           echo "*** is required on your system"
615           echo "***"
616           echo "*** If you have an old version installed, it is best to remove it, although"
617           echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"
618           echo "***"
619           echo "*** If you have a RedHat 5.0 system, you should remove the GTK package that"
620           echo "*** came with the system with the command"
621           echo "***"
622           echo "***    rpm --erase --nodeps gtk gtk-devel" ],
623         [ echo "*** The test program failed to compile or link. See the file config.log for the"
624           echo "*** exact error that occured. This usually means GTK was incorrectly installed"
625           echo "*** or that you have moved GTK since it was installed. In the latter case, you"
626           echo "*** may want to edit the gtk-config script: $GTK_CONFIG" ])
627           CFLAGS="$ac_save_CFLAGS"
628           LIBS="$ac_save_LIBS"
629        fi
630      fi
631      GTK_CFLAGS=""
632      GTK_LIBS=""
633      ifelse([$3], , :, [$3])
634   fi
635   AC_SUBST(GTK_CFLAGS)
636   AC_SUBST(GTK_LIBS)
637   rm -f conf.gtktest
638 ])
639 ##   -*- autoconf -*-
640
641
642 dnl    This file is part of the KDE libraries/packages
643 dnl    Copyright (C) 1997 Janos Farkas (chexum@shadow.banki.hu)
644 dnl              (C) 1997,98,99 Stephan Kulow (coolo@kde.org)
645 dnl              (C) 2002 g10 Code GmbH
646 dnl              Modified for PINENTRY by Marcus Brinkmann.
647 dnl
648 dnl    This file is free software; you can redistribute it and/or
649 dnl    modify it under the terms of the GNU Library General Public
650 dnl    License as published by the Free Software Foundation; either
651 dnl    version 2 of the License, or (at your option) any later version.
652
653 dnl    This library is distributed in the hope that it will be useful,
654 dnl    but WITHOUT ANY WARRANTY; without even the implied warranty of
655 dnl    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
656 dnl    Library General Public License for more details.
657
658 dnl    You should have received a copy of the GNU Library General Public License
659 dnl    along with this library; see the file COPYING.LIB.  If not, write to
660 dnl    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
661 dnl    Boston, MA 02111-1307, USA.
662
663 dnl ------------------------------------------------------------------------
664 dnl Forward compatibility macros (make autoconf 2.13 look like 2.50),
665 dnl thanks to Raja R Harinath.
666 dnl ------------------------------------------------------------------------
667 dnl
668 ifdef([_AC_PATH_X_XMKMF],[],
669    [AC_DEFUN([_AC_PATH_X_XMKMF],[AC_PATH_X_XMKMF])])
670
671 # KDE_PATH_X_DIRECT
672 dnl Internal subroutine of AC_PATH_X.
673 dnl Set ac_x_includes and/or ac_x_libraries.
674 AC_DEFUN(KDE_PATH_X_DIRECT,
675 [if test "$ac_x_includes" = NO; then
676   # Guess where to find include files, by looking for this one X11 .h file.
677   test -z "$x_direct_test_include" && x_direct_test_include=X11/Intrinsic.h
678
679   # First, try using that file with no special directory specified.
680 AC_TRY_CPP([#include <$x_direct_test_include>],
681 [# We can compile using X headers with no special include directory.
682 ac_x_includes=],
683 [# Look for the header file in a standard set of common directories.
684 # Check X11 before X11Rn because it is often a symlink to the current release.
685   for ac_dir in               \
686     /usr/X11/include          \
687     /usr/X11R6/include        \
688     /usr/X11R5/include        \
689     /usr/X11R4/include        \
690                               \
691     /usr/include/X11          \
692     /usr/include/X11R6        \
693     /usr/include/X11R5        \
694     /usr/include/X11R4        \
695                               \
696     /usr/local/X11/include    \
697     /usr/local/X11R6/include  \
698     /usr/local/X11R5/include  \
699     /usr/local/X11R4/include  \
700                               \
701     /usr/local/include/X11    \
702     /usr/local/include/X11R6  \
703     /usr/local/include/X11R5  \
704     /usr/local/include/X11R4  \
705                               \
706     /usr/X386/include         \
707     /usr/x386/include         \
708     /usr/XFree86/include/X11  \
709                               \
710     /usr/include              \
711     /usr/local/include        \
712     /usr/unsupported/include  \
713     /usr/athena/include       \
714     /usr/local/x11r5/include  \
715     /usr/lpp/Xamples/include  \
716                               \
717     /usr/openwin/include      \
718     /usr/openwin/share/include \
719     ; \
720   do
721     if test -r "$ac_dir/$x_direct_test_include"; then
722       ac_x_includes=$ac_dir
723       break
724     fi
725   done])
726 fi # $ac_x_includes = NO
727
728 if test "$ac_x_libraries" = NO; then
729   # Check for the libraries.
730
731   test -z "$x_direct_test_library" && x_direct_test_library=Xt
732   test -z "$x_direct_test_function" && x_direct_test_function=XtMalloc
733
734   # See if we find them without any special options.
735   # Don't add to $LIBS permanently.
736   ac_save_LIBS="$LIBS"
737   LIBS="-l$x_direct_test_library $LIBS"
738 AC_TRY_LINK(, [${x_direct_test_function}()],
739 [LIBS="$ac_save_LIBS"
740 # We can link X programs with no special library path.
741 ac_x_libraries=],
742 [LIBS="$ac_save_LIBS"
743 # First see if replacing the include by lib works.
744 # Check X11 before X11Rn because it is often a symlink to the current release.
745 for ac_dir in `echo "$ac_x_includes" | sed s/include/lib/` \
746     /usr/X11/lib          \
747     /usr/X11R6/lib        \
748     /usr/X11R5/lib        \
749     /usr/X11R4/lib        \
750                           \
751     /usr/lib/X11          \
752     /usr/lib/X11R6        \
753     /usr/lib/X11R5        \
754     /usr/lib/X11R4        \
755                           \
756     /usr/local/X11/lib    \
757     /usr/local/X11R6/lib  \
758     /usr/local/X11R5/lib  \
759     /usr/local/X11R4/lib  \
760                           \
761     /usr/local/lib/X11    \
762     /usr/local/lib/X11R6  \
763     /usr/local/lib/X11R5  \
764     /usr/local/lib/X11R4  \
765                           \
766     /usr/X386/lib         \
767     /usr/x386/lib         \
768     /usr/XFree86/lib/X11  \
769                           \
770     /usr/lib              \
771     /usr/local/lib        \
772     /usr/unsupported/lib  \
773     /usr/athena/lib       \
774     /usr/local/x11r5/lib  \
775     /usr/lpp/Xamples/lib  \
776     /lib/usr/lib/X11      \
777                           \
778     /usr/openwin/lib      \
779     /usr/openwin/share/lib \
780     ; \
781 do
782 dnl Don't even attempt the hair of trying to link an X program!
783   for ac_extension in a so sl; do
784     if test -r $ac_dir/lib${x_direct_test_library}.$ac_extension; then
785       ac_x_libraries=$ac_dir
786       break 2
787     fi
788   done
789 done])
790 fi # $ac_x_libraries = NO
791 ])
792
793
794 dnl ------------------------------------------------------------------------
795 dnl Find a file (or one of more files in a list of dirs)
796 dnl ------------------------------------------------------------------------
797 dnl
798 AC_DEFUN(AC_FIND_FILE,
799 [
800 $3=NO
801 for i in $2;
802 do
803   for j in $1;
804   do
805     echo "configure: __oline__: $i/$j" >&AC_FD_CC
806     if test -r "$i/$j"; then
807       echo "taking that" >&AC_FD_CC
808       $3=$i
809       break 2
810     fi
811   done
812 done
813 ])
814
815 dnl KDE_FIND_PATH(programm-name, variable-name, list of directories,
816 dnl     if-not-found, test-parameter)
817 AC_DEFUN(KDE_FIND_PATH,
818 [
819    AC_MSG_CHECKING([for $1])
820    if test -n "$$2"; then
821         kde_cv_path="$$2";
822    else
823         kde_cache=`echo $1 | sed 'y%./+-%__p_%'`
824
825         AC_CACHE_VAL(kde_cv_path_$kde_cache,
826         [
827         kde_cv_path="NONE"
828         dirs="$3"
829         kde_save_IFS=$IFS
830         IFS=':'
831         for dir in $PATH; do
832           dirs="$dirs $dir"
833         done
834         IFS=$kde_save_IFS
835
836         for dir in $dirs; do
837           if test -x "$dir/$1"; then
838             if test -n "$5"
839             then
840               evalstr="$dir/$1 $5 2>&1 "
841               if eval $evalstr; then
842                 kde_cv_path="$dir/$1"
843                 break
844               fi
845             else
846                 kde_cv_path="$dir/$1"
847                 break
848             fi
849           fi
850         done
851
852         eval "kde_cv_path_$kde_cache=$kde_cv_path"
853
854         ])
855
856       eval "kde_cv_path=\"`echo '$kde_cv_path_'$kde_cache`\""
857
858    fi
859
860    if test -z "$kde_cv_path" || test "$kde_cv_path" = NONE; then
861       AC_MSG_RESULT(not found)
862       $4
863    else
864       AC_MSG_RESULT($kde_cv_path)
865       $2=$kde_cv_path
866
867    fi
868 ])
869
870 AC_DEFUN(KDE_MOC_ERROR_MESSAGE,
871 [
872     AC_MSG_ERROR([No Qt meta object compiler (moc) found!
873 Please check whether you installed Qt correctly.
874 You need to have a running moc binary.
875 configure tried to run $ac_cv_path_moc and the test didn't
876 succeed. If configure shouldn't have tried this one, set
877 the environment variable MOC to the right one before running
878 configure.
879 ])
880 ])
881
882 dnl ------------------------------------------------------------------------
883 dnl Find the meta object compiler and the ui compiler in the PATH,
884 dnl in $QTDIR/bin, and some more usual places
885 dnl ------------------------------------------------------------------------
886 dnl
887 AC_DEFUN(AC_PATH_QT_MOC_UIC,
888 [
889    qt_bindirs=""
890    for dir in $kde_qt_dirs; do
891       qt_bindirs="$qt_bindirs $dir/bin $dir/src/moc"
892    done
893    qt_bindirs="$qt_bindirs /usr/bin /usr/X11R6/bin /usr/local/qt/bin"
894    if test ! "$ac_qt_bindir" = "NO"; then
895       qt_bindirs="$ac_qt_bindir $qt_bindirs"
896    fi
897
898    KDE_FIND_PATH(moc, MOC, [$qt_bindirs], [KDE_MOC_ERROR_MESSAGE])
899    AC_SUBST(MOC)
900 ])
901
902 AC_DEFUN(KDE_1_CHECK_PATHS,
903 [
904   KDE_1_CHECK_PATH_HEADERS
905
906   KDE_TEST_RPATH=
907
908   if test -n "$USE_RPATH"; then
909
910      if test -n "$kde_libraries"; then
911        KDE_TEST_RPATH="-Wl,--rpath -Wl,$kde_libraries"
912      fi
913
914      if test -n "$qt_libraries"; then
915        KDE_TEST_RPATH="$KDE_TEST_RPATH -Wl,--rpath -Wl,$qt_libraries"
916      fi
917
918      if test -n "$x_libraries"; then
919        KDE_TEST_RPATH="$KDE_TEST_RPATH -Wl,--rpath -Wl,$x_libraries"
920      fi
921
922      KDE_TEST_RPATH="$KDE_TEST_RPATH"
923   fi
924
925 if eval `KDEDIR= ./conftest 2>&5`; then
926   kde_result=done
927 else
928   kde_result=problems
929 fi
930
931 KDEDIR= ./conftest 2> /dev/null >&5 # make an echo for config.log
932 kde_have_all_paths=yes
933
934 KDE_SET_PATHS($kde_result)
935
936 ])
937
938 AC_DEFUN(KDE_SET_PATHS,
939 [
940   kde_cv_all_paths="kde_have_all_paths=\"yes\" \
941         kde_htmldir=\"$kde_htmldir\" \
942         kde_appsdir=\"$kde_appsdir\" \
943         kde_icondir=\"$kde_icondir\" \
944         kde_sounddir=\"$kde_sounddir\" \
945         kde_datadir=\"$kde_datadir\" \
946         kde_locale=\"$kde_locale\" \
947         kde_cgidir=\"$kde_cgidir\" \
948         kde_confdir=\"$kde_confdir\" \
949         kde_mimedir=\"$kde_mimedir\" \
950         kde_toolbardir=\"$kde_toolbardir\" \
951         kde_wallpaperdir=\"$kde_wallpaperdir\" \
952         kde_templatesdir=\"$kde_templatesdir\" \
953         kde_bindir=\"$kde_bindir\" \
954         kde_servicesdir=\"$kde_servicesdir\" \
955         kde_servicetypesdir=\"$kde_servicetypesdir\" \
956         kde_moduledir=\"$kde_moduledir\" \
957    kde_styledir=\"$kde_styledir\" \
958         kde_widgetdir=\"$kde_widgetdir\" \
959         kde_result=$1"
960 ])
961
962 AC_DEFUN(KDE_SET_DEFAULT_PATHS,
963 [
964 if test "$1" = "default"; then
965
966   if test -z "$kde_htmldir"; then
967     kde_htmldir='\${prefix}/share/doc/HTML'
968   fi
969   if test -z "$kde_appsdir"; then
970     kde_appsdir='\${prefix}/share/applnk'
971   fi
972   if test -z "$kde_icondir"; then
973     kde_icondir='\${prefix}/share/icons'
974   fi
975   if test -z "$kde_sounddir"; then
976     kde_sounddir='\${prefix}/share/sounds'
977   fi
978   if test -z "$kde_datadir"; then
979     kde_datadir='\${prefix}/share/apps'
980   fi
981   if test -z "$kde_locale"; then
982     kde_locale='\${prefix}/share/locale'
983   fi
984   if test -z "$kde_cgidir"; then
985     kde_cgidir='\${exec_prefix}/cgi-bin'
986   fi
987   if test -z "$kde_confdir"; then
988     kde_confdir='\${prefix}/share/config'
989   fi
990   if test -z "$kde_mimedir"; then
991     kde_mimedir='\${prefix}/share/mimelnk'
992   fi
993   if test -z "$kde_toolbardir"; then
994     kde_toolbardir='\${prefix}/share/toolbar'
995   fi
996   if test -z "$kde_wallpaperdir"; then
997     kde_wallpaperdir='\${prefix}/share/wallpapers'
998   fi
999   if test -z "$kde_templatesdir"; then
1000     kde_templatesdir='\${prefix}/share/templates'
1001   fi
1002   if test -z "$kde_bindir"; then
1003     kde_bindir='\${exec_prefix}/bin'
1004   fi
1005   if test -z "$kde_servicesdir"; then
1006     kde_servicesdir='\${prefix}/share/services'
1007   fi
1008   if test -z "$kde_servicetypesdir"; then
1009     kde_servicetypesdir='\${prefix}/share/servicetypes'
1010   fi
1011   if test -z "$kde_moduledir"; then
1012     if test "$kde_qtver" = "2"; then
1013       kde_moduledir='\${exec_prefix}/lib/kde2'
1014     else
1015       kde_moduledir='\${exec_prefix}/lib/kde3'
1016     fi
1017   fi
1018   if test -z "$kde_styledir"; then
1019     kde_styledir='\${exec_prefix}/lib/kde3/plugins/styles'
1020   fi
1021   if test -z "$kde_widgetdir"; then
1022     kde_widgetdir='\${exec_prefix}/lib/kde3/plugins/designer'
1023   fi
1024
1025   KDE_SET_PATHS(defaults)
1026
1027 else
1028
1029   if test $kde_qtver = 1; then
1030      AC_MSG_RESULT([compiling])
1031      KDE_1_CHECK_PATHS
1032   else
1033      AC_MSG_ERROR([path checking not yet supported for KDE 2])
1034   fi
1035
1036 fi
1037 ])
1038
1039 AC_DEFUN(KDE_CHECK_PATHS_FOR_COMPLETENESS,
1040 [ if test -z "$kde_htmldir" || test -z "$kde_appsdir" ||
1041    test -z "$kde_icondir" || test -z "$kde_sounddir" ||
1042    test -z "$kde_datadir" || test -z "$kde_locale"  ||
1043    test -z "$kde_cgidir"  || test -z "$kde_confdir" ||
1044    test -z "$kde_mimedir" || test -z "$kde_toolbardir" ||
1045    test -z "$kde_wallpaperdir" || test -z "$kde_templatesdir" ||
1046    test -z "$kde_bindir" || test -z "$kde_servicesdir" ||
1047    test -z "$kde_servicetypesdir" || test -z "$kde_moduledir" ||
1048    test -z "$kde_styledir" || test -z "kde_widgetdir" 
1049    test "x$kde_have_all_paths" != "xyes"; then
1050      kde_have_all_paths=no
1051   fi
1052 ])
1053
1054 AC_DEFUN(KDE_MISSING_PROG_ERROR,
1055 [
1056     AC_MSG_ERROR([The important program $1 was not found!
1057 Please check whether you installed KDE correctly.
1058 ])
1059 ])
1060
1061 AC_DEFUN(KDE_SUBST_PROGRAMS,
1062 [
1063
1064         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"
1065         if test -n "$KDEDIRS"; then
1066            kde_save_IFS=$IFS
1067            IFS=:
1068            for dir in $KDEDIRS; do
1069                 kde_default_bindirs="$dir/bin $kde_default_bindirs "
1070            done
1071            IFS=$kde_save_IFS
1072         fi
1073         kde_default_bindirs="$exec_prefix/bin $prefix/bin $kde_default_bindirs"
1074         KDE_FIND_PATH(kde-config, KDECONFIG, [$kde_default_bindirs])
1075         AC_SUBST(KDECONFIG)
1076
1077         if test -x "$KDECONFIG"; then # it can be "compiled"
1078           kde_libs_prefix=`$KDECONFIG --prefix`
1079           if test -z "$kde_libs_prefix" || test ! -x "$kde_libs_prefix"; then
1080                AC_MSG_ERROR([$KDECONFIG --prefix outputed the non existant prefix '$kde_libs_prefix' for kdelibs.
1081                           This means it has been moved since you installed it.
1082                           This won't work. Please recompile kdelibs for the new prefix.
1083                           ])
1084            fi
1085            kde_libs_htmldir=`$KDECONFIG --install html --expandvars`
1086         else
1087            kde_libs_prefix='$(prefix)'
1088            kde_libs_htmldir='$(kde_htmldir)'
1089         fi
1090         AC_SUBST(kde_libs_prefix)
1091         AC_SUBST(kde_libs_htmldir)
1092 ])dnl
1093
1094 AC_DEFUN(AC_CREATE_KFSSTND,
1095 [
1096 AC_REQUIRE([AC_CHECK_RPATH])
1097
1098 AC_MSG_CHECKING([for KDE paths])
1099 kde_result=""
1100 kde_cached_paths=yes
1101 AC_CACHE_VAL(kde_cv_all_paths,
1102 [
1103   KDE_SET_DEFAULT_PATHS($1)
1104   kde_cached_paths=no
1105 ])
1106 eval "$kde_cv_all_paths"
1107 KDE_CHECK_PATHS_FOR_COMPLETENESS
1108 if test "$kde_have_all_paths" = "no" && test "$kde_cached_paths" = "yes"; then
1109   # wrong values were cached, may be, we can set better ones
1110   kde_result=
1111   kde_htmldir= kde_appsdir= kde_icondir= kde_sounddir=
1112   kde_datadir= kde_locale=  kde_cgidir=  kde_confdir=
1113   kde_mimedir= kde_toolbardir= kde_wallpaperdir= kde_templatesdir=
1114   kde_bindir= kde_servicesdir= kde_servicetypesdir= kde_moduledir=
1115   kde_have_all_paths=
1116   kde_styledir=
1117   kde_widgetdir=
1118   KDE_SET_DEFAULT_PATHS($1)
1119   eval "$kde_cv_all_paths"
1120   KDE_CHECK_PATHS_FOR_COMPLETENESS
1121   kde_result="$kde_result (cache overridden)"
1122 fi
1123 if test "$kde_have_all_paths" = "no"; then
1124   AC_MSG_ERROR([configure could not run a little KDE program to test the environment.
1125 Since it had compiled and linked before, it must be a strange problem on your system.
1126 Look at config.log for details. If you are not able to fix this, look at
1127 http://www.kde.org/faq/installation.html or any www.kde.org mirror.
1128 (If you're using an egcs version on Linux, you may update binutils!)
1129 ])
1130 else
1131   rm -f conftest*
1132   AC_MSG_RESULT($kde_result)
1133 fi
1134
1135 bindir=$kde_bindir
1136
1137 KDE_SUBST_PROGRAMS
1138
1139 ])
1140
1141 AC_DEFUN(AC_SUBST_KFSSTND,
1142 [
1143 AC_SUBST(kde_htmldir)
1144 AC_SUBST(kde_appsdir)
1145 AC_SUBST(kde_icondir)
1146 AC_SUBST(kde_sounddir)
1147 AC_SUBST(kde_datadir)
1148 AC_SUBST(kde_locale)
1149 AC_SUBST(kde_confdir)
1150 AC_SUBST(kde_mimedir)
1151 AC_SUBST(kde_wallpaperdir)
1152 AC_SUBST(kde_bindir)
1153 dnl for KDE 2
1154 AC_SUBST(kde_templatesdir)
1155 AC_SUBST(kde_servicesdir)
1156 AC_SUBST(kde_servicetypesdir)
1157 AC_SUBST(kde_moduledir)
1158 AC_SUBST(kde_styledir)
1159 AC_SUBST(kde_widgetdir)
1160 if test "$kde_qtver" = 1; then
1161   kde_minidir="$kde_icondir/mini"
1162 else
1163 # for KDE 1 - this breaks KDE2 apps using minidir, but
1164 # that's the plan ;-/
1165   kde_minidir="/dev/null"
1166 fi
1167 dnl AC_SUBST(kde_minidir)
1168 dnl AC_SUBST(kde_cgidir)
1169 dnl AC_SUBST(kde_toolbardir)
1170 ])
1171
1172 AC_DEFUN(KDE_MISC_TESTS,
1173 [
1174    AC_LANG_C
1175
1176    # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay.
1177    AC_CHECK_FUNC(shmat, ,
1178      AC_CHECK_LIB(ipc, shmat, X_EXTRA_LIBS="$X_EXTRA_LIBS -lipc"))
1179    AC_SUBST(X_EXTRA_LIBS)
1180 ])
1181
1182 dnl ------------------------------------------------------------------------
1183 dnl Find the header files and libraries for X-Windows. Extended the
1184 dnl macro AC_PATH_X
1185 dnl ------------------------------------------------------------------------
1186 dnl
1187 AC_DEFUN(K_PATH_X,
1188 [
1189 AC_REQUIRE([KDE_MISC_TESTS])dnl
1190
1191 AC_ARG_ENABLE(
1192   embedded,
1193   [  --enable-embedded       link to Qt-embedded, don't use X],
1194   kde_use_qt_emb=$enableval,
1195   kde_use_qt_emb=no
1196 )
1197
1198 AC_ARG_ENABLE(
1199   palmtop,
1200   [  --enable-palmtop       link to Qt-embedded, don't use X and link to the Qt Palmtop Environment],
1201   kde_use_qt_emb_palm=$enableval,
1202   kde_use_qt_emb_palm=no
1203 )
1204
1205 if test "$kde_use_qt_emb" = "no"; then
1206
1207 AC_MSG_CHECKING(for X)
1208 AC_LANG_SAVE
1209 AC_LANG_C
1210 AC_CACHE_VAL(kde_cv_have_x,
1211 [# One or both of the vars are not set, and there is no cached value.
1212 if test "{$x_includes+set}" = set || test "$x_includes" = NONE; then
1213    kde_x_includes=NO
1214 else
1215    kde_x_includes=$x_includes
1216 fi
1217 if test "{$x_libraries+set}" = set || test "$x_libraries" = NONE; then
1218    kde_x_libraries=NO
1219 else
1220    kde_x_libraries=$x_libraries
1221 fi
1222
1223 # below we use the standard autoconf calls
1224 ac_x_libraries=$kde_x_libraries
1225 ac_x_includes=$kde_x_includes
1226
1227 KDE_PATH_X_DIRECT
1228 dnl AC_PATH_X_XMKMF picks /usr/lib as the path for the X libraries.
1229 dnl Unfortunately, if compiling with the N32 ABI, this is not the correct
1230 dnl location. The correct location is /usr/lib32 or an undefined value
1231 dnl (the linker is smart enough to pick the correct default library).
1232 dnl Things work just fine if you use just AC_PATH_X_DIRECT.
1233 dnl Solaris has a similar problem. AC_PATH_X_XMKMF forces x_includes to
1234 dnl /usr/openwin/include, which doesn't work. /usr/include does work, so
1235 dnl x_includes should be left alone.
1236 case "$host" in
1237 mips-sgi-irix6*)
1238   ;;
1239 *-*-solaris*)
1240   ;;
1241 *)
1242   _AC_PATH_X_XMKMF
1243   if test -z "$ac_x_includes"; then
1244     ac_x_includes="."
1245   fi
1246   if test -z "$ac_x_libraries"; then
1247     ac_x_libraries="/usr/lib"
1248   fi
1249 esac
1250 #from now on we use our own again
1251
1252 # when the user already gave --x-includes, we ignore
1253 # what the standard autoconf macros told us.
1254 if test "$kde_x_includes" = NO; then
1255   kde_x_includes=$ac_x_includes
1256 fi
1257
1258 # for --x-libraries too
1259 if test "$kde_x_libraries" = NO; then
1260   kde_x_libraries=$ac_x_libraries
1261 fi
1262
1263 if test "$kde_x_includes" = NO; then
1264   AC_MSG_ERROR([Can't find X includes. Please check your installation and add the correct paths!])
1265 fi
1266
1267 if test "$kde_x_libraries" = NO; then
1268   AC_MSG_ERROR([Can't find X libraries. Please check your installation and add the correct paths!])
1269 fi
1270
1271 # Record where we found X for the cache.
1272 kde_cv_have_x="have_x=yes \
1273          kde_x_includes=$kde_x_includes kde_x_libraries=$kde_x_libraries"
1274 ])dnl
1275
1276 eval "$kde_cv_have_x"
1277
1278 if test "$have_x" != yes; then
1279   AC_MSG_RESULT($have_x)
1280   no_x=yes
1281 else
1282   AC_MSG_RESULT([libraries $kde_x_libraries, headers $kde_x_includes])
1283 fi
1284
1285 if test -z "$kde_x_includes" || test "x$kde_x_includes" = xNONE; then
1286   X_INCLUDES=""
1287   x_includes="."; dnl better than nothing :-
1288  else
1289   x_includes=$kde_x_includes
1290   X_INCLUDES="-I$x_includes"
1291 fi
1292
1293 if test -z "$kde_x_libraries" || test "x$kde_x_libraries" = xNONE; then
1294   X_LDFLAGS=""
1295   x_libraries="/usr/lib"; dnl better than nothing :-
1296  else
1297   x_libraries=$kde_x_libraries
1298   X_LDFLAGS="-L$x_libraries"
1299 fi
1300 all_includes="$X_INCLUDES"
1301 all_libraries="$X_LDFLAGS"
1302
1303 AC_SUBST(X_INCLUDES)
1304 AC_SUBST(X_LDFLAGS)
1305 AC_SUBST(x_libraries)
1306 AC_SUBST(x_includes)
1307
1308 # Check for libraries that X11R6 Xt/Xaw programs need.
1309 ac_save_LDFLAGS="$LDFLAGS"
1310 LDFLAGS="$LDFLAGS $X_LDFLAGS"
1311 # SM needs ICE to (dynamically) link under SunOS 4.x (so we have to
1312 # check for ICE first), but we must link in the order -lSM -lICE or
1313 # we get undefined symbols.  So assume we have SM if we have ICE.
1314 # These have to be linked with before -lX11, unlike the other
1315 # libraries we check for below, so use a different variable.
1316 #  --interran@uluru.Stanford.EDU, kb@cs.umb.edu.
1317 AC_CHECK_LIB(ICE, IceConnectionNumber,
1318   [LIBSM="-lSM -lICE"], , $X_EXTRA_LIBS)
1319 AC_SUBST(LIBSM)
1320 LDFLAGS="$ac_save_LDFLAGS"
1321
1322 AC_SUBST(X_PRE_LIBS)
1323
1324 LIB_X11='-lX11 $(LIBSOCKET)'
1325 AC_SUBST(LIB_X11)
1326
1327 AC_MSG_CHECKING(for libXext)
1328 AC_CACHE_VAL(kde_cv_have_libXext,
1329 [
1330 kde_ldflags_safe="$LDFLAGS"
1331 kde_libs_safe="$LIBS"
1332
1333 LDFLAGS="$LDFLAGS $X_LDFLAGS"
1334 LIBS="-lXext -lX11 $LIBSOCKET"
1335
1336 AC_TRY_LINK([
1337 #include <stdio.h>
1338 #ifdef STDC_HEADERS
1339 # include <stdlib.h>
1340 #endif
1341 ],
1342 [
1343 printf("hello Xext\n");
1344 ],
1345 kde_cv_have_libXext=yes,
1346 kde_cv_have_libXext=no
1347    )
1348
1349 LDFLAGS=$kde_ldflags_safe
1350 LIBS=$kde_libs_safe
1351  ])
1352
1353 AC_MSG_RESULT($kde_cv_have_libXext)
1354
1355 if test "$kde_cv_have_libXext" = "no"; then
1356   AC_MSG_ERROR([We need a working libXext to proceed. Since configure
1357 can't find it itself, we stop here assuming that make wouldn't find
1358 them either.])
1359 fi
1360
1361 LIB_XEXT="-lXext"
1362 QTE_NORTTI=""
1363
1364 else
1365   dnl We're using QT Embedded
1366   CXXFLAGS="$CXXFLAGS -fno-rtti -DQWS"
1367   CFLAGS="$CFLAGS -DQWS"
1368   LDFLAGS="$LDFLAGS -DQWS"
1369   QTE_NORTTI="-fno-rtti -DQWS"
1370   X_PRE_LIBS=""
1371   LIB_X11=""
1372   LIB_XEXT=""
1373   LIBSM=""
1374   X_INCLUDES=""
1375   X_LDFLAGS=""
1376   x_includes=""
1377   x_libraries=""
1378   AC_SUBST(X_PRE_LIBS)
1379   AC_SUBST(LIB_X11)
1380   AC_SUBST(LIBSM)
1381   AC_SUBST(X_INCLUDES)
1382   AC_SUBST(X_LDFLAGS)
1383   AC_SUBST(x_includes)
1384   AC_SUBST(x_libraries)
1385 fi
1386 AC_SUBST(QTE_NORTTI)
1387 AC_SUBST(LIB_XEXT)
1388
1389
1390 AC_LANG_RESTORE
1391
1392 ])
1393
1394 AC_DEFUN(KDE_PRINT_QT_PROGRAM,
1395 [
1396 AC_REQUIRE([KDE_USE_QT])
1397 cat > conftest.$ac_ext <<EOF
1398 #include "confdefs.h"
1399 #include <qglobal.h>
1400 #include <qapplication.h>
1401 EOF
1402 if test "$kde_qtver" = "2"; then
1403 cat >> conftest.$ac_ext <<EOF
1404 #include <qevent.h>
1405 #include <qstring.h>
1406 #include <qstyle.h>
1407 EOF
1408
1409 if test $kde_qtsubver -gt 0; then
1410 cat >> conftest.$ac_ext <<EOF
1411 #include <qiconview.h>
1412 EOF
1413 fi
1414 fi
1415
1416 if test "$kde_qtver" = "3"; then
1417 cat >> conftest.$ac_ext <<EOF
1418 #include <qcursor.h>
1419 #include <qstylefactory.h>
1420 #include <private/qucomextra_p.h>
1421 EOF
1422 fi
1423
1424 echo "#if ! ($kde_qt_verstring)" >> conftest.$ac_ext
1425 cat >> conftest.$ac_ext <<EOF
1426 #error 1
1427 #endif
1428
1429 int main() {
1430 EOF
1431 if test "$kde_qtver" = "2"; then
1432 cat >> conftest.$ac_ext <<EOF
1433     QStringList *t = new QStringList();
1434     Q_UNUSED(t);
1435 EOF
1436 if test $kde_qtsubver -gt 0; then
1437 cat >> conftest.$ac_ext <<EOF
1438     QIconView iv(0);
1439     iv.setWordWrapIconText(false);
1440     QString s;
1441     s.setLatin1("Elvis is alive", 14);
1442 EOF
1443 fi
1444 fi
1445 if test "$kde_qtver" = "3"; then
1446 cat >> conftest.$ac_ext <<EOF
1447     (void)QStyleFactory::create(QString::null);
1448     QCursor c(Qt::WhatsThisCursor);
1449 EOF
1450 fi
1451 cat >> conftest.$ac_ext <<EOF
1452     return 0;
1453 }
1454 EOF
1455 ])
1456
1457 AC_DEFUN(KDE_USE_QT,
1458 [
1459
1460 if test -z "$1"; then
1461   kde_qtver=3
1462   kde_qtsubver=1
1463 else
1464   kde_qtsubver=`echo "$1" | sed -e 's#[0-9][0-9]*\.\([0-9][0-9]*\).*#\1#'`
1465   # following is the check if subversion isnĀ“t found in passed argument
1466   if test "$kde_qtsubver" = "$1"; then
1467     kde_qtsubver=1
1468   fi
1469   kde_qtver=`echo "$1" | sed -e 's#^\([0-9][0-9]*\)\..*#\1#'`
1470   if test "$kde_qtver" = "1"; then
1471     kde_qtsubver=42
1472   fi
1473 fi
1474
1475 if test -z "$2"; then
1476   if test "$kde_qtver" = "2"; then
1477     if test $kde_qtsubver -gt 0; then
1478       kde_qt_minversion=">= Qt 2.2.2"
1479     else
1480       kde_qt_minversion=">= Qt 2.0.2"
1481     fi
1482   fi
1483   if test "$kde_qtver" = "3"; then
1484     kde_qt_minversion=">= Qt 3.0.1"
1485   fi
1486   if test "$kde_qtver" = "1"; then
1487     kde_qt_minversion=">= 1.42 and < 2.0"
1488   fi
1489 else
1490    kde_qt_minversion=$2
1491 fi
1492
1493 if test -z "$3"; then
1494    if test $kde_qtver = 3; then
1495      kde_qt_verstring="QT_VERSION >= 301"
1496    fi
1497    if test $kde_qtver = 2; then
1498      if test $kde_qtsubver -gt 0; then
1499        kde_qt_verstring="QT_VERSION >= 222"
1500      else
1501        kde_qt_verstring="QT_VERSION >= 200"
1502      fi
1503    fi
1504    if test $kde_qtver = 1; then
1505     kde_qt_verstring="QT_VERSION >= 142 && QT_VERSION < 200"
1506    fi
1507 else
1508    kde_qt_verstring=$3
1509 fi
1510
1511 if test $kde_qtver = 3; then
1512   kde_qt_dirs="$QTDIR /usr/lib/qt3 /usr/lib/qt"
1513 fi
1514 if test $kde_qtver = 2; then
1515    kde_qt_dirs="$QTDIR /usr/lib/qt2 /usr/lib/qt"
1516 fi
1517 if test $kde_qtver = 1; then
1518    kde_qt_dirs="$QTDIR /usr/lib/qt"
1519 fi
1520 ])
1521
1522 AC_DEFUN(KDE_CHECK_QT_DIRECT,
1523 [
1524 AC_REQUIRE([KDE_USE_QT])
1525 AC_MSG_CHECKING([if Qt compiles without flags])
1526 AC_CACHE_VAL(kde_cv_qt_direct,
1527 [
1528 AC_LANG_SAVE
1529 AC_LANG_CPLUSPLUS
1530 ac_LD_LIBRARY_PATH_safe=$LD_LIBRARY_PATH
1531 ac_LIBRARY_PATH="$LIBRARY_PATH"
1532 ac_cxxflags_safe="$CXXFLAGS"
1533 ac_ldflags_safe="$LDFLAGS"
1534 ac_libs_safe="$LIBS"
1535
1536 CXXFLAGS="$CXXFLAGS -I$qt_includes"
1537 LDFLAGS="$LDFLAGS $X_LDFLAGS"
1538 if test "x$kde_use_qt_emb" != "xyes"; then
1539 LIBS="$LIBQT -lXext -lX11 $LIBSOCKET"
1540 else
1541 LIBS="$LIBQT $LIBSOCKET"
1542 fi
1543 LD_LIBRARY_PATH=
1544 export LD_LIBRARY_PATH
1545 LIBRARY_PATH=
1546 export LIBRARY_PATH
1547
1548 KDE_PRINT_QT_PROGRAM
1549
1550 if AC_TRY_EVAL(ac_link) && test -s conftest; then
1551   kde_cv_qt_direct="yes"
1552 else
1553   kde_cv_qt_direct="no"
1554   echo "configure: failed program was:" >&AC_FD_CC
1555   cat conftest.$ac_ext >&AC_FD_CC
1556 fi
1557
1558 rm -f conftest*
1559 CXXFLAGS="$ac_cxxflags_safe"
1560 LDFLAGS="$ac_ldflags_safe"
1561 LIBS="$ac_libs_safe"
1562
1563 LD_LIBRARY_PATH="$ac_LD_LIBRARY_PATH_safe"
1564 export LD_LIBRARY_PATH
1565 LIBRARY_PATH="$ac_LIBRARY_PATH"
1566 export LIBRARY_PATH
1567 AC_LANG_RESTORE
1568 ])
1569
1570 if test "$kde_cv_qt_direct" = "yes"; then
1571   AC_MSG_RESULT(yes)
1572   $1
1573 else
1574   AC_MSG_RESULT(no)
1575   $2
1576 fi
1577 ])
1578
1579 dnl ------------------------------------------------------------------------
1580 dnl Try to find the Qt headers and libraries.
1581 dnl $(QT_LDFLAGS) will be -Lqtliblocation (if needed)
1582 dnl and $(QT_INCLUDES) will be -Iqthdrlocation (if needed)
1583 dnl ------------------------------------------------------------------------
1584 dnl
1585 AC_DEFUN(AC_PATH_QT_1_3,
1586 [
1587 AC_REQUIRE([K_PATH_X])
1588 AC_REQUIRE([KDE_USE_QT])
1589
1590 dnl ------------------------------------------------------------------------
1591 dnl Add configure flag to enable linking to MT version of Qt library.
1592 dnl ------------------------------------------------------------------------
1593
1594 AC_ARG_ENABLE(
1595   mt,
1596   [  --disable-mt            link to non-threaded Qt (deprecated)],
1597   kde_use_qt_mt=$enableval,
1598   [
1599     if test $kde_qtver = 3; then
1600       kde_use_qt_mt=yes
1601     else
1602       kde_use_qt_mt=no
1603     fi
1604   ]
1605 )
1606
1607 USING_QT_MT=""
1608
1609 dnl ------------------------------------------------------------------------
1610 dnl If we not get --disable-qt-mt then adjust some vars for the host.
1611 dnl ------------------------------------------------------------------------
1612
1613 KDE_MT_LDFLAGS=
1614 KDE_MT_LIBS=
1615 if test "x$kde_use_qt_mt" = "xyes"; then
1616   KDE_CHECK_THREADING
1617   if test "x$kde_use_threading" = "xyes"; then
1618     CXXFLAGS="$USE_THREADS -DQT_THREAD_SUPPORT $CXXFLAGS"
1619     KDE_MT_LDFLAGS="$USE_THREADS"
1620     KDE_MT_LIBS="$LIBPTHREAD"
1621   else
1622     kde_use_qt_mt=no
1623   fi
1624 fi
1625 AC_SUBST(KDE_MT_LDFLAGS)
1626 AC_SUBST(KDE_MT_LIBS)
1627
1628 kde_qt_was_given=yes
1629
1630 dnl ------------------------------------------------------------------------
1631 dnl If we haven't been told how to link to Qt, we work it out for ourselves.
1632 dnl ------------------------------------------------------------------------
1633 if test -z "$LIBQT_GLOB"; then
1634   if test "x$kde_use_qt_emb" = "xyes"; then
1635     LIBQT_GLOB="libqte.*"
1636   else
1637     LIBQT_GLOB="libqt.*"
1638   fi
1639 fi
1640
1641 if test -z "$LIBQT"; then
1642 dnl ------------------------------------------------------------
1643 dnl If we got --enable-embedded then adjust the Qt library name.
1644 dnl ------------------------------------------------------------
1645   if test "x$kde_use_qt_emb" = "xyes"; then
1646     qtlib="qte"
1647   else
1648     qtlib="qt"
1649   fi
1650
1651   kde_int_qt="-l$qtlib"
1652 else
1653   kde_int_qt="$LIBQT"
1654   kde_lib_qt_set=yes
1655 fi
1656
1657 if test -z "$LIBQPE"; then
1658 dnl ------------------------------------------------------------
1659 dnl If we got --enable-palmtop then add -lqpe to the link line
1660 dnl ------------------------------------------------------------
1661   if test "x$kde_use_qt_emb" = "xyes"; then
1662     if test "x$kde_use_qt_emb_palm" = "xyes"; then
1663       LIB_QPE="-lqpe"
1664     else
1665       LIB_QPE=""
1666     fi
1667   else
1668     LIB_QPE=""
1669   fi
1670 fi
1671
1672 dnl ------------------------------------------------------------------------
1673 dnl If we got --enable-qt-mt then adjust the Qt library name for the host.
1674 dnl ------------------------------------------------------------------------
1675
1676 if test "x$kde_use_qt_mt" = "xyes"; then
1677   if test -z "$LIBQT"; then
1678     LIBQT="-l$qtlib-mt"
1679     kde_int_qt="-l$qtlib-mt"
1680   else
1681     LIBQT="$qtlib-mt"
1682     kde_int_qt="$qtlib-mt"
1683   fi
1684   LIBQT_GLOB="lib$qtlib-mt.*"
1685   USING_QT_MT="using -mt"
1686 else
1687   LIBQT="-l$qtlib"
1688 fi
1689
1690 AC_MSG_CHECKING([for Qt])
1691
1692 if test "x$kde_use_qt_emb" != "xyes"; then
1693 LIBQT="$LIBQT $X_PRE_LIBS -lXext -lX11 $LIBSM $LIBSOCKET"
1694 fi
1695 ac_qt_includes=NO ac_qt_libraries=NO ac_qt_bindir=NO
1696 qt_libraries=""
1697 qt_includes=""
1698 AC_ARG_WITH(qt-dir,
1699     [  --with-qt-dir=DIR       where the root of Qt is installed ],
1700     [  ac_qt_includes="$withval"/include
1701        ac_qt_libraries="$withval"/lib
1702        ac_qt_bindir="$withval"/bin
1703     ])
1704
1705 AC_ARG_WITH(qt-includes,
1706     [  --with-qt-includes=DIR  where the Qt includes are. ],
1707     [
1708        ac_qt_includes="$withval"
1709     ])
1710
1711 kde_qt_libs_given=no
1712
1713 AC_ARG_WITH(qt-libraries,
1714     [  --with-qt-libraries=DIR where the Qt library is installed.],
1715     [  ac_qt_libraries="$withval"
1716        kde_qt_libs_given=yes
1717     ])
1718
1719 AC_CACHE_VAL(ac_cv_have_qt,
1720 [#try to guess Qt locations
1721
1722 qt_incdirs=""
1723 for dir in $kde_qt_dirs; do
1724    qt_incdirs="$qt_incdirs $dir/include $dir"
1725 done
1726 qt_incdirs="$QTINC $qt_incdirs /usr/local/qt/include /usr/include/qt /usr/include /usr/X11R6/include/X11/qt /usr/X11R6/include/qt /usr/X11R6/include/qt2 $x_includes"
1727 if test ! "$ac_qt_includes" = "NO"; then
1728    qt_incdirs="$ac_qt_includes $qt_incdirs"
1729 fi
1730
1731 if test "$kde_qtver" != "1"; then
1732   kde_qt_header=qstyle.h
1733 else
1734   kde_qt_header=qglobal.h
1735 fi
1736
1737 AC_FIND_FILE($kde_qt_header, $qt_incdirs, qt_incdir)
1738 ac_qt_includes="$qt_incdir"
1739
1740 qt_libdirs=""
1741 for dir in $kde_qt_dirs; do
1742    qt_libdirs="$qt_libdirs $dir/lib $dir"
1743 done
1744 qt_libdirs="$QTLIB $qt_libdirs /usr/X11R6/lib /usr/lib /usr/local/qt/lib $x_libraries"
1745 if test ! "$ac_qt_libraries" = "NO"; then
1746   qt_libdir=$ac_qt_libraries
1747 else
1748   qt_libdirs="$ac_qt_libraries $qt_libdirs"
1749   # if the Qt was given, the chance is too big that libqt.* doesn't exist
1750   qt_libdir=NONE
1751   for dir in $qt_libdirs; do
1752     try="ls -1 $dir/${LIBQT_GLOB}"
1753     if test -n "`$try 2> /dev/null`"; then qt_libdir=$dir; break; else echo "tried $dir" >&AC_FD_CC ; fi
1754   done
1755 fi
1756
1757 ac_qt_libraries="$qt_libdir"
1758
1759 AC_LANG_SAVE
1760 AC_LANG_CPLUSPLUS
1761
1762 ac_cxxflags_safe="$CXXFLAGS"
1763 ac_ldflags_safe="$LDFLAGS"
1764 ac_libs_safe="$LIBS"
1765
1766 CXXFLAGS="$CXXFLAGS -I$qt_incdir $all_includes"
1767 LDFLAGS="$LDFLAGS -L$qt_libdir $all_libraries $KDE_MT_LDFLAGS"
1768 LIBS="$LIBS $LIBQT $KDE_MT_LIBS"
1769
1770 KDE_PRINT_QT_PROGRAM
1771
1772 if AC_TRY_EVAL(ac_link) && test -s conftest; then
1773   rm -f conftest*
1774 else
1775   echo "configure: failed program was:" >&AC_FD_CC
1776   cat conftest.$ac_ext >&AC_FD_CC
1777   ac_qt_libraries="NO"
1778 fi
1779 rm -f conftest*
1780 CXXFLAGS="$ac_cxxflags_safe"
1781 LDFLAGS="$ac_ldflags_safe"
1782 LIBS="$ac_libs_safe"
1783
1784 AC_LANG_RESTORE
1785 if test "$ac_qt_includes" = NO || test "$ac_qt_libraries" = NO; then
1786   ac_cv_have_qt="have_qt=no"
1787   ac_qt_notfound=""
1788   missing_qt_mt=""
1789   if test "$ac_qt_includes" = NO; then
1790     if test "$ac_qt_libraries" = NO; then
1791       ac_qt_notfound="(headers and libraries)";
1792     else
1793       ac_qt_notfound="(headers)";
1794     fi
1795   else
1796     if test "x$kde_use_qt_mt" = "xyes"; then
1797        missing_qt_mt="
1798 Make sure that you have compiled Qt with thread support!"
1799        ac_qt_notfound="(library $qtlib-mt)";
1800     else
1801        ac_qt_notfound="(library $qtlib)";
1802     fi
1803   fi
1804
1805   AC_MSG_ERROR([Qt ($kde_qt_minversion) $ac_qt_notfound not found. Please check your installation!
1806 For more details about this problem, look at the end of config.log.$missing_qt_mt])
1807 else
1808   have_qt="yes"
1809 fi
1810 ])
1811
1812 eval "$ac_cv_have_qt"
1813
1814 if test "$have_qt" != yes; then
1815   AC_MSG_RESULT([$have_qt]);
1816 else
1817   ac_cv_have_qt="have_qt=yes \
1818     ac_qt_includes=$ac_qt_includes ac_qt_libraries=$ac_qt_libraries"
1819   AC_MSG_RESULT([libraries $ac_qt_libraries, headers $ac_qt_includes $USING_QT_MT])
1820
1821   qt_libraries="$ac_qt_libraries"
1822   qt_includes="$ac_qt_includes"
1823 fi
1824
1825 if test ! "$kde_qt_libs_given" = "yes"; then
1826 KDE_CHECK_QT_DIRECT(qt_libraries= ,[])
1827 fi
1828
1829 AC_SUBST(qt_libraries)
1830 AC_SUBST(qt_includes)
1831
1832 if test "$qt_includes" = "$x_includes" || test -z "$qt_includes"; then
1833  QT_INCLUDES=""
1834 else
1835  QT_INCLUDES="-I$qt_includes"
1836  all_includes="$QT_INCLUDES $all_includes"
1837 fi
1838
1839 if test "$qt_libraries" = "$x_libraries" || test -z "$qt_libraries"; then
1840  QT_LDFLAGS=""
1841 else
1842  QT_LDFLAGS="-L$qt_libraries"
1843  all_libraries="$all_libraries $QT_LDFLAGS"
1844 fi
1845 test -z "$KDE_MT_LDFLAGS" || all_libraries="$all_libraries $KDE_MT_LDFLAGS"
1846
1847 AC_SUBST(QT_INCLUDES)
1848 AC_SUBST(QT_LDFLAGS)
1849 AC_PATH_QT_MOC_UIC
1850
1851 if test "x$kde_use_qt_emb" != "xyes"; then
1852 LIB_QT="$kde_int_qt "'-lXext $(LIB_X11) $(LIBSM)'
1853 else
1854 LIB_QT=$kde_int_qt
1855 fi
1856 test -z "$KDE_MT_LIBS" || LIB_QT="$LIB_QT $KDE_MT_LIBS"
1857
1858 AC_SUBST(LIB_QT)
1859 AC_SUBST(LIB_QPE)
1860
1861 AC_SUBST(kde_qtver)
1862 ])
1863
1864 AC_DEFUN(AC_PATH_QT,
1865 [
1866 AC_PATH_QT_1_3
1867 ])
1868
1869 dnl ------------------------------------------------------------------------
1870 dnl Now, the same with KDE
1871 dnl $(KDE_LDFLAGS) will be the kdeliblocation (if needed)
1872 dnl and $(kde_includes) will be the kdehdrlocation (if needed)
1873 dnl ------------------------------------------------------------------------
1874 dnl
1875 AC_DEFUN(AC_BASE_PATH_KDE,
1876 [
1877 AC_PREREQ([2.13])
1878 AC_REQUIRE([AC_PATH_QT])dnl
1879 AC_CHECK_RPATH
1880 AC_MSG_CHECKING([for KDE])
1881
1882 if test "${prefix}" != NONE; then
1883   kde_includes=${prefix}/include
1884   ac_kde_includes=$prefix/include
1885
1886   if test "${exec_prefix}" != NONE; then
1887     kde_libraries=${exec_prefix}/lib
1888     ac_kde_libraries=$exec_prefix/lib
1889   else
1890     kde_libraries=${prefix}/lib
1891     ac_kde_libraries=$prefix/lib
1892   fi
1893 else
1894   ac_kde_includes=
1895   ac_kde_libraries=
1896   kde_libraries=""
1897   kde_includes=""
1898 fi
1899
1900 AC_CACHE_VAL(ac_cv_have_kde,
1901 [#try to guess kde locations
1902
1903 if test "$kde_qtver" = 1; then
1904   kde_check_header="ksock.h"
1905   kde_check_lib="libkdecore.la"
1906 else
1907   kde_check_header="ksharedptr.h"
1908   kde_check_lib="libkio.la"
1909 fi
1910
1911 if test -z "$1"; then
1912
1913 kde_incdirs="/usr/lib/kde/include /usr/local/kde/include /usr/local/include /usr/kde/include /usr/include/kde /usr/include /opt/kde3/include /opt/kde/include $x_includes $qt_includes"
1914 test -n "$KDEDIR" && kde_incdirs="$KDEDIR/include $KDEDIR/include/kde $KDEDIR $kde_incdirs"
1915 kde_incdirs="$ac_kde_includes $kde_incdirs"
1916 AC_FIND_FILE($kde_check_header, $kde_incdirs, kde_incdir)
1917 ac_kde_includes="$kde_incdir"
1918
1919 if test -n "$ac_kde_includes" && test ! -r "$ac_kde_includes/$kde_check_header"; then
1920   AC_MSG_ERROR([
1921 in the prefix, you've chosen, are no KDE headers installed. This will fail.
1922 So, check this please and use another prefix!])
1923 fi
1924
1925 kde_libdirs="/usr/lib/kde/lib /usr/local/kde/lib /usr/kde/lib /usr/lib/kde /usr/lib/kde3 /usr/lib /usr/X11R6/lib /usr/local/lib /opt/kde3/lib /opt/kde/lib /usr/X11R6/kde/lib"
1926 test -n "$KDEDIR" && kde_libdirs="$KDEDIR/lib $KDEDIR $kde_libdirs"
1927 kde_libdirs="$ac_kde_libraries $kde_libdirs"
1928 AC_FIND_FILE($kde_check_lib, $kde_libdirs, kde_libdir)
1929 ac_kde_libraries="$kde_libdir"
1930
1931 if test -n "$ac_kde_libraries" && test ! -r "$ac_kde_libraries/$kde_check_lib"; then
1932 AC_MSG_ERROR([
1933 in the prefix, you've chosen, are no KDE libraries installed. This will fail.
1934 So, check this please and use another prefix!])
1935 fi
1936 ac_kde_libraries="$kde_libdir"
1937
1938 if test "$ac_kde_includes" = NO || test "$ac_kde_libraries" = NO; then
1939   ac_cv_have_kde="have_kde=no"
1940 else
1941   ac_cv_have_kde="have_kde=yes \
1942     ac_kde_includes=$ac_kde_includes ac_kde_libraries=$ac_kde_libraries"
1943 fi
1944
1945 else dnl test -z $1
1946
1947   ac_cv_have_kde="have_kde=no"
1948
1949 fi
1950 ])dnl
1951
1952 eval "$ac_cv_have_kde"
1953
1954 if test "$have_kde" != "yes"; then
1955  if test "${prefix}" = NONE; then
1956   ac_kde_prefix="$ac_default_prefix"
1957  else
1958   ac_kde_prefix="$prefix"
1959  fi
1960  if test "$exec_prefix" = NONE; then
1961   ac_kde_exec_prefix="$ac_kde_prefix"
1962   AC_MSG_RESULT([will be installed in $ac_kde_prefix])
1963  else
1964   ac_kde_exec_prefix="$exec_prefix"
1965   AC_MSG_RESULT([will be installed in $ac_kde_prefix and $ac_kde_exec_prefix])
1966  fi
1967
1968  kde_libraries="${ac_kde_exec_prefix}/lib"
1969  kde_includes=${ac_kde_prefix}/include
1970
1971 else
1972   ac_cv_have_kde="have_kde=yes \
1973     ac_kde_includes=$ac_kde_includes ac_kde_libraries=$ac_kde_libraries"
1974   AC_MSG_RESULT([libraries $ac_kde_libraries, headers $ac_kde_includes])
1975
1976   kde_libraries="$ac_kde_libraries"
1977   kde_includes="$ac_kde_includes"
1978 fi
1979 AC_SUBST(kde_libraries)
1980 AC_SUBST(kde_includes)
1981
1982 if test "$kde_includes" = "$x_includes" || test "$kde_includes" = "$qt_includes"  || test "$kde_includes" = "/usr/include"; then
1983  KDE_INCLUDES=""
1984 else
1985  KDE_INCLUDES="-I$kde_includes"
1986  all_includes="$KDE_INCLUDES $all_includes"
1987 fi
1988  
1989 KDE_LDFLAGS="-L$kde_libraries"
1990 if test ! "$kde_libraries" = "$x_libraries" && test ! "$kde_libraries" = "$qt_libraries" ; then 
1991  all_libraries="$all_libraries $KDE_LDFLAGS"
1992 fi
1993
1994 AC_SUBST(KDE_LDFLAGS)
1995 AC_SUBST(KDE_INCLUDES)
1996
1997 AC_SUBST(all_includes)
1998 AC_SUBST(all_libraries)
1999
2000 AC_SUBST(AUTODIRS)
2001 ])
2002
2003
2004 AC_DEFUN(KDE_1_CHECK_PATH_HEADERS,
2005 [
2006     AC_MSG_CHECKING([for KDE headers installed])
2007     AC_LANG_SAVE
2008     AC_LANG_CPLUSPLUS
2009 cat > conftest.$ac_ext <<EOF
2010 #ifdef STDC_HEADERS
2011 # include <stdlib.h>
2012 #endif
2013 #include <stdio.h>
2014 #include "confdefs.h"
2015 #include <kapp.h>
2016
2017 int main() {
2018     printf("kde_htmldir=\\"%s\\"\n", KApplication::kde_htmldir().data());
2019     printf("kde_appsdir=\\"%s\\"\n", KApplication::kde_appsdir().data());
2020     printf("kde_icondir=\\"%s\\"\n", KApplication::kde_icondir().data());
2021     printf("kde_sounddir=\\"%s\\"\n", KApplication::kde_sounddir().data());
2022     printf("kde_datadir=\\"%s\\"\n", KApplication::kde_datadir().data());
2023     printf("kde_locale=\\"%s\\"\n", KApplication::kde_localedir().data());
2024     printf("kde_cgidir=\\"%s\\"\n", KApplication::kde_cgidir().data());
2025     printf("kde_confdir=\\"%s\\"\n", KApplication::kde_configdir().data());
2026     printf("kde_mimedir=\\"%s\\"\n", KApplication::kde_mimedir().data());
2027     printf("kde_toolbardir=\\"%s\\"\n", KApplication::kde_toolbardir().data());
2028     printf("kde_wallpaperdir=\\"%s\\"\n",
2029         KApplication::kde_wallpaperdir().data());
2030     printf("kde_bindir=\\"%s\\"\n", KApplication::kde_bindir().data());
2031     printf("kde_partsdir=\\"%s\\"\n", KApplication::kde_partsdir().data());
2032     printf("kde_servicesdir=\\"/tmp/dummy\\"\n");
2033     printf("kde_servicetypesdir=\\"/tmp/dummy\\"\n");
2034     printf("kde_moduledir=\\"/tmp/dummy\\"\n");
2035     printf("kde_styledir=\\"/tmp/dummy\\"\n");
2036     printf("kde_widgetdir=\\"/tmp/dummy\\"\n");
2037     return 0;
2038     }
2039 EOF
2040
2041  ac_compile='${CXX-g++} -c $CXXFLAGS $all_includes $CPPFLAGS conftest.$ac_ext'
2042  if AC_TRY_EVAL(ac_compile); then
2043    AC_MSG_RESULT(yes)
2044  else
2045    AC_MSG_ERROR([your system is not able to compile a small KDE application!
2046 Check, if you installed the KDE header files correctly.
2047 For more details about this problem, look at the end of config.log.])
2048   fi
2049
2050   AC_LANG_RESTORE
2051 ])
2052
2053
2054 AC_DEFUN(KDE_CREATE_LIBS_ALIASES,
2055 [
2056    AC_REQUIRE([KDE_MISC_TESTS])
2057    AC_REQUIRE([K_PATH_X])
2058
2059 if test $kde_qtver != 1; then
2060    LIB_KDECORE='-lkdecore'
2061    AC_SUBST(LIB_KDECORE)
2062    LIB_KDEUI='-lkdeui'
2063    AC_SUBST(LIB_KDEUI)
2064 else
2065    LIB_KDECORE='-lkdecore -lXext $(LIB_QT)'
2066    AC_SUBST(LIB_KDECORE)
2067    LIB_KDEUI='-lkdeui $(LIB_KDECORE)'
2068    AC_SUBST(LIB_KDEUI)
2069 fi
2070 ])
2071
2072 AC_DEFUN(AC_PATH_KDE,
2073 [
2074   AC_BASE_PATH_KDE
2075   AC_ARG_ENABLE(path-check, [  --disable-path-check    don't try to find out, where to install],
2076   [
2077   if test "$enableval" = "no";
2078     then ac_use_path_checking="default"
2079     else ac_use_path_checking=""
2080   fi
2081   ],
2082   [
2083   if test "$kde_qtver" = 1;
2084     then ac_use_path_checking=""
2085     else ac_use_path_checking="default"
2086   fi
2087   ]
2088   )
2089
2090   AC_CREATE_KFSSTND($ac_use_path_checking)
2091
2092   AC_SUBST_KFSSTND
2093   KDE_CREATE_LIBS_ALIASES
2094 ])
2095
2096
2097 AC_DEFUN(KDE_CHECK_COMPILER_FLAG,
2098 [
2099 AC_MSG_CHECKING(whether $CXX supports -$1)
2100 kde_cache=`echo $1 | sed 'y% .=/+-%____p_%'`
2101 AC_CACHE_VAL(kde_cv_prog_cxx_$kde_cache,
2102 [
2103   AC_LANG_SAVE
2104   AC_LANG_CPLUSPLUS
2105   save_CXXFLAGS="$CXXFLAGS"
2106   CXXFLAGS="$CXXFLAGS -$1"
2107   AC_TRY_LINK([],[ return 0; ], [eval "kde_cv_prog_cxx_$kde_cache=yes"], [])
2108   CXXFLAGS="$save_CXXFLAGS"
2109   AC_LANG_RESTORE
2110 ])
2111 if eval "test \"`echo '$kde_cv_prog_cxx_'$kde_cache`\" = yes"; then
2112  AC_MSG_RESULT(yes)
2113  :
2114  $2
2115 else
2116  AC_MSG_RESULT(no)
2117  :
2118  $3
2119 fi
2120 ])
2121
2122 dnl AC_REMOVE_FORBIDDEN removes forbidden arguments from variables
2123 dnl use: AC_REMOVE_FORBIDDEN(CC, [-forbid -bad-option whatever])
2124 dnl it's all white-space separated
2125 AC_DEFUN(AC_REMOVE_FORBIDDEN,
2126 [ __val=$$1
2127   __forbid=" $2 "
2128   if test -n "$__val"; then
2129     __new=""
2130     ac_save_IFS=$IFS
2131     IFS="       "
2132     for i in $__val; do
2133       case "$__forbid" in
2134         *" $i "*) AC_MSG_WARN([found forbidden $i in $1, removing it]) ;;
2135         *) # Careful to not add spaces, where there were none, because otherwise
2136            # libtool gets confused, if we change e.g. CXX
2137            if test -z "$__new" ; then __new=$i ; else __new="$__new $i" ; fi ;;
2138       esac
2139     done
2140     IFS=$ac_save_IFS
2141     $1=$__new
2142   fi
2143 ])
2144
2145 dnl AC_VALIDIFY_CXXFLAGS checks for forbidden flags the user may have given
2146 AC_DEFUN(AC_VALIDIFY_CXXFLAGS,
2147 [dnl
2148 if test "x$kde_use_qt_emb" != "xyes"; then
2149  AC_REMOVE_FORBIDDEN(CXX, [-fno-rtti -rpath])
2150  AC_REMOVE_FORBIDDEN(CXXFLAGS, [-fno-rtti -rpath])
2151 else
2152  AC_REMOVE_FORBIDDEN(CXX, [-rpath])
2153  AC_REMOVE_FORBIDDEN(CXXFLAGS, [-rpath])
2154 fi
2155 ])
2156
2157 AC_DEFUN(AC_CHECK_COMPILERS,
2158 [
2159   AC_ARG_ENABLE(debug,[  --enable-debug[=ARG]    enables debug symbols (yes|no|full) [default=no]],
2160   [
2161     case $enableval in
2162       yes)
2163         kde_use_debug_code="yes"
2164         kde_use_debug_define=no
2165         ;;
2166       full)
2167         kde_use_debug_code="full"
2168         kde_use_debug_define=no
2169         ;;
2170       *)
2171         kde_use_debug_code="no"
2172         kde_use_debug_define=yes
2173         ;;
2174     esac
2175   ], 
2176     [kde_use_debug_code="no"
2177       kde_use_debug_define=no
2178   ])
2179
2180   dnl Just for configure --help
2181   AC_ARG_ENABLE(dummyoption,[  --disable-debug         disables debug output and debug symbols [default=no]],[],[])
2182
2183   AC_ARG_ENABLE(strict,[  --enable-strict         compiles with strict compiler options (may not work!)],
2184    [
2185     if test $enableval = "no"; then
2186          kde_use_strict_options="no"
2187        else
2188          kde_use_strict_options="yes"
2189     fi
2190    ], [kde_use_strict_options="no"])
2191
2192   AC_ARG_ENABLE(profile,[  --enable-profile        creates profiling infos [default=no]],
2193     [kde_use_profiling=$enableval],
2194     [kde_use_profiling="no"]
2195   )
2196
2197   dnl this prevents stupid AC_PROG_CC to add "-g" to the default CFLAGS
2198   CFLAGS=" $CFLAGS"
2199
2200   AC_PROG_CC 
2201
2202   AC_PROG_CPP
2203
2204   if test "$GCC" = "yes"; then
2205     if test "$kde_use_debug_code" != "no"; then
2206       if test $kde_use_debug_code = "full"; then
2207         CFLAGS="-g3 $CFLAGS"
2208       else
2209         CFLAGS="-g -O2 $CFLAGS"
2210       fi
2211       case $host in
2212         *-*-linux-gnu)  
2213           CFLAGS="-ansi -W -Wall -pedantic -Wshadow -Wpointer-arith -Wmissing-prototypes -Wwrite-strings -D_XOPEN_SOURCE=500 -D_BSD_SOURCE $CFLAGS"
2214         ;;
2215       esac
2216     else
2217       CFLAGS="-O2 $CFLAGS"
2218     fi
2219   fi
2220
2221   if test "$kde_use_debug_define" = "yes"; then
2222     CFLAGS="-DNDEBUG $CFLAGS"
2223   fi
2224
2225   case "$host" in
2226   *-*-sysv4.2uw*) CFLAGS="-D_UNIXWARE $CFLAGS";;
2227   *-*-sysv5uw7*) CFLAGS="-D_UNIXWARE7 $CFLAGS";;
2228   esac
2229
2230   if test -z "$LDFLAGS" && test "$kde_use_debug_code" = "no" && test "$GCC" = "yes"; then
2231      LDFLAGS=""
2232   fi
2233
2234   CXXFLAGS=" $CXXFLAGS"
2235
2236   AC_PROG_CXX
2237
2238   if test "$GXX" = "yes" || test "$CXX" = "KCC"; then
2239     if test "$kde_use_debug_code" != "no"; then
2240       if test "$CXX" = "KCC"; then
2241         CXXFLAGS="+K0 -Wall -pedantic -W -Wpointer-arith -Wmissing-prototypes -Wwrite-strings $CXXFLAGS"
2242       else
2243         if test $kde_use_debug_code = "full"; then
2244           CXXFLAGS="-g3 -Wall -pedantic -W -Wpointer-arith -Wmissing-prototypes -Wwrite-strings $CXXFLAGS"
2245         else
2246           CXXFLAGS="-g -O2 -Wall -pedantic -W -Wpointer-arith -Wmissing-prototypes -Wwrite-strings $CXXFLAGS"
2247         fi
2248       fi
2249       KDE_CHECK_COMPILER_FLAG(Wno-long-long,[CXXFLAGS="-Wno-long-long $CXXFLAGS"])
2250       KDE_CHECK_COMPILER_FLAG(Wnon-virtual-dtor,[CXXFLAGS="-Wnon-virtual-dtor $CXXFLAGS"])
2251       KDE_CHECK_COMPILER_FLAG(fno-builtin,[CXXFLAGS="-fno-builtin $CXXFLAGS"])
2252
2253       case $host in  dnl
2254       *-*-linux-gnu)
2255         CXXFLAGS="-ansi -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -Wbad-function-cast -Wcast-align -Wundef -Wconversion $CXXFLAGS"
2256         ;;
2257       esac
2258
2259       if test "$kde_use_strict_options" = "yes"; then
2260         CXXFLAGS="-Wcast-qual -Wbad-function-cast -Wshadow -Wcast-align $CXXFLAGS"
2261       fi
2262
2263       if test "$kde_very_strict" = "yes"; then
2264         CXXFLAGS="-Wold-style-cast -Wredundant-decls -Wconversion $CXXFLAGS"
2265       fi
2266     else
2267       if test "$CXX" = "KCC"; then
2268         CXXFLAGS="+K3 $CXXFLAGS"
2269       else
2270         CXXFLAGS="-O2 $CXXFLAGS"
2271       fi  
2272     fi
2273   fi
2274
2275   if test "$kde_use_debug_define" = "yes"; then
2276     CXXFLAGS="-DNDEBUG -DNO_DEBUG $CXXFLAGS"
2277   fi  
2278
2279   if test "$kde_use_profiling" = "yes"; then
2280     KDE_CHECK_COMPILER_FLAG(pg,
2281     [
2282       CFLAGS="-pg $CFLAGS"
2283       CXXFLAGS="-pg $CXXFLAGS"
2284     ])
2285   fi
2286     
2287   KDE_CHECK_COMPILER_FLAG(fexceptions,[CXXFLAGS="$CXXFLAGS -fexceptions"])
2288
2289   case "$host" in
2290       *-*-irix*)  test "$GXX" = yes && CXXFLAGS="-D_LANGUAGE_C_PLUS_PLUS -D__LANGUAGE_C_PLUS_PLUS $CXXFLAGS" ;;
2291       *-*-sysv4.2uw*) CXXFLAGS="-D_UNIXWARE $CXXFLAGS";;
2292       *-*-sysv5uw7*) CXXFLAGS="-D_UNIXWARE7 $CXXFLAGS";;
2293       *-*-solaris*) 
2294         if test "$GXX" = yes; then
2295           libstdcpp=`$CXX -print-file-name=libstdc++.so`
2296           if test ! -f $libstdcpp; then
2297              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])
2298           fi
2299         fi
2300         ;;
2301   esac
2302
2303   AC_VALIDIFY_CXXFLAGS
2304
2305   AC_PROG_CXXCPP
2306
2307   ifdef([AM_DEPENDENCIES], AC_REQUIRE([KDE_ADD_DEPENDENCIES]), [])
2308
2309   KDE_CXXFLAGS=
2310   AC_SUBST(KDE_CXXFLAGS)
2311 ])
2312
2313 AC_DEFUN(KDE_ADD_DEPENDENCIES,
2314 [
2315    [A]M_DEPENDENCIES(CC)
2316    [A]M_DEPENDENCIES(CXX)
2317 ])
2318
2319 AC_DEFUN(AC_CHECK_RPATH,
2320 [
2321 AC_MSG_CHECKING(for rpath)
2322 AC_ARG_ENABLE(rpath,
2323       [  --disable-rpath         do not use the rpath feature of ld],
2324       USE_RPATH=$enableval, USE_RPATH=yes)
2325
2326 if test -z "$KDE_RPATH" && test "$USE_RPATH" = "yes"; then
2327
2328   KDE_RPATH="-Wl,--rpath -Wl,\$(kde_libraries)"
2329
2330   if test -n "$qt_libraries"; then
2331     KDE_RPATH="$KDE_RPATH -Wl,--rpath -Wl,\$(qt_libraries)"
2332   fi
2333   dnl $x_libraries is set to /usr/lib in case
2334   if test -n "$X_LDFLAGS"; then
2335     KDE_RPATH="$KDE_RPATH -Wl,--rpath -Wl,\$(x_libraries)"
2336   fi
2337 fi
2338 AC_SUBST(KDE_RPATH)
2339 AC_MSG_RESULT($USE_RPATH)
2340 ])
2341
2342
2343 AC_DEFUN(KDE_CHECK_LIBPTHREAD,
2344 [
2345 AC_CHECK_LIB(pthread, pthread_create, [LIBPTHREAD="-lpthread"] )
2346 AC_SUBST(LIBPTHREAD)
2347 ])
2348
2349 AC_DEFUN(KDE_CHECK_PTHREAD_OPTION,
2350 [
2351     AC_ARG_ENABLE(kernel-threads, [  --enable-kernel-threads Enable the use of the LinuxThreads port on FreeBSD/i386 only.],
2352         kde_use_kernthreads=$enableval, kde_use_kernthreads=no)
2353
2354     if test "$kde_use_kernthreads" = "yes"; then
2355       ac_save_CXXFLAGS="$CXXFLAGS"
2356       ac_save_CFLAGS="$CXXFLAGS"
2357       CXXFLAGS="-I/usr/local/include/pthread/linuxthreads $CXXFLAGS"
2358       CFLAGS="-I/usr/local/include/pthread/linuxthreads $CFLAGS"
2359       AC_CHECK_HEADERS(pthread/linuxthreads/pthread.h)
2360       CXXFLAGS="$ac_save_CXXFLAGS"
2361       CFLAGS="$ac_save_CFLAGS"
2362       if test "$ac_cv_header_pthread_linuxthreads_pthread_h" = "no"; then
2363         kde_use_kernthreads=no
2364       else
2365         dnl Add proper -I and -l statements
2366         AC_CHECK_LIB(lthread, pthread_join, [LIBPTHREAD="-llthread -llgcc_r"]) dnl for FreeBSD
2367         if test "x$LIBPTHREAD" = "x"; then
2368           kde_use_kernthreads=no
2369         else
2370           USE_THREADS="-D_THREAD_SAFE -I/usr/local/include/pthread/linuxthreads"
2371         fi
2372       fi
2373     else 
2374       USE_THREADS=""
2375       if test -z "$LIBPTHREAD"; then
2376         KDE_CHECK_COMPILER_FLAG(pthread, [USE_THREADS="-pthread"] )
2377       fi
2378     fi
2379
2380     case $host_os in
2381         solaris*)
2382                 KDE_CHECK_COMPILER_FLAG(mt, [USE_THREADS="-mt"])
2383                 CXXFLAGS="$CXXFLAGS -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -DUSE_SOLARIS -DSVR4"
2384                 ;;
2385         freebsd*)
2386                 CXXFLAGS="$CXXFLAGS -D_THREAD_SAFE"
2387                 ;;
2388         aix*)
2389                 CXXFLAGS="$CXXFLAGS -D_THREAD_SAFE"
2390                 LIBPTHREAD="$LIBPTHREAD -lc_r"
2391                 ;;
2392         linux*) CXXFLAGS="$CXXFLAGS -D_REENTRANT"
2393                 if test "$CXX" = "KCC"; then
2394                   CXXFLAGS="$CXXFLAGS --thread_safe"
2395                 fi
2396                 ;;
2397         *)
2398                 ;;
2399     esac
2400     AC_SUBST(USE_THREADS)
2401     AC_SUBST(LIBPTHREAD)
2402 ])
2403
2404 AC_DEFUN(KDE_CHECK_THREADING,
2405 [
2406   AC_REQUIRE([KDE_CHECK_LIBPTHREAD])
2407   AC_REQUIRE([KDE_CHECK_PTHREAD_OPTION])
2408   dnl default is yes if libpthread is found and no if no libpthread is available
2409   if test -z "$LIBPTHREAD"; then
2410     if test -z "$USE_THREADS"; then
2411       kde_check_threading_default=no
2412     else
2413       kde_check_threading_default=yes
2414     fi
2415   else
2416     kde_check_threading_default=yes
2417   fi
2418   AC_ARG_ENABLE(threading, [  --disable-threading     disables threading even if libpthread found ],
2419    kde_use_threading=$enableval, kde_use_threading=$kde_check_threading_default)
2420   if test "x$kde_use_threading" = "xyes"; then
2421     AC_DEFINE(HAVE_LIBPTHREAD, 1, [Define if you have a working libpthread (will enable threaded code)])
2422   fi
2423 ])
2424
2425 AC_DEFUN(KDE_LANG_CPLUSPLUS,
2426 [AC_LANG_CPLUSPLUS
2427 ac_link='rm -rf SunWS_cache; ${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&AC_FD_CC'
2428 pushdef([AC_LANG_CPLUSPLUS], [popdef([AC_LANG_CPLUSPLUS]) KDE_LANG_CPLUSPLUS])
2429 ])
2430
2431 pushdef([AC_LANG_CPLUSPLUS],
2432 [popdef([AC_LANG_CPLUSPLUS])
2433 KDE_LANG_CPLUSPLUS
2434 ])