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],
22 for ac_dir in $1 /usr/include;
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],
38 for ac_dir in $1 /usr/lib;
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],
54 dnl never add -I/usr/include to the CPPFLAGS
55 if test "x$1" = "x/usr/include"; then
58 echo "$2" | grep "\-I$1" > /dev/null
60 if test $result = 0; then
63 ac_path_to_include=" -I$1"
68 dnl ---------------------------------------------------------------------------
69 dnl Path to link, already defined
70 dnl ---------------------------------------------------------------------------
71 AC_DEFUN([WX_LINK_PATH_EXIST],
73 echo "$2" | grep "\-L$1" > /dev/null
75 if test $result = 0; then
78 ac_path_to_link=" -L$1"
82 dnl ===========================================================================
84 dnl ===========================================================================
86 dnl ---------------------------------------------------------------------------
87 dnl WX_CPP_NEW_HEADERS checks whether the compiler has "new" <iostream> header
88 dnl or only the old <iostream.h> one - it may be generally assumed that if
89 dnl <iostream> exists, the other "new" headers (without .h) exist too.
91 dnl call WX_CPP_NEW_HEADERS(actiof-if-true, action-if-false-or-cross-compiling)
92 dnl ---------------------------------------------------------------------------
94 AC_DEFUN([WX_CPP_NEW_HEADERS],
96 if test "$cross_compiling" = "yes"; then
97 ifelse([$2], , :, [$2])
102 AC_CHECK_HEADERS(iostream)
104 if test "$ac_cv_header_iostream" = "yes" ; then
105 ifelse([$1], , :, [$1])
107 ifelse([$2], , :, [$2])
114 dnl ---------------------------------------------------------------------------
115 dnl WX_CPP_BOOL checks whether the C++ compiler has a built in bool type
117 dnl call WX_CPP_BOOL - will define HAVE_BOOL if the compiler supports bool
118 dnl ---------------------------------------------------------------------------
120 AC_DEFUN([WX_CPP_BOOL],
122 AC_CACHE_CHECK([if C++ compiler supports bool], wx_cv_cpp_bool,
146 if test "$wx_cv_cpp_bool" = "yes"; then
151 dnl ---------------------------------------------------------------------------
152 dnl WX_CPP_EXPLICIT checks whether the C++ compiler support the explicit
153 dnl keyword and defines HAVE_EXPLICIT if this is the case
154 dnl ---------------------------------------------------------------------------
156 AC_DEFUN([WX_CPP_EXPLICIT],
158 AC_CACHE_CHECK([if C++ compiler supports the explicit keyword],
164 dnl do the test in 2 steps: first check that the compiler knows about the
165 dnl explicit keyword at all and then verify that it really honours it
168 class Foo { public: explicit Foo(int) {} };
176 class Foo { public: explicit Foo(int) {} };
177 static void TakeFoo(const Foo& foo) { }
193 if test "$wx_cv_explicit" = "yes"; then
194 AC_DEFINE(HAVE_EXPLICIT)
198 dnl ---------------------------------------------------------------------------
199 dnl a slightly better AC_C_BIGENDIAN macro which allows cross-compiling
200 dnl ---------------------------------------------------------------------------
202 AC_DEFUN([WX_C_BIGENDIAN],
203 [AC_CACHE_CHECK([whether byte ordering is bigendian], ac_cv_c_bigendian,
204 [ac_cv_c_bigendian=unknown
205 # See if sys/param.h defines the BYTE_ORDER macro.
206 AC_TRY_COMPILE([#include <sys/types.h>
207 #include <sys/param.h>], [
208 #if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
210 #endif], [# It does; now see whether it defined to BIG_ENDIAN or not.
211 AC_TRY_COMPILE([#include <sys/types.h>
212 #include <sys/param.h>], [
213 #if BYTE_ORDER != BIG_ENDIAN
215 #endif], ac_cv_c_bigendian=yes, ac_cv_c_bigendian=no)])
216 if test $ac_cv_c_bigendian = unknown; then
217 AC_TRY_RUN([main () {
218 /* Are we little or big endian? From Harbison&Steele. */
222 char c[sizeof (long)];
225 exit (u.c[sizeof (long) - 1] == 1);
226 }], [ac_cv_c_bigendian=no], [ac_cv_c_bigendian=yes], [ac_cv_c_bigendian=unknown])
228 if test $ac_cv_c_bigendian = unknown; then
229 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])
231 if test $ac_cv_c_bigendian = yes; then
232 AC_DEFINE(WORDS_BIGENDIAN)
236 dnl ---------------------------------------------------------------------------
237 dnl override AC_ARG_ENABLE/WITH to cache the results in .cache file
238 dnl ---------------------------------------------------------------------------
240 AC_DEFUN([WX_ARG_CACHE_INIT],
242 wx_arg_cache_file="configarg.cache"
243 echo "loading argument cache $wx_arg_cache_file"
244 rm -f ${wx_arg_cache_file}.tmp
245 touch ${wx_arg_cache_file}.tmp
246 touch ${wx_arg_cache_file}
249 AC_DEFUN([WX_ARG_CACHE_FLUSH],
251 echo "saving argument cache $wx_arg_cache_file"
252 mv ${wx_arg_cache_file}.tmp ${wx_arg_cache_file}
255 dnl this macro checks for a three-valued command line --with argument:
256 dnl possible arguments are 'yes', 'no', 'sys', or 'builtin'
257 dnl usage: WX_ARG_SYS_WITH(option, helpmessage, variable-name)
258 AC_DEFUN([WX_ARG_SYS_WITH],
260 AC_MSG_CHECKING([for --with-$1])
262 AC_ARG_WITH($1, [$2],
264 if test "$withval" = yes; then
265 ac_cv_use_$1='$3=yes'
266 elif test "$withval" = no; then
268 elif test "$withval" = sys; then
269 ac_cv_use_$1='$3=sys'
270 elif test "$withval" = builtin; then
271 ac_cv_use_$1='$3=builtin'
273 AC_MSG_ERROR([Invalid value for --with-$1: should be yes, no, sys, or builtin])
277 LINE=`grep "$3" ${wx_arg_cache_file}`
278 if test "x$LINE" != x ; then
284 ac_cv_use_$1='$3='$DEFAULT_$3
288 if test "$no_cache" != 1; then
289 echo $ac_cv_use_$1 >> ${wx_arg_cache_file}.tmp
292 if test "$$3" = yes; then
294 elif test "$$3" = no; then
296 elif test "$$3" = sys; then
297 AC_MSG_RESULT([system version])
298 elif test "$$3" = builtin; then
299 AC_MSG_RESULT([builtin version])
301 AC_MSG_ERROR([Invalid value for --with-$1: should be yes, no, sys, or builtin])
305 dnl this macro checks for a command line argument and caches the result
306 dnl usage: WX_ARG_WITH(option, helpmessage, variable-name)
307 AC_DEFUN([WX_ARG_WITH],
309 AC_MSG_CHECKING([for --with-$1])
311 AC_ARG_WITH($1, [$2],
313 if test "$withval" = yes; then
314 ac_cv_use_$1='$3=yes'
320 LINE=`grep "$3" ${wx_arg_cache_file}`
321 if test "x$LINE" != x ; then
327 ac_cv_use_$1='$3='$DEFAULT_$3
331 if test "$no_cache" != 1; then
332 echo $ac_cv_use_$1 >> ${wx_arg_cache_file}.tmp
335 if test "$$3" = yes; then
342 dnl like WX_ARG_WITH but uses AC_ARG_ENABLE instead of AC_ARG_WITH
343 dnl usage: WX_ARG_ENABLE(option, helpmessage, variable-name, enablestring)
345 dnl enablestring is a hack and allows to show "checking for --disable-foo"
346 dnl message when running configure instead of the default "checking for
347 dnl --enable-foo" one whih is useful for the options enabled by default
348 AC_DEFUN([WX_ARG_ENABLE],
351 AC_MSG_CHECKING([for --${enablestring:-enable}-$1])
353 AC_ARG_ENABLE($1, [$2],
355 if test "$enableval" = yes; then
356 ac_cv_use_$1='$3=yes'
362 LINE=`grep "$3" ${wx_arg_cache_file}`
363 if test "x$LINE" != x ; then
369 ac_cv_use_$1='$3='$DEFAULT_$3
373 if test "$no_cache" != 1; then
374 echo $ac_cv_use_$1 >> ${wx_arg_cache_file}.tmp
377 if test "$$3" = yes; then
385 dnl ===========================================================================
386 dnl Linker features test
387 dnl ===========================================================================
389 dnl ---------------------------------------------------------------------------
390 dnl WX_VERSIONED_SYMBOLS checks whether the linker can create versioned
391 dnl symbols. If it can, sets LDFLAGS_VERSIONING to $CXX flags needed to use
392 dnl version script file named versionfile
394 dnl call WX_VERSIONED_SYMBOLS(versionfile)
395 dnl ---------------------------------------------------------------------------
396 AC_DEFUN([WX_VERSIONED_SYMBOLS],
400 dnl Check for known non-gcc cases:
403 if test "x$GCC" != "xyes" ; then
404 LDFLAGS_VERSIONING="-M $1"
410 dnl Generic check for GCC or GCC-like behaviour (Intel C++, GCC):
411 if test $found_versioning = no ; then
412 AC_CACHE_CHECK([if the linker accepts --version-script], wx_cv_version_script,
414 echo "VER_1 { *; };" >conftest.sym
415 echo "int main() { return 0; }" >conftest.cpp
418 $CXX -o conftest.output $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.cpp
419 -Wl,--version-script,conftest.sym >/dev/null 2>conftest.stderr]) ; then
420 if test -s conftest.stderr ; then
421 wx_cv_version_script=no
423 wx_cv_version_script=yes
426 wx_cv_version_script=no
428 rm -f conftest.output conftest.stderr conftest.sym conftest.cpp
430 if test $wx_cv_version_script = yes ; then
431 LDFLAGS_VERSIONING="-Wl,--version-script,$1"
437 dnl ===========================================================================
438 dnl "3rd party" macros included here because they are not widely available
439 dnl ===========================================================================
441 dnl ---------------------------------------------------------------------------
442 dnl test for availability of iconv()
443 dnl ---------------------------------------------------------------------------
445 dnl From Bruno Haible.
449 dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
450 dnl those with the standalone portable GNU libiconv installed).
452 AC_ARG_WITH([libiconv-prefix],
453 [ --with-libiconv-prefix=DIR search for libiconv in DIR/include and DIR/lib], [
454 for dir in `echo "$withval" | tr : ' '`; do
455 if test -d $dir/include; then CPPFLAGS="$CPPFLAGS -I$dir/include"; fi
456 if test -d $dir/lib; then LDFLAGS="$LDFLAGS -L$dir/lib"; fi
460 AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
461 am_cv_func_iconv="no, consider installing GNU libiconv"
463 AC_TRY_LINK([#include <stdlib.h>
465 [iconv_t cd = iconv_open("","");
466 iconv(cd,NULL,NULL,NULL,NULL);
468 am_cv_func_iconv=yes)
469 if test "$am_cv_func_iconv" != yes; then
472 AC_TRY_LINK([#include <stdlib.h>
474 [iconv_t cd = iconv_open("","");
475 iconv(cd,NULL,NULL,NULL,NULL);
478 am_cv_func_iconv=yes)
482 if test "$am_cv_func_iconv" = yes; then
483 AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
484 AC_CACHE_CHECK([if iconv needs const], wx_cv_func_iconv_const,
492 #if defined(__STDC__) || defined(__cplusplus)
493 size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
499 wx_cv_func_iconv_const="no",
500 wx_cv_func_iconv_const="yes"
505 if test "x$wx_cv_func_iconv_const" = "xyes"; then
509 AC_DEFINE_UNQUOTED(ICONV_CONST, $iconv_const,
510 [Define as const if the declaration of iconv() needs const.])
513 if test "$am_cv_lib_iconv" = yes; then
519 dnl ---------------------------------------------------------------------------
520 dnl AC_SYS_LARGEFILE (partly based on the code from autoconf 2.5x)
521 dnl ---------------------------------------------------------------------------
523 dnl WX_SYS_LARGEFILE_TEST
525 dnl NB: original autoconf test was checking if compiler supported 6 bit off_t
526 dnl arithmetic properly but this failed miserably with gcc under Linux
527 dnl whereas the system still supports 64 bit files, so now simply check
528 dnl that off_t is big enough
529 define(WX_SYS_LARGEFILE_TEST,
531 unsigned int field: sizeof(off_t) == 8;
536 dnl WX_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE, CACHE-VAR)
537 define(WX_SYS_LARGEFILE_MACRO_VALUE,
539 AC_CACHE_CHECK([for $1 value needed for large files], [$3],
541 AC_TRY_COMPILE([#define $1 $2
542 #include <sys/types.h>],
543 WX_SYS_LARGEFILE_TEST,
549 if test "$$3" != no; then
551 AC_DEFINE_UNQUOTED([$1], [$$3])
558 dnl By default, many hosts won't let programs access large files;
559 dnl one must use special compiler options to get large-file access to work.
560 dnl For more details about this brain damage please see:
561 dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
562 AC_DEFUN([AC_SYS_LARGEFILE],
563 [AC_ARG_ENABLE(largefile,
564 [ --disable-largefile omit support for large files])
565 if test "$enable_largefile" != no; then
566 dnl _FILE_OFFSET_BITS==64 is needed for Linux, Solaris, ...
567 dnl _LARGE_FILES -- for AIX
569 WX_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS, 64, ac_cv_sys_file_offset_bits)
570 if test "x$wx_largefile" != "xyes"; then
571 WX_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES, 1, ac_cv_sys_large_files)
574 AC_MSG_CHECKING(if large file support is available)
575 if test "x$wx_largefile" = "xyes"; then
576 AC_DEFINE(HAVE_LARGEFILE_SUPPORT)
578 AC_MSG_RESULT($wx_largefile)