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