]> git.saurik.com Git - wxWidgets.git/blame_incremental - acinclude.m4
mac paths updated
[wxWidgets.git] / acinclude.m4
... / ...
CommitLineData
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
11
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])
24
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=
36for ac_dir in $1 /usr/include;
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, lib 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[
51 ac_find_libraries=
52 for ac_dir in $1;
53 do
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
57 break 2
58 fi
59 done
60 done
61])
62
63dnl ---------------------------------------------------------------------------
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
76dnl ---------------------------------------------------------------------------
77dnl Path to include, already defined
78dnl ---------------------------------------------------------------------------
79AC_DEFUN([WX_INCLUDE_PATH_EXIST],
80[
81 dnl never add -I/usr/include to the CPPFLAGS
82 if test "x$1" = "x/usr/include"; then
83 ac_path_to_include=""
84 else
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
92 fi
93])
94
95dnl ---------------------------------------------------------------------------
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
101dnl ---------------------------------------------------------------------------
102AC_DEFUN([WX_LINK_PATH_EXIST],
103[
104 dnl never add -L/usr/libXXX explicitely to libpath
105 if test "$1" = "default location"; then
106 ac_path_to_link=""
107 else
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
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
127dnl call WX_CPP_NEW_HEADERS(actiof-if-true, action-if-false)
128dnl ---------------------------------------------------------------------------
129
130AC_DEFUN([WX_CPP_NEW_HEADERS],
131[
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
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
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
230dnl ---------------------------------------------------------------------------
231dnl WX_CHECK_FUNCS(FUNCTIONS...,
232dnl [ACTION-IF-FOUND],
233dnl [ACTION-IF-NOT-FOUND],
234dnl [EXTRA-DEFINES-AND-INCLUDES],
235dnl [EXTRA-TEST-CODE])
236dnl
237dnl Checks that the functions listed in FUNCTIONS exist in the headers and the
238dnl libs. For each function, if it is found then defines 'HAVE_FUNCTION' and
239dnl executes ACTION-IF-FOUND, otherwise executes ACTION-IF-NOT-FOUND.
240dnl
241dnl The code from EXTRA-DEFINES-AND-INCLUDES is inserted into the test before
242dnl the default headers are included, and EXTRA-TEST-CODE is inserted into
243dnl the main() function after the default test for existence.
244dnl
245dnl Examples:
246dnl # the simple case
247dnl WX_CHECK_FUNCS(stat)
248dnl # use break to finish the loop early
249dnl WX_CHECK_FUNCS(mkstemp mktemp, break)
250dnl # extra defines
251dnl WX_CHECK_FUNCS(strtok_r, [], [], [#define _RREENTRANT])
252dnl # extra includes
253dnl WX_CHECK_FUNCS(swprintf, [], [], [#include <wchar.h>])
254dnl # checking the signature with extra test code
255dnl WX_CHECK_FUNCS(gettimeofday, [], [], [#include <sys/time.h>]
256dnl [struct timeval tv; struct timezone tz; gettimeofday(&tv, &tz)])
257dnl ---------------------------------------------------------------------------
258
259AC_DEFUN([WX_CHECK_FUNCS],
260[
261 for wx_func in $1
262 do
263 AC_CACHE_CHECK(
264 [for $wx_func],
265 [wx_cv_func_$wx_func],
266 [
267 AC_LINK_IFELSE(
268 [
269 AC_LANG_PROGRAM(
270 [
271 $4
272 AC_INCLUDES_DEFAULT
273 ],
274 [
275 #ifndef $wx_func
276 &$wx_func;
277 #endif
278 $5
279 ])
280 ],
281 [eval wx_cv_func_$wx_func=yes],
282 [eval wx_cv_func_$wx_func=no])
283 ])
284
285 if eval test \$wx_cv_func_$wx_func = yes
286 then
287 AC_DEFINE_UNQUOTED([AS_TR_CPP([HAVE_$wx_func])])
288 $2
289 else
290 :
291 $3
292 fi
293 done
294])
295
296dnl ---------------------------------------------------------------------------
297dnl a slightly better AC_C_BIGENDIAN macro which allows cross-compiling
298dnl ---------------------------------------------------------------------------
299
300AC_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.
304AC_TRY_COMPILE([#include <sys/types.h>
305#include <sys/param.h>], [
306#if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
307 bogus endian macros
308#endif], [# It does; now see whether it defined to BIG_ENDIAN or not.
309AC_TRY_COMPILE([#include <sys/types.h>
310#include <sys/param.h>], [
311#if BYTE_ORDER != BIG_ENDIAN
312 not big endian
313#endif], ac_cv_c_bigendian=yes, ac_cv_c_bigendian=no)])
314if test $ac_cv_c_bigendian = unknown; then
315AC_TRY_RUN([main () {
316 /* Are we little or big endian? From Harbison&Steele. */
317 union
318 {
319 long l;
320 char c[sizeof (long)];
321 } u;
322 u.l = 1;
323 exit (u.c[sizeof (long) - 1] == 1);
324}], [ac_cv_c_bigendian=no], [ac_cv_c_bigendian=yes], [ac_cv_c_bigendian=unknown])
325fi])
326if 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])
328fi
329if test $ac_cv_c_bigendian = yes; then
330 AC_DEFINE(WORDS_BIGENDIAN)
331fi
332])
333
334dnl ---------------------------------------------------------------------------
335dnl override AC_ARG_ENABLE/WITH to handle options defaults
336dnl ---------------------------------------------------------------------------
337
338dnl this macro checks for a three-valued command line --with argument:
339dnl possible arguments are 'yes', 'no', 'sys', or 'builtin'
340dnl usage: WX_ARG_SYS_WITH(option, helpmessage, variable-name)
341dnl
342dnl the default value (used if the option is not specified at all) is the value
343dnl of wxUSE_ALL_FEATURES (which is "yes" by default but can be changed by
344dnl giving configure --disable-all-features option)
345AC_DEFUN([WX_ARG_SYS_WITH],
346 [
347 AC_MSG_CHECKING([for --with-$1])
348 AC_ARG_WITH($1, [$2],
349 [
350 if test "$withval" = yes; then
351 AS_TR_SH(wx_cv_use_$1)='$3=yes'
352 elif test "$withval" = no; then
353 AS_TR_SH(wx_cv_use_$1)='$3=no'
354 elif test "$withval" = sys; then
355 AS_TR_SH(wx_cv_use_$1)='$3=sys'
356 elif test "$withval" = builtin; then
357 AS_TR_SH(wx_cv_use_$1)='$3=builtin'
358 else
359 AC_MSG_ERROR([Invalid value for --with-$1: should be yes, no, sys, or builtin])
360 fi
361 ],
362 [
363 AS_TR_SH(wx_cv_use_$1)='$3=${'DEFAULT_$3":-$wxUSE_ALL_FEATURES}"
364 ])
365
366 eval "$AS_TR_SH(wx_cv_use_$1)"
367
368 if test "$$3" = yes; then
369 AC_MSG_RESULT(yes)
370 elif test "$$3" = no; then
371 AC_MSG_RESULT(no)
372 elif test "$$3" = sys; then
373 AC_MSG_RESULT([system version])
374 elif test "$$3" = builtin; then
375 AC_MSG_RESULT([builtin version])
376 else
377 AC_MSG_ERROR([Invalid value for --with-$1: should be yes, no, sys, or builtin])
378 fi
379 ])
380
381dnl this macro simply checks for a command line argument
382dnl usage: WX_ARG_WITH(option, helpmessage, variable-name, [withstring])
383AC_DEFUN([WX_ARG_WITH],
384 [
385 withstring=$4
386 defaultval=$wxUSE_ALL_FEATURES
387 if test -z "$defaultval"; then
388 if test x"$withstring" = xwithout; then
389 defaultval=yes
390 else
391 defaultval=no
392 fi
393 fi
394 AC_MSG_CHECKING([for --${withstring:-with}-$1])
395 AC_ARG_WITH($1, [$2],
396 [
397 if test "$withval" = yes; then
398 AS_TR_SH(wx_cv_use_$1)='$3=yes'
399 else
400 AS_TR_SH(wx_cv_use_$1)='$3=no'
401 fi
402 ],
403 [
404 AS_TR_SH(wx_cv_use_$1)='$3=${'DEFAULT_$3":-$defaultval}"
405 ])
406
407 eval "$AS_TR_SH(wx_cv_use_$1)"
408
409 if test x"$withstring" = xwithout; then
410 if test $$3 = yes; then
411 result=no
412 else
413 result=yes
414 fi
415 else
416 result=$$3
417 fi
418
419 AC_MSG_RESULT($result)
420 ])
421
422dnl same as WX_ARG_WITH but makes it clear that the option is enabled by default
423AC_DEFUN([WX_ARG_WITHOUT], [WX_ARG_WITH($1, [$2], $3, without)])
424
425dnl like WX_ARG_WITH but uses AC_ARG_ENABLE instead of AC_ARG_WITH
426dnl usage: WX_ARG_ENABLE(option, helpmessage, var, [enablestring], [default])
427dnl
428dnl enablestring can be omitted or a literal string "disable" and allows to
429dnl show "checking for --disable-foo" message when running configure instead of
430dnl the default "checking for --enable-foo" one whih is useful for the options
431dnl enabled by default
432dnl
433dnl the "default" argument can be omitted or contain the default value to use
434dnl for the option if it's unspecified
435AC_DEFUN([WX_ARG_ENABLE],
436 [
437 enablestring=$4
438 defaultval=$5
439 if test -z "$defaultval"; then
440 if test x"$enablestring" = xdisable; then
441 defaultval=yes
442 else
443 defaultval=no
444 fi
445 fi
446
447 AC_MSG_CHECKING([for --${enablestring:-enable}-$1])
448 AC_ARG_ENABLE($1, [$2],
449 [
450 if test "$enableval" = yes; then
451 AS_TR_SH(wx_cv_use_$1)='$3=yes'
452 else
453 AS_TR_SH(wx_cv_use_$1)='$3=no'
454 fi
455 ],
456 [
457 AS_TR_SH(wx_cv_use_$1)='$3=${'DEFAULT_$3":-$defaultval}"
458 ])
459
460 eval "$AS_TR_SH(wx_cv_use_$1)"
461
462 if test x"$enablestring" = xdisable; then
463 if test $$3 = yes; then
464 result=no
465 else
466 result=yes
467 fi
468 else
469 result=$$3
470 fi
471
472 AC_MSG_RESULT($result)
473 ])
474
475dnl the same as WX_ARG_ENABLE but makes it more clear that the option is
476dnl enabled by default
477AC_DEFUN([WX_ARG_DISABLE], [WX_ARG_ENABLE($1, [$2], $3, disable)])
478
479dnl same as WX_ARG_ENABLE but defaults to wxUSE_ALL_FEATURES instead of "yes"
480AC_DEFUN([WX_ARG_FEATURE], [WX_ARG_ENABLE($1, [$2], $3,, $wxUSE_ALL_FEATURES)])
481
482dnl Like WX_ARG_ENABLE but accepts a parameter.
483dnl
484dnl Usage:
485dnl WX_ARG_ENABLE_PARAM(option, helpmessage, variable-name, enablestring)
486dnl
487dnl Example:
488dnl WX_ARG_ENABLE_PARAM(foo, [[ --enable-foo[=bar] use foo]], wxUSE_FOO)
489dnl
490dnl --enable-foo wxUSE_FOO=yes
491dnl --disable-foo wxUSE_FOO=no
492dnl --enable-foo=bar wxUSE_FOO=bar
493dnl <not given> wxUSE_FOO=$DEFAULT_wxUSE_FOO
494dnl
495AC_DEFUN([WX_ARG_ENABLE_PARAM],
496 [
497 enablestring=$4
498 AC_MSG_CHECKING([for --${enablestring:-enable}-$1])
499 AC_ARG_ENABLE($1, [$2],
500 [
501 wx_cv_use_$1="$3='$enableval'"
502 ],
503 [
504 wx_cv_use_$1='$3='$DEFAULT_$3
505 ])
506
507 eval "$wx_cv_use_$1"
508
509 AC_MSG_RESULT([$$3])
510 ])
511
512dnl ===========================================================================
513dnl Linker features test
514dnl ===========================================================================
515
516dnl ---------------------------------------------------------------------------
517dnl WX_VERSIONED_SYMBOLS checks whether the linker can create versioned
518dnl symbols. If it can, sets LDFLAGS_VERSIONING to $CXX flags needed to use
519dnl version script file named versionfile
520dnl
521dnl call WX_VERSIONED_SYMBOLS(versionfile)
522dnl ---------------------------------------------------------------------------
523AC_DEFUN([WX_VERSIONED_SYMBOLS],
524[
525 case "${host}" in
526 *-*-cygwin* | *-*-mingw* )
527 dnl although ld does support version script option on these
528 dnl platforms, it doesn't make much sense to use it under Win32
529 dnl and, moreover, this breaks linking because of a bug in handling
530 dnl paths in -Wl,--version-script,path option (if we ever do need
531 dnl to use it for cygwin/mingw32, keep in mind that replacing last
532 dnl comma with the equal sign works) so
533 dnl simply disable it
534 wx_cv_version_script=no
535 ;;
536
537 *)
538 AC_CACHE_CHECK([if the linker accepts --version-script], wx_cv_version_script,
539 [
540 echo "VER_1 { *; };" >conftest.sym
541 echo "int main() { return 0; }" >conftest.cpp
542
543 if AC_TRY_COMMAND([
544 $CXX -o conftest.output $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.cpp
545 -Wl,--version-script,conftest.sym >/dev/null 2>conftest.stderr]) ; then
546 if test -s conftest.stderr ; then
547 wx_cv_version_script=no
548 else
549 wx_cv_version_script=yes
550 fi
551 else
552 wx_cv_version_script=no
553 fi
554
555 dnl There's a problem in some old linkers with --version-script that
556 dnl can cause linking to fail when you have objects with vtables in
557 dnl libs 3 deep. This is known to happen in netbsd and openbsd with
558 dnl ld 2.11.2.
559 dnl
560 dnl To test for this we need to make some shared libs and
561 dnl unfortunately we can't be sure of the right way to do that. If the
562 dnl first two compiles don't succeed then it looks like the test isn't
563 dnl working and the result is ignored, but if OTOH the first two
564 dnl succeed but the third does not then the bug has been detected and
565 dnl the --version-script flag is dropped.
566 if test $wx_cv_version_script = yes
567 then
568 echo "struct B { virtual ~B() { } }; \
569 struct D : public B { }; \
570 void F() { D d; }" > conftest.cpp
571
572 if AC_TRY_COMMAND([
573 $CXX -shared -fPIC -o conftest1.output $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.cpp
574 -Wl,--version-script,conftest.sym >/dev/null 2>/dev/null]) &&
575 AC_TRY_COMMAND([
576 $CXX -shared -fPIC -o conftest2.output $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.cpp
577 -Wl,--version-script,conftest.sym conftest1.output >/dev/null 2>/dev/null])
578 then
579 if AC_TRY_COMMAND([
580 $CXX -shared -fPIC -o conftest3.output $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.cpp
581 -Wl,--version-script,conftest.sym conftest2.output conftest1.output >/dev/null 2>/dev/null])
582 then
583 wx_cv_version_script=yes
584 else
585 wx_cv_version_script=no
586 fi
587 fi
588 fi
589
590 rm -f conftest.output conftest.stderr conftest.sym conftest.cpp
591 rm -f conftest1.output conftest2.output conftest3.output
592 ])
593
594 if test $wx_cv_version_script = yes ; then
595 LDFLAGS_VERSIONING="-Wl,--version-script,$1"
596 fi
597 ;;
598 esac
599])
600
601
602dnl ===========================================================================
603dnl "3rd party" macros included here because they are not widely available
604dnl ===========================================================================
605
606dnl ---------------------------------------------------------------------------
607dnl test for availability of iconv()
608dnl ---------------------------------------------------------------------------
609
610dnl From Bruno Haible.
611
612AC_DEFUN([AM_ICONV],
613[
614 dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
615 dnl those with the standalone portable GNU libiconv installed).
616
617 AC_ARG_WITH([libiconv-prefix],
618[ --with-libiconv-prefix=DIR search for libiconv in DIR/include and DIR/lib], [
619 for dir in `echo "$withval" | tr : ' '`; do
620 if test -d $dir/include; then CPPFLAGS="$CPPFLAGS -I$dir/include"; fi
621 if test -d $dir/lib; then LDFLAGS="$LDFLAGS -L$dir/lib"; fi
622 done
623 ])
624
625 AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
626 am_cv_func_iconv="no, consider installing GNU libiconv"
627 am_cv_lib_iconv=no
628 AC_TRY_LINK([#include <stdlib.h>
629#include <iconv.h>],
630 [iconv_t cd = iconv_open("","");
631 iconv(cd,NULL,NULL,NULL,NULL);
632 iconv_close(cd);],
633 am_cv_func_iconv=yes)
634 if test "$am_cv_func_iconv" != yes; then
635 am_save_LIBS="$LIBS"
636 LIBS="$LIBS -liconv"
637 AC_TRY_LINK([#include <stdlib.h>
638#include <iconv.h>],
639 [iconv_t cd = iconv_open("","");
640 iconv(cd,NULL,NULL,NULL,NULL);
641 iconv_close(cd);],
642 am_cv_lib_iconv=yes
643 am_cv_func_iconv=yes)
644 LIBS="$am_save_LIBS"
645 fi
646 ])
647 if test "$am_cv_func_iconv" = yes; then
648 AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
649 AC_CACHE_CHECK([if iconv needs const], wx_cv_func_iconv_const,
650 AC_TRY_COMPILE([
651#include <stdlib.h>
652#include <iconv.h>
653extern
654#ifdef __cplusplus
655"C"
656#endif
657#if defined(__STDC__) || defined(__cplusplus)
658size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
659#else
660size_t iconv();
661#endif
662 ],
663 [],
664 wx_cv_func_iconv_const="no",
665 wx_cv_func_iconv_const="yes"
666 )
667 )
668
669 iconv_const=
670 if test "x$wx_cv_func_iconv_const" = "xyes"; then
671 iconv_const="const"
672 fi
673
674 AC_DEFINE_UNQUOTED(ICONV_CONST, $iconv_const,
675 [Define as const if the declaration of iconv() needs const.])
676 fi
677 LIBICONV=
678 if test "$am_cv_lib_iconv" = yes; then
679 LIBICONV="-liconv"
680 fi
681 AC_SUBST(LIBICONV)
682])
683
684dnl ---------------------------------------------------------------------------
685dnl AC_SYS_LARGEFILE (partly based on the code from autoconf 2.5x)
686dnl ---------------------------------------------------------------------------
687
688dnl WX_SYS_LARGEFILE_TEST
689dnl
690dnl NB: original autoconf test was checking if compiler supported 6 bit off_t
691dnl arithmetic properly but this failed miserably with gcc under Linux
692dnl whereas the system still supports 64 bit files, so now simply check
693dnl that off_t is big enough
694define(WX_SYS_LARGEFILE_TEST,
695[typedef struct {
696 unsigned int field: sizeof(off_t) == 8;
697} wxlf;
698])
699
700
701dnl WX_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE, CACHE-VAR)
702define(WX_SYS_LARGEFILE_MACRO_VALUE,
703[
704 AC_CACHE_CHECK([for $1 value needed for large files], [$3],
705 [
706 AC_TRY_COMPILE([#define $1 $2
707 #include <sys/types.h>],
708 WX_SYS_LARGEFILE_TEST,
709 [$3=$2],
710 [$3=no])
711 ]
712 )
713
714 if test "$$3" != no; then
715 wx_largefile=yes
716 AC_DEFINE_UNQUOTED([$1], [$$3])
717 fi
718])
719
720
721dnl AC_SYS_LARGEFILE
722dnl ----------------
723dnl By default, many hosts won't let programs access large files;
724dnl one must use special compiler options to get large-file access to work.
725dnl For more details about this brain damage please see:
726dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
727AC_DEFUN([AC_SYS_LARGEFILE],
728[AC_ARG_ENABLE(largefile,
729 [ --disable-largefile omit support for large files])
730if test "$enable_largefile" != no; then
731 dnl _FILE_OFFSET_BITS==64 is needed for Linux, Solaris, ...
732 dnl _LARGE_FILES -- for AIX
733 wx_largefile=no
734 WX_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS, 64, ac_cv_sys_file_offset_bits)
735 if test "x$wx_largefile" != "xyes"; then
736 WX_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES, 1, ac_cv_sys_large_files)
737 fi
738
739 AC_MSG_CHECKING(if large file support is available)
740 if test "x$wx_largefile" = "xyes"; then
741 AC_DEFINE(HAVE_LARGEFILE_SUPPORT)
742 fi
743 AC_MSG_RESULT($wx_largefile)
744fi
745])
746
747
748dnl Available from the GNU Autoconf Macro Archive at:
749dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_const_cast.html
750dnl
751AC_DEFUN([AC_CXX_CONST_CAST],
752[AC_CACHE_CHECK(whether the compiler supports const_cast<>,
753ac_cv_cxx_const_cast,
754[AC_LANG_SAVE
755 AC_LANG_CPLUSPLUS
756 AC_TRY_COMPILE(,[int x = 0;const int& y = x;int& z = const_cast<int&>(y);return z;],
757 ac_cv_cxx_const_cast=yes, ac_cv_cxx_const_cast=no)
758 AC_LANG_RESTORE
759])
760if test "$ac_cv_cxx_const_cast" = yes; then
761 AC_DEFINE(HAVE_CONST_CAST,,[define if the compiler supports const_cast<>])
762fi
763])
764
765dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_reinterpret_cast.html
766AC_DEFUN([AC_CXX_REINTERPRET_CAST],
767[AC_CACHE_CHECK(whether the compiler supports reinterpret_cast<>,
768ac_cv_cxx_reinterpret_cast,
769[AC_LANG_SAVE
770 AC_LANG_CPLUSPLUS
771 AC_TRY_COMPILE([#include <typeinfo>
772class Base { public : Base () {} virtual void f () = 0;};
773class Derived : public Base { public : Derived () {} virtual void f () {} };
774class Unrelated { public : Unrelated () {} };
775int g (Unrelated&) { return 0; }],[
776Derived d;Base& b=d;Unrelated& e=reinterpret_cast<Unrelated&>(b);return g(e);],
777 ac_cv_cxx_reinterpret_cast=yes, ac_cv_cxx_reinterpret_cast=no)
778 AC_LANG_RESTORE
779])
780if test "$ac_cv_cxx_reinterpret_cast" = yes; then
781 AC_DEFINE(HAVE_REINTERPRET_CAST,,
782 [define if the compiler supports reinterpret_cast<>])
783fi
784])
785
786dnl and http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_static_cast.html
787AC_DEFUN([AC_CXX_STATIC_CAST],
788[AC_CACHE_CHECK(whether the compiler supports static_cast<>,
789ac_cv_cxx_static_cast,
790[AC_LANG_SAVE
791 AC_LANG_CPLUSPLUS
792 AC_TRY_COMPILE([#include <typeinfo>
793class Base { public : Base () {} virtual void f () = 0; };
794class Derived : public Base { public : Derived () {} virtual void f () {} };
795int g (Derived&) { return 0; }],[
796Derived d; Base& b = d; Derived& s = static_cast<Derived&> (b); return g (s);],
797 ac_cv_cxx_static_cast=yes, ac_cv_cxx_static_cast=no)
798 AC_LANG_RESTORE
799])
800if test "$ac_cv_cxx_static_cast" = yes; then
801 AC_DEFINE(HAVE_STATIC_CAST,, [define if the compiler supports static_cast<>])
802fi
803])
804
805dnl http://autoconf-archive.cryp.to/ac_cxx_dynamic_cast.html
806AC_DEFUN([AC_CXX_DYNAMIC_CAST],
807[AC_CACHE_CHECK(whether the compiler supports dynamic_cast<>,
808ac_cv_cxx_dynamic_cast,
809[AC_LANG_SAVE
810 AC_LANG_CPLUSPLUS
811 AC_TRY_COMPILE([#include <typeinfo>
812class Base { public : Base () {} virtual void f () = 0;};
813class Derived : public Base { public : Derived () {} virtual void f () {} };],[
814Derived d; Base& b=d; return dynamic_cast<Derived*>(&b) ? 0 : 1;],
815 ac_cv_cxx_dynamic_cast=yes, ac_cv_cxx_dynamic_cast=no)
816 AC_LANG_RESTORE
817])
818if test "$ac_cv_cxx_dynamic_cast" = yes; then
819 AC_DEFINE(HAVE_DYNAMIC_CAST,,[define if the compiler supports dynamic_cast<>])
820fi
821])
822