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