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