]> git.saurik.com Git - wxWidgets.git/blame - aclocal.m4
TRUE not true; FALSE not false
[wxWidgets.git] / aclocal.m4
CommitLineData
579d8138 1dnl aclocal.m4 generated automatically by aclocal 1.4-p5
8168de4c 2
579d8138 3dnl Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
90dd450c
VZ
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
986ecc86
VZ
159dnl ---------------------------------------------------------------------------
160dnl WX_CPP_EXPLICIT checks whether the C++ compiler support the explicit
161dnl keyword and defines HAVE_EXPLICIT if this is the case
162dnl ---------------------------------------------------------------------------
163
164AC_DEFUN([WX_CPP_EXPLICIT],
165[
166 AC_CACHE_CHECK([if C++ compiler supports the explicit keyword],
167 wx_cv_explicit,
168 [
169 AC_LANG_SAVE
170 AC_LANG_CPLUSPLUS
171
172 dnl do the test in 2 steps: first check that the compiler knows about the
173 dnl explicit keyword at all and then verify that it really honours it
174 AC_TRY_COMPILE(
175 [
176 class Foo { public: explicit Foo(int) {} };
177 ],
178 [
179 return 0;
180 ],
181 [
182 AC_TRY_COMPILE(
183 [
184 class Foo { public: explicit Foo(int) {} };
185 static void TakeFoo(const Foo& foo) { }
186 ],
187 [
188 TakeFoo(17);
189 return 0;
190 ],
191 wx_cv_explicit=no,
192 wx_cv_explicit=yes
193 )
194 ],
195 wx_cv_explicit=no
196 )
197
198 AC_LANG_RESTORE
199 ])
200
201 if test "$wx_cv_explicit" = "yes"; then
202 AC_DEFINE(HAVE_EXPLICIT)
203 fi
204])
205
b040e242
VS
206dnl ---------------------------------------------------------------------------
207dnl a slightly better AC_C_BIGENDIAN macro which allows cross-compiling
208dnl ---------------------------------------------------------------------------
209
210AC_DEFUN([WX_C_BIGENDIAN],
211[AC_CACHE_CHECK([whether byte ordering is bigendian], ac_cv_c_bigendian,
212[ac_cv_c_bigendian=unknown
213# See if sys/param.h defines the BYTE_ORDER macro.
214AC_TRY_COMPILE([#include <sys/types.h>
215#include <sys/param.h>], [
216#if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
217 bogus endian macros
218#endif], [# It does; now see whether it defined to BIG_ENDIAN or not.
219AC_TRY_COMPILE([#include <sys/types.h>
220#include <sys/param.h>], [
221#if BYTE_ORDER != BIG_ENDIAN
222 not big endian
223#endif], ac_cv_c_bigendian=yes, ac_cv_c_bigendian=no)])
224if test $ac_cv_c_bigendian = unknown; then
225AC_TRY_RUN([main () {
226 /* Are we little or big endian? From Harbison&Steele. */
227 union
228 {
229 long l;
230 char c[sizeof (long)];
231 } u;
232 u.l = 1;
233 exit (u.c[sizeof (long) - 1] == 1);
234}], [ac_cv_c_bigendian=no], [ac_cv_c_bigendian=yes], [ac_cv_c_bigendian=unknown])
235fi])
236if test $ac_cv_c_bigendian = unknown; then
237 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])
238fi
239if test $ac_cv_c_bigendian = yes; then
240 AC_DEFINE(WORDS_BIGENDIAN)
241fi
242])
243
244dnl ---------------------------------------------------------------------------
245dnl override AC_ARG_ENABLE/WITH to cache the results in .cache file
246dnl ---------------------------------------------------------------------------
247
248AC_DEFUN([WX_ARG_CACHE_INIT],
249 [
250 wx_arg_cache_file="configarg.cache"
251 echo "loading argument cache $wx_arg_cache_file"
252 rm -f ${wx_arg_cache_file}.tmp
253 touch ${wx_arg_cache_file}.tmp
254 touch ${wx_arg_cache_file}
255 ])
256
257AC_DEFUN([WX_ARG_CACHE_FLUSH],
258 [
259 echo "saving argument cache $wx_arg_cache_file"
260 mv ${wx_arg_cache_file}.tmp ${wx_arg_cache_file}
261 ])
262
263dnl this macro checks for a three-valued command line --with argument:
264dnl possible arguments are 'yes', 'no', 'sys', or 'builtin'
265dnl usage: WX_ARG_SYS_WITH(option, helpmessage, variable-name)
266AC_DEFUN([WX_ARG_SYS_WITH],
267 [
268 AC_MSG_CHECKING([for --with-$1])
269 no_cache=0
270 AC_ARG_WITH($1, [$2],
271 [
272 if test "$withval" = yes; then
273 ac_cv_use_$1='$3=yes'
274 elif test "$withval" = no; then
275 ac_cv_use_$1='$3=no'
276 elif test "$withval" = sys; then
277 ac_cv_use_$1='$3=sys'
278 elif test "$withval" = builtin; then
279 ac_cv_use_$1='$3=builtin'
280 else
281 AC_MSG_ERROR([Invalid value for --with-$1: should be yes, no, sys, or builtin])
282 fi
283 ],
284 [
285 LINE=`grep "$3" ${wx_arg_cache_file}`
286 if test "x$LINE" != x ; then
287 eval "DEFAULT_$LINE"
288 else
289 no_cache=1
290 fi
291
292 ac_cv_use_$1='$3='$DEFAULT_$3
293 ])
294
295 eval "$ac_cv_use_$1"
296 if test "$no_cache" != 1; then
297 echo $ac_cv_use_$1 >> ${wx_arg_cache_file}.tmp
298 fi
299
300 if test "$$3" = yes; then
301 AC_MSG_RESULT(yes)
302 elif test "$$3" = no; then
303 AC_MSG_RESULT(no)
304 elif test "$$3" = sys; then
305 AC_MSG_RESULT([system version])
306 elif test "$$3" = builtin; then
307 AC_MSG_RESULT([builtin version])
308 else
309 AC_MSG_ERROR([Invalid value for --with-$1: should be yes, no, sys, or builtin])
310 fi
311 ])
312
313dnl this macro checks for a command line argument and caches the result
314dnl usage: WX_ARG_WITH(option, helpmessage, variable-name)
315AC_DEFUN([WX_ARG_WITH],
316 [
317 AC_MSG_CHECKING([for --with-$1])
318 no_cache=0
319 AC_ARG_WITH($1, [$2],
320 [
321 if test "$withval" = yes; then
322 ac_cv_use_$1='$3=yes'
323 else
324 ac_cv_use_$1='$3=no'
325 fi
326 ],
327 [
328 LINE=`grep "$3" ${wx_arg_cache_file}`
329 if test "x$LINE" != x ; then
330 eval "DEFAULT_$LINE"
331 else
332 no_cache=1
333 fi
334
335 ac_cv_use_$1='$3='$DEFAULT_$3
336 ])
337
338 eval "$ac_cv_use_$1"
339 if test "$no_cache" != 1; then
340 echo $ac_cv_use_$1 >> ${wx_arg_cache_file}.tmp
341 fi
342
343 if test "$$3" = yes; then
344 AC_MSG_RESULT(yes)
345 else
346 AC_MSG_RESULT(no)
347 fi
348 ])
349
350dnl like WX_ARG_WITH but uses AC_ARG_ENABLE instead of AC_ARG_WITH
5005acfe 351dnl usage: WX_ARG_ENABLE(option, helpmessage, variable-name, enablestring)
b040e242
VS
352AC_DEFUN([WX_ARG_ENABLE],
353 [
5005acfe
VZ
354 enablestring=$4
355 AC_MSG_CHECKING([for --${enablestring:-enable}-$1])
b040e242
VS
356 no_cache=0
357 AC_ARG_ENABLE($1, [$2],
358 [
359 if test "$enableval" = yes; then
360 ac_cv_use_$1='$3=yes'
361 else
362 ac_cv_use_$1='$3=no'
363 fi
364 ],
365 [
366 LINE=`grep "$3" ${wx_arg_cache_file}`
367 if test "x$LINE" != x ; then
368 eval "DEFAULT_$LINE"
369 else
370 no_cache=1
371 fi
372
373 ac_cv_use_$1='$3='$DEFAULT_$3
374 ])
375
376 eval "$ac_cv_use_$1"
377 if test "$no_cache" != 1; then
378 echo $ac_cv_use_$1 >> ${wx_arg_cache_file}.tmp
379 fi
380
381 if test "$$3" = yes; then
382 AC_MSG_RESULT(yes)
383 else
384 AC_MSG_RESULT(no)
385 fi
386 ])
387
388
389
390dnl ===========================================================================
391dnl "3rd party" macros included here because they are not widely available
392dnl ===========================================================================
393
b040e242
VS
394dnl ---------------------------------------------------------------------------
395dnl test for availability of iconv()
396dnl ---------------------------------------------------------------------------
397
b040e242
VS
398dnl From Bruno Haible.
399
400AC_DEFUN([AM_ICONV],
401[
402 dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
403 dnl those with the standalone portable GNU libiconv installed).
404
405 AC_ARG_WITH([libiconv-prefix],
406[ --with-libiconv-prefix=DIR search for libiconv in DIR/include and DIR/lib], [
407 for dir in `echo "$withval" | tr : ' '`; do
408 if test -d $dir/include; then CPPFLAGS="$CPPFLAGS -I$dir/include"; fi
409 if test -d $dir/lib; then LDFLAGS="$LDFLAGS -L$dir/lib"; fi
410 done
411 ])
412
413 AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
414 am_cv_func_iconv="no, consider installing GNU libiconv"
415 am_cv_lib_iconv=no
416 AC_TRY_LINK([#include <stdlib.h>
417#include <iconv.h>],
418 [iconv_t cd = iconv_open("","");
419 iconv(cd,NULL,NULL,NULL,NULL);
420 iconv_close(cd);],
421 am_cv_func_iconv=yes)
422 if test "$am_cv_func_iconv" != yes; then
423 am_save_LIBS="$LIBS"
424 LIBS="$LIBS -liconv"
425 AC_TRY_LINK([#include <stdlib.h>
426#include <iconv.h>],
427 [iconv_t cd = iconv_open("","");
428 iconv(cd,NULL,NULL,NULL,NULL);
429 iconv_close(cd);],
430 am_cv_lib_iconv=yes
431 am_cv_func_iconv=yes)
432 LIBS="$am_save_LIBS"
433 fi
434 ])
435 if test "$am_cv_func_iconv" = yes; then
436 AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
b7043674 437 AC_CACHE_CHECK([if iconv needs const], wx_cv_func_iconv_const,
b040e242
VS
438 AC_TRY_COMPILE([
439#include <stdlib.h>
440#include <iconv.h>
441extern
442#ifdef __cplusplus
443"C"
444#endif
445#if defined(__STDC__) || defined(__cplusplus)
446size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
447#else
448size_t iconv();
449#endif
b7043674
VZ
450 ],
451 [],
452 wx_cv_func_iconv_const="no",
453 wx_cv_func_iconv_const="yes"
454 )
455 )
456
457 iconv_const=
1c405bb5 458 if test "x$wx_cv_func_iconv_const" = "xyes"; then
b7043674
VZ
459 iconv_const="const"
460 fi
461
462 AC_DEFINE_UNQUOTED(ICONV_CONST, $iconv_const,
b040e242
VS
463 [Define as const if the declaration of iconv() needs const.])
464 fi
465 LIBICONV=
466 if test "$am_cv_lib_iconv" = yes; then
467 LIBICONV="-liconv"
468 fi
469 AC_SUBST(LIBICONV)
470])
471
90dd450c
VZ
472dnl ---------------------------------------------------------------------------
473dnl AC_SYS_LARGEFILE (partly based on the code from autoconf 2.5x)
474dnl ---------------------------------------------------------------------------
475
476dnl WX_SYS_LARGEFILE_TEST
477dnl
478dnl NB: original autoconf test was checking if compiler supported 6 bit off_t
479dnl arithmetic properly but this failed miserably with gcc under Linux
480dnl whereas the system still supports 64 bit files, so now simply check
481dnl that off_t is big enough
482define(WX_SYS_LARGEFILE_TEST,
483[typedef struct {
484 unsigned int field: sizeof(off_t) == 8;
485} wxlf;
486])
487
488
489dnl WX_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE, CACHE-VAR)
490define(WX_SYS_LARGEFILE_MACRO_VALUE,
491[
492 AC_CACHE_CHECK([for $1 value needed for large files], [$3],
493 [
494 AC_TRY_COMPILE([#define $1 $2
495 #include <sys/types.h>],
496 WX_SYS_LARGEFILE_TEST,
497 [$3=$2],
498 [$3=no])
499 ]
500 )
501
502 if test "$$3" != no; then
5a5d3c08 503 wx_largefile=yes
90dd450c
VZ
504 AC_DEFINE_UNQUOTED([$1], [$$3])
505 fi
506])
507
508
509dnl AC_SYS_LARGEFILE
510dnl ----------------
511dnl By default, many hosts won't let programs access large files;
512dnl one must use special compiler options to get large-file access to work.
513dnl For more details about this brain damage please see:
514dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
515AC_DEFUN([AC_SYS_LARGEFILE],
516[AC_ARG_ENABLE(largefile,
517 [ --disable-largefile omit support for large files])
518if test "$enable_largefile" != no; then
519 dnl _FILE_OFFSET_BITS==64 is needed for Linux, Solaris, ...
520 dnl _LARGE_FILES -- for AIX
5a5d3c08 521 wx_largefile=no
90dd450c
VZ
522 WX_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS, 64, ac_cv_sys_file_offset_bits)
523 if test "x$wx_largefile" != "xyes"; then
524 WX_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES, 1, ac_cv_sys_large_files)
525 fi
526
5a5d3c08 527 AC_MSG_CHECKING(if large file support is available)
90dd450c
VZ
528 if test "x$wx_largefile" = "xyes"; then
529 AC_DEFINE(HAVE_LARGEFILE_SUPPORT)
530 fi
5a5d3c08 531 AC_MSG_RESULT($wx_largefile)
90dd450c
VZ
532fi
533])
b040e242 534
9e691f46
VZ
535# Configure paths for GTK+
536# Owen Taylor 1997-2001
b040e242
VS
537
538dnl AM_PATH_GTK_2_0([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]])
9e691f46
VZ
539dnl Test for GTK+, and define GTK_CFLAGS and GTK_LIBS, if gthread is specified in MODULES,
540dnl pass to pkg-config
3f345b47 541dnl
b040e242 542AC_DEFUN(AM_PATH_GTK_2_0,
9e691f46
VZ
543[dnl
544dnl Get the cflags and libraries from pkg-config
3f345b47 545dnl
9e691f46
VZ
546AC_ARG_ENABLE(gtktest, [ --disable-gtktest do not try to compile and run a test GTK+ program],
547 , enable_gtktest=yes)
3f345b47 548
9e691f46 549 pkg_config_args=gtk+-2.0
3f345b47
VZ
550 for module in . $4
551 do
552 case "$module" in
9e691f46
VZ
553 gthread)
554 pkg_config_args="$pkg_config_args gthread-2.0"
3f345b47
VZ
555 ;;
556 esac
557 done
558
9e691f46
VZ
559 no_gtk=""
560
561 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
562
563 if test x$PKG_CONFIG != xno ; then
564 if pkg-config --atleast-pkgconfig-version 0.7 ; then
565 :
566 else
567 echo *** pkg-config too old; version 0.7 or better required.
568 no_gtk=yes
569 PKG_CONFIG=no
570 fi
571 else
572 no_gtk=yes
8168de4c 573 fi
9e691f46
VZ
574
575 min_gtk_version=ifelse([$1], ,2.0.0,$1)
576 AC_MSG_CHECKING(for GTK+ - version >= $min_gtk_version)
577
578 if test x$PKG_CONFIG != xno ; then
579 ## don't try to run the test against uninstalled libtool libs
580 if $PKG_CONFIG --uninstalled $pkg_config_args; then
581 echo "Will use uninstalled version of GTK+ found in PKG_CONFIG_PATH"
582 enable_gtktest=no
583 fi
584
585 if $PKG_CONFIG --atleast-version $min_gtk_version $pkg_config_args; then
586 :
587 else
588 no_gtk=yes
589 fi
8168de4c
VZ
590 fi
591
9e691f46
VZ
592 if test x"$no_gtk" = x ; then
593 GTK_CFLAGS=`$PKG_CONFIG $pkg_config_args --cflags`
594 GTK_LIBS=`$PKG_CONFIG $pkg_config_args --libs`
595 gtk_config_major_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
3f345b47 596 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
9e691f46 597 gtk_config_minor_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
3f345b47 598 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
9e691f46 599 gtk_config_micro_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
3f345b47
VZ
600 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
601 if test "x$enable_gtktest" = "xyes" ; then
602 ac_save_CFLAGS="$CFLAGS"
603 ac_save_LIBS="$LIBS"
604 CFLAGS="$CFLAGS $GTK_CFLAGS"
605 LIBS="$GTK_LIBS $LIBS"
8168de4c 606dnl
9e691f46
VZ
607dnl Now check if the installed GTK+ is sufficiently new. (Also sanity
608dnl checks the results of pkg-config to some extent)
8168de4c 609dnl
3f345b47
VZ
610 rm -f conf.gtktest
611 AC_TRY_RUN([
8168de4c 612#include <gtk/gtk.h>
8168de4c
VZ
613#include <stdio.h>
614#include <stdlib.h>
615
9e691f46 616int
8168de4c
VZ
617main ()
618{
619 int major, minor, micro;
3f345b47 620 char *tmp_version;
8168de4c 621
3f345b47 622 system ("touch conf.gtktest");
8168de4c 623
3f345b47
VZ
624 /* HP/UX 9 (%@#!) writes to sscanf strings */
625 tmp_version = g_strdup("$min_gtk_version");
626 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
627 printf("%s, bad version string\n", "$min_gtk_version");
8168de4c
VZ
628 exit(1);
629 }
630
3f345b47
VZ
631 if ((gtk_major_version != $gtk_config_major_version) ||
632 (gtk_minor_version != $gtk_config_minor_version) ||
633 (gtk_micro_version != $gtk_config_micro_version))
634 {
9e691f46 635 printf("\n*** 'pkg-config --modversion gtk+-2.0' returned %d.%d.%d, but GTK+ (%d.%d.%d)\n",
3f345b47
VZ
636 $gtk_config_major_version, $gtk_config_minor_version, $gtk_config_micro_version,
637 gtk_major_version, gtk_minor_version, gtk_micro_version);
9e691f46 638 printf ("*** was found! If pkg-config was correct, then it is best\n");
3f345b47
VZ
639 printf ("*** to remove the old version of GTK+. You may also be able to fix the error\n");
640 printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
641 printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
642 printf("*** required on your system.\n");
9e691f46
VZ
643 printf("*** If pkg-config was wrong, set the environment variable PKG_CONFIG_PATH\n");
644 printf("*** to point to the correct configuration files\n");
645 }
3f345b47 646 else if ((gtk_major_version != GTK_MAJOR_VERSION) ||
9e691f46 647 (gtk_minor_version != GTK_MINOR_VERSION) ||
3f345b47
VZ
648 (gtk_micro_version != GTK_MICRO_VERSION))
649 {
650 printf("*** GTK+ header files (version %d.%d.%d) do not match\n",
9e691f46 651 GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION);
3f345b47 652 printf("*** library (version %d.%d.%d)\n",
9e691f46 653 gtk_major_version, gtk_minor_version, gtk_micro_version);
3f345b47 654 }
3f345b47
VZ
655 else
656 {
657 if ((gtk_major_version > major) ||
658 ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
659 ((gtk_major_version == major) && (gtk_minor_version == minor) && (gtk_micro_version >= micro)))
660 {
661 return 0;
662 }
663 else
664 {
665 printf("\n*** An old version of GTK+ (%d.%d.%d) was found.\n",
666 gtk_major_version, gtk_minor_version, gtk_micro_version);
667 printf("*** You need a version of GTK+ newer than %d.%d.%d. The latest version of\n",
9e691f46 668 major, minor, micro);
3f345b47
VZ
669 printf("*** GTK+ is always available from ftp://ftp.gtk.org.\n");
670 printf("***\n");
671 printf("*** If you have already installed a sufficiently new version, this error\n");
9e691f46 672 printf("*** probably means that the wrong copy of the pkg-config shell script is\n");
3f345b47 673 printf("*** being found. The easiest way to fix this is to remove the old version\n");
9e691f46
VZ
674 printf("*** of GTK+, but you can also set the PKG_CONFIG environment to point to the\n");
675 printf("*** correct copy of pkg-config. (In this case, you will have to\n");
3f345b47
VZ
676 printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
677 printf("*** so that the correct libraries are found at run-time))\n");
678 }
679 }
680 return 1;
8168de4c
VZ
681}
682],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
3f345b47
VZ
683 CFLAGS="$ac_save_CFLAGS"
684 LIBS="$ac_save_LIBS"
685 fi
8168de4c
VZ
686 fi
687 if test "x$no_gtk" = x ; then
b040e242 688 AC_MSG_RESULT(yes (version $gtk_config_major_version.$gtk_config_minor_version.$gtk_config_micro_version))
9e691f46 689 ifelse([$2], , :, [$2])
8168de4c
VZ
690 else
691 AC_MSG_RESULT(no)
9e691f46
VZ
692 if test "$PKG_CONFIG" = "no" ; then
693 echo "*** A new enough version of pkg-config was not found."
694 echo "*** See http://pkgconfig.sourceforge.net"
3f345b47
VZ
695 else
696 if test -f conf.gtktest ; then
697 :
698 else
9e691f46 699 echo "*** Could not run GTK+ test program, checking why..."
579d8138
VS
700 ac_save_CFLAGS="$CFLAGS"
701 ac_save_LIBS="$LIBS"
3f345b47
VZ
702 CFLAGS="$CFLAGS $GTK_CFLAGS"
703 LIBS="$LIBS $GTK_LIBS"
704 AC_TRY_LINK([
705#include <gtk/gtk.h>
706#include <stdio.h>
707], [ return ((gtk_major_version) || (gtk_minor_version) || (gtk_micro_version)); ],
708 [ echo "*** The test program compiled, but did not run. This usually means"
9e691f46
VZ
709 echo "*** that the run-time linker is not finding GTK+ or finding the wrong"
710 echo "*** version of GTK+. If it is not finding GTK+, you'll need to set your"
3f345b47
VZ
711 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
712 echo "*** to the installed location Also, make sure you have run ldconfig if that"
713 echo "*** is required on your system"
9e691f46 714 echo "***"
3f345b47 715 echo "*** If you have an old version installed, it is best to remove it, although"
9e691f46 716 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ],
3f345b47 717 [ echo "*** The test program failed to compile or link. See the file config.log for the"
579d8138 718 echo "*** exact error that occured. This usually means GTK+ is incorrectly installed."])
3f345b47
VZ
719 CFLAGS="$ac_save_CFLAGS"
720 LIBS="$ac_save_LIBS"
721 fi
722 fi
8168de4c
VZ
723 GTK_CFLAGS=""
724 GTK_LIBS=""
725 ifelse([$3], , :, [$3])
726 fi
727 AC_SUBST(GTK_CFLAGS)
728 AC_SUBST(GTK_LIBS)
3f345b47 729 rm -f conf.gtktest
8168de4c
VZ
730])
731
579d8138
VS
732
733dnl PKG_CHECK_MODULES(GSTUFF, gtk+-2.0 >= 1.3 glib = 1.3.4, action-if, action-not)
734dnl defines GSTUFF_LIBS, GSTUFF_CFLAGS, see pkg-config man page
735dnl also defines GSTUFF_PKG_ERRORS on error
736AC_DEFUN(PKG_CHECK_MODULES, [
737 succeeded=no
738
739 if test -z "$PKG_CONFIG"; then
740 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
741 fi
742
743 if test "$PKG_CONFIG" = "no" ; then
744 echo "*** The pkg-config script could not be found. Make sure it is"
745 echo "*** in your path, or set the PKG_CONFIG environment variable"
746 echo "*** to the full path to pkg-config."
747 echo "*** Or see http://www.freedesktop.org/software/pkgconfig to get pkg-config."
748 else
749 PKG_CONFIG_MIN_VERSION=0.9.0
750 if $PKG_CONFIG --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
751 AC_MSG_CHECKING(for $2)
752
753 if $PKG_CONFIG --exists "$2" ; then
754 AC_MSG_RESULT(yes)
755 succeeded=yes
756
757 AC_MSG_CHECKING($1_CFLAGS)
758 $1_CFLAGS=`$PKG_CONFIG --cflags "$2"`
759 AC_MSG_RESULT($$1_CFLAGS)
760
761 AC_MSG_CHECKING($1_LIBS)
762 $1_LIBS=`$PKG_CONFIG --libs "$2"`
763 AC_MSG_RESULT($$1_LIBS)
764 else
765 $1_CFLAGS=""
766 $1_LIBS=""
767 ## If we have a custom action on failure, don't print errors, but
768 ## do set a variable so people can do so.
769 $1_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"`
770 ifelse([$4], ,echo $$1_PKG_ERRORS,)
771 fi
772
773 AC_SUBST($1_CFLAGS)
774 AC_SUBST($1_LIBS)
775 else
776 echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
777 echo "*** See http://www.freedesktop.org/software/pkgconfig"
778 fi
779 fi
780
781 if test $succeeded = yes; then
782 ifelse([$3], , :, [$3])
783 else
784 ifelse([$4], , AC_MSG_ERROR([Library requirements ($2) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them.]), [$4])
785 fi
786])
787
788
789
b040e242
VS
790# Configure paths for GTK+
791# Owen Taylor 97-11-3
792
793dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]])
ecc7ceee
OK
794dnl Test for GTK, and define GTK_CFLAGS and GTK_LIBS
795dnl
b040e242
VS
796AC_DEFUN(AM_PATH_GTK,
797[dnl
798dnl Get the cflags and libraries from the gtk-config script
ecc7ceee
OK
799dnl
800AC_ARG_WITH(gtk-prefix,[ --with-gtk-prefix=PFX Prefix where GTK is installed (optional)],
801 gtk_config_prefix="$withval", gtk_config_prefix="")
802AC_ARG_WITH(gtk-exec-prefix,[ --with-gtk-exec-prefix=PFX Exec prefix where GTK is installed (optional)],
803 gtk_config_exec_prefix="$withval", gtk_config_exec_prefix="")
804AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
b040e242 805 , enable_gtktest=yes)
ecc7ceee
OK
806
807 for module in . $4
808 do
809 case "$module" in
b040e242 810 gthread)
ecc7ceee
OK
811 gtk_config_args="$gtk_config_args gthread"
812 ;;
813 esac
814 done
815
816 if test x$gtk_config_exec_prefix != x ; then
817 gtk_config_args="$gtk_config_args --exec-prefix=$gtk_config_exec_prefix"
b040e242
VS
818 if test x${GTK_CONFIG+set} != xset ; then
819 GTK_CONFIG=$gtk_config_exec_prefix/bin/gtk-config
ecc7ceee
OK
820 fi
821 fi
822 if test x$gtk_config_prefix != x ; then
823 gtk_config_args="$gtk_config_args --prefix=$gtk_config_prefix"
b040e242
VS
824 if test x${GTK_CONFIG+set} != xset ; then
825 GTK_CONFIG=$gtk_config_prefix/bin/gtk-config
ecc7ceee
OK
826 fi
827 fi
828
b040e242
VS
829 AC_PATH_PROG(GTK_CONFIG, gtk-config, no)
830 min_gtk_version=ifelse([$1], ,0.99.7,$1)
ecc7ceee
OK
831 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
832 no_gtk=""
b040e242 833 if test "$GTK_CONFIG" = "no" ; then
ecc7ceee
OK
834 no_gtk=yes
835 else
b040e242
VS
836 GTK_CFLAGS=`$GTK_CONFIG $gtk_config_args --cflags`
837 GTK_LIBS=`$GTK_CONFIG $gtk_config_args --libs`
838 gtk_config_major_version=`$GTK_CONFIG $gtk_config_args --version | \
ecc7ceee 839 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
b040e242 840 gtk_config_minor_version=`$GTK_CONFIG $gtk_config_args --version | \
ecc7ceee 841 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
b040e242 842 gtk_config_micro_version=`$GTK_CONFIG $gtk_config_args --version | \
ecc7ceee
OK
843 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
844 if test "x$enable_gtktest" = "xyes" ; then
845 ac_save_CFLAGS="$CFLAGS"
846 ac_save_LIBS="$LIBS"
847 CFLAGS="$CFLAGS $GTK_CFLAGS"
848 LIBS="$GTK_LIBS $LIBS"
849dnl
850dnl Now check if the installed GTK is sufficiently new. (Also sanity
b040e242 851dnl checks the results of gtk-config to some extent
ecc7ceee
OK
852dnl
853 rm -f conf.gtktest
854 AC_TRY_RUN([
855#include <gtk/gtk.h>
856#include <stdio.h>
857#include <stdlib.h>
858
b040e242 859int
ecc7ceee
OK
860main ()
861{
862 int major, minor, micro;
863 char *tmp_version;
864
865 system ("touch conf.gtktest");
866
867 /* HP/UX 9 (%@#!) writes to sscanf strings */
868 tmp_version = g_strdup("$min_gtk_version");
869 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
870 printf("%s, bad version string\n", "$min_gtk_version");
871 exit(1);
872 }
873
874 if ((gtk_major_version != $gtk_config_major_version) ||
875 (gtk_minor_version != $gtk_config_minor_version) ||
876 (gtk_micro_version != $gtk_config_micro_version))
877 {
b040e242 878 printf("\n*** 'gtk-config --version' returned %d.%d.%d, but GTK+ (%d.%d.%d)\n",
ecc7ceee
OK
879 $gtk_config_major_version, $gtk_config_minor_version, $gtk_config_micro_version,
880 gtk_major_version, gtk_minor_version, gtk_micro_version);
b040e242 881 printf ("*** was found! If gtk-config was correct, then it is best\n");
ecc7ceee
OK
882 printf ("*** to remove the old version of GTK+. You may also be able to fix the error\n");
883 printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
884 printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
885 printf("*** required on your system.\n");
b040e242
VS
886 printf("*** If gtk-config was wrong, set the environment variable GTK_CONFIG\n");
887 printf("*** to point to the correct copy of gtk-config, and remove the file config.cache\n");
ecc7ceee 888 printf("*** before re-running configure\n");
b040e242 889 }
ecc7ceee
OK
890#if defined (GTK_MAJOR_VERSION) && defined (GTK_MINOR_VERSION) && defined (GTK_MICRO_VERSION)
891 else if ((gtk_major_version != GTK_MAJOR_VERSION) ||
b040e242 892 (gtk_minor_version != GTK_MINOR_VERSION) ||
ecc7ceee
OK
893 (gtk_micro_version != GTK_MICRO_VERSION))
894 {
895 printf("*** GTK+ header files (version %d.%d.%d) do not match\n",
b040e242 896 GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION);
ecc7ceee 897 printf("*** library (version %d.%d.%d)\n",
b040e242 898 gtk_major_version, gtk_minor_version, gtk_micro_version);
ecc7ceee
OK
899 }
900#endif /* defined (GTK_MAJOR_VERSION) ... */
901 else
902 {
903 if ((gtk_major_version > major) ||
904 ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
905 ((gtk_major_version == major) && (gtk_minor_version == minor) && (gtk_micro_version >= micro)))
906 {
907 return 0;
908 }
909 else
910 {
911 printf("\n*** An old version of GTK+ (%d.%d.%d) was found.\n",
912 gtk_major_version, gtk_minor_version, gtk_micro_version);
913 printf("*** You need a version of GTK+ newer than %d.%d.%d. The latest version of\n",
b040e242 914 major, minor, micro);
ecc7ceee
OK
915 printf("*** GTK+ is always available from ftp://ftp.gtk.org.\n");
916 printf("***\n");
917 printf("*** If you have already installed a sufficiently new version, this error\n");
b040e242 918 printf("*** probably means that the wrong copy of the gtk-config shell script is\n");
ecc7ceee 919 printf("*** being found. The easiest way to fix this is to remove the old version\n");
b040e242
VS
920 printf("*** of GTK+, but you can also set the GTK_CONFIG environment to point to the\n");
921 printf("*** correct copy of gtk-config. (In this case, you will have to\n");
ecc7ceee
OK
922 printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
923 printf("*** so that the correct libraries are found at run-time))\n");
924 }
925 }
926 return 1;
927}
928],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
929 CFLAGS="$ac_save_CFLAGS"
930 LIBS="$ac_save_LIBS"
931 fi
932 fi
933 if test "x$no_gtk" = x ; then
b040e242
VS
934 AC_MSG_RESULT(yes)
935 ifelse([$2], , :, [$2])
ecc7ceee
OK
936 else
937 AC_MSG_RESULT(no)
b040e242
VS
938 if test "$GTK_CONFIG" = "no" ; then
939 echo "*** The gtk-config script installed by GTK could not be found"
ecc7ceee 940 echo "*** If GTK was installed in PREFIX, make sure PREFIX/bin is in"
b040e242
VS
941 echo "*** your path, or set the GTK_CONFIG environment variable to the"
942 echo "*** full path to gtk-config."
ecc7ceee
OK
943 else
944 if test -f conf.gtktest ; then
945 :
946 else
947 echo "*** Could not run GTK test program, checking why..."
948 CFLAGS="$CFLAGS $GTK_CFLAGS"
949 LIBS="$LIBS $GTK_LIBS"
950 AC_TRY_LINK([
951#include <gtk/gtk.h>
952#include <stdio.h>
953], [ return ((gtk_major_version) || (gtk_minor_version) || (gtk_micro_version)); ],
954 [ echo "*** The test program compiled, but did not run. This usually means"
955 echo "*** that the run-time linker is not finding GTK or finding the wrong"
956 echo "*** version of GTK. If it is not finding GTK, you'll need to set your"
957 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
958 echo "*** to the installed location Also, make sure you have run ldconfig if that"
959 echo "*** is required on your system"
b040e242 960 echo "***"
ecc7ceee
OK
961 echo "*** If you have an old version installed, it is best to remove it, although"
962 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"
963 echo "***"
964 echo "*** If you have a RedHat 5.0 system, you should remove the GTK package that"
965 echo "*** came with the system with the command"
966 echo "***"
967 echo "*** rpm --erase --nodeps gtk gtk-devel" ],
968 [ echo "*** The test program failed to compile or link. See the file config.log for the"
969 echo "*** exact error that occured. This usually means GTK was incorrectly installed"
970 echo "*** or that you have moved GTK since it was installed. In the latter case, you"
b040e242 971 echo "*** may want to edit the gtk-config script: $GTK_CONFIG" ])
ecc7ceee
OK
972 CFLAGS="$ac_save_CFLAGS"
973 LIBS="$ac_save_LIBS"
974 fi
975 fi
976 GTK_CFLAGS=""
977 GTK_LIBS=""
978 ifelse([$3], , :, [$3])
979 fi
980 AC_SUBST(GTK_CFLAGS)
981 AC_SUBST(GTK_LIBS)
982 rm -f conf.gtktest
983])
8168de4c 984