]> git.saurik.com Git - wxWidgets.git/blame - acinclude.m4
compilation fix for !WXWIN_COMPATIBILITY_2_2
[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=
22for 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
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=
38for 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
49dnl ---------------------------------------------------------------------------
50dnl Path to include, already defined
51dnl ---------------------------------------------------------------------------
52AC_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
64dnl ---------------------------------------------------------------------------
65dnl Path to link, already defined
66dnl ---------------------------------------------------------------------------
67AC_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
78dnl ===========================================================================
79dnl C++ features test
80dnl ===========================================================================
81
82dnl ---------------------------------------------------------------------------
83dnl WX_CPP_NEW_HEADERS checks whether the compiler has "new" <iostream> header
84dnl or only the old <iostream.h> one - it may be generally assumed that if
85dnl <iostream> exists, the other "new" headers (without .h) exist too.
86dnl
87dnl call WX_CPP_NEW_HEADERS(actiof-if-true, action-if-false-or-cross-compiling)
88dnl ---------------------------------------------------------------------------
89
90AC_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
110dnl ---------------------------------------------------------------------------
111dnl WX_CPP_BOOL checks whether the C++ compiler has a built in bool type
112dnl
113dnl call WX_CPP_BOOL - will define HAVE_BOOL if the compiler supports bool
114dnl ---------------------------------------------------------------------------
115
116AC_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
147dnl ---------------------------------------------------------------------------
148dnl a slightly better AC_C_BIGENDIAN macro which allows cross-compiling
149dnl ---------------------------------------------------------------------------
150
151AC_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.
155AC_TRY_COMPILE([#include <sys/types.h>
156#include <sys/param.h>], [
157#if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
158 bogus endian macros
159#endif], [# It does; now see whether it defined to BIG_ENDIAN or not.
160AC_TRY_COMPILE([#include <sys/types.h>
161#include <sys/param.h>], [
162#if BYTE_ORDER != BIG_ENDIAN
163 not big endian
164#endif], ac_cv_c_bigendian=yes, ac_cv_c_bigendian=no)])
165if test $ac_cv_c_bigendian = unknown; then
166AC_TRY_RUN([main () {
167 /* Are we little or big endian? From Harbison&Steele. */
168 union
169 {
170 long l;
171 char c[sizeof (long)];
172 } u;
173 u.l = 1;
174 exit (u.c[sizeof (long) - 1] == 1);
175}], [ac_cv_c_bigendian=no], [ac_cv_c_bigendian=yes], [ac_cv_c_bigendian=unknown])
176fi])
177if 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])
179fi
180if test $ac_cv_c_bigendian = yes; then
181 AC_DEFINE(WORDS_BIGENDIAN)
182fi
183])
184
185dnl ---------------------------------------------------------------------------
186dnl override AC_ARG_ENABLE/WITH to cache the results in .cache file
187dnl ---------------------------------------------------------------------------
188
189AC_DEFUN([WX_ARG_CACHE_INIT],
190 [
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}
196 ])
197
198AC_DEFUN([WX_ARG_CACHE_FLUSH],
199 [
200 echo "saving argument cache $wx_arg_cache_file"
201 mv ${wx_arg_cache_file}.tmp ${wx_arg_cache_file}
202 ])
203
204dnl this macro checks for a three-valued command line --with argument:
205dnl possible arguments are 'yes', 'no', 'sys', or 'builtin'
206dnl usage: WX_ARG_SYS_WITH(option, helpmessage, variable-name)
207AC_DEFUN([WX_ARG_SYS_WITH],
208 [
209 AC_MSG_CHECKING([for --with-$1])
210 no_cache=0
211 AC_ARG_WITH($1, [$2],
212 [
213 if test "$withval" = yes; then
214 ac_cv_use_$1='$3=yes'
215 elif test "$withval" = no; then
216 ac_cv_use_$1='$3=no'
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'
221 else
222 AC_MSG_ERROR([Invalid value for --with-$1: should be yes, no, sys, or builtin])
223 fi
224 ],
225 [
226 LINE=`grep "$3" ${wx_arg_cache_file}`
227 if test "x$LINE" != x ; then
228 eval "DEFAULT_$LINE"
229 else
230 no_cache=1
231 fi
232
233 ac_cv_use_$1='$3='$DEFAULT_$3
234 ])
235
236 eval "$ac_cv_use_$1"
237 if test "$no_cache" != 1; then
238 echo $ac_cv_use_$1 >> ${wx_arg_cache_file}.tmp
239 fi
240
241 if test "$$3" = yes; then
242 AC_MSG_RESULT(yes)
243 elif test "$$3" = no; then
244 AC_MSG_RESULT(no)
245 elif test "$$3" = sys; then
246 AC_MSG_RESULT([system version])
247 elif test "$$3" = builtin; then
248 AC_MSG_RESULT([builtin version])
249 else
250 AC_MSG_ERROR([Invalid value for --with-$1: should be yes, no, sys, or builtin])
251 fi
252 ])
253
254dnl this macro checks for a command line argument and caches the result
255dnl usage: WX_ARG_WITH(option, helpmessage, variable-name)
256AC_DEFUN([WX_ARG_WITH],
257 [
258 AC_MSG_CHECKING([for --with-$1])
259 no_cache=0
260 AC_ARG_WITH($1, [$2],
261 [
262 if test "$withval" = yes; then
263 ac_cv_use_$1='$3=yes'
264 else
265 ac_cv_use_$1='$3=no'
266 fi
267 ],
268 [
269 LINE=`grep "$3" ${wx_arg_cache_file}`
270 if test "x$LINE" != x ; then
271 eval "DEFAULT_$LINE"
272 else
273 no_cache=1
274 fi
275
276 ac_cv_use_$1='$3='$DEFAULT_$3
277 ])
278
279 eval "$ac_cv_use_$1"
280 if test "$no_cache" != 1; then
281 echo $ac_cv_use_$1 >> ${wx_arg_cache_file}.tmp
282 fi
283
284 if test "$$3" = yes; then
285 AC_MSG_RESULT(yes)
286 else
287 AC_MSG_RESULT(no)
288 fi
289 ])
290
291dnl like WX_ARG_WITH but uses AC_ARG_ENABLE instead of AC_ARG_WITH
292dnl usage: WX_ARG_ENABLE(option, helpmessage, variable-name)
293AC_DEFUN([WX_ARG_ENABLE],
294 [
295 AC_MSG_CHECKING([for --enable-$1])
296 no_cache=0
297 AC_ARG_ENABLE($1, [$2],
298 [
299 if test "$enableval" = yes; then
300 ac_cv_use_$1='$3=yes'
301 else
302 ac_cv_use_$1='$3=no'
303 fi
304 ],
305 [
306 LINE=`grep "$3" ${wx_arg_cache_file}`
307 if test "x$LINE" != x ; then
308 eval "DEFAULT_$LINE"
309 else
310 no_cache=1
311 fi
312
313 ac_cv_use_$1='$3='$DEFAULT_$3
314 ])
315
316 eval "$ac_cv_use_$1"
317 if test "$no_cache" != 1; then
318 echo $ac_cv_use_$1 >> ${wx_arg_cache_file}.tmp
319 fi
320
321 if test "$$3" = yes; then
322 AC_MSG_RESULT(yes)
323 else
324 AC_MSG_RESULT(no)
325 fi
326 ])
327
328
329
330dnl ===========================================================================
331dnl "3rd party" macros included here because they are not widely available
332dnl ===========================================================================
333
b040e242
VS
334dnl ---------------------------------------------------------------------------
335dnl test for availability of iconv()
336dnl ---------------------------------------------------------------------------
337
b040e242
VS
338dnl From Bruno Haible.
339
340AC_DEFUN([AM_ICONV],
341[
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).
344
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
350 done
351 ])
352
353 AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
354 am_cv_func_iconv="no, consider installing GNU libiconv"
355 am_cv_lib_iconv=no
356 AC_TRY_LINK([#include <stdlib.h>
357#include <iconv.h>],
358 [iconv_t cd = iconv_open("","");
359 iconv(cd,NULL,NULL,NULL,NULL);
360 iconv_close(cd);],
361 am_cv_func_iconv=yes)
362 if test "$am_cv_func_iconv" != yes; then
363 am_save_LIBS="$LIBS"
364 LIBS="$LIBS -liconv"
365 AC_TRY_LINK([#include <stdlib.h>
366#include <iconv.h>],
367 [iconv_t cd = iconv_open("","");
368 iconv(cd,NULL,NULL,NULL,NULL);
369 iconv_close(cd);],
370 am_cv_lib_iconv=yes
371 am_cv_func_iconv=yes)
372 LIBS="$am_save_LIBS"
373 fi
374 ])
375 if test "$am_cv_func_iconv" = yes; then
376 AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
b7043674 377 AC_CACHE_CHECK([if iconv needs const], wx_cv_func_iconv_const,
b040e242
VS
378 AC_TRY_COMPILE([
379#include <stdlib.h>
380#include <iconv.h>
381extern
382#ifdef __cplusplus
383"C"
384#endif
385#if defined(__STDC__) || defined(__cplusplus)
386size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
387#else
388size_t iconv();
389#endif
b7043674
VZ
390 ],
391 [],
392 wx_cv_func_iconv_const="no",
393 wx_cv_func_iconv_const="yes"
394 )
395 )
396
397 iconv_const=
1c405bb5 398 if test "x$wx_cv_func_iconv_const" = "xyes"; then
b7043674
VZ
399 iconv_const="const"
400 fi
401
402 AC_DEFINE_UNQUOTED(ICONV_CONST, $iconv_const,
b040e242
VS
403 [Define as const if the declaration of iconv() needs const.])
404 fi
405 LIBICONV=
406 if test "$am_cv_lib_iconv" = yes; then
407 LIBICONV="-liconv"
408 fi
409 AC_SUBST(LIBICONV)
410])
411