1 dnl ---------------------------------------------------------------------------
3 dnl Macros for configure.in for wxWindows by Robert Roebling, Phil Blecker,
4 dnl Vadim Zeitlin and Ron Lee
6 dnl This script is under the wxWindows licence.
9 dnl ---------------------------------------------------------------------------
11 dnl ===========================================================================
12 dnl macros to find the a file in the list of include/lib paths
13 dnl ===========================================================================
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],
24 if test -f "$ac_dir/$2"; then
25 ac_find_includes=$ac_dir
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],
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
49 dnl ---------------------------------------------------------------------------
50 dnl Path to include, already defined
51 dnl ---------------------------------------------------------------------------
52 AC_DEFUN([WX_INCLUDE_PATH_EXIST],
55 echo "$2" | grep "\-I$1" > /dev/null
57 if test $result = 0; then
60 ac_path_to_include=" -I$1"
64 dnl ---------------------------------------------------------------------------
65 dnl Path to link, already defined
66 dnl ---------------------------------------------------------------------------
67 AC_DEFUN([WX_LINK_PATH_EXIST],
69 echo "$2" | grep "\-L$1" > /dev/null
71 if test $result = 0; then
74 ac_path_to_link=" -L$1"
78 dnl ===========================================================================
80 dnl ===========================================================================
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.
87 dnl call WX_CPP_NEW_HEADERS(actiof-if-true, action-if-false-or-cross-compiling)
88 dnl ---------------------------------------------------------------------------
90 AC_DEFUN([WX_CPP_NEW_HEADERS],
92 if test "$cross_compiling" = "yes"; then
93 ifelse([$2], , :, [$2])
98 AC_CHECK_HEADERS(iostream)
100 if test "$ac_cv_header_iostream" = "yes" ; then
101 ifelse([$1], , :, [$1])
103 ifelse([$2], , :, [$2])
110 dnl ---------------------------------------------------------------------------
111 dnl WX_CPP_BOOL checks whether the C++ compiler has a built in bool type
113 dnl call WX_CPP_BOOL - will define HAVE_BOOL if the compiler supports bool
114 dnl ---------------------------------------------------------------------------
116 AC_DEFUN([WX_CPP_BOOL],
118 AC_CACHE_CHECK([if C++ compiler supports bool], wx_cv_cpp_bool,
142 if test "$wx_cv_cpp_bool" = "yes"; then
147 dnl ---------------------------------------------------------------------------
148 dnl a slightly better AC_C_BIGENDIAN macro which allows cross-compiling
149 dnl ---------------------------------------------------------------------------
151 AC_DEFUN([WX_C_BIGENDIAN],
152 [AC_CACHE_CHECK([whether byte ordering is bigendian], ac_cv_c_bigendian,
153 [ac_cv_c_bigendian=unknown
154 # See if sys/param.h defines the BYTE_ORDER macro.
155 AC_TRY_COMPILE([#include <sys/types.h>
156 #include <sys/param.h>], [
157 #if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
159 #endif], [# It does; now see whether it defined to BIG_ENDIAN or not.
160 AC_TRY_COMPILE([#include <sys/types.h>
161 #include <sys/param.h>], [
162 #if BYTE_ORDER != BIG_ENDIAN
164 #endif], ac_cv_c_bigendian=yes, ac_cv_c_bigendian=no)])
165 if test $ac_cv_c_bigendian = unknown; then
166 AC_TRY_RUN([main () {
167 /* Are we little or big endian? From Harbison&Steele. */
171 char c[sizeof (long)];
174 exit (u.c[sizeof (long) - 1] == 1);
175 }], [ac_cv_c_bigendian=no], [ac_cv_c_bigendian=yes], [ac_cv_c_bigendian=unknown])
177 if test $ac_cv_c_bigendian = unknown; then
178 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])
180 if test $ac_cv_c_bigendian = yes; then
181 AC_DEFINE(WORDS_BIGENDIAN)
185 dnl ---------------------------------------------------------------------------
186 dnl override AC_ARG_ENABLE/WITH to cache the results in .cache file
187 dnl ---------------------------------------------------------------------------
189 AC_DEFUN([WX_ARG_CACHE_INIT],
191 wx_arg_cache_file="configarg.cache"
192 echo "loading argument cache $wx_arg_cache_file"
193 rm -f ${wx_arg_cache_file}.tmp
194 touch ${wx_arg_cache_file}.tmp
195 touch ${wx_arg_cache_file}
198 AC_DEFUN([WX_ARG_CACHE_FLUSH],
200 echo "saving argument cache $wx_arg_cache_file"
201 mv ${wx_arg_cache_file}.tmp ${wx_arg_cache_file}
204 dnl this macro checks for a three-valued command line --with argument:
205 dnl possible arguments are 'yes', 'no', 'sys', or 'builtin'
206 dnl usage: WX_ARG_SYS_WITH(option, helpmessage, variable-name)
207 AC_DEFUN([WX_ARG_SYS_WITH],
209 AC_MSG_CHECKING([for --with-$1])
211 AC_ARG_WITH($1, [$2],
213 if test "$withval" = yes; then
214 ac_cv_use_$1='$3=yes'
215 elif test "$withval" = no; then
217 elif test "$withval" = sys; then
218 ac_cv_use_$1='$3=sys'
219 elif test "$withval" = builtin; then
220 ac_cv_use_$1='$3=builtin'
222 AC_MSG_ERROR([Invalid value for --with-$1: should be yes, no, sys, or builtin])
226 LINE=`grep "$3" ${wx_arg_cache_file}`
227 if test "x$LINE" != x ; then
233 ac_cv_use_$1='$3='$DEFAULT_$3
237 if test "$no_cache" != 1; then
238 echo $ac_cv_use_$1 >> ${wx_arg_cache_file}.tmp
241 if test "$$3" = yes; then
243 elif test "$$3" = no; then
245 elif test "$$3" = sys; then
246 AC_MSG_RESULT([system version])
247 elif test "$$3" = builtin; then
248 AC_MSG_RESULT([builtin version])
250 AC_MSG_ERROR([Invalid value for --with-$1: should be yes, no, sys, or builtin])
254 dnl this macro checks for a command line argument and caches the result
255 dnl usage: WX_ARG_WITH(option, helpmessage, variable-name)
256 AC_DEFUN([WX_ARG_WITH],
258 AC_MSG_CHECKING([for --with-$1])
260 AC_ARG_WITH($1, [$2],
262 if test "$withval" = yes; then
263 ac_cv_use_$1='$3=yes'
269 LINE=`grep "$3" ${wx_arg_cache_file}`
270 if test "x$LINE" != x ; then
276 ac_cv_use_$1='$3='$DEFAULT_$3
280 if test "$no_cache" != 1; then
281 echo $ac_cv_use_$1 >> ${wx_arg_cache_file}.tmp
284 if test "$$3" = yes; then
291 dnl like WX_ARG_WITH but uses AC_ARG_ENABLE instead of AC_ARG_WITH
292 dnl usage: WX_ARG_ENABLE(option, helpmessage, variable-name)
293 AC_DEFUN([WX_ARG_ENABLE],
295 AC_MSG_CHECKING([for --enable-$1])
297 AC_ARG_ENABLE($1, [$2],
299 if test "$enableval" = yes; then
300 ac_cv_use_$1='$3=yes'
306 LINE=`grep "$3" ${wx_arg_cache_file}`
307 if test "x$LINE" != x ; then
313 ac_cv_use_$1='$3='$DEFAULT_$3
317 if test "$no_cache" != 1; then
318 echo $ac_cv_use_$1 >> ${wx_arg_cache_file}.tmp
321 if test "$$3" = yes; then
330 dnl ===========================================================================
331 dnl "3rd party" macros included here because they are not widely available
332 dnl ===========================================================================
334 dnl ---------------------------------------------------------------------------
335 dnl test for availability of iconv()
336 dnl ---------------------------------------------------------------------------
338 dnl From Bruno Haible.
342 dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
343 dnl those with the standalone portable GNU libiconv installed).
345 AC_ARG_WITH([libiconv-prefix],
346 [ --with-libiconv-prefix=DIR search for libiconv in DIR/include and DIR/lib], [
347 for dir in `echo "$withval" | tr : ' '`; do
348 if test -d $dir/include; then CPPFLAGS="$CPPFLAGS -I$dir/include"; fi
349 if test -d $dir/lib; then LDFLAGS="$LDFLAGS -L$dir/lib"; fi
353 AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
354 am_cv_func_iconv="no, consider installing GNU libiconv"
356 AC_TRY_LINK([#include <stdlib.h>
358 [iconv_t cd = iconv_open("","");
359 iconv(cd,NULL,NULL,NULL,NULL);
361 am_cv_func_iconv=yes)
362 if test "$am_cv_func_iconv" != yes; then
365 AC_TRY_LINK([#include <stdlib.h>
367 [iconv_t cd = iconv_open("","");
368 iconv(cd,NULL,NULL,NULL,NULL);
371 am_cv_func_iconv=yes)
375 if test "$am_cv_func_iconv" = yes; then
376 AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
377 AC_CACHE_CHECK([if iconv needs const], wx_cv_func_iconv_const,
385 #if defined(__STDC__) || defined(__cplusplus)
386 size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
392 wx_cv_func_iconv_const="no",
393 wx_cv_func_iconv_const="yes"
398 if test "x$wx_cv_func_iconv_const" = "xyes"; then
402 AC_DEFINE_UNQUOTED(ICONV_CONST, $iconv_const,
403 [Define as const if the declaration of iconv() needs const.])
406 if test "$am_cv_lib_iconv" = yes; then
412 dnl ---------------------------------------------------------------------------
413 dnl AC_SYS_LARGEFILE (partly based on the code from autoconf 2.5x)
414 dnl ---------------------------------------------------------------------------
416 dnl WX_SYS_LARGEFILE_TEST
418 dnl NB: original autoconf test was checking if compiler supported 6 bit off_t
419 dnl arithmetic properly but this failed miserably with gcc under Linux
420 dnl whereas the system still supports 64 bit files, so now simply check
421 dnl that off_t is big enough
422 define(WX_SYS_LARGEFILE_TEST,
424 unsigned int field: sizeof(off_t) == 8;
429 dnl WX_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE, CACHE-VAR)
430 define(WX_SYS_LARGEFILE_MACRO_VALUE,
432 AC_CACHE_CHECK([for $1 value needed for large files], [$3],
434 AC_TRY_COMPILE([#define $1 $2
435 #include <sys/types.h>],
436 WX_SYS_LARGEFILE_TEST,
442 if test "$$3" != no; then
444 AC_DEFINE_UNQUOTED([$1], [$$3])
451 dnl By default, many hosts won't let programs access large files;
452 dnl one must use special compiler options to get large-file access to work.
453 dnl For more details about this brain damage please see:
454 dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
455 AC_DEFUN([AC_SYS_LARGEFILE],
456 [AC_ARG_ENABLE(largefile,
457 [ --disable-largefile omit support for large files])
458 if test "$enable_largefile" != no; then
459 dnl _FILE_OFFSET_BITS==64 is needed for Linux, Solaris, ...
460 dnl _LARGE_FILES -- for AIX
462 WX_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS, 64, ac_cv_sys_file_offset_bits)
463 if test "x$wx_largefile" != "xyes"; then
464 WX_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES, 1, ac_cv_sys_large_files)
467 AC_MSG_CHECKING(if large file support is available)
468 if test "x$wx_largefile" = "xyes"; then
469 AC_DEFINE(HAVE_LARGEFILE_SUPPORT)
471 AC_MSG_RESULT($wx_largefile)