1 dnl ---------------------------------------------------------------------------
3 dnl Macros for configure.in for wxWindows by Robert Roebling, Phil Blecker,
4 dnl Vadim Zeitlin and Ron Lee
6 dnl This script is under the wxWindows licence.
9 dnl ---------------------------------------------------------------------------
11 dnl ===========================================================================
12 dnl macros to find the a file in the list of include/lib paths
13 dnl ===========================================================================
15 dnl ---------------------------------------------------------------------------
16 dnl call WX_PATH_FIND_INCLUDES(search path, header name), sets ac_find_includes
17 dnl to the full name of the file that was found or leaves it empty if not found
18 dnl ---------------------------------------------------------------------------
19 AC_DEFUN([WX_PATH_FIND_INCLUDES],
24 if test -f "$ac_dir/$2"; then
25 ac_find_includes=$ac_dir
31 dnl ---------------------------------------------------------------------------
32 dnl call WX_PATH_FIND_LIBRARIES(search path, header name), sets ac_find_libraries
33 dnl to the full name of the file that was found or leaves it empty if not found
34 dnl ---------------------------------------------------------------------------
35 AC_DEFUN([WX_PATH_FIND_LIBRARIES],
40 for ac_extension in a so sl dylib; do
41 if test -f "$ac_dir/lib$2.$ac_extension"; then
42 ac_find_libraries=$ac_dir
49 dnl ---------------------------------------------------------------------------
50 dnl Path to include, already defined
51 dnl ---------------------------------------------------------------------------
52 AC_DEFUN([WX_INCLUDE_PATH_EXIST],
55 echo "$2" | grep "\-I$1" > /dev/null
57 if test $result = 0; then
60 ac_path_to_include=" -I$1"
64 dnl ---------------------------------------------------------------------------
65 dnl Path to link, already defined
66 dnl ---------------------------------------------------------------------------
67 AC_DEFUN([WX_LINK_PATH_EXIST],
69 echo "$2" | grep "\-L$1" > /dev/null
71 if test $result = 0; then
74 ac_path_to_link=" -L$1"
78 dnl ===========================================================================
80 dnl ===========================================================================
82 dnl ---------------------------------------------------------------------------
83 dnl WX_CPP_NEW_HEADERS checks whether the compiler has "new" <iostream> header
84 dnl or only the old <iostream.h> one - it may be generally assumed that if
85 dnl <iostream> exists, the other "new" headers (without .h) exist too.
87 dnl call WX_CPP_NEW_HEADERS(actiof-if-true, action-if-false-or-cross-compiling)
88 dnl ---------------------------------------------------------------------------
90 AC_DEFUN([WX_CPP_NEW_HEADERS],
92 if test "$cross_compiling" = "yes"; then
93 ifelse([$2], , :, [$2])
98 AC_CHECK_HEADERS(iostream)
100 if test "$ac_cv_header_iostream" = "yes" ; then
101 ifelse([$1], , :, [$1])
103 ifelse([$2], , :, [$2])
110 dnl ---------------------------------------------------------------------------
111 dnl WX_CPP_BOOL checks whether the C++ compiler has a built in bool type
113 dnl call WX_CPP_BOOL - will define HAVE_BOOL if the compiler supports bool
114 dnl ---------------------------------------------------------------------------
116 AC_DEFUN([WX_CPP_BOOL],
118 AC_CACHE_CHECK([if C++ compiler supports bool], wx_cv_cpp_bool,
142 if test "$wx_cv_cpp_bool" = "yes"; then
147 dnl ---------------------------------------------------------------------------
148 dnl a slightly better AC_C_BIGENDIAN macro which allows cross-compiling
149 dnl ---------------------------------------------------------------------------
151 AC_DEFUN([WX_C_BIGENDIAN],
152 [AC_CACHE_CHECK([whether byte ordering is bigendian], ac_cv_c_bigendian,
153 [ac_cv_c_bigendian=unknown
154 # See if sys/param.h defines the BYTE_ORDER macro.
155 AC_TRY_COMPILE([#include <sys/types.h>
156 #include <sys/param.h>], [
157 #if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
159 #endif], [# It does; now see whether it defined to BIG_ENDIAN or not.
160 AC_TRY_COMPILE([#include <sys/types.h>
161 #include <sys/param.h>], [
162 #if BYTE_ORDER != BIG_ENDIAN
164 #endif], ac_cv_c_bigendian=yes, ac_cv_c_bigendian=no)])
165 if test $ac_cv_c_bigendian = unknown; then
166 AC_TRY_RUN([main () {
167 /* Are we little or big endian? From Harbison&Steele. */
171 char c[sizeof (long)];
174 exit (u.c[sizeof (long) - 1] == 1);
175 }], [ac_cv_c_bigendian=no], [ac_cv_c_bigendian=yes], [ac_cv_c_bigendian=unknown])
177 if test $ac_cv_c_bigendian = unknown; then
178 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])
180 if test $ac_cv_c_bigendian = yes; then
181 AC_DEFINE(WORDS_BIGENDIAN)
185 dnl ---------------------------------------------------------------------------
186 dnl override AC_ARG_ENABLE/WITH to cache the results in .cache file
187 dnl ---------------------------------------------------------------------------
189 AC_DEFUN([WX_ARG_CACHE_INIT],
191 wx_arg_cache_file="configarg.cache"
192 echo "loading argument cache $wx_arg_cache_file"
193 rm -f ${wx_arg_cache_file}.tmp
194 touch ${wx_arg_cache_file}.tmp
195 touch ${wx_arg_cache_file}
198 AC_DEFUN([WX_ARG_CACHE_FLUSH],
200 echo "saving argument cache $wx_arg_cache_file"
201 mv ${wx_arg_cache_file}.tmp ${wx_arg_cache_file}
204 dnl this macro checks for a three-valued command line --with argument:
205 dnl possible arguments are 'yes', 'no', 'sys', or 'builtin'
206 dnl usage: WX_ARG_SYS_WITH(option, helpmessage, variable-name)
207 AC_DEFUN([WX_ARG_SYS_WITH],
209 AC_MSG_CHECKING([for --with-$1])
211 AC_ARG_WITH($1, [$2],
213 if test "$withval" = yes; then
214 ac_cv_use_$1='$3=yes'
215 elif test "$withval" = no; then
217 elif test "$withval" = sys; then
218 ac_cv_use_$1='$3=sys'
219 elif test "$withval" = builtin; then
220 ac_cv_use_$1='$3=builtin'
222 AC_MSG_ERROR([Invalid value for --with-$1: should be yes, no, sys, or builtin])
226 LINE=`grep "$3" ${wx_arg_cache_file}`
227 if test "x$LINE" != x ; then
233 ac_cv_use_$1='$3='$DEFAULT_$3
237 if test "$no_cache" != 1; then
238 echo $ac_cv_use_$1 >> ${wx_arg_cache_file}.tmp
241 if test "$$3" = yes; then
243 elif test "$$3" = no; then
245 elif test "$$3" = sys; then
246 AC_MSG_RESULT([system version])
247 elif test "$$3" = builtin; then
248 AC_MSG_RESULT([builtin version])
250 AC_MSG_ERROR([Invalid value for --with-$1: should be yes, no, sys, or builtin])
254 dnl this macro checks for a command line argument and caches the result
255 dnl usage: WX_ARG_WITH(option, helpmessage, variable-name)
256 AC_DEFUN([WX_ARG_WITH],
258 AC_MSG_CHECKING([for --with-$1])
260 AC_ARG_WITH($1, [$2],
262 if test "$withval" = yes; then
263 ac_cv_use_$1='$3=yes'
269 LINE=`grep "$3" ${wx_arg_cache_file}`
270 if test "x$LINE" != x ; then
276 ac_cv_use_$1='$3='$DEFAULT_$3
280 if test "$no_cache" != 1; then
281 echo $ac_cv_use_$1 >> ${wx_arg_cache_file}.tmp
284 if test "$$3" = yes; then
291 dnl like WX_ARG_WITH but uses AC_ARG_ENABLE instead of AC_ARG_WITH
292 dnl usage: WX_ARG_ENABLE(option, helpmessage, variable-name)
293 AC_DEFUN([WX_ARG_ENABLE],
295 AC_MSG_CHECKING([for --enable-$1])
297 AC_ARG_ENABLE($1, [$2],
299 if test "$enableval" = yes; then
300 ac_cv_use_$1='$3=yes'
306 LINE=`grep "$3" ${wx_arg_cache_file}`
307 if test "x$LINE" != x ; then
313 ac_cv_use_$1='$3='$DEFAULT_$3
317 if test "$no_cache" != 1; then
318 echo $ac_cv_use_$1 >> ${wx_arg_cache_file}.tmp
321 if test "$$3" = yes; then
330 dnl ===========================================================================
331 dnl "3rd party" macros included here because they are not widely available
332 dnl ===========================================================================
335 dnl ---------------------------------------------------------------------------
336 dnl test for availability of iconv()
337 dnl ---------------------------------------------------------------------------
339 dnl From Bruno Haible.
343 dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
344 dnl those with the standalone portable GNU libiconv installed).
346 AC_ARG_WITH([libiconv-prefix],
347 [ --with-libiconv-prefix=DIR search for libiconv in DIR/include and DIR/lib], [
348 for dir in `echo "$withval" | tr : ' '`; do
349 if test -d $dir/include; then CPPFLAGS="$CPPFLAGS -I$dir/include"; fi
350 if test -d $dir/lib; then LDFLAGS="$LDFLAGS -L$dir/lib"; fi
354 AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
355 am_cv_func_iconv="no, consider installing GNU libiconv"
357 AC_TRY_LINK([#include <stdlib.h>
359 [iconv_t cd = iconv_open("","");
360 iconv(cd,NULL,NULL,NULL,NULL);
362 am_cv_func_iconv=yes)
363 if test "$am_cv_func_iconv" != yes; then
366 AC_TRY_LINK([#include <stdlib.h>
368 [iconv_t cd = iconv_open("","");
369 iconv(cd,NULL,NULL,NULL,NULL);
372 am_cv_func_iconv=yes)
376 if test "$am_cv_func_iconv" = yes; then
377 AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
378 AC_CACHE_CHECK([if iconv needs const], wx_cv_func_iconv_const,
386 #if defined(__STDC__) || defined(__cplusplus)
387 size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
393 wx_cv_func_iconv_const="no",
394 wx_cv_func_iconv_const="yes"
399 if test "x$wx_cv_func_iconv_const" = "xyes"; then
403 AC_DEFINE_UNQUOTED(ICONV_CONST, $iconv_const,
404 [Define as const if the declaration of iconv() needs const.])
407 if test "$am_cv_lib_iconv" = yes; then
414 dnl ---------------------------------------------------------------------------
415 dnl test for GTK+ 2.0
416 dnl ---------------------------------------------------------------------------
418 dnl AM_PATH_GTK_2_0([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]])
419 dnl Test for GTK, and define GTK_CFLAGS and GTK_LIBS
421 AC_DEFUN(AM_PATH_GTK_2_0,
423 dnl Get the cflags and libraries from the gtk-config-2.0 script
425 AC_ARG_WITH(gtk-prefix,[ --with-gtk-prefix=PFX Prefix where GTK is installed (optional)],
426 gtk_config_prefix="$withval", gtk_config_prefix="")
427 AC_ARG_WITH(gtk-exec-prefix,[ --with-gtk-exec-prefix=PFX Exec prefix where GTK is installed (optional)],
428 gtk_config_exec_prefix="$withval", gtk_config_exec_prefix="")
429 AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
430 , enable_gtktest=yes)
436 gtk_config_args="$gtk_config_args gthread"
441 if test x$gtk_config_exec_prefix != x ; then
442 gtk_config_args="$gtk_config_args --exec-prefix=$gtk_config_exec_prefix"
443 if test x${GTK_CONFIG_2_0+set} != xset ; then
444 GTK_CONFIG_2_0=$gtk_config_exec_prefix/bin/gtk-config-2.0
447 if test x$gtk_config_prefix != x ; then
448 gtk_config_args="$gtk_config_args --prefix=$gtk_config_prefix"
449 if test x${GTK_CONFIG_2_0+set} != xset ; then
450 GTK_CONFIG_2_0=$gtk_config_prefix/bin/gtk-config-2.0
454 AC_PATH_PROG(GTK_CONFIG_2_0, gtk-config-2.0, no)
455 min_gtk_version=ifelse([$1], ,1.3.1,$1)
456 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
458 if test "$GTK_CONFIG_2_0" = "no" ; then
461 GTK_CFLAGS=`$GTK_CONFIG_2_0 $gtk_config_args --cflags`
462 GTK_LIBS=`$GTK_CONFIG_2_0 $gtk_config_args --libs`
463 gtk_config_major_version=`$GTK_CONFIG_2_0 $gtk_config_args --version | \
464 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
465 gtk_config_minor_version=`$GTK_CONFIG_2_0 $gtk_config_args --version | \
466 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
467 gtk_config_micro_version=`$GTK_CONFIG_2_0 $gtk_config_args --version | \
468 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
469 if test "x$enable_gtktest" = "xyes" ; then
470 ac_save_CFLAGS="$CFLAGS"
472 CFLAGS="$CFLAGS $GTK_CFLAGS"
473 LIBS="$GTK_LIBS $LIBS"
475 dnl Now check if the installed GTK is sufficiently new. (Also sanity
476 dnl checks the results of gtk-config-2.0 to some extent
487 int major, minor, micro;
490 system ("touch conf.gtktest");
492 /* HP/UX 9 (%@#!) writes to sscanf strings */
493 tmp_version = g_strdup("$min_gtk_version");
494 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) {
495 printf("%s, bad version string\n", "$min_gtk_version");
499 if ((gtk_major_version != $gtk_config_major_version) ||
500 (gtk_minor_version != $gtk_config_minor_version) ||
501 (gtk_micro_version != $gtk_config_micro_version))
503 printf("\n*** 'gtk-config-2.0 --version' returned %d.%d.%d, but GTK+ (%d.%d.%d)\n",
504 $gtk_config_major_version, $gtk_config_minor_version, $gtk_config_micro_version,
505 gtk_major_version, gtk_minor_version, gtk_micro_version);
506 printf ("*** was found! If gtk-config-2.0 was correct, then it is best\n");
507 printf ("*** to remove the old version of GTK+. You may also be able to fix the error\n");
508 printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
509 printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
510 printf("*** required on your system.\n");
511 printf("*** If gtk-config-2.0 was wrong, set the environment variable GTK_CONFIG_2_0\n");
512 printf("*** to point to the correct copy of gtk-config-2.0, and remove the file config.cache\n");
513 printf("*** before re-running configure\n");
515 #if defined (GTK_MAJOR_VERSION) && defined (GTK_MINOR_VERSION) && defined (GTK_MICRO_VERSION)
516 else if ((gtk_major_version != GTK_MAJOR_VERSION) ||
517 (gtk_minor_version != GTK_MINOR_VERSION) ||
518 (gtk_micro_version != GTK_MICRO_VERSION))
520 printf("*** GTK+ header files (version %d.%d.%d) do not match\n",
521 GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION);
522 printf("*** library (version %d.%d.%d)\n",
523 gtk_major_version, gtk_minor_version, gtk_micro_version);
525 #endif /* defined (GTK_MAJOR_VERSION) ... */
528 if ((gtk_major_version > major) ||
529 ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
530 ((gtk_major_version == major) && (gtk_minor_version == minor) && (gtk_micro_version >= micro)))
536 printf("\n*** An old version of GTK+ (%d.%d.%d) was found.\n",
537 gtk_major_version, gtk_minor_version, gtk_micro_version);
538 printf("*** You need a version of GTK+ newer than %d.%d.%d. The latest version of\n",
539 major, minor, micro);
540 printf("*** GTK+ is always available from ftp://ftp.gtk.org.\n");
542 printf("*** If you have already installed a sufficiently new version, this error\n");
543 printf("*** probably means that the wrong copy of the gtk-config-2.0 shell script is\n");
544 printf("*** being found. The easiest way to fix this is to remove the old version\n");
545 printf("*** of GTK+, but you can also set the GTK_CONFIG_2_0 environment to point to the\n");
546 printf("*** correct copy of gtk-config-2.0. (In this case, you will have to\n");
547 printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
548 printf("*** so that the correct libraries are found at run-time))\n");
553 ],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
554 CFLAGS="$ac_save_CFLAGS"
558 if test "x$no_gtk" = x ; then
559 AC_MSG_RESULT(yes (version $gtk_config_major_version.$gtk_config_minor_version.$gtk_config_micro_version))
560 ifelse([$2], , :, [$2])
563 if test "$GTK_CONFIG_2_0" = "no" ; then
564 echo "*** The gtk-config-2.0 script installed by GTK could not be found"
565 echo "*** If GTK was installed in PREFIX, make sure PREFIX/bin is in"
566 echo "*** your path, or set the GTK_CONFIG_2_0 environment variable to the"
567 echo "*** full path to gtk-config-2.0."
569 if test -f conf.gtktest ; then
572 echo "*** Could not run GTK test program, checking why..."
573 CFLAGS="$CFLAGS $GTK_CFLAGS"
574 LIBS="$LIBS $GTK_LIBS"
578 ], [ return ((gtk_major_version) || (gtk_minor_version) || (gtk_micro_version)); ],
579 [ echo "*** The test program compiled, but did not run. This usually means"
580 echo "*** that the run-time linker is not finding GTK or finding the wrong"
581 echo "*** version of GTK. If it is not finding GTK, you'll need to set your"
582 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
583 echo "*** to the installed location Also, make sure you have run ldconfig if that"
584 echo "*** is required on your system"
586 echo "*** If you have an old version installed, it is best to remove it, although"
587 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"
589 echo "*** If you have a RedHat 5.0 system, you should remove the GTK package that"
590 echo "*** came with the system with the command"
592 echo "*** rpm --erase --nodeps gtk gtk-devel" ],
593 [ echo "*** The test program failed to compile or link. See the file config.log for the"
594 echo "*** exact error that occured. This usually means GTK was incorrectly installed"
595 echo "*** or that you have moved GTK since it was installed. In the latter case, you"
596 echo "*** may want to edit the gtk-config-2.0 script: $GTK_CONFIG_2_0" ])
597 CFLAGS="$ac_save_CFLAGS"
603 ifelse([$3], , :, [$3])