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)
340 AC_DEFUN([WX_ARG_ENABLE],
342 AC_MSG_CHECKING([for --enable-$1])
344 AC_ARG_ENABLE($1, [$2],
346 if test "$enableval" = yes; then
347 ac_cv_use_$1='$3=yes'
353 LINE=`grep "$3" ${wx_arg_cache_file}`
354 if test "x$LINE" != x ; then
360 ac_cv_use_$1='$3='$DEFAULT_$3
364 if test "$no_cache" != 1; then
365 echo $ac_cv_use_$1 >> ${wx_arg_cache_file}.tmp
368 if test "$$3" = yes; then
377 dnl ===========================================================================
378 dnl "3rd party" macros included here because they are not widely available
379 dnl ===========================================================================
381 dnl ---------------------------------------------------------------------------
382 dnl test for availability of iconv()
383 dnl ---------------------------------------------------------------------------
385 dnl From Bruno Haible.
389 dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
390 dnl those with the standalone portable GNU libiconv installed).
392 AC_ARG_WITH([libiconv-prefix],
393 [ --with-libiconv-prefix=DIR search for libiconv in DIR/include and DIR/lib], [
394 for dir in `echo "$withval" | tr : ' '`; do
395 if test -d $dir/include; then CPPFLAGS="$CPPFLAGS -I$dir/include"; fi
396 if test -d $dir/lib; then LDFLAGS="$LDFLAGS -L$dir/lib"; fi
400 AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
401 am_cv_func_iconv="no, consider installing GNU libiconv"
403 AC_TRY_LINK([#include <stdlib.h>
405 [iconv_t cd = iconv_open("","");
406 iconv(cd,NULL,NULL,NULL,NULL);
408 am_cv_func_iconv=yes)
409 if test "$am_cv_func_iconv" != yes; then
412 AC_TRY_LINK([#include <stdlib.h>
414 [iconv_t cd = iconv_open("","");
415 iconv(cd,NULL,NULL,NULL,NULL);
418 am_cv_func_iconv=yes)
422 if test "$am_cv_func_iconv" = yes; then
423 AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
424 AC_CACHE_CHECK([if iconv needs const], wx_cv_func_iconv_const,
432 #if defined(__STDC__) || defined(__cplusplus)
433 size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
439 wx_cv_func_iconv_const="no",
440 wx_cv_func_iconv_const="yes"
445 if test "x$wx_cv_func_iconv_const" = "xyes"; then
449 AC_DEFINE_UNQUOTED(ICONV_CONST, $iconv_const,
450 [Define as const if the declaration of iconv() needs const.])
453 if test "$am_cv_lib_iconv" = yes; then
459 dnl ---------------------------------------------------------------------------
460 dnl AC_SYS_LARGEFILE (partly based on the code from autoconf 2.5x)
461 dnl ---------------------------------------------------------------------------
463 dnl WX_SYS_LARGEFILE_TEST
465 dnl NB: original autoconf test was checking if compiler supported 6 bit off_t
466 dnl arithmetic properly but this failed miserably with gcc under Linux
467 dnl whereas the system still supports 64 bit files, so now simply check
468 dnl that off_t is big enough
469 define(WX_SYS_LARGEFILE_TEST,
471 unsigned int field: sizeof(off_t) == 8;
476 dnl WX_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE, CACHE-VAR)
477 define(WX_SYS_LARGEFILE_MACRO_VALUE,
479 AC_CACHE_CHECK([for $1 value needed for large files], [$3],
481 AC_TRY_COMPILE([#define $1 $2
482 #include <sys/types.h>],
483 WX_SYS_LARGEFILE_TEST,
489 if test "$$3" != no; then
491 AC_DEFINE_UNQUOTED([$1], [$$3])
498 dnl By default, many hosts won't let programs access large files;
499 dnl one must use special compiler options to get large-file access to work.
500 dnl For more details about this brain damage please see:
501 dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
502 AC_DEFUN([AC_SYS_LARGEFILE],
503 [AC_ARG_ENABLE(largefile,
504 [ --disable-largefile omit support for large files])
505 if test "$enable_largefile" != no; then
506 dnl _FILE_OFFSET_BITS==64 is needed for Linux, Solaris, ...
507 dnl _LARGE_FILES -- for AIX
509 WX_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS, 64, ac_cv_sys_file_offset_bits)
510 if test "x$wx_largefile" != "xyes"; then
511 WX_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES, 1, ac_cv_sys_large_files)
514 AC_MSG_CHECKING(if large file support is available)
515 if test "x$wx_largefile" = "xyes"; then
516 AC_DEFINE(HAVE_LARGEFILE_SUPPORT)
518 AC_MSG_RESULT($wx_largefile)