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