]> git.saurik.com Git - wxWidgets.git/blame - acinclude.m4
bug fix & carbon support
[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
11dnl ===========================================================================
12dnl macros to find the a file in the list of include/lib paths
13dnl ===========================================================================
14
15dnl ---------------------------------------------------------------------------
16dnl call WX_PATH_FIND_INCLUDES(search path, header name), sets ac_find_includes
17dnl to the full name of the file that was found or leaves it empty if not found
18dnl ---------------------------------------------------------------------------
19AC_DEFUN([WX_PATH_FIND_INCLUDES],
20[
21ac_find_includes=
2b5f62a0 22for ac_dir in $1 /usr/include;
b040e242
VS
23 do
24 if test -f "$ac_dir/$2"; then
25 ac_find_includes=$ac_dir
26 break
27 fi
28 done
29])
30
31dnl ---------------------------------------------------------------------------
32dnl call WX_PATH_FIND_LIBRARIES(search path, header name), sets ac_find_libraries
33dnl to the full name of the file that was found or leaves it empty if not found
34dnl ---------------------------------------------------------------------------
35AC_DEFUN([WX_PATH_FIND_LIBRARIES],
36[
37ac_find_libraries=
2b5f62a0 38for ac_dir in $1 /usr/lib;
b040e242
VS
39 do
40 for ac_extension in a so sl dylib; do
41 if test -f "$ac_dir/lib$2.$ac_extension"; then
42 ac_find_libraries=$ac_dir
43 break 2
44 fi
45 done
46 done
47])
48
49dnl ---------------------------------------------------------------------------
50dnl Path to include, already defined
51dnl ---------------------------------------------------------------------------
52AC_DEFUN([WX_INCLUDE_PATH_EXIST],
53[
2b5f62a0
VZ
54 dnl never add -I/usr/include to the CPPFLAGS
55 if test "x$1" = "x/usr/include"; then
b040e242
VS
56 ac_path_to_include=""
57 else
2b5f62a0
VZ
58 echo "$2" | grep "\-I$1" > /dev/null
59 result=$?
60 if test $result = 0; then
61 ac_path_to_include=""
62 else
63 ac_path_to_include=" -I$1"
64 fi
b040e242
VS
65 fi
66])
67
68dnl ---------------------------------------------------------------------------
69dnl Path to link, already defined
70dnl ---------------------------------------------------------------------------
71AC_DEFUN([WX_LINK_PATH_EXIST],
72[
73 echo "$2" | grep "\-L$1" > /dev/null
74 result=$?
75 if test $result = 0; then
76 ac_path_to_link=""
77 else
78 ac_path_to_link=" -L$1"
79 fi
80])
81
82dnl ===========================================================================
83dnl C++ features test
84dnl ===========================================================================
85
86dnl ---------------------------------------------------------------------------
87dnl WX_CPP_NEW_HEADERS checks whether the compiler has "new" <iostream> header
88dnl or only the old <iostream.h> one - it may be generally assumed that if
89dnl <iostream> exists, the other "new" headers (without .h) exist too.
90dnl
91dnl call WX_CPP_NEW_HEADERS(actiof-if-true, action-if-false-or-cross-compiling)
92dnl ---------------------------------------------------------------------------
93
94AC_DEFUN([WX_CPP_NEW_HEADERS],
95[
96 if test "$cross_compiling" = "yes"; then
97 ifelse([$2], , :, [$2])
98 else
99 AC_LANG_SAVE
100 AC_LANG_CPLUSPLUS
101
102 AC_CHECK_HEADERS(iostream)
103
104 if test "$ac_cv_header_iostream" = "yes" ; then
105 ifelse([$1], , :, [$1])
106 else
107 ifelse([$2], , :, [$2])
108 fi
109
110 AC_LANG_RESTORE
111 fi
112])
113
114dnl ---------------------------------------------------------------------------
115dnl WX_CPP_BOOL checks whether the C++ compiler has a built in bool type
116dnl
117dnl call WX_CPP_BOOL - will define HAVE_BOOL if the compiler supports bool
118dnl ---------------------------------------------------------------------------
119
120AC_DEFUN([WX_CPP_BOOL],
121[
122 AC_CACHE_CHECK([if C++ compiler supports bool], wx_cv_cpp_bool,
123 [
124 AC_LANG_SAVE
125 AC_LANG_CPLUSPLUS
126
127 AC_TRY_COMPILE(
128 [
129 ],
130 [
131 bool b = true;
132
133 return 0;
134 ],
135 [
136 wx_cv_cpp_bool=yes
137 ],
138 [
139 wx_cv_cpp_bool=no
140 ]
141 )
142
143 AC_LANG_RESTORE
144 ])
145
146 if test "$wx_cv_cpp_bool" = "yes"; then
147 AC_DEFINE(HAVE_BOOL)
148 fi
149])
150
986ecc86
VZ
151dnl ---------------------------------------------------------------------------
152dnl WX_CPP_EXPLICIT checks whether the C++ compiler support the explicit
153dnl keyword and defines HAVE_EXPLICIT if this is the case
154dnl ---------------------------------------------------------------------------
155
156AC_DEFUN([WX_CPP_EXPLICIT],
157[
158 AC_CACHE_CHECK([if C++ compiler supports the explicit keyword],
159 wx_cv_explicit,
160 [
161 AC_LANG_SAVE
162 AC_LANG_CPLUSPLUS
163
164 dnl do the test in 2 steps: first check that the compiler knows about the
165 dnl explicit keyword at all and then verify that it really honours it
166 AC_TRY_COMPILE(
167 [
168 class Foo { public: explicit Foo(int) {} };
169 ],
170 [
171 return 0;
172 ],
173 [
174 AC_TRY_COMPILE(
175 [
176 class Foo { public: explicit Foo(int) {} };
177 static void TakeFoo(const Foo& foo) { }
178 ],
179 [
180 TakeFoo(17);
181 return 0;
182 ],
183 wx_cv_explicit=no,
184 wx_cv_explicit=yes
185 )
186 ],
187 wx_cv_explicit=no
188 )
189
190 AC_LANG_RESTORE
191 ])
192
193 if test "$wx_cv_explicit" = "yes"; then
194 AC_DEFINE(HAVE_EXPLICIT)
195 fi
196])
197
b040e242
VS
198dnl ---------------------------------------------------------------------------
199dnl a slightly better AC_C_BIGENDIAN macro which allows cross-compiling
200dnl ---------------------------------------------------------------------------
201
202AC_DEFUN([WX_C_BIGENDIAN],
203[AC_CACHE_CHECK([whether byte ordering is bigendian], ac_cv_c_bigendian,
204[ac_cv_c_bigendian=unknown
205# See if sys/param.h defines the BYTE_ORDER macro.
206AC_TRY_COMPILE([#include <sys/types.h>
207#include <sys/param.h>], [
208#if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
209 bogus endian macros
210#endif], [# It does; now see whether it defined to BIG_ENDIAN or not.
211AC_TRY_COMPILE([#include <sys/types.h>
212#include <sys/param.h>], [
213#if BYTE_ORDER != BIG_ENDIAN
214 not big endian
215#endif], ac_cv_c_bigendian=yes, ac_cv_c_bigendian=no)])
216if test $ac_cv_c_bigendian = unknown; then
217AC_TRY_RUN([main () {
218 /* Are we little or big endian? From Harbison&Steele. */
219 union
220 {
221 long l;
222 char c[sizeof (long)];
223 } u;
224 u.l = 1;
225 exit (u.c[sizeof (long) - 1] == 1);
226}], [ac_cv_c_bigendian=no], [ac_cv_c_bigendian=yes], [ac_cv_c_bigendian=unknown])
227fi])
228if test $ac_cv_c_bigendian = unknown; then
229 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])
230fi
231if test $ac_cv_c_bigendian = yes; then
232 AC_DEFINE(WORDS_BIGENDIAN)
233fi
234])
235
236dnl ---------------------------------------------------------------------------
237dnl override AC_ARG_ENABLE/WITH to cache the results in .cache file
238dnl ---------------------------------------------------------------------------
239
240AC_DEFUN([WX_ARG_CACHE_INIT],
241 [
242 wx_arg_cache_file="configarg.cache"
243 echo "loading argument cache $wx_arg_cache_file"
244 rm -f ${wx_arg_cache_file}.tmp
245 touch ${wx_arg_cache_file}.tmp
246 touch ${wx_arg_cache_file}
247 ])
248
249AC_DEFUN([WX_ARG_CACHE_FLUSH],
250 [
251 echo "saving argument cache $wx_arg_cache_file"
252 mv ${wx_arg_cache_file}.tmp ${wx_arg_cache_file}
253 ])
254
255dnl this macro checks for a three-valued command line --with argument:
256dnl possible arguments are 'yes', 'no', 'sys', or 'builtin'
257dnl usage: WX_ARG_SYS_WITH(option, helpmessage, variable-name)
258AC_DEFUN([WX_ARG_SYS_WITH],
259 [
260 AC_MSG_CHECKING([for --with-$1])
261 no_cache=0
262 AC_ARG_WITH($1, [$2],
263 [
264 if test "$withval" = yes; then
265 ac_cv_use_$1='$3=yes'
266 elif test "$withval" = no; then
267 ac_cv_use_$1='$3=no'
268 elif test "$withval" = sys; then
269 ac_cv_use_$1='$3=sys'
270 elif test "$withval" = builtin; then
271 ac_cv_use_$1='$3=builtin'
272 else
273 AC_MSG_ERROR([Invalid value for --with-$1: should be yes, no, sys, or builtin])
274 fi
275 ],
276 [
277 LINE=`grep "$3" ${wx_arg_cache_file}`
278 if test "x$LINE" != x ; then
279 eval "DEFAULT_$LINE"
280 else
281 no_cache=1
282 fi
283
284 ac_cv_use_$1='$3='$DEFAULT_$3
285 ])
286
287 eval "$ac_cv_use_$1"
288 if test "$no_cache" != 1; then
289 echo $ac_cv_use_$1 >> ${wx_arg_cache_file}.tmp
290 fi
291
292 if test "$$3" = yes; then
293 AC_MSG_RESULT(yes)
294 elif test "$$3" = no; then
295 AC_MSG_RESULT(no)
296 elif test "$$3" = sys; then
297 AC_MSG_RESULT([system version])
298 elif test "$$3" = builtin; then
299 AC_MSG_RESULT([builtin version])
300 else
301 AC_MSG_ERROR([Invalid value for --with-$1: should be yes, no, sys, or builtin])
302 fi
303 ])
304
305dnl this macro checks for a command line argument and caches the result
306dnl usage: WX_ARG_WITH(option, helpmessage, variable-name)
307AC_DEFUN([WX_ARG_WITH],
308 [
309 AC_MSG_CHECKING([for --with-$1])
310 no_cache=0
311 AC_ARG_WITH($1, [$2],
312 [
313 if test "$withval" = yes; then
314 ac_cv_use_$1='$3=yes'
315 else
316 ac_cv_use_$1='$3=no'
317 fi
318 ],
319 [
320 LINE=`grep "$3" ${wx_arg_cache_file}`
321 if test "x$LINE" != x ; then
322 eval "DEFAULT_$LINE"
323 else
324 no_cache=1
325 fi
326
327 ac_cv_use_$1='$3='$DEFAULT_$3
328 ])
329
330 eval "$ac_cv_use_$1"
331 if test "$no_cache" != 1; then
332 echo $ac_cv_use_$1 >> ${wx_arg_cache_file}.tmp
333 fi
334
335 if test "$$3" = yes; then
336 AC_MSG_RESULT(yes)
337 else
338 AC_MSG_RESULT(no)
339 fi
340 ])
341
342dnl like WX_ARG_WITH but uses AC_ARG_ENABLE instead of AC_ARG_WITH
5005acfe
VZ
343dnl usage: WX_ARG_ENABLE(option, helpmessage, variable-name, enablestring)
344dnl
345dnl enablestring is a hack and allows to show "checking for --disable-foo"
346dnl message when running configure instead of the default "checking for
347dnl --enable-foo" one whih is useful for the options enabled by default
b040e242
VS
348AC_DEFUN([WX_ARG_ENABLE],
349 [
5005acfe
VZ
350 enablestring=$4
351 AC_MSG_CHECKING([for --${enablestring:-enable}-$1])
b040e242
VS
352 no_cache=0
353 AC_ARG_ENABLE($1, [$2],
354 [
355 if test "$enableval" = yes; then
356 ac_cv_use_$1='$3=yes'
357 else
358 ac_cv_use_$1='$3=no'
359 fi
360 ],
361 [
362 LINE=`grep "$3" ${wx_arg_cache_file}`
363 if test "x$LINE" != x ; then
364 eval "DEFAULT_$LINE"
365 else
366 no_cache=1
367 fi
368
369 ac_cv_use_$1='$3='$DEFAULT_$3
370 ])
371
372 eval "$ac_cv_use_$1"
373 if test "$no_cache" != 1; then
374 echo $ac_cv_use_$1 >> ${wx_arg_cache_file}.tmp
375 fi
376
377 if test "$$3" = yes; then
378 AC_MSG_RESULT(yes)
379 else
380 AC_MSG_RESULT(no)
381 fi
382 ])
383
384
2b5f62a0
VZ
385dnl ===========================================================================
386dnl Linker features test
387dnl ===========================================================================
388
389dnl ---------------------------------------------------------------------------
390dnl WX_VERSIONED_SYMBOLS checks whether the linker can create versioned
391dnl symbols. If it can, sets LDFLAGS_VERSIONING to $CXX flags needed to use
392dnl version script file named versionfile
393dnl
394dnl call WX_VERSIONED_SYMBOLS(versionfile)
395dnl ---------------------------------------------------------------------------
396AC_DEFUN([WX_VERSIONED_SYMBOLS],
397[
398 found_versioning=no
399
b4eecb7e
VS
400 dnl FIXME - doesn't work, Solaris linker doesn't accept wildcards
401 dnl in the script.
402 dnl dnl Check for known non-gcc cases:
403 dnl case "${host}" in
404 dnl *-*-solaris2* )
405 dnl if test "x$GCC" != "xyes" ; then
406 dnl LDFLAGS_VERSIONING="-M $1"
407 dnl found_versioning=yes
408 dnl fi
409 dnl ;;
410 dnl esac
2b5f62a0
VZ
411
412 dnl Generic check for GCC or GCC-like behaviour (Intel C++, GCC):
413 if test $found_versioning = no ; then
414 AC_CACHE_CHECK([if the linker accepts --version-script], wx_cv_version_script,
415 [
416 echo "VER_1 { *; };" >conftest.sym
417 echo "int main() { return 0; }" >conftest.cpp
418
419 if AC_TRY_COMMAND([
420 $CXX -o conftest.output $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.cpp
421 -Wl,--version-script,conftest.sym >/dev/null 2>conftest.stderr]) ; then
422 if test -s conftest.stderr ; then
423 wx_cv_version_script=no
424 else
425 wx_cv_version_script=yes
426 fi
427 else
428 wx_cv_version_script=no
429 fi
430 rm -f conftest.output conftest.stderr conftest.sym conftest.cpp
431 ])
432 if test $wx_cv_version_script = yes ; then
433 LDFLAGS_VERSIONING="-Wl,--version-script,$1"
434 fi
435 fi
436])
437
b040e242
VS
438
439dnl ===========================================================================
440dnl "3rd party" macros included here because they are not widely available
441dnl ===========================================================================
442
b040e242
VS
443dnl ---------------------------------------------------------------------------
444dnl test for availability of iconv()
445dnl ---------------------------------------------------------------------------
446
b040e242
VS
447dnl From Bruno Haible.
448
449AC_DEFUN([AM_ICONV],
450[
451 dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
452 dnl those with the standalone portable GNU libiconv installed).
453
454 AC_ARG_WITH([libiconv-prefix],
455[ --with-libiconv-prefix=DIR search for libiconv in DIR/include and DIR/lib], [
456 for dir in `echo "$withval" | tr : ' '`; do
457 if test -d $dir/include; then CPPFLAGS="$CPPFLAGS -I$dir/include"; fi
458 if test -d $dir/lib; then LDFLAGS="$LDFLAGS -L$dir/lib"; fi
459 done
460 ])
461
462 AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
463 am_cv_func_iconv="no, consider installing GNU libiconv"
464 am_cv_lib_iconv=no
465 AC_TRY_LINK([#include <stdlib.h>
466#include <iconv.h>],
467 [iconv_t cd = iconv_open("","");
468 iconv(cd,NULL,NULL,NULL,NULL);
469 iconv_close(cd);],
470 am_cv_func_iconv=yes)
471 if test "$am_cv_func_iconv" != yes; then
472 am_save_LIBS="$LIBS"
473 LIBS="$LIBS -liconv"
474 AC_TRY_LINK([#include <stdlib.h>
475#include <iconv.h>],
476 [iconv_t cd = iconv_open("","");
477 iconv(cd,NULL,NULL,NULL,NULL);
478 iconv_close(cd);],
479 am_cv_lib_iconv=yes
480 am_cv_func_iconv=yes)
481 LIBS="$am_save_LIBS"
482 fi
483 ])
484 if test "$am_cv_func_iconv" = yes; then
485 AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
b7043674 486 AC_CACHE_CHECK([if iconv needs const], wx_cv_func_iconv_const,
b040e242
VS
487 AC_TRY_COMPILE([
488#include <stdlib.h>
489#include <iconv.h>
490extern
491#ifdef __cplusplus
492"C"
493#endif
494#if defined(__STDC__) || defined(__cplusplus)
495size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
496#else
497size_t iconv();
498#endif
b7043674
VZ
499 ],
500 [],
501 wx_cv_func_iconv_const="no",
502 wx_cv_func_iconv_const="yes"
503 )
504 )
505
506 iconv_const=
1c405bb5 507 if test "x$wx_cv_func_iconv_const" = "xyes"; then
b7043674
VZ
508 iconv_const="const"
509 fi
510
511 AC_DEFINE_UNQUOTED(ICONV_CONST, $iconv_const,
b040e242
VS
512 [Define as const if the declaration of iconv() needs const.])
513 fi
514 LIBICONV=
515 if test "$am_cv_lib_iconv" = yes; then
516 LIBICONV="-liconv"
517 fi
518 AC_SUBST(LIBICONV)
519])
520
90dd450c
VZ
521dnl ---------------------------------------------------------------------------
522dnl AC_SYS_LARGEFILE (partly based on the code from autoconf 2.5x)
523dnl ---------------------------------------------------------------------------
524
525dnl WX_SYS_LARGEFILE_TEST
526dnl
527dnl NB: original autoconf test was checking if compiler supported 6 bit off_t
528dnl arithmetic properly but this failed miserably with gcc under Linux
529dnl whereas the system still supports 64 bit files, so now simply check
530dnl that off_t is big enough
531define(WX_SYS_LARGEFILE_TEST,
532[typedef struct {
533 unsigned int field: sizeof(off_t) == 8;
534} wxlf;
535])
536
537
538dnl WX_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE, CACHE-VAR)
539define(WX_SYS_LARGEFILE_MACRO_VALUE,
540[
541 AC_CACHE_CHECK([for $1 value needed for large files], [$3],
542 [
543 AC_TRY_COMPILE([#define $1 $2
544 #include <sys/types.h>],
545 WX_SYS_LARGEFILE_TEST,
546 [$3=$2],
547 [$3=no])
548 ]
549 )
550
551 if test "$$3" != no; then
5a5d3c08 552 wx_largefile=yes
90dd450c
VZ
553 AC_DEFINE_UNQUOTED([$1], [$$3])
554 fi
555])
556
557
558dnl AC_SYS_LARGEFILE
559dnl ----------------
560dnl By default, many hosts won't let programs access large files;
561dnl one must use special compiler options to get large-file access to work.
562dnl For more details about this brain damage please see:
563dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
564AC_DEFUN([AC_SYS_LARGEFILE],
565[AC_ARG_ENABLE(largefile,
566 [ --disable-largefile omit support for large files])
567if test "$enable_largefile" != no; then
568 dnl _FILE_OFFSET_BITS==64 is needed for Linux, Solaris, ...
569 dnl _LARGE_FILES -- for AIX
5a5d3c08 570 wx_largefile=no
90dd450c
VZ
571 WX_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS, 64, ac_cv_sys_file_offset_bits)
572 if test "x$wx_largefile" != "xyes"; then
573 WX_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES, 1, ac_cv_sys_large_files)
574 fi
575
5a5d3c08 576 AC_MSG_CHECKING(if large file support is available)
90dd450c
VZ
577 if test "x$wx_largefile" = "xyes"; then
578 AC_DEFINE(HAVE_LARGEFILE_SUPPORT)
579 fi
5a5d3c08 580 AC_MSG_RESULT($wx_largefile)
90dd450c
VZ
581fi
582])