]> git.saurik.com Git - wxWidgets.git/blame - aclocal.m4
wxSVGDC class README.TXT
[wxWidgets.git] / aclocal.m4
CommitLineData
90dd450c 1dnl aclocal.m4 generated automatically by aclocal 1.4
8168de4c 2
90dd450c
VZ
3dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
8168de4c 7
90dd450c
VZ
8dnl This program is distributed in the hope that it will be useful,
9dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without
10dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A
11dnl PARTICULAR PURPOSE.
8168de4c 12
b040e242
VS
13dnl ---------------------------------------------------------------------------
14dnl
15dnl Macros for configure.in for wxWindows by Robert Roebling, Phil Blecker,
16dnl Vadim Zeitlin and Ron Lee
17dnl
18dnl This script is under the wxWindows licence.
19dnl
20dnl Version: $Id$
21dnl ---------------------------------------------------------------------------
22
23dnl ===========================================================================
24dnl macros to find the a file in the list of include/lib paths
25dnl ===========================================================================
26
27dnl ---------------------------------------------------------------------------
28dnl call WX_PATH_FIND_INCLUDES(search path, header name), sets ac_find_includes
29dnl to the full name of the file that was found or leaves it empty if not found
30dnl ---------------------------------------------------------------------------
31AC_DEFUN([WX_PATH_FIND_INCLUDES],
32[
33ac_find_includes=
34for 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
43dnl ---------------------------------------------------------------------------
44dnl call WX_PATH_FIND_LIBRARIES(search path, header name), sets ac_find_libraries
45dnl to the full name of the file that was found or leaves it empty if not found
46dnl ---------------------------------------------------------------------------
47AC_DEFUN([WX_PATH_FIND_LIBRARIES],
48[
49ac_find_libraries=
50for 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
61dnl ---------------------------------------------------------------------------
62dnl Path to include, already defined
63dnl ---------------------------------------------------------------------------
64AC_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
76dnl ---------------------------------------------------------------------------
77dnl Path to link, already defined
78dnl ---------------------------------------------------------------------------
79AC_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
90dnl ===========================================================================
91dnl C++ features test
92dnl ===========================================================================
93
94dnl ---------------------------------------------------------------------------
95dnl WX_CPP_NEW_HEADERS checks whether the compiler has "new" <iostream> header
96dnl or only the old <iostream.h> one - it may be generally assumed that if
97dnl <iostream> exists, the other "new" headers (without .h) exist too.
98dnl
99dnl call WX_CPP_NEW_HEADERS(actiof-if-true, action-if-false-or-cross-compiling)
100dnl ---------------------------------------------------------------------------
101
102AC_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
122dnl ---------------------------------------------------------------------------
123dnl WX_CPP_BOOL checks whether the C++ compiler has a built in bool type
124dnl
125dnl call WX_CPP_BOOL - will define HAVE_BOOL if the compiler supports bool
126dnl ---------------------------------------------------------------------------
127
128AC_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
159dnl ---------------------------------------------------------------------------
160dnl a slightly better AC_C_BIGENDIAN macro which allows cross-compiling
161dnl ---------------------------------------------------------------------------
162
163AC_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.
167AC_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.
172AC_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)])
177if test $ac_cv_c_bigendian = unknown; then
178AC_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])
188fi])
189if 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])
191fi
192if test $ac_cv_c_bigendian = yes; then
193 AC_DEFINE(WORDS_BIGENDIAN)
194fi
195])
196
197dnl ---------------------------------------------------------------------------
198dnl override AC_ARG_ENABLE/WITH to cache the results in .cache file
199dnl ---------------------------------------------------------------------------
200
201AC_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
210AC_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
216dnl this macro checks for a three-valued command line --with argument:
217dnl possible arguments are 'yes', 'no', 'sys', or 'builtin'
218dnl usage: WX_ARG_SYS_WITH(option, helpmessage, variable-name)
219AC_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
266dnl this macro checks for a command line argument and caches the result
267dnl usage: WX_ARG_WITH(option, helpmessage, variable-name)
268AC_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
303dnl like WX_ARG_WITH but uses AC_ARG_ENABLE instead of AC_ARG_WITH
304dnl usage: WX_ARG_ENABLE(option, helpmessage, variable-name)
305AC_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
342dnl ===========================================================================
343dnl "3rd party" macros included here because they are not widely available
344dnl ===========================================================================
345
b040e242
VS
346dnl ---------------------------------------------------------------------------
347dnl test for availability of iconv()
348dnl ---------------------------------------------------------------------------
349
b040e242
VS
350dnl From Bruno Haible.
351
352AC_DEFUN([AM_ICONV],
353[
354 dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
355 dnl those with the standalone portable GNU libiconv installed).
356
357 AC_ARG_WITH([libiconv-prefix],
358[ --with-libiconv-prefix=DIR search for libiconv in DIR/include and DIR/lib], [
359 for dir in `echo "$withval" | tr : ' '`; do
360 if test -d $dir/include; then CPPFLAGS="$CPPFLAGS -I$dir/include"; fi
361 if test -d $dir/lib; then LDFLAGS="$LDFLAGS -L$dir/lib"; fi
362 done
363 ])
364
365 AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
366 am_cv_func_iconv="no, consider installing GNU libiconv"
367 am_cv_lib_iconv=no
368 AC_TRY_LINK([#include <stdlib.h>
369#include <iconv.h>],
370 [iconv_t cd = iconv_open("","");
371 iconv(cd,NULL,NULL,NULL,NULL);
372 iconv_close(cd);],
373 am_cv_func_iconv=yes)
374 if test "$am_cv_func_iconv" != yes; then
375 am_save_LIBS="$LIBS"
376 LIBS="$LIBS -liconv"
377 AC_TRY_LINK([#include <stdlib.h>
378#include <iconv.h>],
379 [iconv_t cd = iconv_open("","");
380 iconv(cd,NULL,NULL,NULL,NULL);
381 iconv_close(cd);],
382 am_cv_lib_iconv=yes
383 am_cv_func_iconv=yes)
384 LIBS="$am_save_LIBS"
385 fi
386 ])
387 if test "$am_cv_func_iconv" = yes; then
388 AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
b7043674 389 AC_CACHE_CHECK([if iconv needs const], wx_cv_func_iconv_const,
b040e242
VS
390 AC_TRY_COMPILE([
391#include <stdlib.h>
392#include <iconv.h>
393extern
394#ifdef __cplusplus
395"C"
396#endif
397#if defined(__STDC__) || defined(__cplusplus)
398size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
399#else
400size_t iconv();
401#endif
b7043674
VZ
402 ],
403 [],
404 wx_cv_func_iconv_const="no",
405 wx_cv_func_iconv_const="yes"
406 )
407 )
408
409 iconv_const=
1c405bb5 410 if test "x$wx_cv_func_iconv_const" = "xyes"; then
b7043674
VZ
411 iconv_const="const"
412 fi
413
414 AC_DEFINE_UNQUOTED(ICONV_CONST, $iconv_const,
b040e242
VS
415 [Define as const if the declaration of iconv() needs const.])
416 fi
417 LIBICONV=
418 if test "$am_cv_lib_iconv" = yes; then
419 LIBICONV="-liconv"
420 fi
421 AC_SUBST(LIBICONV)
422])
423
90dd450c
VZ
424dnl ---------------------------------------------------------------------------
425dnl AC_SYS_LARGEFILE (partly based on the code from autoconf 2.5x)
426dnl ---------------------------------------------------------------------------
427
428dnl WX_SYS_LARGEFILE_TEST
429dnl
430dnl NB: original autoconf test was checking if compiler supported 6 bit off_t
431dnl arithmetic properly but this failed miserably with gcc under Linux
432dnl whereas the system still supports 64 bit files, so now simply check
433dnl that off_t is big enough
434define(WX_SYS_LARGEFILE_TEST,
435[typedef struct {
436 unsigned int field: sizeof(off_t) == 8;
437} wxlf;
438])
439
440
441dnl WX_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE, CACHE-VAR)
442define(WX_SYS_LARGEFILE_MACRO_VALUE,
443[
444 AC_CACHE_CHECK([for $1 value needed for large files], [$3],
445 [
446 AC_TRY_COMPILE([#define $1 $2
447 #include <sys/types.h>],
448 WX_SYS_LARGEFILE_TEST,
449 [$3=$2],
450 [$3=no])
451 ]
452 )
453
454 if test "$$3" != no; then
5a5d3c08 455 wx_largefile=yes
90dd450c
VZ
456 AC_DEFINE_UNQUOTED([$1], [$$3])
457 fi
458])
459
460
461dnl AC_SYS_LARGEFILE
462dnl ----------------
463dnl By default, many hosts won't let programs access large files;
464dnl one must use special compiler options to get large-file access to work.
465dnl For more details about this brain damage please see:
466dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
467AC_DEFUN([AC_SYS_LARGEFILE],
468[AC_ARG_ENABLE(largefile,
469 [ --disable-largefile omit support for large files])
470if test "$enable_largefile" != no; then
471 dnl _FILE_OFFSET_BITS==64 is needed for Linux, Solaris, ...
472 dnl _LARGE_FILES -- for AIX
5a5d3c08 473 wx_largefile=no
90dd450c
VZ
474 WX_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS, 64, ac_cv_sys_file_offset_bits)
475 if test "x$wx_largefile" != "xyes"; then
476 WX_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES, 1, ac_cv_sys_large_files)
477 fi
478
5a5d3c08 479 AC_MSG_CHECKING(if large file support is available)
90dd450c
VZ
480 if test "x$wx_largefile" = "xyes"; then
481 AC_DEFINE(HAVE_LARGEFILE_SUPPORT)
482 fi
5a5d3c08 483 AC_MSG_RESULT($wx_largefile)
90dd450c
VZ
484fi
485])
b040e242 486
9e691f46
VZ
487# Configure paths for GTK+
488# Owen Taylor 1997-2001
b040e242
VS
489
490dnl AM_PATH_GTK_2_0([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]])
9e691f46
VZ
491dnl Test for GTK+, and define GTK_CFLAGS and GTK_LIBS, if gthread is specified in MODULES,
492dnl pass to pkg-config
3f345b47 493dnl
b040e242 494AC_DEFUN(AM_PATH_GTK_2_0,
9e691f46
VZ
495[dnl
496dnl Get the cflags and libraries from pkg-config
3f345b47 497dnl
9e691f46
VZ
498AC_ARG_ENABLE(gtktest, [ --disable-gtktest do not try to compile and run a test GTK+ program],
499 , enable_gtktest=yes)
3f345b47 500
9e691f46 501 pkg_config_args=gtk+-2.0
3f345b47
VZ
502 for module in . $4
503 do
504 case "$module" in
9e691f46
VZ
505 gthread)
506 pkg_config_args="$pkg_config_args gthread-2.0"
3f345b47
VZ
507 ;;
508 esac
509 done
510
9e691f46
VZ
511 no_gtk=""
512
513 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
514
515 if test x$PKG_CONFIG != xno ; then
516 if pkg-config --atleast-pkgconfig-version 0.7 ; then
517 :
518 else
519 echo *** pkg-config too old; version 0.7 or better required.
520 no_gtk=yes
521 PKG_CONFIG=no
522 fi
523 else
524 no_gtk=yes
8168de4c 525 fi
9e691f46
VZ
526
527 min_gtk_version=ifelse([$1], ,2.0.0,$1)
528 AC_MSG_CHECKING(for GTK+ - version >= $min_gtk_version)
529
530 if test x$PKG_CONFIG != xno ; then
531 ## don't try to run the test against uninstalled libtool libs
532 if $PKG_CONFIG --uninstalled $pkg_config_args; then
533 echo "Will use uninstalled version of GTK+ found in PKG_CONFIG_PATH"
534 enable_gtktest=no
535 fi
536
537 if $PKG_CONFIG --atleast-version $min_gtk_version $pkg_config_args; then
538 :
539 else
540 no_gtk=yes
541 fi
8168de4c
VZ
542 fi
543
9e691f46
VZ
544 if test x"$no_gtk" = x ; then
545 GTK_CFLAGS=`$PKG_CONFIG $pkg_config_args --cflags`
546 GTK_LIBS=`$PKG_CONFIG $pkg_config_args --libs`
547 gtk_config_major_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
3f345b47 548 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
9e691f46 549 gtk_config_minor_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
3f345b47 550 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
9e691f46 551 gtk_config_micro_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
3f345b47
VZ
552 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
553 if test "x$enable_gtktest" = "xyes" ; then
554 ac_save_CFLAGS="$CFLAGS"
555 ac_save_LIBS="$LIBS"
556 CFLAGS="$CFLAGS $GTK_CFLAGS"
557 LIBS="$GTK_LIBS $LIBS"
8168de4c 558dnl
9e691f46
VZ
559dnl Now check if the installed GTK+ is sufficiently new. (Also sanity
560dnl checks the results of pkg-config to some extent)
8168de4c 561dnl
3f345b47
VZ
562 rm -f conf.gtktest
563 AC_TRY_RUN([
8168de4c 564#include <gtk/gtk.h>
8168de4c
VZ
565#include <stdio.h>
566#include <stdlib.h>
567
9e691f46 568int
8168de4c
VZ
569main ()
570{
571 int major, minor, micro;
3f345b47 572 char *tmp_version;
8168de4c 573
3f345b47 574 system ("touch conf.gtktest");
8168de4c 575
3f345b47
VZ
576 /* HP/UX 9 (%@#!) writes to sscanf strings */
577 tmp_version = g_strdup("$min_gtk_version");
578 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
579 printf("%s, bad version string\n", "$min_gtk_version");
8168de4c
VZ
580 exit(1);
581 }
582
3f345b47
VZ
583 if ((gtk_major_version != $gtk_config_major_version) ||
584 (gtk_minor_version != $gtk_config_minor_version) ||
585 (gtk_micro_version != $gtk_config_micro_version))
586 {
9e691f46 587 printf("\n*** 'pkg-config --modversion gtk+-2.0' returned %d.%d.%d, but GTK+ (%d.%d.%d)\n",
3f345b47
VZ
588 $gtk_config_major_version, $gtk_config_minor_version, $gtk_config_micro_version,
589 gtk_major_version, gtk_minor_version, gtk_micro_version);
9e691f46 590 printf ("*** was found! If pkg-config was correct, then it is best\n");
3f345b47
VZ
591 printf ("*** to remove the old version of GTK+. You may also be able to fix the error\n");
592 printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
593 printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
594 printf("*** required on your system.\n");
9e691f46
VZ
595 printf("*** If pkg-config was wrong, set the environment variable PKG_CONFIG_PATH\n");
596 printf("*** to point to the correct configuration files\n");
597 }
3f345b47 598 else if ((gtk_major_version != GTK_MAJOR_VERSION) ||
9e691f46 599 (gtk_minor_version != GTK_MINOR_VERSION) ||
3f345b47
VZ
600 (gtk_micro_version != GTK_MICRO_VERSION))
601 {
602 printf("*** GTK+ header files (version %d.%d.%d) do not match\n",
9e691f46 603 GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION);
3f345b47 604 printf("*** library (version %d.%d.%d)\n",
9e691f46 605 gtk_major_version, gtk_minor_version, gtk_micro_version);
3f345b47 606 }
3f345b47
VZ
607 else
608 {
609 if ((gtk_major_version > major) ||
610 ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
611 ((gtk_major_version == major) && (gtk_minor_version == minor) && (gtk_micro_version >= micro)))
612 {
613 return 0;
614 }
615 else
616 {
617 printf("\n*** An old version of GTK+ (%d.%d.%d) was found.\n",
618 gtk_major_version, gtk_minor_version, gtk_micro_version);
619 printf("*** You need a version of GTK+ newer than %d.%d.%d. The latest version of\n",
9e691f46 620 major, minor, micro);
3f345b47
VZ
621 printf("*** GTK+ is always available from ftp://ftp.gtk.org.\n");
622 printf("***\n");
623 printf("*** If you have already installed a sufficiently new version, this error\n");
9e691f46 624 printf("*** probably means that the wrong copy of the pkg-config shell script is\n");
3f345b47 625 printf("*** being found. The easiest way to fix this is to remove the old version\n");
9e691f46
VZ
626 printf("*** of GTK+, but you can also set the PKG_CONFIG environment to point to the\n");
627 printf("*** correct copy of pkg-config. (In this case, you will have to\n");
3f345b47
VZ
628 printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
629 printf("*** so that the correct libraries are found at run-time))\n");
630 }
631 }
632 return 1;
8168de4c
VZ
633}
634],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
3f345b47
VZ
635 CFLAGS="$ac_save_CFLAGS"
636 LIBS="$ac_save_LIBS"
637 fi
8168de4c
VZ
638 fi
639 if test "x$no_gtk" = x ; then
b040e242 640 AC_MSG_RESULT(yes (version $gtk_config_major_version.$gtk_config_minor_version.$gtk_config_micro_version))
9e691f46 641 ifelse([$2], , :, [$2])
8168de4c
VZ
642 else
643 AC_MSG_RESULT(no)
9e691f46
VZ
644 if test "$PKG_CONFIG" = "no" ; then
645 echo "*** A new enough version of pkg-config was not found."
646 echo "*** See http://pkgconfig.sourceforge.net"
3f345b47
VZ
647 else
648 if test -f conf.gtktest ; then
649 :
650 else
9e691f46 651 echo "*** Could not run GTK+ test program, checking why..."
3f345b47
VZ
652 CFLAGS="$CFLAGS $GTK_CFLAGS"
653 LIBS="$LIBS $GTK_LIBS"
654 AC_TRY_LINK([
655#include <gtk/gtk.h>
656#include <stdio.h>
657], [ return ((gtk_major_version) || (gtk_minor_version) || (gtk_micro_version)); ],
658 [ echo "*** The test program compiled, but did not run. This usually means"
9e691f46
VZ
659 echo "*** that the run-time linker is not finding GTK+ or finding the wrong"
660 echo "*** version of GTK+. If it is not finding GTK+, you'll need to set your"
3f345b47
VZ
661 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
662 echo "*** to the installed location Also, make sure you have run ldconfig if that"
663 echo "*** is required on your system"
9e691f46 664 echo "***"
3f345b47 665 echo "*** If you have an old version installed, it is best to remove it, although"
9e691f46 666 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ],
3f345b47 667 [ echo "*** The test program failed to compile or link. See the file config.log for the"
9e691f46
VZ
668 echo "*** exact error that occured. This usually means GTK+ was incorrectly installed"
669 echo "*** or that you have moved GTK+ since it was installed. In the latter case, you"
670 echo "*** may want to edit the pkg-config script: $PKG_CONFIG" ])
3f345b47
VZ
671 CFLAGS="$ac_save_CFLAGS"
672 LIBS="$ac_save_LIBS"
673 fi
674 fi
8168de4c
VZ
675 GTK_CFLAGS=""
676 GTK_LIBS=""
677 ifelse([$3], , :, [$3])
678 fi
679 AC_SUBST(GTK_CFLAGS)
680 AC_SUBST(GTK_LIBS)
3f345b47 681 rm -f conf.gtktest
8168de4c
VZ
682])
683
b040e242
VS
684# Configure paths for GTK+
685# Owen Taylor 97-11-3
686
687dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]])
ecc7ceee
OK
688dnl Test for GTK, and define GTK_CFLAGS and GTK_LIBS
689dnl
b040e242
VS
690AC_DEFUN(AM_PATH_GTK,
691[dnl
692dnl Get the cflags and libraries from the gtk-config script
ecc7ceee
OK
693dnl
694AC_ARG_WITH(gtk-prefix,[ --with-gtk-prefix=PFX Prefix where GTK is installed (optional)],
695 gtk_config_prefix="$withval", gtk_config_prefix="")
696AC_ARG_WITH(gtk-exec-prefix,[ --with-gtk-exec-prefix=PFX Exec prefix where GTK is installed (optional)],
697 gtk_config_exec_prefix="$withval", gtk_config_exec_prefix="")
698AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
b040e242 699 , enable_gtktest=yes)
ecc7ceee
OK
700
701 for module in . $4
702 do
703 case "$module" in
b040e242 704 gthread)
ecc7ceee
OK
705 gtk_config_args="$gtk_config_args gthread"
706 ;;
707 esac
708 done
709
710 if test x$gtk_config_exec_prefix != x ; then
711 gtk_config_args="$gtk_config_args --exec-prefix=$gtk_config_exec_prefix"
b040e242
VS
712 if test x${GTK_CONFIG+set} != xset ; then
713 GTK_CONFIG=$gtk_config_exec_prefix/bin/gtk-config
ecc7ceee
OK
714 fi
715 fi
716 if test x$gtk_config_prefix != x ; then
717 gtk_config_args="$gtk_config_args --prefix=$gtk_config_prefix"
b040e242
VS
718 if test x${GTK_CONFIG+set} != xset ; then
719 GTK_CONFIG=$gtk_config_prefix/bin/gtk-config
ecc7ceee
OK
720 fi
721 fi
722
b040e242
VS
723 AC_PATH_PROG(GTK_CONFIG, gtk-config, no)
724 min_gtk_version=ifelse([$1], ,0.99.7,$1)
ecc7ceee
OK
725 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
726 no_gtk=""
b040e242 727 if test "$GTK_CONFIG" = "no" ; then
ecc7ceee
OK
728 no_gtk=yes
729 else
b040e242
VS
730 GTK_CFLAGS=`$GTK_CONFIG $gtk_config_args --cflags`
731 GTK_LIBS=`$GTK_CONFIG $gtk_config_args --libs`
732 gtk_config_major_version=`$GTK_CONFIG $gtk_config_args --version | \
ecc7ceee 733 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
b040e242 734 gtk_config_minor_version=`$GTK_CONFIG $gtk_config_args --version | \
ecc7ceee 735 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
b040e242 736 gtk_config_micro_version=`$GTK_CONFIG $gtk_config_args --version | \
ecc7ceee
OK
737 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
738 if test "x$enable_gtktest" = "xyes" ; then
739 ac_save_CFLAGS="$CFLAGS"
740 ac_save_LIBS="$LIBS"
741 CFLAGS="$CFLAGS $GTK_CFLAGS"
742 LIBS="$GTK_LIBS $LIBS"
743dnl
744dnl Now check if the installed GTK is sufficiently new. (Also sanity
b040e242 745dnl checks the results of gtk-config to some extent
ecc7ceee
OK
746dnl
747 rm -f conf.gtktest
748 AC_TRY_RUN([
749#include <gtk/gtk.h>
750#include <stdio.h>
751#include <stdlib.h>
752
b040e242 753int
ecc7ceee
OK
754main ()
755{
756 int major, minor, micro;
757 char *tmp_version;
758
759 system ("touch conf.gtktest");
760
761 /* HP/UX 9 (%@#!) writes to sscanf strings */
762 tmp_version = g_strdup("$min_gtk_version");
763 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
764 printf("%s, bad version string\n", "$min_gtk_version");
765 exit(1);
766 }
767
768 if ((gtk_major_version != $gtk_config_major_version) ||
769 (gtk_minor_version != $gtk_config_minor_version) ||
770 (gtk_micro_version != $gtk_config_micro_version))
771 {
b040e242 772 printf("\n*** 'gtk-config --version' returned %d.%d.%d, but GTK+ (%d.%d.%d)\n",
ecc7ceee
OK
773 $gtk_config_major_version, $gtk_config_minor_version, $gtk_config_micro_version,
774 gtk_major_version, gtk_minor_version, gtk_micro_version);
b040e242 775 printf ("*** was found! If gtk-config was correct, then it is best\n");
ecc7ceee
OK
776 printf ("*** to remove the old version of GTK+. You may also be able to fix the error\n");
777 printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
778 printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
779 printf("*** required on your system.\n");
b040e242
VS
780 printf("*** If gtk-config was wrong, set the environment variable GTK_CONFIG\n");
781 printf("*** to point to the correct copy of gtk-config, and remove the file config.cache\n");
ecc7ceee 782 printf("*** before re-running configure\n");
b040e242 783 }
ecc7ceee
OK
784#if defined (GTK_MAJOR_VERSION) && defined (GTK_MINOR_VERSION) && defined (GTK_MICRO_VERSION)
785 else if ((gtk_major_version != GTK_MAJOR_VERSION) ||
b040e242 786 (gtk_minor_version != GTK_MINOR_VERSION) ||
ecc7ceee
OK
787 (gtk_micro_version != GTK_MICRO_VERSION))
788 {
789 printf("*** GTK+ header files (version %d.%d.%d) do not match\n",
b040e242 790 GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION);
ecc7ceee 791 printf("*** library (version %d.%d.%d)\n",
b040e242 792 gtk_major_version, gtk_minor_version, gtk_micro_version);
ecc7ceee
OK
793 }
794#endif /* defined (GTK_MAJOR_VERSION) ... */
795 else
796 {
797 if ((gtk_major_version > major) ||
798 ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
799 ((gtk_major_version == major) && (gtk_minor_version == minor) && (gtk_micro_version >= micro)))
800 {
801 return 0;
802 }
803 else
804 {
805 printf("\n*** An old version of GTK+ (%d.%d.%d) was found.\n",
806 gtk_major_version, gtk_minor_version, gtk_micro_version);
807 printf("*** You need a version of GTK+ newer than %d.%d.%d. The latest version of\n",
b040e242 808 major, minor, micro);
ecc7ceee
OK
809 printf("*** GTK+ is always available from ftp://ftp.gtk.org.\n");
810 printf("***\n");
811 printf("*** If you have already installed a sufficiently new version, this error\n");
b040e242 812 printf("*** probably means that the wrong copy of the gtk-config shell script is\n");
ecc7ceee 813 printf("*** being found. The easiest way to fix this is to remove the old version\n");
b040e242
VS
814 printf("*** of GTK+, but you can also set the GTK_CONFIG environment to point to the\n");
815 printf("*** correct copy of gtk-config. (In this case, you will have to\n");
ecc7ceee
OK
816 printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
817 printf("*** so that the correct libraries are found at run-time))\n");
818 }
819 }
820 return 1;
821}
822],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
823 CFLAGS="$ac_save_CFLAGS"
824 LIBS="$ac_save_LIBS"
825 fi
826 fi
827 if test "x$no_gtk" = x ; then
b040e242
VS
828 AC_MSG_RESULT(yes)
829 ifelse([$2], , :, [$2])
ecc7ceee
OK
830 else
831 AC_MSG_RESULT(no)
b040e242
VS
832 if test "$GTK_CONFIG" = "no" ; then
833 echo "*** The gtk-config script installed by GTK could not be found"
ecc7ceee 834 echo "*** If GTK was installed in PREFIX, make sure PREFIX/bin is in"
b040e242
VS
835 echo "*** your path, or set the GTK_CONFIG environment variable to the"
836 echo "*** full path to gtk-config."
ecc7ceee
OK
837 else
838 if test -f conf.gtktest ; then
839 :
840 else
841 echo "*** Could not run GTK test program, checking why..."
842 CFLAGS="$CFLAGS $GTK_CFLAGS"
843 LIBS="$LIBS $GTK_LIBS"
844 AC_TRY_LINK([
845#include <gtk/gtk.h>
846#include <stdio.h>
847], [ return ((gtk_major_version) || (gtk_minor_version) || (gtk_micro_version)); ],
848 [ echo "*** The test program compiled, but did not run. This usually means"
849 echo "*** that the run-time linker is not finding GTK or finding the wrong"
850 echo "*** version of GTK. If it is not finding GTK, you'll need to set your"
851 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
852 echo "*** to the installed location Also, make sure you have run ldconfig if that"
853 echo "*** is required on your system"
b040e242 854 echo "***"
ecc7ceee
OK
855 echo "*** If you have an old version installed, it is best to remove it, although"
856 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"
857 echo "***"
858 echo "*** If you have a RedHat 5.0 system, you should remove the GTK package that"
859 echo "*** came with the system with the command"
860 echo "***"
861 echo "*** rpm --erase --nodeps gtk gtk-devel" ],
862 [ echo "*** The test program failed to compile or link. See the file config.log for the"
863 echo "*** exact error that occured. This usually means GTK was incorrectly installed"
864 echo "*** or that you have moved GTK since it was installed. In the latter case, you"
b040e242 865 echo "*** may want to edit the gtk-config script: $GTK_CONFIG" ])
ecc7ceee
OK
866 CFLAGS="$ac_save_CFLAGS"
867 LIBS="$ac_save_LIBS"
868 fi
869 fi
870 GTK_CFLAGS=""
871 GTK_LIBS=""
872 ifelse([$3], , :, [$3])
873 fi
874 AC_SUBST(GTK_CFLAGS)
875 AC_SUBST(GTK_LIBS)
876 rm -f conf.gtktest
877])
8168de4c 878