]> git.saurik.com Git - wxWidgets.git/blame - acinclude.m4
checked locations between 2.8 and 2.9
[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
1f7e12cc 135 AC_CHECK_HEADERS([iostream],,, [ ])
b040e242
VS
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
040b3497
MW
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
1ad9ba14 287 AC_DEFINE_UNQUOTED([AS_TR_CPP([HAVE_$wx_func])])
040b3497
MW
288 $2
289 else
290 :
291 $3
292 fi
293 done
294])
295
b040e242
VS
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 cache the results in .cache file
336dnl ---------------------------------------------------------------------------
337
338AC_DEFUN([WX_ARG_CACHE_INIT],
339 [
340 wx_arg_cache_file="configarg.cache"
341 echo "loading argument cache $wx_arg_cache_file"
342 rm -f ${wx_arg_cache_file}.tmp
343 touch ${wx_arg_cache_file}.tmp
344 touch ${wx_arg_cache_file}
345 ])
346
347AC_DEFUN([WX_ARG_CACHE_FLUSH],
348 [
349 echo "saving argument cache $wx_arg_cache_file"
350 mv ${wx_arg_cache_file}.tmp ${wx_arg_cache_file}
351 ])
352
d970f7d5
VZ
353dnl return the name of the variable to store the value of the given
354dnl WX_ARG_WITH/ENABLE option
355AC_DEFUN([WX_ARG_CACHE_NAME],)
356
b040e242
VS
357dnl this macro checks for a three-valued command line --with argument:
358dnl possible arguments are 'yes', 'no', 'sys', or 'builtin'
359dnl usage: WX_ARG_SYS_WITH(option, helpmessage, variable-name)
6e198e97
VZ
360dnl
361dnl the default value (used if the option is not specified at all) is the value
362dnl of wxUSE_ALL_FEATURES (which is "yes" by default but can be changed by
363dnl giving configure --disable-all-features option)
b040e242
VS
364AC_DEFUN([WX_ARG_SYS_WITH],
365 [
366 AC_MSG_CHECKING([for --with-$1])
b040e242
VS
367 AC_ARG_WITH($1, [$2],
368 [
369 if test "$withval" = yes; then
d970f7d5 370 AS_TR_SH(wx_cv_use_$1)='$3=yes'
b040e242 371 elif test "$withval" = no; then
d970f7d5 372 AS_TR_SH(wx_cv_use_$1)='$3=no'
b040e242 373 elif test "$withval" = sys; then
d970f7d5 374 AS_TR_SH(wx_cv_use_$1)='$3=sys'
b040e242 375 elif test "$withval" = builtin; then
d970f7d5 376 AS_TR_SH(wx_cv_use_$1)='$3=builtin'
b040e242
VS
377 else
378 AC_MSG_ERROR([Invalid value for --with-$1: should be yes, no, sys, or builtin])
379 fi
8743ec79 380 cache=yes
b040e242
VS
381 ],
382 [
dc6923a5 383 LINE=`grep "^$3=" ${wx_arg_cache_file}`
b040e242 384 if test "x$LINE" != x ; then
8630a814
VZ
385 eval "DEFAULT_$LINE"
386 cache=yes
387 else
388 cache=no
b040e242
VS
389 fi
390
d970f7d5 391 AS_TR_SH(wx_cv_use_$1)='$3=${'DEFAULT_$3":-$wxUSE_ALL_FEATURES}"
b040e242
VS
392 ])
393
d970f7d5 394 eval "$AS_TR_SH(wx_cv_use_$1)"
8743ec79
VZ
395 if test "x$cache" = xyes; then
396 echo "$3=$$3" >> ${wx_arg_cache_file}.tmp
b040e242
VS
397 fi
398
399 if test "$$3" = yes; then
400 AC_MSG_RESULT(yes)
401 elif test "$$3" = no; then
402 AC_MSG_RESULT(no)
403 elif test "$$3" = sys; then
404 AC_MSG_RESULT([system version])
405 elif test "$$3" = builtin; then
406 AC_MSG_RESULT([builtin version])
407 else
408 AC_MSG_ERROR([Invalid value for --with-$1: should be yes, no, sys, or builtin])
409 fi
410 ])
411
412dnl this macro checks for a command line argument and caches the result
1c14217d 413dnl usage: WX_ARG_WITH(option, helpmessage, variable-name, [withstring])
b040e242
VS
414AC_DEFUN([WX_ARG_WITH],
415 [
077c7880 416 withstring=$4
47124ca6
VZ
417 defaultval=$wxUSE_ALL_FEATURES
418 if test -z "$defaultval"; then
419 if test x"$withstring" = xwithout; then
420 defaultval=yes
421 else
422 defaultval=no
423 fi
424 fi
1c14217d 425 AC_MSG_CHECKING([for --${withstring:-with}-$1])
b040e242
VS
426 AC_ARG_WITH($1, [$2],
427 [
428 if test "$withval" = yes; then
d970f7d5 429 AS_TR_SH(wx_cv_use_$1)='$3=yes'
b040e242 430 else
d970f7d5 431 AS_TR_SH(wx_cv_use_$1)='$3=no'
b040e242 432 fi
8743ec79 433 cache=yes
b040e242
VS
434 ],
435 [
dc6923a5 436 LINE=`grep "^$3=" ${wx_arg_cache_file}`
b040e242 437 if test "x$LINE" != x ; then
8630a814
VZ
438 eval "DEFAULT_$LINE"
439 cache=yes
440 else
441 cache=no
b040e242
VS
442 fi
443
47124ca6 444 AS_TR_SH(wx_cv_use_$1)='$3=${'DEFAULT_$3":-$defaultval}"
b040e242
VS
445 ])
446
d970f7d5 447 eval "$AS_TR_SH(wx_cv_use_$1)"
1c2aa6f2 448 if test "x$cache" = xyes; then
8743ec79 449 echo "$3=$$3" >> ${wx_arg_cache_file}.tmp
b040e242
VS
450 fi
451
6e198e97
VZ
452 if test x"$withstring" = xwithout; then
453 if test $$3 = yes; then
454 result=no
455 else
456 result=yes
457 fi
b040e242 458 else
6e198e97 459 result=$$3
b040e242 460 fi
6e198e97
VZ
461
462 AC_MSG_RESULT($result)
b040e242
VS
463 ])
464
6e198e97
VZ
465dnl same as WX_ARG_WITH but makes it clear that the option is enabled by default
466AC_DEFUN([WX_ARG_WITHOUT], [WX_ARG_WITH($1, [$2], $3, without)])
467
b040e242 468dnl like WX_ARG_WITH but uses AC_ARG_ENABLE instead of AC_ARG_WITH
6e198e97 469dnl usage: WX_ARG_ENABLE(option, helpmessage, var, [enablestring], [default])
5005acfe 470dnl
6e198e97
VZ
471dnl enablestring can be omitted or a literal string "disable" and allows to
472dnl show "checking for --disable-foo" message when running configure instead of
473dnl the default "checking for --enable-foo" one whih is useful for the options
474dnl enabled by default
475dnl
476dnl the "default" argument can be omitted or contain the default value to use
477dnl for the option if it's unspecified
b040e242
VS
478AC_DEFUN([WX_ARG_ENABLE],
479 [
077c7880 480 enablestring=$4
6e198e97 481 defaultval=$5
b7ed9e10 482 if test -z "$defaultval"; then
6e198e97
VZ
483 if test x"$enablestring" = xdisable; then
484 defaultval=yes
485 else
486 defaultval=no
487 fi
488 fi
489
5005acfe 490 AC_MSG_CHECKING([for --${enablestring:-enable}-$1])
b040e242
VS
491 AC_ARG_ENABLE($1, [$2],
492 [
493 if test "$enableval" = yes; then
d970f7d5 494 AS_TR_SH(wx_cv_use_$1)='$3=yes'
b040e242 495 else
d970f7d5 496 AS_TR_SH(wx_cv_use_$1)='$3=no'
b040e242 497 fi
8743ec79 498 cache=yes
b040e242
VS
499 ],
500 [
dc6923a5 501 LINE=`grep "^$3=" ${wx_arg_cache_file}`
b040e242 502 if test "x$LINE" != x ; then
8630a814
VZ
503 eval "DEFAULT_$LINE"
504 cache=yes
505 else
506 cache=no
b040e242
VS
507 fi
508
d970f7d5 509 AS_TR_SH(wx_cv_use_$1)='$3=${'DEFAULT_$3":-$defaultval}"
b040e242
VS
510 ])
511
d970f7d5 512 eval "$AS_TR_SH(wx_cv_use_$1)"
8743ec79
VZ
513 if test "x$cache" = xyes; then
514 echo "$3=$$3" >> ${wx_arg_cache_file}.tmp
b040e242
VS
515 fi
516
6e198e97
VZ
517 if test x"$enablestring" = xdisable; then
518 if test $$3 = yes; then
519 result=no
520 else
521 result=yes
522 fi
b040e242 523 else
6e198e97 524 result=$$3
b040e242 525 fi
6e198e97
VZ
526
527 AC_MSG_RESULT($result)
b040e242
VS
528 ])
529
6e198e97
VZ
530dnl the same as WX_ARG_ENABLE but makes it more clear that the option is
531dnl enabled by default
532AC_DEFUN([WX_ARG_DISABLE], [WX_ARG_ENABLE($1, [$2], $3, disable)])
533
534dnl same as WX_ARG_ENABLE but defaults to wxUSE_ALL_FEATURES instead of "yes"
535AC_DEFUN([WX_ARG_FEATURE], [WX_ARG_ENABLE($1, [$2], $3,, $wxUSE_ALL_FEATURES)])
b040e242 536
95768535
MW
537dnl Like WX_ARG_ENABLE but accepts a parameter.
538dnl
539dnl Usage:
540dnl WX_ARG_ENABLE_PARAM(option, helpmessage, variable-name, enablestring)
541dnl
542dnl Example:
543dnl WX_ARG_ENABLE_PARAM(foo, [[ --enable-foo[=bar] use foo]], wxUSE_FOO)
077c7880 544dnl
95768535
MW
545dnl --enable-foo wxUSE_FOO=yes
546dnl --disable-foo wxUSE_FOO=no
547dnl --enable-foo=bar wxUSE_FOO=bar
ca4c9b7e
VS
548dnl <not given> value from configarg.cache or
549dnl wxUSE_FOO=$DEFAULT_wxUSE_FOO
077c7880 550dnl
95768535
MW
551AC_DEFUN([WX_ARG_ENABLE_PARAM],
552 [
553 enablestring=$4
554 AC_MSG_CHECKING([for --${enablestring:-enable}-$1])
95768535
MW
555 AC_ARG_ENABLE($1, [$2],
556 [
557 wx_cv_use_$1="$3='$enableval'"
8743ec79 558 cache=yes
95768535
MW
559 ],
560 [
dc6923a5 561 LINE=`grep "^$3=" ${wx_arg_cache_file}`
95768535
MW
562 if test "x$LINE" != x ; then
563 eval "DEFAULT_$LINE"
8630a814
VZ
564 cache=yes
565 else
566 cache=no
95768535 567 fi
6e198e97 568
ca4c9b7e 569 wx_cv_use_$1='$3='$DEFAULT_$3
95768535
MW
570 ])
571
572 eval "$wx_cv_use_$1"
8743ec79
VZ
573 if test "x$cache" = xyes; then
574 echo "$3=$$3" >> ${wx_arg_cache_file}.tmp
95768535
MW
575 fi
576
577 AC_MSG_RESULT([$$3])
578 ])
579
2b5f62a0
VZ
580dnl ===========================================================================
581dnl Linker features test
582dnl ===========================================================================
583
584dnl ---------------------------------------------------------------------------
585dnl WX_VERSIONED_SYMBOLS checks whether the linker can create versioned
586dnl symbols. If it can, sets LDFLAGS_VERSIONING to $CXX flags needed to use
587dnl version script file named versionfile
588dnl
589dnl call WX_VERSIONED_SYMBOLS(versionfile)
590dnl ---------------------------------------------------------------------------
591AC_DEFUN([WX_VERSIONED_SYMBOLS],
592[
077c7880
VZ
593 case "${host}" in
594 *-*-cygwin* | *-*-mingw* )
595 dnl although ld does support version script option on these
596 dnl platforms, it doesn't make much sense to use it under Win32
597 dnl and, moreover, this breaks linking because of a bug in handling
598 dnl paths in -Wl,--version-script,path option (if we ever do need
599 dnl to use it for cygwin/mingw32, keep in mind that replacing last
600 dnl comma with the equal sign works) so
601 dnl simply disable it
2dbd07cb 602 wx_cv_version_script=no
077c7880
VZ
603 ;;
604
605 *)
606 AC_CACHE_CHECK([if the linker accepts --version-script], wx_cv_version_script,
607 [
608 echo "VER_1 { *; };" >conftest.sym
609 echo "int main() { return 0; }" >conftest.cpp
610
611 if AC_TRY_COMMAND([
612 $CXX -o conftest.output $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.cpp
613 -Wl,--version-script,conftest.sym >/dev/null 2>conftest.stderr]) ; then
614 if test -s conftest.stderr ; then
615 wx_cv_version_script=no
616 else
617 wx_cv_version_script=yes
618 fi
619 else
620 wx_cv_version_script=no
621 fi
622
623 dnl There's a problem in some old linkers with --version-script that
624 dnl can cause linking to fail when you have objects with vtables in
625 dnl libs 3 deep. This is known to happen in netbsd and openbsd with
626 dnl ld 2.11.2.
627 dnl
628 dnl To test for this we need to make some shared libs and
629 dnl unfortunately we can't be sure of the right way to do that. If the
630 dnl first two compiles don't succeed then it looks like the test isn't
631 dnl working and the result is ignored, but if OTOH the first two
632 dnl succeed but the third does not then the bug has been detected and
633 dnl the --version-script flag is dropped.
634 if test $wx_cv_version_script = yes
635 then
636 echo "struct B { virtual ~B() { } }; \
637 struct D : public B { }; \
638 void F() { D d; }" > conftest.cpp
639
640 if AC_TRY_COMMAND([
641 $CXX -shared -fPIC -o conftest1.output $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.cpp
642 -Wl,--version-script,conftest.sym >/dev/null 2>/dev/null]) &&
643 AC_TRY_COMMAND([
644 $CXX -shared -fPIC -o conftest2.output $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.cpp
645 -Wl,--version-script,conftest.sym conftest1.output >/dev/null 2>/dev/null])
646 then
647 if AC_TRY_COMMAND([
648 $CXX -shared -fPIC -o conftest3.output $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.cpp
649 -Wl,--version-script,conftest.sym conftest2.output conftest1.output >/dev/null 2>/dev/null])
650 then
651 wx_cv_version_script=yes
652 else
653 wx_cv_version_script=no
654 fi
655 fi
656 fi
657
658 rm -f conftest.output conftest.stderr conftest.sym conftest.cpp
659 rm -f conftest1.output conftest2.output conftest3.output
660 ])
661
662 if test $wx_cv_version_script = yes ; then
663 LDFLAGS_VERSIONING="-Wl,--version-script,$1"
e5d4b470 664 fi
077c7880
VZ
665 ;;
666 esac
2b5f62a0
VZ
667])
668
b040e242
VS
669
670dnl ===========================================================================
671dnl "3rd party" macros included here because they are not widely available
672dnl ===========================================================================
673
b040e242
VS
674dnl ---------------------------------------------------------------------------
675dnl test for availability of iconv()
676dnl ---------------------------------------------------------------------------
677
b040e242
VS
678dnl From Bruno Haible.
679
680AC_DEFUN([AM_ICONV],
681[
682 dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
683 dnl those with the standalone portable GNU libiconv installed).
684
685 AC_ARG_WITH([libiconv-prefix],
686[ --with-libiconv-prefix=DIR search for libiconv in DIR/include and DIR/lib], [
687 for dir in `echo "$withval" | tr : ' '`; do
688 if test -d $dir/include; then CPPFLAGS="$CPPFLAGS -I$dir/include"; fi
689 if test -d $dir/lib; then LDFLAGS="$LDFLAGS -L$dir/lib"; fi
690 done
691 ])
692
693 AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
694 am_cv_func_iconv="no, consider installing GNU libiconv"
695 am_cv_lib_iconv=no
696 AC_TRY_LINK([#include <stdlib.h>
697#include <iconv.h>],
698 [iconv_t cd = iconv_open("","");
699 iconv(cd,NULL,NULL,NULL,NULL);
700 iconv_close(cd);],
701 am_cv_func_iconv=yes)
702 if test "$am_cv_func_iconv" != yes; then
703 am_save_LIBS="$LIBS"
704 LIBS="$LIBS -liconv"
705 AC_TRY_LINK([#include <stdlib.h>
706#include <iconv.h>],
707 [iconv_t cd = iconv_open("","");
708 iconv(cd,NULL,NULL,NULL,NULL);
709 iconv_close(cd);],
710 am_cv_lib_iconv=yes
711 am_cv_func_iconv=yes)
712 LIBS="$am_save_LIBS"
713 fi
714 ])
715 if test "$am_cv_func_iconv" = yes; then
716 AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
b7043674 717 AC_CACHE_CHECK([if iconv needs const], wx_cv_func_iconv_const,
b040e242
VS
718 AC_TRY_COMPILE([
719#include <stdlib.h>
720#include <iconv.h>
721extern
722#ifdef __cplusplus
723"C"
724#endif
725#if defined(__STDC__) || defined(__cplusplus)
726size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
727#else
728size_t iconv();
729#endif
b7043674
VZ
730 ],
731 [],
732 wx_cv_func_iconv_const="no",
733 wx_cv_func_iconv_const="yes"
734 )
735 )
736
737 iconv_const=
1c405bb5 738 if test "x$wx_cv_func_iconv_const" = "xyes"; then
b7043674
VZ
739 iconv_const="const"
740 fi
741
742 AC_DEFINE_UNQUOTED(ICONV_CONST, $iconv_const,
b040e242
VS
743 [Define as const if the declaration of iconv() needs const.])
744 fi
745 LIBICONV=
746 if test "$am_cv_lib_iconv" = yes; then
747 LIBICONV="-liconv"
748 fi
749 AC_SUBST(LIBICONV)
750])
751
90dd450c
VZ
752dnl ---------------------------------------------------------------------------
753dnl AC_SYS_LARGEFILE (partly based on the code from autoconf 2.5x)
754dnl ---------------------------------------------------------------------------
755
756dnl WX_SYS_LARGEFILE_TEST
757dnl
758dnl NB: original autoconf test was checking if compiler supported 6 bit off_t
759dnl arithmetic properly but this failed miserably with gcc under Linux
760dnl whereas the system still supports 64 bit files, so now simply check
761dnl that off_t is big enough
762define(WX_SYS_LARGEFILE_TEST,
763[typedef struct {
764 unsigned int field: sizeof(off_t) == 8;
765} wxlf;
766])
767
768
769dnl WX_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE, CACHE-VAR)
770define(WX_SYS_LARGEFILE_MACRO_VALUE,
771[
772 AC_CACHE_CHECK([for $1 value needed for large files], [$3],
773 [
774 AC_TRY_COMPILE([#define $1 $2
775 #include <sys/types.h>],
776 WX_SYS_LARGEFILE_TEST,
777 [$3=$2],
778 [$3=no])
779 ]
780 )
781
782 if test "$$3" != no; then
5a5d3c08 783 wx_largefile=yes
90dd450c
VZ
784 AC_DEFINE_UNQUOTED([$1], [$$3])
785 fi
786])
787
788
789dnl AC_SYS_LARGEFILE
790dnl ----------------
791dnl By default, many hosts won't let programs access large files;
792dnl one must use special compiler options to get large-file access to work.
793dnl For more details about this brain damage please see:
794dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
795AC_DEFUN([AC_SYS_LARGEFILE],
796[AC_ARG_ENABLE(largefile,
797 [ --disable-largefile omit support for large files])
798if test "$enable_largefile" != no; then
799 dnl _FILE_OFFSET_BITS==64 is needed for Linux, Solaris, ...
800 dnl _LARGE_FILES -- for AIX
5a5d3c08 801 wx_largefile=no
90dd450c
VZ
802 WX_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS, 64, ac_cv_sys_file_offset_bits)
803 if test "x$wx_largefile" != "xyes"; then
804 WX_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES, 1, ac_cv_sys_large_files)
805 fi
806
5a5d3c08 807 AC_MSG_CHECKING(if large file support is available)
90dd450c
VZ
808 if test "x$wx_largefile" = "xyes"; then
809 AC_DEFINE(HAVE_LARGEFILE_SUPPORT)
810 fi
5a5d3c08 811 AC_MSG_RESULT($wx_largefile)
90dd450c
VZ
812fi
813])
521196a2
MB
814
815
816dnl Available from the GNU Autoconf Macro Archive at:
817dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_const_cast.html
818dnl
819AC_DEFUN([AC_CXX_CONST_CAST],
820[AC_CACHE_CHECK(whether the compiler supports const_cast<>,
821ac_cv_cxx_const_cast,
822[AC_LANG_SAVE
823 AC_LANG_CPLUSPLUS
824 AC_TRY_COMPILE(,[int x = 0;const int& y = x;int& z = const_cast<int&>(y);return z;],
825 ac_cv_cxx_const_cast=yes, ac_cv_cxx_const_cast=no)
826 AC_LANG_RESTORE
827])
828if test "$ac_cv_cxx_const_cast" = yes; then
829 AC_DEFINE(HAVE_CONST_CAST,,[define if the compiler supports const_cast<>])
830fi
831])
ecfd48ca 832
4eeb39ab
VZ
833dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_reinterpret_cast.html
834AC_DEFUN([AC_CXX_REINTERPRET_CAST],
835[AC_CACHE_CHECK(whether the compiler supports reinterpret_cast<>,
836ac_cv_cxx_reinterpret_cast,
837[AC_LANG_SAVE
838 AC_LANG_CPLUSPLUS
839 AC_TRY_COMPILE([#include <typeinfo>
840class Base { public : Base () {} virtual void f () = 0;};
841class Derived : public Base { public : Derived () {} virtual void f () {} };
842class Unrelated { public : Unrelated () {} };
843int g (Unrelated&) { return 0; }],[
844Derived d;Base& b=d;Unrelated& e=reinterpret_cast<Unrelated&>(b);return g(e);],
845 ac_cv_cxx_reinterpret_cast=yes, ac_cv_cxx_reinterpret_cast=no)
846 AC_LANG_RESTORE
847])
848if test "$ac_cv_cxx_reinterpret_cast" = yes; then
849 AC_DEFINE(HAVE_REINTERPRET_CAST,,
850 [define if the compiler supports reinterpret_cast<>])
851fi
852])
853
ecfd48ca
VZ
854dnl and http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_static_cast.html
855AC_DEFUN([AC_CXX_STATIC_CAST],
856[AC_CACHE_CHECK(whether the compiler supports static_cast<>,
857ac_cv_cxx_static_cast,
858[AC_LANG_SAVE
859 AC_LANG_CPLUSPLUS
860 AC_TRY_COMPILE([#include <typeinfo>
861class Base { public : Base () {} virtual void f () = 0; };
862class Derived : public Base { public : Derived () {} virtual void f () {} };
863int g (Derived&) { return 0; }],[
864Derived d; Base& b = d; Derived& s = static_cast<Derived&> (b); return g (s);],
865 ac_cv_cxx_static_cast=yes, ac_cv_cxx_static_cast=no)
866 AC_LANG_RESTORE
867])
868if test "$ac_cv_cxx_static_cast" = yes; then
869 AC_DEFINE(HAVE_STATIC_CAST,, [define if the compiler supports static_cast<>])
870fi
871])
d1150ea7
VZ
872
873dnl http://autoconf-archive.cryp.to/ac_cxx_dynamic_cast.html
874AC_DEFUN([AC_CXX_DYNAMIC_CAST],
875[AC_CACHE_CHECK(whether the compiler supports dynamic_cast<>,
876ac_cv_cxx_dynamic_cast,
877[AC_LANG_SAVE
878 AC_LANG_CPLUSPLUS
879 AC_TRY_COMPILE([#include <typeinfo>
880class Base { public : Base () {} virtual void f () = 0;};
881class Derived : public Base { public : Derived () {} virtual void f () {} };],[
882Derived d; Base& b=d; return dynamic_cast<Derived*>(&b) ? 0 : 1;],
883 ac_cv_cxx_dynamic_cast=yes, ac_cv_cxx_dynamic_cast=no)
884 AC_LANG_RESTORE
885])
886if test "$ac_cv_cxx_dynamic_cast" = yes; then
887 AC_DEFINE(HAVE_DYNAMIC_CAST,,[define if the compiler supports dynamic_cast<>])
888fi
889])
890