]> git.saurik.com Git - wxWidgets.git/blame - acinclude.m4
document the wxWindow::Get/SetLayoutDirection functions
[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
986ecc86
VZ
146dnl ---------------------------------------------------------------------------
147dnl WX_CPP_EXPLICIT checks whether the C++ compiler support the explicit
148dnl keyword and defines HAVE_EXPLICIT if this is the case
149dnl ---------------------------------------------------------------------------
150
151AC_DEFUN([WX_CPP_EXPLICIT],
152[
153 AC_CACHE_CHECK([if C++ compiler supports the explicit keyword],
154 wx_cv_explicit,
155 [
156 AC_LANG_SAVE
157 AC_LANG_CPLUSPLUS
158
159 dnl do the test in 2 steps: first check that the compiler knows about the
160 dnl explicit keyword at all and then verify that it really honours it
161 AC_TRY_COMPILE(
162 [
163 class Foo { public: explicit Foo(int) {} };
164 ],
165 [
166 return 0;
167 ],
168 [
169 AC_TRY_COMPILE(
170 [
171 class Foo { public: explicit Foo(int) {} };
172 static void TakeFoo(const Foo& foo) { }
173 ],
174 [
175 TakeFoo(17);
176 return 0;
177 ],
178 wx_cv_explicit=no,
179 wx_cv_explicit=yes
180 )
181 ],
182 wx_cv_explicit=no
183 )
184
185 AC_LANG_RESTORE
186 ])
187
188 if test "$wx_cv_explicit" = "yes"; then
189 AC_DEFINE(HAVE_EXPLICIT)
190 fi
191])
192
040b3497
MW
193dnl ---------------------------------------------------------------------------
194dnl WX_CHECK_FUNCS(FUNCTIONS...,
195dnl [ACTION-IF-FOUND],
196dnl [ACTION-IF-NOT-FOUND],
197dnl [EXTRA-DEFINES-AND-INCLUDES],
198dnl [EXTRA-TEST-CODE])
199dnl
200dnl Checks that the functions listed in FUNCTIONS exist in the headers and the
201dnl libs. For each function, if it is found then defines 'HAVE_FUNCTION' and
202dnl executes ACTION-IF-FOUND, otherwise executes ACTION-IF-NOT-FOUND.
203dnl
204dnl The code from EXTRA-DEFINES-AND-INCLUDES is inserted into the test before
205dnl the default headers are included, and EXTRA-TEST-CODE is inserted into
206dnl the main() function after the default test for existence.
207dnl
208dnl Examples:
209dnl # the simple case
210dnl WX_CHECK_FUNCS(stat)
211dnl # use break to finish the loop early
212dnl WX_CHECK_FUNCS(mkstemp mktemp, break)
213dnl # extra defines
214dnl WX_CHECK_FUNCS(strtok_r, [], [], [#define _RREENTRANT])
215dnl # extra includes
216dnl WX_CHECK_FUNCS(swprintf, [], [], [#include <wchar.h>])
217dnl # checking the signature with extra test code
218dnl WX_CHECK_FUNCS(gettimeofday, [], [], [#include <sys/time.h>]
219dnl [struct timeval tv; struct timezone tz; gettimeofday(&tv, &tz)])
220dnl ---------------------------------------------------------------------------
221
222AC_DEFUN([WX_CHECK_FUNCS],
223[
224 for wx_func in $1
225 do
226 AC_CACHE_CHECK(
227 [for $wx_func],
228 [wx_cv_func_$wx_func],
229 [
230 AC_LINK_IFELSE(
231 [
232 AC_LANG_PROGRAM(
233 [
234 $4
235 AC_INCLUDES_DEFAULT
236 ],
237 [
238 #ifndef $wx_func
239 &$wx_func;
240 #endif
241 $5
242 ])
243 ],
244 [eval wx_cv_func_$wx_func=yes],
245 [eval wx_cv_func_$wx_func=no])
246 ])
247
248 if eval test \$wx_cv_func_$wx_func = yes
249 then
1ad9ba14 250 AC_DEFINE_UNQUOTED([AS_TR_CPP([HAVE_$wx_func])])
040b3497
MW
251 $2
252 else
253 :
254 $3
255 fi
256 done
257])
258
b040e242
VS
259dnl ---------------------------------------------------------------------------
260dnl a slightly better AC_C_BIGENDIAN macro which allows cross-compiling
261dnl ---------------------------------------------------------------------------
262
263AC_DEFUN([WX_C_BIGENDIAN],
264[AC_CACHE_CHECK([whether byte ordering is bigendian], ac_cv_c_bigendian,
265[ac_cv_c_bigendian=unknown
266# See if sys/param.h defines the BYTE_ORDER macro.
267AC_TRY_COMPILE([#include <sys/types.h>
268#include <sys/param.h>], [
269#if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
270 bogus endian macros
271#endif], [# It does; now see whether it defined to BIG_ENDIAN or not.
272AC_TRY_COMPILE([#include <sys/types.h>
273#include <sys/param.h>], [
274#if BYTE_ORDER != BIG_ENDIAN
275 not big endian
276#endif], ac_cv_c_bigendian=yes, ac_cv_c_bigendian=no)])
277if test $ac_cv_c_bigendian = unknown; then
278AC_TRY_RUN([main () {
279 /* Are we little or big endian? From Harbison&Steele. */
280 union
281 {
282 long l;
283 char c[sizeof (long)];
284 } u;
285 u.l = 1;
286 exit (u.c[sizeof (long) - 1] == 1);
287}], [ac_cv_c_bigendian=no], [ac_cv_c_bigendian=yes], [ac_cv_c_bigendian=unknown])
288fi])
289if test $ac_cv_c_bigendian = unknown; then
290 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])
291fi
292if test $ac_cv_c_bigendian = yes; then
293 AC_DEFINE(WORDS_BIGENDIAN)
294fi
295])
296
297dnl ---------------------------------------------------------------------------
8d7a7fe2 298dnl override AC_ARG_ENABLE/WITH to handle options defaults
b040e242
VS
299dnl ---------------------------------------------------------------------------
300
b040e242
VS
301dnl this macro checks for a three-valued command line --with argument:
302dnl possible arguments are 'yes', 'no', 'sys', or 'builtin'
303dnl usage: WX_ARG_SYS_WITH(option, helpmessage, variable-name)
6e198e97
VZ
304dnl
305dnl the default value (used if the option is not specified at all) is the value
306dnl of wxUSE_ALL_FEATURES (which is "yes" by default but can be changed by
307dnl giving configure --disable-all-features option)
b040e242
VS
308AC_DEFUN([WX_ARG_SYS_WITH],
309 [
310 AC_MSG_CHECKING([for --with-$1])
b040e242
VS
311 AC_ARG_WITH($1, [$2],
312 [
313 if test "$withval" = yes; then
d970f7d5 314 AS_TR_SH(wx_cv_use_$1)='$3=yes'
b040e242 315 elif test "$withval" = no; then
d970f7d5 316 AS_TR_SH(wx_cv_use_$1)='$3=no'
b040e242 317 elif test "$withval" = sys; then
d970f7d5 318 AS_TR_SH(wx_cv_use_$1)='$3=sys'
b040e242 319 elif test "$withval" = builtin; then
d970f7d5 320 AS_TR_SH(wx_cv_use_$1)='$3=builtin'
b040e242
VS
321 else
322 AC_MSG_ERROR([Invalid value for --with-$1: should be yes, no, sys, or builtin])
323 fi
324 ],
325 [
d970f7d5 326 AS_TR_SH(wx_cv_use_$1)='$3=${'DEFAULT_$3":-$wxUSE_ALL_FEATURES}"
b040e242
VS
327 ])
328
d970f7d5 329 eval "$AS_TR_SH(wx_cv_use_$1)"
b040e242
VS
330
331 if test "$$3" = yes; then
332 AC_MSG_RESULT(yes)
333 elif test "$$3" = no; then
334 AC_MSG_RESULT(no)
335 elif test "$$3" = sys; then
336 AC_MSG_RESULT([system version])
337 elif test "$$3" = builtin; then
338 AC_MSG_RESULT([builtin version])
339 else
340 AC_MSG_ERROR([Invalid value for --with-$1: should be yes, no, sys, or builtin])
341 fi
342 ])
343
8d7a7fe2 344dnl this macro simply checks for a command line argument
1c14217d 345dnl usage: WX_ARG_WITH(option, helpmessage, variable-name, [withstring])
b040e242
VS
346AC_DEFUN([WX_ARG_WITH],
347 [
077c7880 348 withstring=$4
47124ca6
VZ
349 defaultval=$wxUSE_ALL_FEATURES
350 if test -z "$defaultval"; then
351 if test x"$withstring" = xwithout; then
352 defaultval=yes
353 else
354 defaultval=no
355 fi
356 fi
1c14217d 357 AC_MSG_CHECKING([for --${withstring:-with}-$1])
b040e242
VS
358 AC_ARG_WITH($1, [$2],
359 [
360 if test "$withval" = yes; then
d970f7d5 361 AS_TR_SH(wx_cv_use_$1)='$3=yes'
b040e242 362 else
d970f7d5 363 AS_TR_SH(wx_cv_use_$1)='$3=no'
b040e242
VS
364 fi
365 ],
366 [
47124ca6 367 AS_TR_SH(wx_cv_use_$1)='$3=${'DEFAULT_$3":-$defaultval}"
b040e242
VS
368 ])
369
d970f7d5 370 eval "$AS_TR_SH(wx_cv_use_$1)"
b040e242 371
6e198e97
VZ
372 if test x"$withstring" = xwithout; then
373 if test $$3 = yes; then
374 result=no
375 else
376 result=yes
377 fi
b040e242 378 else
6e198e97 379 result=$$3
b040e242 380 fi
6e198e97
VZ
381
382 AC_MSG_RESULT($result)
b040e242
VS
383 ])
384
6e198e97
VZ
385dnl same as WX_ARG_WITH but makes it clear that the option is enabled by default
386AC_DEFUN([WX_ARG_WITHOUT], [WX_ARG_WITH($1, [$2], $3, without)])
387
b040e242 388dnl like WX_ARG_WITH but uses AC_ARG_ENABLE instead of AC_ARG_WITH
6e198e97 389dnl usage: WX_ARG_ENABLE(option, helpmessage, var, [enablestring], [default])
5005acfe 390dnl
6e198e97
VZ
391dnl enablestring can be omitted or a literal string "disable" and allows to
392dnl show "checking for --disable-foo" message when running configure instead of
393dnl the default "checking for --enable-foo" one whih is useful for the options
394dnl enabled by default
395dnl
396dnl the "default" argument can be omitted or contain the default value to use
397dnl for the option if it's unspecified
b040e242
VS
398AC_DEFUN([WX_ARG_ENABLE],
399 [
077c7880 400 enablestring=$4
6e198e97 401 defaultval=$5
b7ed9e10 402 if test -z "$defaultval"; then
6e198e97
VZ
403 if test x"$enablestring" = xdisable; then
404 defaultval=yes
405 else
406 defaultval=no
407 fi
408 fi
409
5005acfe 410 AC_MSG_CHECKING([for --${enablestring:-enable}-$1])
b040e242
VS
411 AC_ARG_ENABLE($1, [$2],
412 [
413 if test "$enableval" = yes; then
d970f7d5 414 AS_TR_SH(wx_cv_use_$1)='$3=yes'
b040e242 415 else
d970f7d5 416 AS_TR_SH(wx_cv_use_$1)='$3=no'
b040e242
VS
417 fi
418 ],
419 [
d970f7d5 420 AS_TR_SH(wx_cv_use_$1)='$3=${'DEFAULT_$3":-$defaultval}"
b040e242
VS
421 ])
422
d970f7d5 423 eval "$AS_TR_SH(wx_cv_use_$1)"
b040e242 424
6e198e97
VZ
425 if test x"$enablestring" = xdisable; then
426 if test $$3 = yes; then
427 result=no
428 else
429 result=yes
430 fi
b040e242 431 else
6e198e97 432 result=$$3
b040e242 433 fi
6e198e97
VZ
434
435 AC_MSG_RESULT($result)
b040e242
VS
436 ])
437
6e198e97
VZ
438dnl the same as WX_ARG_ENABLE but makes it more clear that the option is
439dnl enabled by default
440AC_DEFUN([WX_ARG_DISABLE], [WX_ARG_ENABLE($1, [$2], $3, disable)])
441
442dnl same as WX_ARG_ENABLE but defaults to wxUSE_ALL_FEATURES instead of "yes"
443AC_DEFUN([WX_ARG_FEATURE], [WX_ARG_ENABLE($1, [$2], $3,, $wxUSE_ALL_FEATURES)])
b040e242 444
95768535
MW
445dnl Like WX_ARG_ENABLE but accepts a parameter.
446dnl
447dnl Usage:
448dnl WX_ARG_ENABLE_PARAM(option, helpmessage, variable-name, enablestring)
449dnl
450dnl Example:
451dnl WX_ARG_ENABLE_PARAM(foo, [[ --enable-foo[=bar] use foo]], wxUSE_FOO)
077c7880 452dnl
95768535
MW
453dnl --enable-foo wxUSE_FOO=yes
454dnl --disable-foo wxUSE_FOO=no
455dnl --enable-foo=bar wxUSE_FOO=bar
8d7a7fe2 456dnl <not given> wxUSE_FOO=$DEFAULT_wxUSE_FOO
077c7880 457dnl
95768535
MW
458AC_DEFUN([WX_ARG_ENABLE_PARAM],
459 [
460 enablestring=$4
461 AC_MSG_CHECKING([for --${enablestring:-enable}-$1])
95768535
MW
462 AC_ARG_ENABLE($1, [$2],
463 [
464 wx_cv_use_$1="$3='$enableval'"
465 ],
466 [
ca4c9b7e 467 wx_cv_use_$1='$3='$DEFAULT_$3
95768535
MW
468 ])
469
470 eval "$wx_cv_use_$1"
95768535
MW
471
472 AC_MSG_RESULT([$$3])
473 ])
474
2b5f62a0
VZ
475dnl ===========================================================================
476dnl Linker features test
477dnl ===========================================================================
478
479dnl ---------------------------------------------------------------------------
480dnl WX_VERSIONED_SYMBOLS checks whether the linker can create versioned
481dnl symbols. If it can, sets LDFLAGS_VERSIONING to $CXX flags needed to use
482dnl version script file named versionfile
483dnl
484dnl call WX_VERSIONED_SYMBOLS(versionfile)
485dnl ---------------------------------------------------------------------------
486AC_DEFUN([WX_VERSIONED_SYMBOLS],
487[
077c7880
VZ
488 case "${host}" in
489 *-*-cygwin* | *-*-mingw* )
490 dnl although ld does support version script option on these
491 dnl platforms, it doesn't make much sense to use it under Win32
492 dnl and, moreover, this breaks linking because of a bug in handling
493 dnl paths in -Wl,--version-script,path option (if we ever do need
494 dnl to use it for cygwin/mingw32, keep in mind that replacing last
495 dnl comma with the equal sign works) so
496 dnl simply disable it
2dbd07cb 497 wx_cv_version_script=no
077c7880
VZ
498 ;;
499
500 *)
501 AC_CACHE_CHECK([if the linker accepts --version-script], wx_cv_version_script,
502 [
503 echo "VER_1 { *; };" >conftest.sym
504 echo "int main() { return 0; }" >conftest.cpp
505
506 if AC_TRY_COMMAND([
507 $CXX -o conftest.output $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.cpp
508 -Wl,--version-script,conftest.sym >/dev/null 2>conftest.stderr]) ; then
509 if test -s conftest.stderr ; then
510 wx_cv_version_script=no
511 else
512 wx_cv_version_script=yes
513 fi
514 else
515 wx_cv_version_script=no
516 fi
517
518 dnl There's a problem in some old linkers with --version-script that
519 dnl can cause linking to fail when you have objects with vtables in
520 dnl libs 3 deep. This is known to happen in netbsd and openbsd with
521 dnl ld 2.11.2.
522 dnl
523 dnl To test for this we need to make some shared libs and
524 dnl unfortunately we can't be sure of the right way to do that. If the
525 dnl first two compiles don't succeed then it looks like the test isn't
526 dnl working and the result is ignored, but if OTOH the first two
527 dnl succeed but the third does not then the bug has been detected and
528 dnl the --version-script flag is dropped.
529 if test $wx_cv_version_script = yes
530 then
531 echo "struct B { virtual ~B() { } }; \
532 struct D : public B { }; \
533 void F() { D d; }" > conftest.cpp
534
535 if AC_TRY_COMMAND([
536 $CXX -shared -fPIC -o conftest1.output $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.cpp
537 -Wl,--version-script,conftest.sym >/dev/null 2>/dev/null]) &&
538 AC_TRY_COMMAND([
539 $CXX -shared -fPIC -o conftest2.output $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.cpp
540 -Wl,--version-script,conftest.sym conftest1.output >/dev/null 2>/dev/null])
541 then
542 if AC_TRY_COMMAND([
543 $CXX -shared -fPIC -o conftest3.output $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.cpp
544 -Wl,--version-script,conftest.sym conftest2.output conftest1.output >/dev/null 2>/dev/null])
545 then
546 wx_cv_version_script=yes
547 else
548 wx_cv_version_script=no
549 fi
550 fi
551 fi
552
553 rm -f conftest.output conftest.stderr conftest.sym conftest.cpp
554 rm -f conftest1.output conftest2.output conftest3.output
555 ])
556
557 if test $wx_cv_version_script = yes ; then
558 LDFLAGS_VERSIONING="-Wl,--version-script,$1"
e5d4b470 559 fi
077c7880
VZ
560 ;;
561 esac
2b5f62a0
VZ
562])
563
b040e242
VS
564
565dnl ===========================================================================
566dnl "3rd party" macros included here because they are not widely available
567dnl ===========================================================================
568
b040e242
VS
569dnl ---------------------------------------------------------------------------
570dnl test for availability of iconv()
571dnl ---------------------------------------------------------------------------
572
b040e242
VS
573dnl From Bruno Haible.
574
575AC_DEFUN([AM_ICONV],
576[
577 dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
578 dnl those with the standalone portable GNU libiconv installed).
579
580 AC_ARG_WITH([libiconv-prefix],
581[ --with-libiconv-prefix=DIR search for libiconv in DIR/include and DIR/lib], [
582 for dir in `echo "$withval" | tr : ' '`; do
583 if test -d $dir/include; then CPPFLAGS="$CPPFLAGS -I$dir/include"; fi
584 if test -d $dir/lib; then LDFLAGS="$LDFLAGS -L$dir/lib"; fi
585 done
586 ])
587
588 AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
589 am_cv_func_iconv="no, consider installing GNU libiconv"
590 am_cv_lib_iconv=no
591 AC_TRY_LINK([#include <stdlib.h>
592#include <iconv.h>],
593 [iconv_t cd = iconv_open("","");
594 iconv(cd,NULL,NULL,NULL,NULL);
595 iconv_close(cd);],
596 am_cv_func_iconv=yes)
597 if test "$am_cv_func_iconv" != yes; then
598 am_save_LIBS="$LIBS"
599 LIBS="$LIBS -liconv"
600 AC_TRY_LINK([#include <stdlib.h>
601#include <iconv.h>],
602 [iconv_t cd = iconv_open("","");
603 iconv(cd,NULL,NULL,NULL,NULL);
604 iconv_close(cd);],
605 am_cv_lib_iconv=yes
606 am_cv_func_iconv=yes)
607 LIBS="$am_save_LIBS"
608 fi
609 ])
610 if test "$am_cv_func_iconv" = yes; then
611 AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
b7043674 612 AC_CACHE_CHECK([if iconv needs const], wx_cv_func_iconv_const,
b040e242
VS
613 AC_TRY_COMPILE([
614#include <stdlib.h>
615#include <iconv.h>
616extern
617#ifdef __cplusplus
618"C"
619#endif
620#if defined(__STDC__) || defined(__cplusplus)
621size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
622#else
623size_t iconv();
624#endif
b7043674
VZ
625 ],
626 [],
627 wx_cv_func_iconv_const="no",
628 wx_cv_func_iconv_const="yes"
629 )
630 )
631
632 iconv_const=
1c405bb5 633 if test "x$wx_cv_func_iconv_const" = "xyes"; then
b7043674
VZ
634 iconv_const="const"
635 fi
636
637 AC_DEFINE_UNQUOTED(ICONV_CONST, $iconv_const,
b040e242
VS
638 [Define as const if the declaration of iconv() needs const.])
639 fi
640 LIBICONV=
641 if test "$am_cv_lib_iconv" = yes; then
642 LIBICONV="-liconv"
643 fi
644 AC_SUBST(LIBICONV)
645])
646
90dd450c
VZ
647dnl ---------------------------------------------------------------------------
648dnl AC_SYS_LARGEFILE (partly based on the code from autoconf 2.5x)
649dnl ---------------------------------------------------------------------------
650
651dnl WX_SYS_LARGEFILE_TEST
652dnl
653dnl NB: original autoconf test was checking if compiler supported 6 bit off_t
654dnl arithmetic properly but this failed miserably with gcc under Linux
655dnl whereas the system still supports 64 bit files, so now simply check
656dnl that off_t is big enough
657define(WX_SYS_LARGEFILE_TEST,
658[typedef struct {
659 unsigned int field: sizeof(off_t) == 8;
660} wxlf;
661])
662
663
664dnl WX_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE, CACHE-VAR)
665define(WX_SYS_LARGEFILE_MACRO_VALUE,
666[
667 AC_CACHE_CHECK([for $1 value needed for large files], [$3],
668 [
669 AC_TRY_COMPILE([#define $1 $2
670 #include <sys/types.h>],
671 WX_SYS_LARGEFILE_TEST,
672 [$3=$2],
673 [$3=no])
674 ]
675 )
676
677 if test "$$3" != no; then
5a5d3c08 678 wx_largefile=yes
90dd450c
VZ
679 AC_DEFINE_UNQUOTED([$1], [$$3])
680 fi
681])
682
683
684dnl AC_SYS_LARGEFILE
685dnl ----------------
686dnl By default, many hosts won't let programs access large files;
687dnl one must use special compiler options to get large-file access to work.
688dnl For more details about this brain damage please see:
689dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
690AC_DEFUN([AC_SYS_LARGEFILE],
691[AC_ARG_ENABLE(largefile,
692 [ --disable-largefile omit support for large files])
693if test "$enable_largefile" != no; then
694 dnl _FILE_OFFSET_BITS==64 is needed for Linux, Solaris, ...
695 dnl _LARGE_FILES -- for AIX
5a5d3c08 696 wx_largefile=no
90dd450c
VZ
697 WX_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS, 64, ac_cv_sys_file_offset_bits)
698 if test "x$wx_largefile" != "xyes"; then
699 WX_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES, 1, ac_cv_sys_large_files)
700 fi
701
5a5d3c08 702 AC_MSG_CHECKING(if large file support is available)
90dd450c
VZ
703 if test "x$wx_largefile" = "xyes"; then
704 AC_DEFINE(HAVE_LARGEFILE_SUPPORT)
705 fi
5a5d3c08 706 AC_MSG_RESULT($wx_largefile)
90dd450c
VZ
707fi
708])
521196a2 709