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