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