]> git.saurik.com Git - wxWidgets.git/blob - acinclude.m4
18ea55aad3dd7772f1d542a35fbcd76fecc79fb2
[wxWidgets.git] / acinclude.m4
1 dnl ---------------------------------------------------------------------------
2 dnl
3 dnl Macros for configure.in for wxWindows by Robert Roebling, Phil Blecker,
4 dnl Vadim Zeitlin and Ron Lee
5 dnl
6 dnl This script is under the wxWindows licence.
7 dnl
8 dnl Version: $Id$
9 dnl ---------------------------------------------------------------------------
10
11 dnl ===========================================================================
12 dnl macros to detect specialty compiler options
13 dnl ===========================================================================
14
15 dnl Figure out if we need to pass -ext o to compiler (MetroWerks)
16 AC_DEFUN([AC_WX_METROWERKS_EXTO],
17 [AC_CACHE_CHECK([if the _AC_LANG compiler requires -ext o], wx_cv_[]_AC_LANG_ABBREV[]_exto,
18 dnl First create an empty conf test
19 [AC_LANG_CONFTEST([AC_LANG_PROGRAM()])
20 dnl Now remove .o and .c.o or .cc.o
21 rm -f conftest.$ac_objext conftest.$ac_ext.o
22 dnl Now compile the test
23 AS_IF([AC_TRY_EVAL(ac_compile)],
24 dnl If the test succeeded look for conftest.c.o or conftest.cc.o
25 [for ac_file in `(ls conftest.* 2>/dev/null)`; do
26 case $ac_file in
27 conftest.$ac_ext.o)
28 wx_cv_[]_AC_LANG_ABBREV[]_exto="-ext o"
29 ;;
30 *)
31 ;;
32 esac
33 done],
34 [AC_MSG_FAILURE([cannot figure out if compiler needs -ext o: cannot compile])
35 ]) dnl AS_IF
36
37 rm -f conftest.$ac_ext.o conftest.$ac_objext conftest.$ac_ext
38 ]) dnl AC_CACHE_CHECK
39
40 if test "x$wx_cv_[]_AC_LANG_ABBREV[]_exto" '!=' "x"; then
41 if test "[]_AC_LANG_ABBREV[]" = "c"; then
42 CFLAGS="$wx_cv_[]_AC_LANG_ABBREV[]_exto $CFLAGS"
43 fi
44 if test "[]_AC_LANG_ABBREV[]" = "cxx"; then
45 CXXFLAGS="$wx_cv_[]_AC_LANG_ABBREV[]_exto $CXXFLAGS"
46 fi
47 fi
48 ]) dnl AC_DEFUN
49
50
51 dnl ===========================================================================
52 dnl macros to find the a file in the list of include/lib paths
53 dnl ===========================================================================
54
55 dnl ---------------------------------------------------------------------------
56 dnl call WX_PATH_FIND_INCLUDES(search path, header name), sets ac_find_includes
57 dnl to the full name of the file that was found or leaves it empty if not found
58 dnl ---------------------------------------------------------------------------
59 AC_DEFUN([WX_PATH_FIND_INCLUDES],
60 [
61 ac_find_includes=
62 for ac_dir in $1 /usr/include;
63 do
64 if test -f "$ac_dir/$2"; then
65 ac_find_includes=$ac_dir
66 break
67 fi
68 done
69 ])
70
71 dnl ---------------------------------------------------------------------------
72 dnl call WX_PATH_FIND_LIBRARIES(search path, header name), sets ac_find_libraries
73 dnl to the full name of the file that was found or leaves it empty if not found
74 dnl ---------------------------------------------------------------------------
75 AC_DEFUN([WX_PATH_FIND_LIBRARIES],
76 [
77 ac_find_libraries=
78 for ac_dir in $1 /usr/lib;
79 do
80 for ac_extension in a so sl dylib; do
81 if test -f "$ac_dir/lib$2.$ac_extension"; then
82 ac_find_libraries=$ac_dir
83 break 2
84 fi
85 done
86 done
87 ])
88
89 dnl ---------------------------------------------------------------------------
90 dnl Path to include, already defined
91 dnl ---------------------------------------------------------------------------
92 AC_DEFUN([WX_INCLUDE_PATH_EXIST],
93 [
94 dnl never add -I/usr/include to the CPPFLAGS
95 if test "x$1" = "x/usr/include"; then
96 ac_path_to_include=""
97 else
98 echo "$2" | grep "\-I$1" > /dev/null
99 result=$?
100 if test $result = 0; then
101 ac_path_to_include=""
102 else
103 ac_path_to_include=" -I$1"
104 fi
105 fi
106 ])
107
108 dnl ---------------------------------------------------------------------------
109 dnl Path to link, already defined
110 dnl ---------------------------------------------------------------------------
111 AC_DEFUN([WX_LINK_PATH_EXIST],
112 [
113 echo "$2" | grep "\-L$1" > /dev/null
114 result=$?
115 if test $result = 0; then
116 ac_path_to_link=""
117 else
118 ac_path_to_link=" -L$1"
119 fi
120 ])
121
122 dnl ===========================================================================
123 dnl C++ features test
124 dnl ===========================================================================
125
126 dnl ---------------------------------------------------------------------------
127 dnl WX_CPP_NEW_HEADERS checks whether the compiler has "new" <iostream> header
128 dnl or only the old <iostream.h> one - it may be generally assumed that if
129 dnl <iostream> exists, the other "new" headers (without .h) exist too.
130 dnl
131 dnl call WX_CPP_NEW_HEADERS(actiof-if-true, action-if-false)
132 dnl ---------------------------------------------------------------------------
133
134 AC_DEFUN([WX_CPP_NEW_HEADERS],
135 [
136 AC_LANG_SAVE
137 AC_LANG_CPLUSPLUS
138
139 AC_CHECK_HEADERS(iostream)
140
141 if test "$ac_cv_header_iostream" = "yes" ; then
142 ifelse([$1], , :, [$1])
143 else
144 ifelse([$2], , :, [$2])
145 fi
146
147 AC_LANG_RESTORE
148 ])
149
150 dnl ---------------------------------------------------------------------------
151 dnl WX_CPP_BOOL checks whether the C++ compiler has a built in bool type
152 dnl
153 dnl call WX_CPP_BOOL - will define HAVE_BOOL if the compiler supports bool
154 dnl ---------------------------------------------------------------------------
155
156 AC_DEFUN([WX_CPP_BOOL],
157 [
158 AC_CACHE_CHECK([if C++ compiler supports bool], wx_cv_cpp_bool,
159 [
160 AC_LANG_SAVE
161 AC_LANG_CPLUSPLUS
162
163 AC_TRY_COMPILE(
164 [
165 ],
166 [
167 bool b = true;
168
169 return 0;
170 ],
171 [
172 wx_cv_cpp_bool=yes
173 ],
174 [
175 wx_cv_cpp_bool=no
176 ]
177 )
178
179 AC_LANG_RESTORE
180 ])
181
182 if test "$wx_cv_cpp_bool" = "yes"; then
183 AC_DEFINE(HAVE_BOOL)
184 fi
185 ])
186
187 dnl ---------------------------------------------------------------------------
188 dnl WX_CPP_EXPLICIT checks whether the C++ compiler support the explicit
189 dnl keyword and defines HAVE_EXPLICIT if this is the case
190 dnl ---------------------------------------------------------------------------
191
192 AC_DEFUN([WX_CPP_EXPLICIT],
193 [
194 AC_CACHE_CHECK([if C++ compiler supports the explicit keyword],
195 wx_cv_explicit,
196 [
197 AC_LANG_SAVE
198 AC_LANG_CPLUSPLUS
199
200 dnl do the test in 2 steps: first check that the compiler knows about the
201 dnl explicit keyword at all and then verify that it really honours it
202 AC_TRY_COMPILE(
203 [
204 class Foo { public: explicit Foo(int) {} };
205 ],
206 [
207 return 0;
208 ],
209 [
210 AC_TRY_COMPILE(
211 [
212 class Foo { public: explicit Foo(int) {} };
213 static void TakeFoo(const Foo& foo) { }
214 ],
215 [
216 TakeFoo(17);
217 return 0;
218 ],
219 wx_cv_explicit=no,
220 wx_cv_explicit=yes
221 )
222 ],
223 wx_cv_explicit=no
224 )
225
226 AC_LANG_RESTORE
227 ])
228
229 if test "$wx_cv_explicit" = "yes"; then
230 AC_DEFINE(HAVE_EXPLICIT)
231 fi
232 ])
233
234 dnl ---------------------------------------------------------------------------
235 dnl a slightly better AC_C_BIGENDIAN macro which allows cross-compiling
236 dnl ---------------------------------------------------------------------------
237
238 AC_DEFUN([WX_C_BIGENDIAN],
239 [AC_CACHE_CHECK([whether byte ordering is bigendian], ac_cv_c_bigendian,
240 [ac_cv_c_bigendian=unknown
241 # See if sys/param.h defines the BYTE_ORDER macro.
242 AC_TRY_COMPILE([#include <sys/types.h>
243 #include <sys/param.h>], [
244 #if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
245 bogus endian macros
246 #endif], [# It does; now see whether it defined to BIG_ENDIAN or not.
247 AC_TRY_COMPILE([#include <sys/types.h>
248 #include <sys/param.h>], [
249 #if BYTE_ORDER != BIG_ENDIAN
250 not big endian
251 #endif], ac_cv_c_bigendian=yes, ac_cv_c_bigendian=no)])
252 if test $ac_cv_c_bigendian = unknown; then
253 AC_TRY_RUN([main () {
254 /* Are we little or big endian? From Harbison&Steele. */
255 union
256 {
257 long l;
258 char c[sizeof (long)];
259 } u;
260 u.l = 1;
261 exit (u.c[sizeof (long) - 1] == 1);
262 }], [ac_cv_c_bigendian=no], [ac_cv_c_bigendian=yes], [ac_cv_c_bigendian=unknown])
263 fi])
264 if test $ac_cv_c_bigendian = unknown; then
265 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])
266 fi
267 if test $ac_cv_c_bigendian = yes; then
268 AC_DEFINE(WORDS_BIGENDIAN)
269 fi
270 ])
271
272 dnl ---------------------------------------------------------------------------
273 dnl override AC_ARG_ENABLE/WITH to cache the results in .cache file
274 dnl ---------------------------------------------------------------------------
275
276 AC_DEFUN([WX_ARG_CACHE_INIT],
277 [
278 wx_arg_cache_file="configarg.cache"
279 echo "loading argument cache $wx_arg_cache_file"
280 rm -f ${wx_arg_cache_file}.tmp
281 touch ${wx_arg_cache_file}.tmp
282 touch ${wx_arg_cache_file}
283 ])
284
285 AC_DEFUN([WX_ARG_CACHE_FLUSH],
286 [
287 echo "saving argument cache $wx_arg_cache_file"
288 mv ${wx_arg_cache_file}.tmp ${wx_arg_cache_file}
289 ])
290
291 dnl this macro checks for a three-valued command line --with argument:
292 dnl possible arguments are 'yes', 'no', 'sys', or 'builtin'
293 dnl usage: WX_ARG_SYS_WITH(option, helpmessage, variable-name)
294 AC_DEFUN([WX_ARG_SYS_WITH],
295 [
296 AC_MSG_CHECKING([for --with-$1])
297 no_cache=0
298 AC_ARG_WITH($1, [$2],
299 [
300 if test "$withval" = yes; then
301 ac_cv_use_$1='$3=yes'
302 elif test "$withval" = no; then
303 ac_cv_use_$1='$3=no'
304 elif test "$withval" = sys; then
305 ac_cv_use_$1='$3=sys'
306 elif test "$withval" = builtin; then
307 ac_cv_use_$1='$3=builtin'
308 else
309 AC_MSG_ERROR([Invalid value for --with-$1: should be yes, no, sys, or builtin])
310 fi
311 ],
312 [
313 LINE=`grep "$3" ${wx_arg_cache_file}`
314 if test "x$LINE" != x ; then
315 eval "DEFAULT_$LINE"
316 else
317 no_cache=1
318 fi
319
320 ac_cv_use_$1='$3='$DEFAULT_$3
321 ])
322
323 eval "$ac_cv_use_$1"
324 if test "$no_cache" != 1; then
325 echo $ac_cv_use_$1 >> ${wx_arg_cache_file}.tmp
326 fi
327
328 if test "$$3" = yes; then
329 AC_MSG_RESULT(yes)
330 elif test "$$3" = no; then
331 AC_MSG_RESULT(no)
332 elif test "$$3" = sys; then
333 AC_MSG_RESULT([system version])
334 elif test "$$3" = builtin; then
335 AC_MSG_RESULT([builtin version])
336 else
337 AC_MSG_ERROR([Invalid value for --with-$1: should be yes, no, sys, or builtin])
338 fi
339 ])
340
341 dnl this macro checks for a command line argument and caches the result
342 dnl usage: WX_ARG_WITH(option, helpmessage, variable-name)
343 AC_DEFUN([WX_ARG_WITH],
344 [
345 AC_MSG_CHECKING([for --with-$1])
346 no_cache=0
347 AC_ARG_WITH($1, [$2],
348 [
349 if test "$withval" = yes; then
350 ac_cv_use_$1='$3=yes'
351 else
352 ac_cv_use_$1='$3=no'
353 fi
354 ],
355 [
356 LINE=`grep "$3" ${wx_arg_cache_file}`
357 if test "x$LINE" != x ; then
358 eval "DEFAULT_$LINE"
359 else
360 no_cache=1
361 fi
362
363 ac_cv_use_$1='$3='$DEFAULT_$3
364 ])
365
366 eval "$ac_cv_use_$1"
367 if test "$no_cache" != 1; then
368 echo $ac_cv_use_$1 >> ${wx_arg_cache_file}.tmp
369 fi
370
371 if test "$$3" = yes; then
372 AC_MSG_RESULT(yes)
373 else
374 AC_MSG_RESULT(no)
375 fi
376 ])
377
378 dnl like WX_ARG_WITH but uses AC_ARG_ENABLE instead of AC_ARG_WITH
379 dnl usage: WX_ARG_ENABLE(option, helpmessage, variable-name, enablestring)
380 dnl
381 dnl enablestring is a hack and allows to show "checking for --disable-foo"
382 dnl message when running configure instead of the default "checking for
383 dnl --enable-foo" one whih is useful for the options enabled by default
384 AC_DEFUN([WX_ARG_ENABLE],
385 [
386 enablestring=$4
387 AC_MSG_CHECKING([for --${enablestring:-enable}-$1])
388 no_cache=0
389 AC_ARG_ENABLE($1, [$2],
390 [
391 if test "$enableval" = yes; then
392 ac_cv_use_$1='$3=yes'
393 else
394 ac_cv_use_$1='$3=no'
395 fi
396 ],
397 [
398 LINE=`grep "$3" ${wx_arg_cache_file}`
399 if test "x$LINE" != x ; then
400 eval "DEFAULT_$LINE"
401 else
402 no_cache=1
403 fi
404
405 ac_cv_use_$1='$3='$DEFAULT_$3
406 ])
407
408 eval "$ac_cv_use_$1"
409 if test "$no_cache" != 1; then
410 echo $ac_cv_use_$1 >> ${wx_arg_cache_file}.tmp
411 fi
412
413 if test "$$3" = yes; then
414 AC_MSG_RESULT(yes)
415 else
416 AC_MSG_RESULT(no)
417 fi
418 ])
419
420
421 dnl ===========================================================================
422 dnl Linker features test
423 dnl ===========================================================================
424
425 dnl ---------------------------------------------------------------------------
426 dnl WX_VERSIONED_SYMBOLS checks whether the linker can create versioned
427 dnl symbols. If it can, sets LDFLAGS_VERSIONING to $CXX flags needed to use
428 dnl version script file named versionfile
429 dnl
430 dnl call WX_VERSIONED_SYMBOLS(versionfile)
431 dnl ---------------------------------------------------------------------------
432 AC_DEFUN([WX_VERSIONED_SYMBOLS],
433 [
434 found_versioning=no
435
436 dnl FIXME - doesn't work, Solaris linker doesn't accept wildcards
437 dnl in the script.
438 dnl dnl Check for known non-gcc cases:
439 dnl case "${host}" in
440 dnl *-*-solaris2* )
441 dnl if test "x$GCC" != "xyes" ; then
442 dnl LDFLAGS_VERSIONING="-M $1"
443 dnl found_versioning=yes
444 dnl fi
445 dnl ;;
446 dnl esac
447
448 dnl Generic check for GCC or GCC-like behaviour (Intel C++, GCC):
449 if test $found_versioning = no ; then
450 AC_CACHE_CHECK([if the linker accepts --version-script], wx_cv_version_script,
451 [
452 echo "VER_1 { *; };" >conftest.sym
453 echo "int main() { return 0; }" >conftest.cpp
454
455 if AC_TRY_COMMAND([
456 $CXX -o conftest.output $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.cpp
457 -Wl,--version-script,conftest.sym >/dev/null 2>conftest.stderr]) ; then
458 if test -s conftest.stderr ; then
459 wx_cv_version_script=no
460 else
461 wx_cv_version_script=yes
462 fi
463 else
464 wx_cv_version_script=no
465 fi
466 rm -f conftest.output conftest.stderr conftest.sym conftest.cpp
467 ])
468 if test $wx_cv_version_script = yes ; then
469 LDFLAGS_VERSIONING="-Wl,--version-script,$1"
470 fi
471 fi
472 ])
473
474
475 dnl ===========================================================================
476 dnl "3rd party" macros included here because they are not widely available
477 dnl ===========================================================================
478
479 dnl ---------------------------------------------------------------------------
480 dnl test for availability of iconv()
481 dnl ---------------------------------------------------------------------------
482
483 dnl From Bruno Haible.
484
485 AC_DEFUN([AM_ICONV],
486 [
487 dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
488 dnl those with the standalone portable GNU libiconv installed).
489
490 AC_ARG_WITH([libiconv-prefix],
491 [ --with-libiconv-prefix=DIR search for libiconv in DIR/include and DIR/lib], [
492 for dir in `echo "$withval" | tr : ' '`; do
493 if test -d $dir/include; then CPPFLAGS="$CPPFLAGS -I$dir/include"; fi
494 if test -d $dir/lib; then LDFLAGS="$LDFLAGS -L$dir/lib"; fi
495 done
496 ])
497
498 AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
499 am_cv_func_iconv="no, consider installing GNU libiconv"
500 am_cv_lib_iconv=no
501 AC_TRY_LINK([#include <stdlib.h>
502 #include <iconv.h>],
503 [iconv_t cd = iconv_open("","");
504 iconv(cd,NULL,NULL,NULL,NULL);
505 iconv_close(cd);],
506 am_cv_func_iconv=yes)
507 if test "$am_cv_func_iconv" != yes; then
508 am_save_LIBS="$LIBS"
509 LIBS="$LIBS -liconv"
510 AC_TRY_LINK([#include <stdlib.h>
511 #include <iconv.h>],
512 [iconv_t cd = iconv_open("","");
513 iconv(cd,NULL,NULL,NULL,NULL);
514 iconv_close(cd);],
515 am_cv_lib_iconv=yes
516 am_cv_func_iconv=yes)
517 LIBS="$am_save_LIBS"
518 fi
519 ])
520 if test "$am_cv_func_iconv" = yes; then
521 AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
522 AC_CACHE_CHECK([if iconv needs const], wx_cv_func_iconv_const,
523 AC_TRY_COMPILE([
524 #include <stdlib.h>
525 #include <iconv.h>
526 extern
527 #ifdef __cplusplus
528 "C"
529 #endif
530 #if defined(__STDC__) || defined(__cplusplus)
531 size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
532 #else
533 size_t iconv();
534 #endif
535 ],
536 [],
537 wx_cv_func_iconv_const="no",
538 wx_cv_func_iconv_const="yes"
539 )
540 )
541
542 iconv_const=
543 if test "x$wx_cv_func_iconv_const" = "xyes"; then
544 iconv_const="const"
545 fi
546
547 AC_DEFINE_UNQUOTED(ICONV_CONST, $iconv_const,
548 [Define as const if the declaration of iconv() needs const.])
549 fi
550 LIBICONV=
551 if test "$am_cv_lib_iconv" = yes; then
552 LIBICONV="-liconv"
553 fi
554 AC_SUBST(LIBICONV)
555 ])
556
557 dnl ---------------------------------------------------------------------------
558 dnl AC_SYS_LARGEFILE (partly based on the code from autoconf 2.5x)
559 dnl ---------------------------------------------------------------------------
560
561 dnl WX_SYS_LARGEFILE_TEST
562 dnl
563 dnl NB: original autoconf test was checking if compiler supported 6 bit off_t
564 dnl arithmetic properly but this failed miserably with gcc under Linux
565 dnl whereas the system still supports 64 bit files, so now simply check
566 dnl that off_t is big enough
567 define(WX_SYS_LARGEFILE_TEST,
568 [typedef struct {
569 unsigned int field: sizeof(off_t) == 8;
570 } wxlf;
571 ])
572
573
574 dnl WX_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE, CACHE-VAR)
575 define(WX_SYS_LARGEFILE_MACRO_VALUE,
576 [
577 AC_CACHE_CHECK([for $1 value needed for large files], [$3],
578 [
579 AC_TRY_COMPILE([#define $1 $2
580 #include <sys/types.h>],
581 WX_SYS_LARGEFILE_TEST,
582 [$3=$2],
583 [$3=no])
584 ]
585 )
586
587 if test "$$3" != no; then
588 wx_largefile=yes
589 AC_DEFINE_UNQUOTED([$1], [$$3])
590 fi
591 ])
592
593
594 dnl AC_SYS_LARGEFILE
595 dnl ----------------
596 dnl By default, many hosts won't let programs access large files;
597 dnl one must use special compiler options to get large-file access to work.
598 dnl For more details about this brain damage please see:
599 dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
600 AC_DEFUN([AC_SYS_LARGEFILE],
601 [AC_ARG_ENABLE(largefile,
602 [ --disable-largefile omit support for large files])
603 if test "$enable_largefile" != no; then
604 dnl _FILE_OFFSET_BITS==64 is needed for Linux, Solaris, ...
605 dnl _LARGE_FILES -- for AIX
606 wx_largefile=no
607 WX_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS, 64, ac_cv_sys_file_offset_bits)
608 if test "x$wx_largefile" != "xyes"; then
609 WX_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES, 1, ac_cv_sys_large_files)
610 fi
611
612 AC_MSG_CHECKING(if large file support is available)
613 if test "x$wx_largefile" = "xyes"; then
614 AC_DEFINE(HAVE_LARGEFILE_SUPPORT)
615 fi
616 AC_MSG_RESULT($wx_largefile)
617 fi
618 ])
619
620
621 dnl Available from the GNU Autoconf Macro Archive at:
622 dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_const_cast.html
623 dnl
624 AC_DEFUN([AC_CXX_CONST_CAST],
625 [AC_CACHE_CHECK(whether the compiler supports const_cast<>,
626 ac_cv_cxx_const_cast,
627 [AC_LANG_SAVE
628 AC_LANG_CPLUSPLUS
629 AC_TRY_COMPILE(,[int x = 0;const int& y = x;int& z = const_cast<int&>(y);return z;],
630 ac_cv_cxx_const_cast=yes, ac_cv_cxx_const_cast=no)
631 AC_LANG_RESTORE
632 ])
633 if test "$ac_cv_cxx_const_cast" = yes; then
634 AC_DEFINE(HAVE_CONST_CAST,,[define if the compiler supports const_cast<>])
635 fi
636 ])
637
638 dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_reinterpret_cast.html
639 AC_DEFUN([AC_CXX_REINTERPRET_CAST],
640 [AC_CACHE_CHECK(whether the compiler supports reinterpret_cast<>,
641 ac_cv_cxx_reinterpret_cast,
642 [AC_LANG_SAVE
643 AC_LANG_CPLUSPLUS
644 AC_TRY_COMPILE([#include <typeinfo>
645 class Base { public : Base () {} virtual void f () = 0;};
646 class Derived : public Base { public : Derived () {} virtual void f () {} };
647 class Unrelated { public : Unrelated () {} };
648 int g (Unrelated&) { return 0; }],[
649 Derived d;Base& b=d;Unrelated& e=reinterpret_cast<Unrelated&>(b);return g(e);],
650 ac_cv_cxx_reinterpret_cast=yes, ac_cv_cxx_reinterpret_cast=no)
651 AC_LANG_RESTORE
652 ])
653 if test "$ac_cv_cxx_reinterpret_cast" = yes; then
654 AC_DEFINE(HAVE_REINTERPRET_CAST,,
655 [define if the compiler supports reinterpret_cast<>])
656 fi
657 ])
658
659 dnl and http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_static_cast.html
660 AC_DEFUN([AC_CXX_STATIC_CAST],
661 [AC_CACHE_CHECK(whether the compiler supports static_cast<>,
662 ac_cv_cxx_static_cast,
663 [AC_LANG_SAVE
664 AC_LANG_CPLUSPLUS
665 AC_TRY_COMPILE([#include <typeinfo>
666 class Base { public : Base () {} virtual void f () = 0; };
667 class Derived : public Base { public : Derived () {} virtual void f () {} };
668 int g (Derived&) { return 0; }],[
669 Derived d; Base& b = d; Derived& s = static_cast<Derived&> (b); return g (s);],
670 ac_cv_cxx_static_cast=yes, ac_cv_cxx_static_cast=no)
671 AC_LANG_RESTORE
672 ])
673 if test "$ac_cv_cxx_static_cast" = yes; then
674 AC_DEFINE(HAVE_STATIC_CAST,, [define if the compiler supports static_cast<>])
675 fi
676 ])