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 ---------------------------------------------------------------------------
12 dnl ===========================================================================
13 dnl Objective-C(++) related macros
14 dnl ===========================================================================
15 m4_define([AC_WX_LANG_OBJECTIVEC],
20 m4_define([AC_WX_LANG_OBJECTIVECPLUSPLUS],
25 dnl ===========================================================================
26 dnl macros to find the a file in the list of include/lib paths
27 dnl ===========================================================================
29 dnl ---------------------------------------------------------------------------
30 dnl call WX_PATH_FIND_INCLUDES(search path, header name), sets ac_find_includes
31 dnl to the full name of the file that was found or leaves it empty if not found
32 dnl ---------------------------------------------------------------------------
33 AC_DEFUN([WX_PATH_FIND_INCLUDES],
36 for ac_dir in $1 /usr/include;
38 if test -f "$ac_dir/$2"; then
39 ac_find_includes=$ac_dir
45 dnl ---------------------------------------------------------------------------
46 dnl call WX_PATH_FIND_LIBRARIES(search path, lib name), sets ac_find_libraries
47 dnl to the full name of the file that was found or leaves it empty if not found
48 dnl ---------------------------------------------------------------------------
49 AC_DEFUN([WX_PATH_FIND_LIBRARIES],
54 for ac_extension in a so sl dylib dll.a; do
55 if test -f "$ac_dir/lib$2.$ac_extension"; then
56 ac_find_libraries=$ac_dir
63 dnl ---------------------------------------------------------------------------
64 dnl return list of standard library paths
65 dnl ---------------------------------------------------------------------------
66 dnl return all default locations:
67 dnl - /usr/lib: standard
68 dnl - /usr/lib32: n32 ABI on IRIX
69 dnl - /usr/lib64: n64 ABI on IRIX
70 dnl - /usr/lib/64: 64 bit ABI on Solaris and Linux x86-64
72 dnl NB: if any of directories in the list is not a subdir of /usr, code setting
73 dnl wx_cv_std_libpath needs to be updated
74 AC_DEFUN([WX_STD_LIBPATH], [/usr/lib /usr/lib32 /usr/lib/64 /usr/lib64])
76 dnl ---------------------------------------------------------------------------
77 dnl Path to include, already defined
78 dnl ---------------------------------------------------------------------------
79 AC_DEFUN([WX_INCLUDE_PATH_EXIST],
81 dnl never add -I/usr/include to the CPPFLAGS
82 if test "x$1" = "x/usr/include"; then
85 echo "$2" | grep "\-I$1" > /dev/null
87 if test $result = 0; then
90 ac_path_to_include=" -I$1"
95 dnl ---------------------------------------------------------------------------
96 dnl Usage: WX_LINK_PATH_EXIST(path, libpath)
98 dnl Set ac_path_to_link to nothing if path is already in libpath of to -Lpath
99 dnl if it is not, so that libpath can be set to "$libpath$ac_path_to_link"
100 dnl after calling this function
101 dnl ---------------------------------------------------------------------------
102 AC_DEFUN([WX_LINK_PATH_EXIST],
104 dnl never add -L/usr/libXXX explicitely to libpath
105 if test "$1" = "default location"; then
108 echo "$2" | grep "\-L$1" > /dev/null
110 if test $result = 0; then
113 ac_path_to_link=" -L$1"
118 dnl ===========================================================================
119 dnl C++ features test
120 dnl ===========================================================================
122 dnl ---------------------------------------------------------------------------
123 dnl WX_CPP_NEW_HEADERS checks whether the compiler has "new" <iostream> header
124 dnl or only the old <iostream.h> one - it may be generally assumed that if
125 dnl <iostream> exists, the other "new" headers (without .h) exist too.
127 dnl call WX_CPP_NEW_HEADERS(actiof-if-true, action-if-false)
128 dnl ---------------------------------------------------------------------------
130 AC_DEFUN([WX_CPP_NEW_HEADERS],
135 AC_CHECK_HEADERS([iostream],,, [ ])
137 if test "$ac_cv_header_iostream" = "yes" ; then
138 ifelse([$1], , :, [$1])
140 ifelse([$2], , :, [$2])
146 dnl ---------------------------------------------------------------------------
147 dnl WX_CPP_BOOL checks whether the C++ compiler has a built in bool type
149 dnl call WX_CPP_BOOL - will define HAVE_BOOL if the compiler supports bool
150 dnl ---------------------------------------------------------------------------
152 AC_DEFUN([WX_CPP_BOOL],
154 AC_CACHE_CHECK([if C++ compiler supports bool], wx_cv_cpp_bool,
178 if test "$wx_cv_cpp_bool" = "yes"; then
183 dnl ---------------------------------------------------------------------------
184 dnl WX_CPP_EXPLICIT checks whether the C++ compiler support the explicit
185 dnl keyword and defines HAVE_EXPLICIT if this is the case
186 dnl ---------------------------------------------------------------------------
188 AC_DEFUN([WX_CPP_EXPLICIT],
190 AC_CACHE_CHECK([if C++ compiler supports the explicit keyword],
196 dnl do the test in 2 steps: first check that the compiler knows about the
197 dnl explicit keyword at all and then verify that it really honours it
200 class Foo { public: explicit Foo(int) {} };
208 class Foo { public: explicit Foo(int) {} };
209 static void TakeFoo(const Foo& foo) { }
225 if test "$wx_cv_explicit" = "yes"; then
226 AC_DEFINE(HAVE_EXPLICIT)
230 dnl ---------------------------------------------------------------------------
231 dnl WX_CHECK_FUNCS(FUNCTIONS...,
232 dnl [ACTION-IF-FOUND],
233 dnl [ACTION-IF-NOT-FOUND],
234 dnl [EXTRA-DEFINES-AND-INCLUDES],
235 dnl [EXTRA-TEST-CODE])
237 dnl Checks that the functions listed in FUNCTIONS exist in the headers and the
238 dnl libs. For each function, if it is found then defines 'HAVE_FUNCTION' and
239 dnl executes ACTION-IF-FOUND, otherwise executes ACTION-IF-NOT-FOUND.
241 dnl The code from EXTRA-DEFINES-AND-INCLUDES is inserted into the test before
242 dnl the default headers are included, and EXTRA-TEST-CODE is inserted into
243 dnl the main() function after the default test for existence.
246 dnl # the simple case
247 dnl WX_CHECK_FUNCS(stat)
248 dnl # use break to finish the loop early
249 dnl WX_CHECK_FUNCS(mkstemp mktemp, break)
251 dnl WX_CHECK_FUNCS(strtok_r, [], [], [#define _RREENTRANT])
253 dnl WX_CHECK_FUNCS(swprintf, [], [], [#include <wchar.h>])
254 dnl # checking the signature with extra test code
255 dnl WX_CHECK_FUNCS(gettimeofday, [], [], [#include <sys/time.h>]
256 dnl [struct timeval tv; struct timezone tz; gettimeofday(&tv, &tz)])
257 dnl ---------------------------------------------------------------------------
259 AC_DEFUN([WX_CHECK_FUNCS],
265 [wx_cv_func_$wx_func],
281 [eval wx_cv_func_$wx_func=yes],
282 [eval wx_cv_func_$wx_func=no])
285 if eval test \$wx_cv_func_$wx_func = yes
287 AC_DEFINE_UNQUOTED([HAVE_`echo $wx_func | tr 'a-z' 'A-Z'`])
296 dnl ---------------------------------------------------------------------------
297 dnl a slightly better AC_C_BIGENDIAN macro which allows cross-compiling
298 dnl ---------------------------------------------------------------------------
300 AC_DEFUN([WX_C_BIGENDIAN],
301 [AC_CACHE_CHECK([whether byte ordering is bigendian], ac_cv_c_bigendian,
302 [ac_cv_c_bigendian=unknown
303 # See if sys/param.h defines the BYTE_ORDER macro.
304 AC_TRY_COMPILE([#include <sys/types.h>
305 #include <sys/param.h>], [
306 #if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
308 #endif], [# It does; now see whether it defined to BIG_ENDIAN or not.
309 AC_TRY_COMPILE([#include <sys/types.h>
310 #include <sys/param.h>], [
311 #if BYTE_ORDER != BIG_ENDIAN
313 #endif], ac_cv_c_bigendian=yes, ac_cv_c_bigendian=no)])
314 if test $ac_cv_c_bigendian = unknown; then
315 AC_TRY_RUN([main () {
316 /* Are we little or big endian? From Harbison&Steele. */
320 char c[sizeof (long)];
323 exit (u.c[sizeof (long) - 1] == 1);
324 }], [ac_cv_c_bigendian=no], [ac_cv_c_bigendian=yes], [ac_cv_c_bigendian=unknown])
326 if test $ac_cv_c_bigendian = unknown; then
327 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])
329 if test $ac_cv_c_bigendian = yes; then
330 AC_DEFINE(WORDS_BIGENDIAN)
334 dnl ---------------------------------------------------------------------------
335 dnl override AC_ARG_ENABLE/WITH to cache the results in .cache file
336 dnl ---------------------------------------------------------------------------
338 AC_DEFUN([WX_ARG_CACHE_INIT],
340 wx_arg_cache_file="configarg.cache"
341 echo "loading argument cache $wx_arg_cache_file"
342 rm -f ${wx_arg_cache_file}.tmp
343 touch ${wx_arg_cache_file}.tmp
344 touch ${wx_arg_cache_file}
347 AC_DEFUN([WX_ARG_CACHE_FLUSH],
349 echo "saving argument cache $wx_arg_cache_file"
350 mv ${wx_arg_cache_file}.tmp ${wx_arg_cache_file}
353 dnl return the name of the variable to store the value of the given
354 dnl WX_ARG_WITH/ENABLE option
355 AC_DEFUN([WX_ARG_CACHE_NAME],)
357 dnl this macro checks for a three-valued command line --with argument:
358 dnl possible arguments are 'yes', 'no', 'sys', or 'builtin'
359 dnl usage: WX_ARG_SYS_WITH(option, helpmessage, variable-name)
361 dnl the default value (used if the option is not specified at all) is the value
362 dnl of wxUSE_ALL_FEATURES (which is "yes" by default but can be changed by
363 dnl giving configure --disable-all-features option)
364 AC_DEFUN([WX_ARG_SYS_WITH],
366 AC_MSG_CHECKING([for --with-$1])
367 AC_ARG_WITH($1, [$2],
369 if test "$withval" = yes; then
370 AS_TR_SH(wx_cv_use_$1)='$3=yes'
371 elif test "$withval" = no; then
372 AS_TR_SH(wx_cv_use_$1)='$3=no'
373 elif test "$withval" = sys; then
374 AS_TR_SH(wx_cv_use_$1)='$3=sys'
375 elif test "$withval" = builtin; then
376 AS_TR_SH(wx_cv_use_$1)='$3=builtin'
378 AC_MSG_ERROR([Invalid value for --with-$1: should be yes, no, sys, or builtin])
383 LINE=`grep "^$3=" ${wx_arg_cache_file}`
384 if test "x$LINE" != x ; then
388 AS_TR_SH(wx_cv_use_$1)='$3=${'DEFAULT_$3":-$wxUSE_ALL_FEATURES}"
391 eval "$AS_TR_SH(wx_cv_use_$1)"
392 if test "x$cache" = xyes; then
393 echo "$3=$$3" >> ${wx_arg_cache_file}.tmp
396 if test "$$3" = yes; then
398 elif test "$$3" = no; then
400 elif test "$$3" = sys; then
401 AC_MSG_RESULT([system version])
402 elif test "$$3" = builtin; then
403 AC_MSG_RESULT([builtin version])
405 AC_MSG_ERROR([Invalid value for --with-$1: should be yes, no, sys, or builtin])
409 dnl this macro checks for a command line argument and caches the result
410 dnl usage: WX_ARG_WITH(option, helpmessage, variable-name, [withstring])
411 AC_DEFUN([WX_ARG_WITH],
414 defaultval=$wxUSE_ALL_FEATURES
415 if test -z "$defaultval"; then
416 if test x"$withstring" = xwithout; then
422 AC_MSG_CHECKING([for --${withstring:-with}-$1])
423 AC_ARG_WITH($1, [$2],
425 if test "$withval" = yes; then
426 AS_TR_SH(wx_cv_use_$1)='$3=yes'
428 AS_TR_SH(wx_cv_use_$1)='$3=no'
433 LINE=`grep "^$3=" ${wx_arg_cache_file}`
434 if test "x$LINE" != x ; then
438 AS_TR_SH(wx_cv_use_$1)='$3=${'DEFAULT_$3":-$defaultval}"
441 eval "$AS_TR_SH(wx_cv_use_$1)"
442 if test "x$cache" != xyes; then
443 echo "$3=$$3" >> ${wx_arg_cache_file}.tmp
446 if test x"$withstring" = xwithout; then
447 if test $$3 = yes; then
456 AC_MSG_RESULT($result)
459 dnl same as WX_ARG_WITH but makes it clear that the option is enabled by default
460 AC_DEFUN([WX_ARG_WITHOUT], [WX_ARG_WITH($1, [$2], $3, without)])
462 dnl like WX_ARG_WITH but uses AC_ARG_ENABLE instead of AC_ARG_WITH
463 dnl usage: WX_ARG_ENABLE(option, helpmessage, var, [enablestring], [default])
465 dnl enablestring can be omitted or a literal string "disable" and allows to
466 dnl show "checking for --disable-foo" message when running configure instead of
467 dnl the default "checking for --enable-foo" one whih is useful for the options
468 dnl enabled by default
470 dnl the "default" argument can be omitted or contain the default value to use
471 dnl for the option if it's unspecified
472 AC_DEFUN([WX_ARG_ENABLE],
476 if test -z "$defaultval"; then
477 if test x"$enablestring" = xdisable; then
484 AC_MSG_CHECKING([for --${enablestring:-enable}-$1])
485 AC_ARG_ENABLE($1, [$2],
487 if test "$enableval" = yes; then
488 AS_TR_SH(wx_cv_use_$1)='$3=yes'
490 AS_TR_SH(wx_cv_use_$1)='$3=no'
495 LINE=`grep "^$3=" ${wx_arg_cache_file}`
496 if test "x$LINE" != x ; then
500 AS_TR_SH(wx_cv_use_$1)='$3=${'DEFAULT_$3":-$defaultval}"
503 eval "$AS_TR_SH(wx_cv_use_$1)"
504 if test "x$cache" = xyes; then
505 echo "$3=$$3" >> ${wx_arg_cache_file}.tmp
508 if test x"$enablestring" = xdisable; then
509 if test $$3 = yes; then
518 AC_MSG_RESULT($result)
521 dnl the same as WX_ARG_ENABLE but makes it more clear that the option is
522 dnl enabled by default
523 AC_DEFUN([WX_ARG_DISABLE], [WX_ARG_ENABLE($1, [$2], $3, disable)])
525 dnl same as WX_ARG_ENABLE but defaults to wxUSE_ALL_FEATURES instead of "yes"
526 AC_DEFUN([WX_ARG_FEATURE], [WX_ARG_ENABLE($1, [$2], $3,, $wxUSE_ALL_FEATURES)])
528 dnl Like WX_ARG_ENABLE but accepts a parameter.
531 dnl WX_ARG_ENABLE_PARAM(option, helpmessage, variable-name, enablestring)
534 dnl WX_ARG_ENABLE_PARAM(foo, [[ --enable-foo[=bar] use foo]], wxUSE_FOO)
536 dnl --enable-foo wxUSE_FOO=yes
537 dnl --disable-foo wxUSE_FOO=no
538 dnl --enable-foo=bar wxUSE_FOO=bar
539 dnl <not given> value from configarg.cache or
540 dnl wxUSE_FOO=$DEFAULT_wxUSE_FOO
542 AC_DEFUN([WX_ARG_ENABLE_PARAM],
545 AC_MSG_CHECKING([for --${enablestring:-enable}-$1])
546 AC_ARG_ENABLE($1, [$2],
548 wx_cv_use_$1="$3='$enableval'"
552 LINE=`grep "^$3=" ${wx_arg_cache_file}`
553 if test "x$LINE" != x ; then
557 wx_cv_use_$1='$3='$DEFAULT_$3
561 if test "x$cache" = xyes; then
562 echo "$3=$$3" >> ${wx_arg_cache_file}.tmp
568 dnl ===========================================================================
569 dnl Linker features test
570 dnl ===========================================================================
572 dnl ---------------------------------------------------------------------------
573 dnl WX_VERSIONED_SYMBOLS checks whether the linker can create versioned
574 dnl symbols. If it can, sets LDFLAGS_VERSIONING to $CXX flags needed to use
575 dnl version script file named versionfile
577 dnl call WX_VERSIONED_SYMBOLS(versionfile)
578 dnl ---------------------------------------------------------------------------
579 AC_DEFUN([WX_VERSIONED_SYMBOLS],
582 *-*-cygwin* | *-*-mingw* )
583 dnl although ld does support version script option on these
584 dnl platforms, it doesn't make much sense to use it under Win32
585 dnl and, moreover, this breaks linking because of a bug in handling
586 dnl paths in -Wl,--version-script,path option (if we ever do need
587 dnl to use it for cygwin/mingw32, keep in mind that replacing last
588 dnl comma with the equal sign works) so
589 dnl simply disable it
590 wx_cv_version_script=no
594 AC_CACHE_CHECK([if the linker accepts --version-script], wx_cv_version_script,
596 echo "VER_1 { *; };" >conftest.sym
597 echo "int main() { return 0; }" >conftest.cpp
600 $CXX -o conftest.output $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.cpp
601 -Wl,--version-script,conftest.sym >/dev/null 2>conftest.stderr]) ; then
602 if test -s conftest.stderr ; then
603 wx_cv_version_script=no
605 wx_cv_version_script=yes
608 wx_cv_version_script=no
611 dnl There's a problem in some old linkers with --version-script that
612 dnl can cause linking to fail when you have objects with vtables in
613 dnl libs 3 deep. This is known to happen in netbsd and openbsd with
616 dnl To test for this we need to make some shared libs and
617 dnl unfortunately we can't be sure of the right way to do that. If the
618 dnl first two compiles don't succeed then it looks like the test isn't
619 dnl working and the result is ignored, but if OTOH the first two
620 dnl succeed but the third does not then the bug has been detected and
621 dnl the --version-script flag is dropped.
622 if test $wx_cv_version_script = yes
624 echo "struct B { virtual ~B() { } }; \
625 struct D : public B { }; \
626 void F() { D d; }" > conftest.cpp
629 $CXX -shared -fPIC -o conftest1.output $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.cpp
630 -Wl,--version-script,conftest.sym >/dev/null 2>/dev/null]) &&
632 $CXX -shared -fPIC -o conftest2.output $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.cpp
633 -Wl,--version-script,conftest.sym conftest1.output >/dev/null 2>/dev/null])
636 $CXX -shared -fPIC -o conftest3.output $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.cpp
637 -Wl,--version-script,conftest.sym conftest2.output conftest1.output >/dev/null 2>/dev/null])
639 wx_cv_version_script=yes
641 wx_cv_version_script=no
646 rm -f conftest.output conftest.stderr conftest.sym conftest.cpp
647 rm -f conftest1.output conftest2.output conftest3.output
650 if test $wx_cv_version_script = yes ; then
651 LDFLAGS_VERSIONING="-Wl,--version-script,$1"
658 dnl ===========================================================================
659 dnl "3rd party" macros included here because they are not widely available
660 dnl ===========================================================================
662 dnl ---------------------------------------------------------------------------
663 dnl test for availability of iconv()
664 dnl ---------------------------------------------------------------------------
666 dnl From Bruno Haible.
670 dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
671 dnl those with the standalone portable GNU libiconv installed).
673 AC_ARG_WITH([libiconv-prefix],
674 [ --with-libiconv-prefix=DIR search for libiconv in DIR/include and DIR/lib], [
675 for dir in `echo "$withval" | tr : ' '`; do
676 if test -d $dir/include; then CPPFLAGS="$CPPFLAGS -I$dir/include"; fi
677 if test -d $dir/lib; then LDFLAGS="$LDFLAGS -L$dir/lib"; fi
681 AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
682 am_cv_func_iconv="no, consider installing GNU libiconv"
684 AC_TRY_LINK([#include <stdlib.h>
686 [iconv_t cd = iconv_open("","");
687 iconv(cd,NULL,NULL,NULL,NULL);
689 am_cv_func_iconv=yes)
690 if test "$am_cv_func_iconv" != yes; then
693 AC_TRY_LINK([#include <stdlib.h>
695 [iconv_t cd = iconv_open("","");
696 iconv(cd,NULL,NULL,NULL,NULL);
699 am_cv_func_iconv=yes)
703 if test "$am_cv_func_iconv" = yes; then
704 AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
705 AC_CACHE_CHECK([if iconv needs const], wx_cv_func_iconv_const,
713 #if defined(__STDC__) || defined(__cplusplus)
714 size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
720 wx_cv_func_iconv_const="no",
721 wx_cv_func_iconv_const="yes"
726 if test "x$wx_cv_func_iconv_const" = "xyes"; then
730 AC_DEFINE_UNQUOTED(ICONV_CONST, $iconv_const,
731 [Define as const if the declaration of iconv() needs const.])
734 if test "$am_cv_lib_iconv" = yes; then
740 dnl ---------------------------------------------------------------------------
741 dnl AC_SYS_LARGEFILE (partly based on the code from autoconf 2.5x)
742 dnl ---------------------------------------------------------------------------
744 dnl WX_SYS_LARGEFILE_TEST
746 dnl NB: original autoconf test was checking if compiler supported 6 bit off_t
747 dnl arithmetic properly but this failed miserably with gcc under Linux
748 dnl whereas the system still supports 64 bit files, so now simply check
749 dnl that off_t is big enough
750 define(WX_SYS_LARGEFILE_TEST,
752 unsigned int field: sizeof(off_t) == 8;
757 dnl WX_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE, CACHE-VAR)
758 define(WX_SYS_LARGEFILE_MACRO_VALUE,
760 AC_CACHE_CHECK([for $1 value needed for large files], [$3],
762 AC_TRY_COMPILE([#define $1 $2
763 #include <sys/types.h>],
764 WX_SYS_LARGEFILE_TEST,
770 if test "$$3" != no; then
772 AC_DEFINE_UNQUOTED([$1], [$$3])
779 dnl By default, many hosts won't let programs access large files;
780 dnl one must use special compiler options to get large-file access to work.
781 dnl For more details about this brain damage please see:
782 dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
783 AC_DEFUN([AC_SYS_LARGEFILE],
784 [AC_ARG_ENABLE(largefile,
785 [ --disable-largefile omit support for large files])
786 if test "$enable_largefile" != no; then
787 dnl _FILE_OFFSET_BITS==64 is needed for Linux, Solaris, ...
788 dnl _LARGE_FILES -- for AIX
790 WX_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS, 64, ac_cv_sys_file_offset_bits)
791 if test "x$wx_largefile" != "xyes"; then
792 WX_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES, 1, ac_cv_sys_large_files)
795 AC_MSG_CHECKING(if large file support is available)
796 if test "x$wx_largefile" = "xyes"; then
797 AC_DEFINE(HAVE_LARGEFILE_SUPPORT)
799 AC_MSG_RESULT($wx_largefile)
804 dnl Available from the GNU Autoconf Macro Archive at:
805 dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_const_cast.html
807 AC_DEFUN([AC_CXX_CONST_CAST],
808 [AC_CACHE_CHECK(whether the compiler supports const_cast<>,
809 ac_cv_cxx_const_cast,
812 AC_TRY_COMPILE(,[int x = 0;const int& y = x;int& z = const_cast<int&>(y);return z;],
813 ac_cv_cxx_const_cast=yes, ac_cv_cxx_const_cast=no)
816 if test "$ac_cv_cxx_const_cast" = yes; then
817 AC_DEFINE(HAVE_CONST_CAST,,[define if the compiler supports const_cast<>])
821 dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_reinterpret_cast.html
822 AC_DEFUN([AC_CXX_REINTERPRET_CAST],
823 [AC_CACHE_CHECK(whether the compiler supports reinterpret_cast<>,
824 ac_cv_cxx_reinterpret_cast,
827 AC_TRY_COMPILE([#include <typeinfo>
828 class Base { public : Base () {} virtual void f () = 0;};
829 class Derived : public Base { public : Derived () {} virtual void f () {} };
830 class Unrelated { public : Unrelated () {} };
831 int g (Unrelated&) { return 0; }],[
832 Derived d;Base& b=d;Unrelated& e=reinterpret_cast<Unrelated&>(b);return g(e);],
833 ac_cv_cxx_reinterpret_cast=yes, ac_cv_cxx_reinterpret_cast=no)
836 if test "$ac_cv_cxx_reinterpret_cast" = yes; then
837 AC_DEFINE(HAVE_REINTERPRET_CAST,,
838 [define if the compiler supports reinterpret_cast<>])
842 dnl and http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_static_cast.html
843 AC_DEFUN([AC_CXX_STATIC_CAST],
844 [AC_CACHE_CHECK(whether the compiler supports static_cast<>,
845 ac_cv_cxx_static_cast,
848 AC_TRY_COMPILE([#include <typeinfo>
849 class Base { public : Base () {} virtual void f () = 0; };
850 class Derived : public Base { public : Derived () {} virtual void f () {} };
851 int g (Derived&) { return 0; }],[
852 Derived d; Base& b = d; Derived& s = static_cast<Derived&> (b); return g (s);],
853 ac_cv_cxx_static_cast=yes, ac_cv_cxx_static_cast=no)
856 if test "$ac_cv_cxx_static_cast" = yes; then
857 AC_DEFINE(HAVE_STATIC_CAST,, [define if the compiler supports static_cast<>])
861 dnl http://autoconf-archive.cryp.to/ac_cxx_dynamic_cast.html
862 AC_DEFUN([AC_CXX_DYNAMIC_CAST],
863 [AC_CACHE_CHECK(whether the compiler supports dynamic_cast<>,
864 ac_cv_cxx_dynamic_cast,
867 AC_TRY_COMPILE([#include <typeinfo>
868 class Base { public : Base () {} virtual void f () = 0;};
869 class Derived : public Base { public : Derived () {} virtual void f () {} };],[
870 Derived d; Base& b=d; return dynamic_cast<Derived*>(&b) ? 0 : 1;],
871 ac_cv_cxx_dynamic_cast=yes, ac_cv_cxx_dynamic_cast=no)
874 if test "$ac_cv_cxx_dynamic_cast" = yes; then
875 AC_DEFINE(HAVE_DYNAMIC_CAST,,[define if the compiler supports dynamic_cast<>])