changes to make wxGTK compile with GTK+ 2.0: now it does but the minimal
[wxWidgets.git] / aclocal.m4
1 # aclocal.m4 generated automatically by aclocal 1.6 -*- Autoconf -*-
2
3 # Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002
4 # Free Software Foundation, Inc.
5 # This file is free software; the Free Software Foundation
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
11 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12 # PARTICULAR PURPOSE.
13
14 dnl ---------------------------------------------------------------------------
15 dnl
16 dnl Macros for configure.in for wxWindows by Robert Roebling, Phil Blecker,
17 dnl Vadim Zeitlin and Ron Lee
18 dnl
19 dnl This script is under the wxWindows licence.
20 dnl
21 dnl Version: $Id$
22 dnl ---------------------------------------------------------------------------
23
24 dnl ===========================================================================
25 dnl macros to find the a file in the list of include/lib paths
26 dnl ===========================================================================
27
28 dnl ---------------------------------------------------------------------------
29 dnl call WX_PATH_FIND_INCLUDES(search path, header name), sets ac_find_includes
30 dnl to the full name of the file that was found or leaves it empty if not found
31 dnl ---------------------------------------------------------------------------
32 AC_DEFUN([WX_PATH_FIND_INCLUDES],
33 [
34 ac_find_includes=
35 for ac_dir in $1;
36   do
37     if test -f "$ac_dir/$2"; then
38       ac_find_includes=$ac_dir
39       break
40     fi
41   done
42 ])
43
44 dnl ---------------------------------------------------------------------------
45 dnl call WX_PATH_FIND_LIBRARIES(search path, header name), sets ac_find_libraries
46 dnl to the full name of the file that was found or leaves it empty if not found
47 dnl ---------------------------------------------------------------------------
48 AC_DEFUN([WX_PATH_FIND_LIBRARIES],
49 [
50 ac_find_libraries=
51 for ac_dir in $1;
52   do
53     for ac_extension in a so sl dylib; do
54       if test -f "$ac_dir/lib$2.$ac_extension"; then
55         ac_find_libraries=$ac_dir
56         break 2
57       fi
58     done
59   done
60 ])
61
62 dnl ---------------------------------------------------------------------------
63 dnl Path to include, already defined
64 dnl ---------------------------------------------------------------------------
65 AC_DEFUN([WX_INCLUDE_PATH_EXIST],
66 [
67   ac_path_to_include=$1
68   echo "$2" | grep "\-I$1" > /dev/null
69   result=$?
70   if test $result = 0; then
71     ac_path_to_include=""
72   else
73     ac_path_to_include=" -I$1"
74   fi
75 ])
76
77 dnl ---------------------------------------------------------------------------
78 dnl Path to link, already defined
79 dnl ---------------------------------------------------------------------------
80 AC_DEFUN([WX_LINK_PATH_EXIST],
81 [
82   echo "$2" | grep "\-L$1" > /dev/null
83   result=$?
84   if test $result = 0; then
85     ac_path_to_link=""
86   else
87     ac_path_to_link=" -L$1"
88   fi
89 ])
90
91 dnl ===========================================================================
92 dnl C++ features test
93 dnl ===========================================================================
94
95 dnl ---------------------------------------------------------------------------
96 dnl WX_CPP_NEW_HEADERS checks whether the compiler has "new" <iostream> header
97 dnl or only the old <iostream.h> one - it may be generally assumed that if
98 dnl <iostream> exists, the other "new" headers (without .h) exist too.
99 dnl
100 dnl call WX_CPP_NEW_HEADERS(actiof-if-true, action-if-false-or-cross-compiling)
101 dnl ---------------------------------------------------------------------------
102
103 AC_DEFUN([WX_CPP_NEW_HEADERS],
104 [
105   if test "$cross_compiling" = "yes"; then
106     ifelse([$2], , :, [$2])
107   else
108     AC_LANG_SAVE
109     AC_LANG_CPLUSPLUS
110
111     AC_CHECK_HEADERS(iostream)
112
113     if test "$ac_cv_header_iostream" = "yes" ; then
114       ifelse([$1], , :, [$1])
115     else
116       ifelse([$2], , :, [$2])
117     fi
118
119     AC_LANG_RESTORE
120   fi
121 ])
122
123 dnl ---------------------------------------------------------------------------
124 dnl WX_CPP_BOOL checks whether the C++ compiler has a built in bool type
125 dnl
126 dnl call WX_CPP_BOOL - will define HAVE_BOOL if the compiler supports bool
127 dnl ---------------------------------------------------------------------------
128
129 AC_DEFUN([WX_CPP_BOOL],
130 [
131   AC_CACHE_CHECK([if C++ compiler supports bool], wx_cv_cpp_bool,
132   [
133     AC_LANG_SAVE
134     AC_LANG_CPLUSPLUS
135
136     AC_TRY_COMPILE(
137       [
138       ],
139       [
140         bool b = true;
141
142         return 0;
143       ],
144       [
145         wx_cv_cpp_bool=yes
146       ],
147       [
148         wx_cv_cpp_bool=no
149       ]
150     )
151
152     AC_LANG_RESTORE
153   ])
154
155   if test "$wx_cv_cpp_bool" = "yes"; then
156     AC_DEFINE(HAVE_BOOL)
157   fi
158 ])
159
160 dnl ---------------------------------------------------------------------------
161 dnl a slightly better AC_C_BIGENDIAN macro which allows cross-compiling
162 dnl ---------------------------------------------------------------------------
163
164 AC_DEFUN([WX_C_BIGENDIAN],
165 [AC_CACHE_CHECK([whether byte ordering is bigendian], ac_cv_c_bigendian,
166 [ac_cv_c_bigendian=unknown
167 # See if sys/param.h defines the BYTE_ORDER macro.
168 AC_TRY_COMPILE([#include <sys/types.h>
169 #include <sys/param.h>], [
170 #if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
171  bogus endian macros
172 #endif], [# It does; now see whether it defined to BIG_ENDIAN or not.
173 AC_TRY_COMPILE([#include <sys/types.h>
174 #include <sys/param.h>], [
175 #if BYTE_ORDER != BIG_ENDIAN
176  not big endian
177 #endif], ac_cv_c_bigendian=yes, ac_cv_c_bigendian=no)])
178 if test $ac_cv_c_bigendian = unknown; then
179 AC_TRY_RUN([main () {
180   /* Are we little or big endian?  From Harbison&Steele.  */
181   union
182   {
183     long l;
184     char c[sizeof (long)];
185   } u;
186   u.l = 1;
187   exit (u.c[sizeof (long) - 1] == 1);
188 }], [ac_cv_c_bigendian=no], [ac_cv_c_bigendian=yes], [ac_cv_c_bigendian=unknown])
189 fi])
190 if test $ac_cv_c_bigendian = unknown; then
191   AC_MSG_WARN([Assuming little-endian target machine - this may be overriden by adding the line "ac_cv_c_bigendian=${ac_cv_c_bigendian='yes'}" to config.cache file])
192 fi
193 if test $ac_cv_c_bigendian = yes; then
194   AC_DEFINE(WORDS_BIGENDIAN)
195 fi
196 ])
197
198 dnl ---------------------------------------------------------------------------
199 dnl override AC_ARG_ENABLE/WITH to cache the results in .cache file
200 dnl ---------------------------------------------------------------------------
201
202 AC_DEFUN([WX_ARG_CACHE_INIT],
203         [
204           wx_arg_cache_file="configarg.cache"
205           echo "loading argument cache $wx_arg_cache_file"
206           rm -f ${wx_arg_cache_file}.tmp
207           touch ${wx_arg_cache_file}.tmp
208           touch ${wx_arg_cache_file}
209         ])
210
211 AC_DEFUN([WX_ARG_CACHE_FLUSH],
212         [
213           echo "saving argument cache $wx_arg_cache_file"
214           mv ${wx_arg_cache_file}.tmp ${wx_arg_cache_file}
215         ])
216
217 dnl this macro checks for a three-valued command line --with argument:
218 dnl   possible arguments are 'yes', 'no', 'sys', or 'builtin'
219 dnl usage: WX_ARG_SYS_WITH(option, helpmessage, variable-name)
220 AC_DEFUN([WX_ARG_SYS_WITH],
221         [
222           AC_MSG_CHECKING([for --with-$1])
223           no_cache=0
224           AC_ARG_WITH($1, [$2],
225                       [
226                         if test "$withval" = yes; then
227                           ac_cv_use_$1='$3=yes'
228                         elif test "$withval" = no; then
229                           ac_cv_use_$1='$3=no'
230                         elif test "$withval" = sys; then
231                           ac_cv_use_$1='$3=sys'
232                         elif test "$withval" = builtin; then
233                           ac_cv_use_$1='$3=builtin'
234                         else
235                           AC_MSG_ERROR([Invalid value for --with-$1: should be yes, no, sys, or builtin])
236                         fi
237                       ],
238                       [
239                         LINE=`grep "$3" ${wx_arg_cache_file}`
240                         if test "x$LINE" != x ; then
241                           eval "DEFAULT_$LINE"
242                         else
243                           no_cache=1
244                         fi
245
246                         ac_cv_use_$1='$3='$DEFAULT_$3
247                       ])
248
249           eval "$ac_cv_use_$1"
250           if test "$no_cache" != 1; then
251             echo $ac_cv_use_$1 >> ${wx_arg_cache_file}.tmp
252           fi
253
254           if test "$$3" = yes; then
255             AC_MSG_RESULT(yes)
256           elif test "$$3" = no; then
257             AC_MSG_RESULT(no)
258           elif test "$$3" = sys; then
259             AC_MSG_RESULT([system version])
260           elif test "$$3" = builtin; then
261             AC_MSG_RESULT([builtin version])
262           else
263             AC_MSG_ERROR([Invalid value for --with-$1: should be yes, no, sys, or builtin])
264           fi
265         ])
266
267 dnl this macro checks for a command line argument and caches the result
268 dnl usage: WX_ARG_WITH(option, helpmessage, variable-name)
269 AC_DEFUN([WX_ARG_WITH],
270         [
271           AC_MSG_CHECKING([for --with-$1])
272           no_cache=0
273           AC_ARG_WITH($1, [$2],
274                       [
275                         if test "$withval" = yes; then
276                           ac_cv_use_$1='$3=yes'
277                         else
278                           ac_cv_use_$1='$3=no'
279                         fi
280                       ],
281                       [
282                         LINE=`grep "$3" ${wx_arg_cache_file}`
283                         if test "x$LINE" != x ; then
284                           eval "DEFAULT_$LINE"
285                         else
286                           no_cache=1
287                         fi
288
289                         ac_cv_use_$1='$3='$DEFAULT_$3
290                       ])
291
292           eval "$ac_cv_use_$1"
293           if test "$no_cache" != 1; then
294             echo $ac_cv_use_$1 >> ${wx_arg_cache_file}.tmp
295           fi
296
297           if test "$$3" = yes; then
298             AC_MSG_RESULT(yes)
299           else
300             AC_MSG_RESULT(no)
301           fi
302         ])
303
304 dnl like WX_ARG_WITH but uses AC_ARG_ENABLE instead of AC_ARG_WITH
305 dnl usage: WX_ARG_ENABLE(option, helpmessage, variable-name)
306 AC_DEFUN([WX_ARG_ENABLE],
307         [
308           AC_MSG_CHECKING([for --enable-$1])
309           no_cache=0
310           AC_ARG_ENABLE($1, [$2],
311                         [
312                           if test "$enableval" = yes; then
313                             ac_cv_use_$1='$3=yes'
314                           else
315                             ac_cv_use_$1='$3=no'
316                           fi
317                         ],
318                         [
319                           LINE=`grep "$3" ${wx_arg_cache_file}`
320                           if test "x$LINE" != x ; then
321                             eval "DEFAULT_$LINE"
322                           else
323                             no_cache=1
324                           fi
325
326                           ac_cv_use_$1='$3='$DEFAULT_$3
327                         ])
328
329           eval "$ac_cv_use_$1"
330           if test "$no_cache" != 1; then
331             echo $ac_cv_use_$1 >> ${wx_arg_cache_file}.tmp
332           fi
333
334           if test "$$3" = yes; then
335             AC_MSG_RESULT(yes)
336           else
337             AC_MSG_RESULT(no)
338           fi
339         ])
340
341
342
343 dnl ===========================================================================
344 dnl "3rd party" macros included here because they are not widely available
345 dnl ===========================================================================
346
347 dnl ---------------------------------------------------------------------------
348 dnl test for availability of iconv()
349 dnl ---------------------------------------------------------------------------
350
351 dnl From Bruno Haible.
352
353 AC_DEFUN([AM_ICONV],
354 [
355   dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
356   dnl those with the standalone portable GNU libiconv installed).
357
358   AC_ARG_WITH([libiconv-prefix],
359 [  --with-libiconv-prefix=DIR  search for libiconv in DIR/include and DIR/lib], [
360     for dir in `echo "$withval" | tr : ' '`; do
361       if test -d $dir/include; then CPPFLAGS="$CPPFLAGS -I$dir/include"; fi
362       if test -d $dir/lib; then LDFLAGS="$LDFLAGS -L$dir/lib"; fi
363     done
364    ])
365
366   AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
367     am_cv_func_iconv="no, consider installing GNU libiconv"
368     am_cv_lib_iconv=no
369     AC_TRY_LINK([#include <stdlib.h>
370 #include <iconv.h>],
371       [iconv_t cd = iconv_open("","");
372        iconv(cd,NULL,NULL,NULL,NULL);
373        iconv_close(cd);],
374       am_cv_func_iconv=yes)
375     if test "$am_cv_func_iconv" != yes; then
376       am_save_LIBS="$LIBS"
377       LIBS="$LIBS -liconv"
378       AC_TRY_LINK([#include <stdlib.h>
379 #include <iconv.h>],
380         [iconv_t cd = iconv_open("","");
381          iconv(cd,NULL,NULL,NULL,NULL);
382          iconv_close(cd);],
383         am_cv_lib_iconv=yes
384         am_cv_func_iconv=yes)
385       LIBS="$am_save_LIBS"
386     fi
387   ])
388   if test "$am_cv_func_iconv" = yes; then
389     AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
390     AC_CACHE_CHECK([if iconv needs const], wx_cv_func_iconv_const,
391       AC_TRY_COMPILE([
392 #include <stdlib.h>
393 #include <iconv.h>
394 extern
395 #ifdef __cplusplus
396 "C"
397 #endif
398 #if defined(__STDC__) || defined(__cplusplus)
399 size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
400 #else
401 size_t iconv();
402 #endif
403         ],
404         [],
405         wx_cv_func_iconv_const="no",
406         wx_cv_func_iconv_const="yes"
407       )
408     )
409
410     iconv_const=
411     if test "x$wx_cv_func_iconv_const" = "xyes"; then
412         iconv_const="const"
413     fi
414
415     AC_DEFINE_UNQUOTED(ICONV_CONST, $iconv_const,
416       [Define as const if the declaration of iconv() needs const.])
417   fi
418   LIBICONV=
419   if test "$am_cv_lib_iconv" = yes; then
420     LIBICONV="-liconv"
421   fi
422   AC_SUBST(LIBICONV)
423 ])
424
425
426 # Configure paths for GTK+
427 # Owen Taylor     1997-2001
428
429 dnl AM_PATH_GTK_2_0([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]])
430 dnl Test for GTK+, and define GTK_CFLAGS and GTK_LIBS, if gthread is specified in MODULES, 
431 dnl pass to pkg-config
432 dnl
433 AC_DEFUN(AM_PATH_GTK_2_0,
434 [dnl 
435 dnl Get the cflags and libraries from pkg-config
436 dnl
437 AC_ARG_ENABLE(gtktest, [  --disable-gtktest       do not try to compile and run a test GTK+ program],
438                     , enable_gtktest=yes)
439
440   pkg_config_args=gtk+-2.0
441   for module in . $4
442   do
443       case "$module" in
444          gthread) 
445              pkg_config_args="$pkg_config_args gthread-2.0"
446          ;;
447       esac
448   done
449
450   no_gtk=""
451
452   AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
453
454   if test x$PKG_CONFIG != xno ; then
455     if pkg-config --atleast-pkgconfig-version 0.7 ; then
456       :
457     else
458       echo *** pkg-config too old; version 0.7 or better required.
459       no_gtk=yes
460       PKG_CONFIG=no
461     fi
462   else
463     no_gtk=yes
464   fi
465
466   min_gtk_version=ifelse([$1], ,2.0.0,$1)
467   AC_MSG_CHECKING(for GTK+ - version >= $min_gtk_version)
468
469   if test x$PKG_CONFIG != xno ; then
470     ## don't try to run the test against uninstalled libtool libs
471     if $PKG_CONFIG --uninstalled $pkg_config_args; then
472           echo "Will use uninstalled version of GTK+ found in PKG_CONFIG_PATH"
473           enable_gtktest=no
474     fi
475
476     if $PKG_CONFIG --atleast-version $min_gtk_version $pkg_config_args; then
477           :
478     else
479           no_gtk=yes
480     fi
481   fi
482
483   if test x"$no_gtk" = x ; then
484     GTK_CFLAGS=`$PKG_CONFIG $pkg_config_args --cflags`
485     GTK_LIBS=`$PKG_CONFIG $pkg_config_args --libs`
486     gtk_config_major_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
487            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
488     gtk_config_minor_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
489            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
490     gtk_config_micro_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
491            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
492     if test "x$enable_gtktest" = "xyes" ; then
493       ac_save_CFLAGS="$CFLAGS"
494       ac_save_LIBS="$LIBS"
495       CFLAGS="$CFLAGS $GTK_CFLAGS"
496       LIBS="$GTK_LIBS $LIBS"
497 dnl
498 dnl Now check if the installed GTK+ is sufficiently new. (Also sanity
499 dnl checks the results of pkg-config to some extent)
500 dnl
501       rm -f conf.gtktest
502       AC_TRY_RUN([
503 #include <gtk/gtk.h>
504 #include <stdio.h>
505 #include <stdlib.h>
506
507 int 
508 main ()
509 {
510   int major, minor, micro;
511   char *tmp_version;
512
513   system ("touch conf.gtktest");
514
515   /* HP/UX 9 (%@#!) writes to sscanf strings */
516   tmp_version = g_strdup("$min_gtk_version");
517   if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
518      printf("%s, bad version string\n", "$min_gtk_version");
519      exit(1);
520    }
521
522   if ((gtk_major_version != $gtk_config_major_version) ||
523       (gtk_minor_version != $gtk_config_minor_version) ||
524       (gtk_micro_version != $gtk_config_micro_version))
525     {
526       printf("\n*** 'pkg-config --modversion gtk+-2.0' returned %d.%d.%d, but GTK+ (%d.%d.%d)\n", 
527              $gtk_config_major_version, $gtk_config_minor_version, $gtk_config_micro_version,
528              gtk_major_version, gtk_minor_version, gtk_micro_version);
529       printf ("*** was found! If pkg-config was correct, then it is best\n");
530       printf ("*** to remove the old version of GTK+. You may also be able to fix the error\n");
531       printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
532       printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
533       printf("*** required on your system.\n");
534       printf("*** If pkg-config was wrong, set the environment variable PKG_CONFIG_PATH\n");
535       printf("*** to point to the correct configuration files\n");
536     } 
537   else if ((gtk_major_version != GTK_MAJOR_VERSION) ||
538            (gtk_minor_version != GTK_MINOR_VERSION) ||
539            (gtk_micro_version != GTK_MICRO_VERSION))
540     {
541       printf("*** GTK+ header files (version %d.%d.%d) do not match\n",
542              GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION);
543       printf("*** library (version %d.%d.%d)\n",
544              gtk_major_version, gtk_minor_version, gtk_micro_version);
545     }
546   else
547     {
548       if ((gtk_major_version > major) ||
549         ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
550         ((gtk_major_version == major) && (gtk_minor_version == minor) && (gtk_micro_version >= micro)))
551       {
552         return 0;
553        }
554      else
555       {
556         printf("\n*** An old version of GTK+ (%d.%d.%d) was found.\n",
557                gtk_major_version, gtk_minor_version, gtk_micro_version);
558         printf("*** You need a version of GTK+ newer than %d.%d.%d. The latest version of\n",
559                major, minor, micro);
560         printf("*** GTK+ is always available from ftp://ftp.gtk.org.\n");
561         printf("***\n");
562         printf("*** If you have already installed a sufficiently new version, this error\n");
563         printf("*** probably means that the wrong copy of the pkg-config shell script is\n");
564         printf("*** being found. The easiest way to fix this is to remove the old version\n");
565         printf("*** of GTK+, but you can also set the PKG_CONFIG environment to point to the\n");
566         printf("*** correct copy of pkg-config. (In this case, you will have to\n");
567         printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
568         printf("*** so that the correct libraries are found at run-time))\n");
569       }
570     }
571   return 1;
572 }
573 ],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
574        CFLAGS="$ac_save_CFLAGS"
575        LIBS="$ac_save_LIBS"
576      fi
577   fi
578   if test "x$no_gtk" = x ; then
579      AC_MSG_RESULT(yes (version $gtk_config_major_version.$gtk_config_minor_version.$gtk_config_micro_version))
580      ifelse([$2], , :, [$2])     
581   else
582      AC_MSG_RESULT(no)
583      if test "$PKG_CONFIG" = "no" ; then
584        echo "*** A new enough version of pkg-config was not found."
585        echo "*** See http://pkgconfig.sourceforge.net"
586      else
587        if test -f conf.gtktest ; then
588         :
589        else
590           echo "*** Could not run GTK+ test program, checking why..."
591           CFLAGS="$CFLAGS $GTK_CFLAGS"
592           LIBS="$LIBS $GTK_LIBS"
593           AC_TRY_LINK([
594 #include <gtk/gtk.h>
595 #include <stdio.h>
596 ],      [ return ((gtk_major_version) || (gtk_minor_version) || (gtk_micro_version)); ],
597         [ echo "*** The test program compiled, but did not run. This usually means"
598           echo "*** that the run-time linker is not finding GTK+ or finding the wrong"
599           echo "*** version of GTK+. If it is not finding GTK+, you'll need to set your"
600           echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
601           echo "*** to the installed location  Also, make sure you have run ldconfig if that"
602           echo "*** is required on your system"
603           echo "***"
604           echo "*** If you have an old version installed, it is best to remove it, although"
605           echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ],
606         [ echo "*** The test program failed to compile or link. See the file config.log for the"
607           echo "*** exact error that occured. This usually means GTK+ was incorrectly installed"
608           echo "*** or that you have moved GTK+ since it was installed. In the latter case, you"
609           echo "*** may want to edit the pkg-config script: $PKG_CONFIG" ])
610           CFLAGS="$ac_save_CFLAGS"
611           LIBS="$ac_save_LIBS"
612        fi
613      fi
614      GTK_CFLAGS=""
615      GTK_LIBS=""
616      ifelse([$3], , :, [$3])
617   fi
618   AC_SUBST(GTK_CFLAGS)
619   AC_SUBST(GTK_LIBS)
620   rm -f conf.gtktest
621 ])
622
623 # Configure paths for GTK+
624 # Owen Taylor     97-11-3
625
626 dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]])
627 dnl Test for GTK, and define GTK_CFLAGS and GTK_LIBS
628 dnl
629 AC_DEFUN(AM_PATH_GTK,
630 [dnl 
631 dnl Get the cflags and libraries from the gtk-config script
632 dnl
633 AC_ARG_WITH(gtk-prefix,[  --with-gtk-prefix=PFX   Prefix where GTK is installed (optional)],
634             gtk_config_prefix="$withval", gtk_config_prefix="")
635 AC_ARG_WITH(gtk-exec-prefix,[  --with-gtk-exec-prefix=PFX Exec prefix where GTK is installed (optional)],
636             gtk_config_exec_prefix="$withval", gtk_config_exec_prefix="")
637 AC_ARG_ENABLE(gtktest, [  --disable-gtktest       Do not try to compile and run a test GTK program],
638                     , enable_gtktest=yes)
639
640   for module in . $4
641   do
642       case "$module" in
643          gthread) 
644              gtk_config_args="$gtk_config_args gthread"
645          ;;
646       esac
647   done
648
649   if test x$gtk_config_exec_prefix != x ; then
650      gtk_config_args="$gtk_config_args --exec-prefix=$gtk_config_exec_prefix"
651      if test x${GTK_CONFIG+set} != xset ; then
652         GTK_CONFIG=$gtk_config_exec_prefix/bin/gtk-config
653      fi
654   fi
655   if test x$gtk_config_prefix != x ; then
656      gtk_config_args="$gtk_config_args --prefix=$gtk_config_prefix"
657      if test x${GTK_CONFIG+set} != xset ; then
658         GTK_CONFIG=$gtk_config_prefix/bin/gtk-config
659      fi
660   fi
661
662   AC_PATH_PROG(GTK_CONFIG, gtk-config, no)
663   min_gtk_version=ifelse([$1], ,0.99.7,$1)
664   AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
665   no_gtk=""
666   if test "$GTK_CONFIG" = "no" ; then
667     no_gtk=yes
668   else
669     GTK_CFLAGS=`$GTK_CONFIG $gtk_config_args --cflags`
670     GTK_LIBS=`$GTK_CONFIG $gtk_config_args --libs`
671     gtk_config_major_version=`$GTK_CONFIG $gtk_config_args --version | \
672            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
673     gtk_config_minor_version=`$GTK_CONFIG $gtk_config_args --version | \
674            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
675     gtk_config_micro_version=`$GTK_CONFIG $gtk_config_args --version | \
676            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
677     if test "x$enable_gtktest" = "xyes" ; then
678       ac_save_CFLAGS="$CFLAGS"
679       ac_save_LIBS="$LIBS"
680       CFLAGS="$CFLAGS $GTK_CFLAGS"
681       LIBS="$GTK_LIBS $LIBS"
682 dnl
683 dnl Now check if the installed GTK is sufficiently new. (Also sanity
684 dnl checks the results of gtk-config to some extent
685 dnl
686       rm -f conf.gtktest
687       AC_TRY_RUN([
688 #include <gtk/gtk.h>
689 #include <stdio.h>
690 #include <stdlib.h>
691
692 int 
693 main ()
694 {
695   int major, minor, micro;
696   char *tmp_version;
697
698   system ("touch conf.gtktest");
699
700   /* HP/UX 9 (%@#!) writes to sscanf strings */
701   tmp_version = g_strdup("$min_gtk_version");
702   if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
703      printf("%s, bad version string\n", "$min_gtk_version");
704      exit(1);
705    }
706
707   if ((gtk_major_version != $gtk_config_major_version) ||
708       (gtk_minor_version != $gtk_config_minor_version) ||
709       (gtk_micro_version != $gtk_config_micro_version))
710     {
711       printf("\n*** 'gtk-config --version' returned %d.%d.%d, but GTK+ (%d.%d.%d)\n", 
712              $gtk_config_major_version, $gtk_config_minor_version, $gtk_config_micro_version,
713              gtk_major_version, gtk_minor_version, gtk_micro_version);
714       printf ("*** was found! If gtk-config was correct, then it is best\n");
715       printf ("*** to remove the old version of GTK+. You may also be able to fix the error\n");
716       printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
717       printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
718       printf("*** required on your system.\n");
719       printf("*** If gtk-config was wrong, set the environment variable GTK_CONFIG\n");
720       printf("*** to point to the correct copy of gtk-config, and remove the file config.cache\n");
721       printf("*** before re-running configure\n");
722     } 
723 #if defined (GTK_MAJOR_VERSION) && defined (GTK_MINOR_VERSION) && defined (GTK_MICRO_VERSION)
724   else if ((gtk_major_version != GTK_MAJOR_VERSION) ||
725            (gtk_minor_version != GTK_MINOR_VERSION) ||
726            (gtk_micro_version != GTK_MICRO_VERSION))
727     {
728       printf("*** GTK+ header files (version %d.%d.%d) do not match\n",
729              GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION);
730       printf("*** library (version %d.%d.%d)\n",
731              gtk_major_version, gtk_minor_version, gtk_micro_version);
732     }
733 #endif /* defined (GTK_MAJOR_VERSION) ... */
734   else
735     {
736       if ((gtk_major_version > major) ||
737         ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
738         ((gtk_major_version == major) && (gtk_minor_version == minor) && (gtk_micro_version >= micro)))
739       {
740         return 0;
741        }
742      else
743       {
744         printf("\n*** An old version of GTK+ (%d.%d.%d) was found.\n",
745                gtk_major_version, gtk_minor_version, gtk_micro_version);
746         printf("*** You need a version of GTK+ newer than %d.%d.%d. The latest version of\n",
747                major, minor, micro);
748         printf("*** GTK+ is always available from ftp://ftp.gtk.org.\n");
749         printf("***\n");
750         printf("*** If you have already installed a sufficiently new version, this error\n");
751         printf("*** probably means that the wrong copy of the gtk-config shell script is\n");
752         printf("*** being found. The easiest way to fix this is to remove the old version\n");
753         printf("*** of GTK+, but you can also set the GTK_CONFIG environment to point to the\n");
754         printf("*** correct copy of gtk-config. (In this case, you will have to\n");
755         printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
756         printf("*** so that the correct libraries are found at run-time))\n");
757       }
758     }
759   return 1;
760 }
761 ],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
762        CFLAGS="$ac_save_CFLAGS"
763        LIBS="$ac_save_LIBS"
764      fi
765   fi
766   if test "x$no_gtk" = x ; then
767      AC_MSG_RESULT(yes)
768      ifelse([$2], , :, [$2])     
769   else
770      AC_MSG_RESULT(no)
771      if test "$GTK_CONFIG" = "no" ; then
772        echo "*** The gtk-config script installed by GTK could not be found"
773        echo "*** If GTK was installed in PREFIX, make sure PREFIX/bin is in"
774        echo "*** your path, or set the GTK_CONFIG environment variable to the"
775        echo "*** full path to gtk-config."
776      else
777        if test -f conf.gtktest ; then
778         :
779        else
780           echo "*** Could not run GTK test program, checking why..."
781           CFLAGS="$CFLAGS $GTK_CFLAGS"
782           LIBS="$LIBS $GTK_LIBS"
783           AC_TRY_LINK([
784 #include <gtk/gtk.h>
785 #include <stdio.h>
786 ],      [ return ((gtk_major_version) || (gtk_minor_version) || (gtk_micro_version)); ],
787         [ echo "*** The test program compiled, but did not run. This usually means"
788           echo "*** that the run-time linker is not finding GTK or finding the wrong"
789           echo "*** version of GTK. If it is not finding GTK, you'll need to set your"
790           echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
791           echo "*** to the installed location  Also, make sure you have run ldconfig if that"
792           echo "*** is required on your system"
793           echo "***"
794           echo "*** If you have an old version installed, it is best to remove it, although"
795           echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"
796           echo "***"
797           echo "*** If you have a RedHat 5.0 system, you should remove the GTK package that"
798           echo "*** came with the system with the command"
799           echo "***"
800           echo "***    rpm --erase --nodeps gtk gtk-devel" ],
801         [ echo "*** The test program failed to compile or link. See the file config.log for the"
802           echo "*** exact error that occured. This usually means GTK was incorrectly installed"
803           echo "*** or that you have moved GTK since it was installed. In the latter case, you"
804           echo "*** may want to edit the gtk-config script: $GTK_CONFIG" ])
805           CFLAGS="$ac_save_CFLAGS"
806           LIBS="$ac_save_LIBS"
807        fi
808      fi
809      GTK_CFLAGS=""
810      GTK_LIBS=""
811      ifelse([$3], , :, [$3])
812   fi
813   AC_SUBST(GTK_CFLAGS)
814   AC_SUBST(GTK_LIBS)
815   rm -f conf.gtktest
816 ])
817