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 WX_CPP_EXPLICIT checks whether the C++ compiler support the explicit
149 dnl keyword and defines HAVE_EXPLICIT if this is the case
150 dnl ---------------------------------------------------------------------------
152 AC_DEFUN([WX_CPP_EXPLICIT],
154 AC_CACHE_CHECK([if C++ compiler supports the explicit keyword],
160 dnl do the test in 2 steps: first check that the compiler knows about the
161 dnl explicit keyword at all and then verify that it really honours it
164 class Foo { public: explicit Foo(int) {} };
172 class Foo { public: explicit Foo(int) {} };
173 static void TakeFoo(const Foo& foo) { }
189 if test "$wx_cv_explicit" = "yes"; then
190 AC_DEFINE(HAVE_EXPLICIT)
194 dnl ---------------------------------------------------------------------------
195 dnl a slightly better AC_C_BIGENDIAN macro which allows cross-compiling
196 dnl ---------------------------------------------------------------------------
198 AC_DEFUN([WX_C_BIGENDIAN],
199 [AC_CACHE_CHECK([whether byte ordering is bigendian], ac_cv_c_bigendian,
200 [ac_cv_c_bigendian=unknown
201 # See if sys/param.h defines the BYTE_ORDER macro.
202 AC_TRY_COMPILE([#include <sys/types.h>
203 #include <sys/param.h>], [
204 #if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
206 #endif], [# It does; now see whether it defined to BIG_ENDIAN or not.
207 AC_TRY_COMPILE([#include <sys/types.h>
208 #include <sys/param.h>], [
209 #if BYTE_ORDER != BIG_ENDIAN
211 #endif], ac_cv_c_bigendian=yes, ac_cv_c_bigendian=no)])
212 if test $ac_cv_c_bigendian = unknown; then
213 AC_TRY_RUN([main () {
214 /* Are we little or big endian? From Harbison&Steele. */
218 char c[sizeof (long)];
221 exit (u.c[sizeof (long) - 1] == 1);
222 }], [ac_cv_c_bigendian=no], [ac_cv_c_bigendian=yes], [ac_cv_c_bigendian=unknown])
224 if test $ac_cv_c_bigendian = unknown; then
225 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])
227 if test $ac_cv_c_bigendian = yes; then
228 AC_DEFINE(WORDS_BIGENDIAN)
232 dnl ---------------------------------------------------------------------------
233 dnl override AC_ARG_ENABLE/WITH to cache the results in .cache file
234 dnl ---------------------------------------------------------------------------
236 AC_DEFUN([WX_ARG_CACHE_INIT],
238 wx_arg_cache_file="configarg.cache"
239 echo "loading argument cache $wx_arg_cache_file"
240 rm -f ${wx_arg_cache_file}.tmp
241 touch ${wx_arg_cache_file}.tmp
242 touch ${wx_arg_cache_file}
245 AC_DEFUN([WX_ARG_CACHE_FLUSH],
247 echo "saving argument cache $wx_arg_cache_file"
248 mv ${wx_arg_cache_file}.tmp ${wx_arg_cache_file}
251 dnl this macro checks for a three-valued command line --with argument:
252 dnl possible arguments are 'yes', 'no', 'sys', or 'builtin'
253 dnl usage: WX_ARG_SYS_WITH(option, helpmessage, variable-name)
254 AC_DEFUN([WX_ARG_SYS_WITH],
256 AC_MSG_CHECKING([for --with-$1])
258 AC_ARG_WITH($1, [$2],
260 if test "$withval" = yes; then
261 ac_cv_use_$1='$3=yes'
262 elif test "$withval" = no; then
264 elif test "$withval" = sys; then
265 ac_cv_use_$1='$3=sys'
266 elif test "$withval" = builtin; then
267 ac_cv_use_$1='$3=builtin'
269 AC_MSG_ERROR([Invalid value for --with-$1: should be yes, no, sys, or builtin])
273 LINE=`grep "$3" ${wx_arg_cache_file}`
274 if test "x$LINE" != x ; then
280 ac_cv_use_$1='$3='$DEFAULT_$3
284 if test "$no_cache" != 1; then
285 echo $ac_cv_use_$1 >> ${wx_arg_cache_file}.tmp
288 if test "$$3" = yes; then
290 elif test "$$3" = no; then
292 elif test "$$3" = sys; then
293 AC_MSG_RESULT([system version])
294 elif test "$$3" = builtin; then
295 AC_MSG_RESULT([builtin version])
297 AC_MSG_ERROR([Invalid value for --with-$1: should be yes, no, sys, or builtin])
301 dnl this macro checks for a command line argument and caches the result
302 dnl usage: WX_ARG_WITH(option, helpmessage, variable-name)
303 AC_DEFUN([WX_ARG_WITH],
305 AC_MSG_CHECKING([for --with-$1])
307 AC_ARG_WITH($1, [$2],
309 if test "$withval" = yes; then
310 ac_cv_use_$1='$3=yes'
316 LINE=`grep "$3" ${wx_arg_cache_file}`
317 if test "x$LINE" != x ; then
323 ac_cv_use_$1='$3='$DEFAULT_$3
327 if test "$no_cache" != 1; then
328 echo $ac_cv_use_$1 >> ${wx_arg_cache_file}.tmp
331 if test "$$3" = yes; then
338 dnl like WX_ARG_WITH but uses AC_ARG_ENABLE instead of AC_ARG_WITH
339 dnl usage: WX_ARG_ENABLE(option, helpmessage, variable-name, enablestring)
341 dnl enablestring is a hack and allows to show "checking for --disable-foo"
342 dnl message when running configure instead of the default "checking for
343 dnl --enable-foo" one whih is useful for the options enabled by default
344 AC_DEFUN([WX_ARG_ENABLE],
347 AC_MSG_CHECKING([for --${enablestring:-enable}-$1])
349 AC_ARG_ENABLE($1, [$2],
351 if test "$enableval" = yes; then
352 ac_cv_use_$1='$3=yes'
358 LINE=`grep "$3" ${wx_arg_cache_file}`
359 if test "x$LINE" != x ; then
365 ac_cv_use_$1='$3='$DEFAULT_$3
369 if test "$no_cache" != 1; then
370 echo $ac_cv_use_$1 >> ${wx_arg_cache_file}.tmp
373 if test "$$3" = yes; then
382 dnl ===========================================================================
383 dnl "3rd party" macros included here because they are not widely available
384 dnl ===========================================================================
386 dnl ---------------------------------------------------------------------------
387 dnl test for availability of iconv()
388 dnl ---------------------------------------------------------------------------
390 dnl From Bruno Haible.
394 dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
395 dnl those with the standalone portable GNU libiconv installed).
397 AC_ARG_WITH([libiconv-prefix],
398 [ --with-libiconv-prefix=DIR search for libiconv in DIR/include and DIR/lib], [
399 for dir in `echo "$withval" | tr : ' '`; do
400 if test -d $dir/include; then CPPFLAGS="$CPPFLAGS -I$dir/include"; fi
401 if test -d $dir/lib; then LDFLAGS="$LDFLAGS -L$dir/lib"; fi
405 AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
406 am_cv_func_iconv="no, consider installing GNU libiconv"
408 AC_TRY_LINK([#include <stdlib.h>
410 [iconv_t cd = iconv_open("","");
411 iconv(cd,NULL,NULL,NULL,NULL);
413 am_cv_func_iconv=yes)
414 if test "$am_cv_func_iconv" != yes; then
417 AC_TRY_LINK([#include <stdlib.h>
419 [iconv_t cd = iconv_open("","");
420 iconv(cd,NULL,NULL,NULL,NULL);
423 am_cv_func_iconv=yes)
427 if test "$am_cv_func_iconv" = yes; then
428 AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
429 AC_CACHE_CHECK([if iconv needs const], wx_cv_func_iconv_const,
437 #if defined(__STDC__) || defined(__cplusplus)
438 size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
444 wx_cv_func_iconv_const="no",
445 wx_cv_func_iconv_const="yes"
450 if test "x$wx_cv_func_iconv_const" = "xyes"; then
454 AC_DEFINE_UNQUOTED(ICONV_CONST, $iconv_const,
455 [Define as const if the declaration of iconv() needs const.])
458 if test "$am_cv_lib_iconv" = yes; then
464 dnl ---------------------------------------------------------------------------
465 dnl AC_SYS_LARGEFILE (partly based on the code from autoconf 2.5x)
466 dnl ---------------------------------------------------------------------------
468 dnl WX_SYS_LARGEFILE_TEST
470 dnl NB: original autoconf test was checking if compiler supported 6 bit off_t
471 dnl arithmetic properly but this failed miserably with gcc under Linux
472 dnl whereas the system still supports 64 bit files, so now simply check
473 dnl that off_t is big enough
474 define(WX_SYS_LARGEFILE_TEST,
476 unsigned int field: sizeof(off_t) == 8;
481 dnl WX_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE, CACHE-VAR)
482 define(WX_SYS_LARGEFILE_MACRO_VALUE,
484 AC_CACHE_CHECK([for $1 value needed for large files], [$3],
486 AC_TRY_COMPILE([#define $1 $2
487 #include <sys/types.h>],
488 WX_SYS_LARGEFILE_TEST,
494 if test "$$3" != no; then
496 AC_DEFINE_UNQUOTED([$1], [$$3])
503 dnl By default, many hosts won't let programs access large files;
504 dnl one must use special compiler options to get large-file access to work.
505 dnl For more details about this brain damage please see:
506 dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
507 AC_DEFUN([AC_SYS_LARGEFILE],
508 [AC_ARG_ENABLE(largefile,
509 [ --disable-largefile omit support for large files])
510 if test "$enable_largefile" != no; then
511 dnl _FILE_OFFSET_BITS==64 is needed for Linux, Solaris, ...
512 dnl _LARGE_FILES -- for AIX
514 WX_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS, 64, ac_cv_sys_file_offset_bits)
515 if test "x$wx_largefile" != "xyes"; then
516 WX_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES, 1, ac_cv_sys_large_files)
519 AC_MSG_CHECKING(if large file support is available)
520 if test "x$wx_largefile" = "xyes"; then
521 AC_DEFINE(HAVE_LARGEFILE_SUPPORT)
523 AC_MSG_RESULT($wx_largefile)