1 dnl ---------------------------------------------------------------------------
3 dnl Purpose: Cursom macros for autoconf configure script.
4 dnl Author: Vadim Zeitlin
7 dnl ---------------------------------------------------------------------------
9 dnl ===========================================================================
11 dnl ===========================================================================
13 dnl ---------------------------------------------------------------------------
14 dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
15 dnl Test for GTK, and define GTK_CFLAGS and GTK_LIBS. Uses variables
16 dnl gtk_config_prefix and/or gtk_config_exec_prefix if defined.
17 dnl ---------------------------------------------------------------------------
21 if test x$gtk_config_exec_prefix != x ; then
22 gtk_config_args="$gtk_config_args --exec-prefix=$gtk_config_exec_prefix"
23 if test x${GTK_CONFIG+set} != xset ; then
24 GTK_CONFIG=$gtk_config_exec_prefix/bin/gtk-config
27 if test x$gtk_config_prefix != x ; then
28 gtk_config_args="$gtk_config_args --prefix=$gtk_config_prefix"
29 if test x${GTK_CONFIG+set} != xset ; then
30 GTK_CONFIG=$gtk_config_prefix/bin/gtk-config
34 AC_PATH_PROG(GTK_CONFIG, gtk-config, no)
35 min_gtk_version=ifelse([$1], ,0.99.7,$1)
36 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
38 if test "$GTK_CONFIG" != "no" ; then
39 GTK_CFLAGS=`$GTK_CONFIG --cflags`
40 GTK_LIBS=`$GTK_CONFIG --libs`
41 ac_save_CFLAGS="$CFLAGS"
43 CFLAGS="$CFLAGS $GTK_CFLAGS"
44 LIBS="$LIBS $GTK_LIBS"
46 dnl Now check if the installed GTK is sufficiently new. (Also sanity
47 dnl checks the results of gtk-config to some extent)
56 int major, minor, micro;
58 if (sscanf("$min_gtk_version", "%d.%d.%d", &major, &minor, µ) != 3) {
59 printf("%s, bad version string\n", "$min_gtk_version");
63 if (gtk_minor_version == 1) return FALSE;
65 return !((gtk_major_version > major) ||
66 ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
67 ((gtk_major_version == major) && (gtk_minor_version == minor) && (gtk_micro_version >= micro)));
69 ],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
70 CFLAGS="$ac_save_CFLAGS"
75 if test "x$no_gtk" = x ; then
77 ifelse([$2], , :, [$2])
82 ifelse([$3], , :, [$3])
88 dnl ===========================================================================
89 dnl macros to find the a file in the list of include/lib paths
90 dnl ===========================================================================
92 dnl ---------------------------------------------------------------------------
93 dnl call WX_PATH_FIND_INCLUDES(search path, header name), sets ac_find_includes
94 dnl to the full name of the file that was found or leaves it empty if not found
95 dnl ---------------------------------------------------------------------------
96 AC_DEFUN(WX_PATH_FIND_INCLUDES,
101 if test -f "$ac_dir/$2"; then
102 ac_find_includes=$ac_dir
108 dnl ---------------------------------------------------------------------------
109 dnl call WX_PATH_FIND_LIBRARIES(search path, header name), sets ac_find_includes
110 dnl to the full name of the file that was found or leaves it empty if not found
111 dnl ---------------------------------------------------------------------------
112 AC_DEFUN(WX_PATH_FIND_LIBRARIES,
117 for ac_extension in a so sl; do
118 if test -f "$ac_dir/lib$2.$ac_extension"; then
119 ac_find_libraries=$ac_dir
126 dnl ---------------------------------------------------------------------------
127 dnl Path to include, already defined
128 dnl ---------------------------------------------------------------------------
129 AC_DEFUN(WX_INCLUDE_PATH_EXIST,
131 ac_path_to_include=$1
132 echo "$2" | grep "\-I$1" > /dev/null
134 if test $result = 0; then
135 ac_path_to_include=""
137 ac_path_to_include="-I$1"
141 dnl ---------------------------------------------------------------------------
142 dnl Path to link, already defined
143 dnl ---------------------------------------------------------------------------
144 AC_DEFUN(WX_LINK_PATH_EXIST,
146 echo "$2" | grep "\-L$1" > /dev/null
148 if test $result = 0; then
151 ac_path_to_link="-L$1"
155 dnl ===========================================================================
156 dnl C++ features test
157 dnl ===========================================================================
159 dnl ---------------------------------------------------------------------------
160 dnl WX_CPP_NEW_HEADERS checks whether the compiler has "new" <iostream> header
161 dnl or only the old <iostream.h> one - it may be generally assumed that if
162 dnl <iostream> exists, the other "new" headers (without .h) exist too.
164 dnl call WX_CPP_NEW_HEADERS(actiof-if-true, action-if-false-or-cross-compiling)
165 dnl ---------------------------------------------------------------------------
167 AC_DEFUN(WX_CPP_NEW_HEADERS,
169 if test "$cross_compiling" = "yes"; then
170 ifelse([$2], , :, [$2])
175 AC_CHECK_HEADERS(iostream)
177 if test "x$HAVE_IOSTREAM" = x ; then
178 ifelse([$2], , :, [$2])
180 ifelse([$1], , :, [$1])
187 dnl ---------------------------------------------------------------------------
188 dnl WX_CPP_BOOL checks whether the C++ compiler has a built in bool type
190 dnl call WX_CPP_BOOL - will define HAVE_BOOL if the compiler supports bool
191 dnl ---------------------------------------------------------------------------
193 AC_DEFUN(WX_CPP_BOOL,
195 AC_CACHE_CHECK([if C++ compiler supports bool], wx_cv_cpp_bool,
219 if test "$wx_cv_cpp_bool" = "yes"; then
224 dnl ---------------------------------------------------------------------------
225 dnl WX_CPP_SIZE_T_IS_NOT_INT checks whether size_t and int are different types,
226 dnl i.e. whether we may overload operator[] on its argument type
227 dnl ---------------------------------------------------------------------------
229 AC_DEFUN(WX_CPP_SIZE_T_IS_NOT_INT,
231 AC_CACHE_CHECK([if size_t and int are different types], wx_cv_cpp_sizet_not_int,
242 S(char *s) { m_s = s; }
244 char operator[](size_t n) const { return m_s[n]; }
245 char operator[](int n) const { return m_s[n]; }
257 return s[n1] == s[n2];
260 AC_DEFINE(wxUSE_SIZE_T_STRING_OPERATOR) wx_cv_cpp_sizet_not_int=yes,
261 wx_cv_cpp_sizet_not_int=no,
262 wx_cv_cpp_sizet_not_int=no
269 dnl ---------------------------------------------------------------------------
270 dnl a slightly better AC_C_BIGENDIAN macro which allows cross-compiling
271 dnl ---------------------------------------------------------------------------
273 AC_DEFUN(WX_C_BIGENDIAN,
274 [AC_CACHE_CHECK(whether byte ordering is bigendian, ac_cv_c_bigendian,
275 [ac_cv_c_bigendian=unknown
276 # See if sys/param.h defines the BYTE_ORDER macro.
277 AC_TRY_COMPILE([#include <sys/types.h>
278 #include <sys/param.h>], [
279 #if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
281 #endif], [# It does; now see whether it defined to BIG_ENDIAN or not.
282 AC_TRY_COMPILE([#include <sys/types.h>
283 #include <sys/param.h>], [
284 #if BYTE_ORDER != BIG_ENDIAN
286 #endif], ac_cv_c_bigendian=yes, ac_cv_c_bigendian=no)])
287 if test $ac_cv_c_bigendian = unknown; then
288 AC_TRY_RUN([main () {
289 /* Are we little or big endian? From Harbison&Steele. */
293 char c[sizeof (long)];
296 exit (u.c[sizeof (long) - 1] == 1);
297 }], ac_cv_c_bigendian=no, ac_cv_c_bigendian=yes, ac_cv_c_bigendian=unknown)
299 if test $ac_cv_c_bigendian = unknown; then
300 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])
302 if test $ac_cv_c_bigendian = yes; then
303 AC_DEFINE(WORDS_BIGENDIAN)
307 dnl ---------------------------------------------------------------------------
308 dnl override AC_ARG_ENABLE/WITH to cache the results in .cache file
309 dnl ---------------------------------------------------------------------------
311 AC_DEFUN(WX_ARG_CACHE_INIT,
313 wx_arg_cache_file="configarg.cache"
314 echo "loading argument cache $wx_arg_cache_file"
315 rm -f ${wx_arg_cache_file}.tmp
316 touch ${wx_arg_cache_file}.tmp
317 touch ${wx_arg_cache_file}
320 AC_DEFUN(WX_ARG_CACHE_FLUSH,
322 echo "saving argument cache $wx_arg_cache_file"
323 mv ${wx_arg_cache_file}.tmp ${wx_arg_cache_file}
326 dnl this macro checks for a command line argument and caches the result
327 dnl usage: WX_ARG_WITH(option, helpmessage, variable-name)
328 AC_DEFUN(WX_ARG_WITH,
330 AC_MSG_CHECKING("for --with-$1")
334 if test "$withval" = yes; then
335 ac_cv_use_$1='$3=yes'
341 LINE=`grep "$3" ${wx_arg_cache_file}`
342 if test "x$LINE" != x ; then
348 ac_cv_use_$1='$3='$DEFAULT_$3
352 if test "$no_cache" != 1; then
353 echo $ac_cv_use_$1 >> ${wx_arg_cache_file}.tmp
356 if test "$$3" = yes; then
363 dnl like WX_ARG_WITH but uses AC_ARG_ENABLE instead of AC_ARG_WITH
364 dnl usage: WX_ARG_ENABLE(option, helpmessage, variable-name)
365 AC_DEFUN(WX_ARG_ENABLE,
367 AC_MSG_CHECKING("for --enable-$1")
369 AC_ARG_ENABLE($1, $2,
371 if test "$enableval" = yes; then
372 ac_cv_use_$1='$3=yes'
378 LINE=`grep "$3" ${wx_arg_cache_file}`
379 if test "x$LINE" != x ; then
385 ac_cv_use_$1='$3='$DEFAULT_$3
389 if test "$no_cache" != 1; then
390 echo $ac_cv_use_$1 >> ${wx_arg_cache_file}.tmp
393 if test "$$3" = yes; then