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