]> git.saurik.com Git - wxWidgets.git/blame_incremental - acinclude.m4
New makefile updates.
[wxWidgets.git] / acinclude.m4
... / ...
CommitLineData
1dnl ---------------------------------------------------------------------------
2dnl
3dnl Purpose: Cursom macros for autoconf configure script.
4dnl Author: Vadim Zeitlin
5dnl Created: 26.05.99
6dnl Version: $Id$
7dnl ---------------------------------------------------------------------------
8
9dnl ===========================================================================
10dnl GKT+ version test
11dnl ===========================================================================
12
13dnl ---------------------------------------------------------------------------
14dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
15dnl Test for GTK, and define GTK_CFLAGS and GTK_LIBS. Uses variables
16dnl gtk_config_prefix and/or gtk_config_exec_prefix if defined.
17dnl ---------------------------------------------------------------------------
18dnl
19AC_DEFUN(AM_PATH_GTK,
20[
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
25 fi
26 fi
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
31 fi
32 fi
33
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)
37 no_gtk=""
38 if test "$GTK_CONFIG" != "no" ; then
39 GTK_CFLAGS=`$GTK_CONFIG --cflags`
40 GTK_LIBS=`$GTK_CONFIG --libs`
41 ac_save_CFLAGS="$CFLAGS"
42 ac_save_LIBS="$LIBS"
43 CFLAGS="$CFLAGS $GTK_CFLAGS"
44 LIBS="$LIBS $GTK_LIBS"
45dnl
46dnl Now check if the installed GTK is sufficiently new. (Also sanity
47dnl checks the results of gtk-config to some extent)
48dnl
49 AC_TRY_RUN([
50#include <gtk/gtk.h>
51#include <stdio.h>
52
53int
54main ()
55{
56 int major, minor, micro;
57
58 if (sscanf("$min_gtk_version", "%d.%d.%d", &major, &minor, &micro) != 3) {
59 printf("%s, bad version string\n", "$min_gtk_version");
60 exit(1);
61 }
62
63 if (gtk_minor_version == 1) return FALSE;
64
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)));
68}
69],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
70 CFLAGS="$ac_save_CFLAGS"
71 LIBS="$ac_save_LIBS"
72 else
73 no_gtk=yes
74 fi
75 if test "x$no_gtk" = x ; then
76 AC_MSG_RESULT(yes)
77 ifelse([$2], , :, [$2])
78 else
79 AC_MSG_RESULT(no)
80 GTK_CFLAGS=""
81 GTK_LIBS=""
82 ifelse([$3], , :, [$3])
83 fi
84 AC_SUBST(GTK_CFLAGS)
85 AC_SUBST(GTK_LIBS)
86])
87
88dnl ===========================================================================
89dnl macros to find the a file in the list of include/lib paths
90dnl ===========================================================================
91
92dnl ---------------------------------------------------------------------------
93dnl call WX_PATH_FIND_INCLUDES(search path, header name), sets ac_find_includes
94dnl to the full name of the file that was found or leaves it empty if not found
95dnl ---------------------------------------------------------------------------
96AC_DEFUN(WX_PATH_FIND_INCLUDES,
97[
98ac_find_includes=
99for ac_dir in $1;
100 do
101 if test -f "$ac_dir/$2"; then
102 ac_find_includes=$ac_dir
103 break
104 fi
105 done
106])
107
108dnl ---------------------------------------------------------------------------
109dnl call WX_PATH_FIND_LIBRARIES(search path, header name), sets ac_find_includes
110dnl to the full name of the file that was found or leaves it empty if not found
111dnl ---------------------------------------------------------------------------
112AC_DEFUN(WX_PATH_FIND_LIBRARIES,
113[
114ac_find_libraries=
115for ac_dir in $1;
116 do
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
120 break 2
121 fi
122 done
123 done
124])
125
126dnl ---------------------------------------------------------------------------
127dnl Path to include, already defined
128dnl ---------------------------------------------------------------------------
129AC_DEFUN(WX_INCLUDE_PATH_EXIST,
130[
131 ac_path_to_include=$1
132 echo "$2" | grep "\-I$1" > /dev/null
133 result=$?
134 if test $result = 0; then
135 ac_path_to_include=""
136 else
137 ac_path_to_include="-I$1"
138 fi
139])
140
141dnl ---------------------------------------------------------------------------
142dnl Path to link, already defined
143dnl ---------------------------------------------------------------------------
144AC_DEFUN(WX_LINK_PATH_EXIST,
145[
146 echo "$2" | grep "\-L$1" > /dev/null
147 result=$?
148 if test $result = 0; then
149 ac_path_to_link=""
150 else
151 ac_path_to_link="-L$1"
152 fi
153])
154
155dnl ===========================================================================
156dnl C++ features test
157dnl ===========================================================================
158
159dnl ---------------------------------------------------------------------------
160dnl WX_CPP_NEW_HEADERS checks whether the compiler has "new" <iostream> header
161dnl or only the old <iostream.h> one - it may be generally assumed that if
162dnl <iostream> exists, the other "new" headers (without .h) exist too.
163dnl
164dnl call WX_CPP_NEW_HEADERS(actiof-if-true, action-if-false-or-cross-compiling)
165dnl ---------------------------------------------------------------------------
166
167AC_DEFUN(WX_CPP_NEW_HEADERS,
168[
169 if test "$cross_compiling" = "yes"; then
170 ifelse([$2], , :, [$2])
171 else
172 AC_LANG_SAVE
173 AC_LANG_CPLUSPLUS
174
175 AC_CHECK_HEADERS(iostream)
176
177 if test "x$HAVE_IOSTREAM" = x ; then
178 ifelse([$2], , :, [$2])
179 else
180 ifelse([$1], , :, [$1])
181 fi
182
183 AC_LANG_RESTORE
184 fi
185])
186
187dnl ---------------------------------------------------------------------------
188dnl WX_CPP_BOOL checks whether the C++ compiler has a built in bool type
189dnl
190dnl call WX_CPP_BOOL - will define HAVE_BOOL if the compiler supports bool
191dnl ---------------------------------------------------------------------------
192
193AC_DEFUN(WX_CPP_BOOL,
194[
195 AC_CACHE_CHECK([if C++ compiler supports bool], wx_cv_cpp_bool,
196 [
197 AC_LANG_SAVE
198 AC_LANG_CPLUSPLUS
199
200 AC_TRY_RUN([
201 int main()
202 {
203 bool b = true;
204
205 return 0;
206 }
207 ],
208 [
209 AC_DEFINE(HAVE_BOOL)
210 wx_cv_cpp_bool=yes
211 ],
212 wx_cv_cpp_bool=no,
213 wx_cv_cpp_bool=no
214 )
215
216 AC_LANG_RESTORE
217 ])
218
219 if test "$wx_cv_cpp_bool" = "yes"; then
220 AC_DEFINE(HAVE_BOOL)
221 fi
222])
223
224dnl ---------------------------------------------------------------------------
225dnl WX_CPP_SIZE_T_IS_NOT_INT checks whether size_t and int are different types,
226dnl i.e. whether we may overload operator[] on its argument type
227dnl ---------------------------------------------------------------------------
228
229AC_DEFUN(WX_CPP_SIZE_T_IS_NOT_INT,
230[
231 AC_CACHE_CHECK([if size_t and int are different types], wx_cv_cpp_sizet_not_int,
232 [
233 AC_LANG_SAVE
234 AC_LANG_CPLUSPLUS
235
236 AC_TRY_RUN([
237 #include <stdlib.h>
238
239 class S
240 {
241 public:
242 S(char *s) { m_s = s; }
243
244 char operator[](size_t n) const { return m_s[n]; }
245 char operator[](int n) const { return m_s[n]; }
246
247 private:
248 char *m_s;
249 };
250
251 int main()
252 {
253 S s("dummy");
254 size_t n1 = 2;
255 int n2 = 3;
256
257 return s[n1] == s[n2];
258 }
259 ],
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
263 )
264
265 AC_LANG_RESTORE
266 ])
267])
268
269dnl ---------------------------------------------------------------------------
270dnl a slightly better AC_C_BIGENDIAN macro which allows cross-compiling
271dnl ---------------------------------------------------------------------------
272
273AC_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.
277AC_TRY_COMPILE([#include <sys/types.h>
278#include <sys/param.h>], [
279#if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
280 bogus endian macros
281#endif], [# It does; now see whether it defined to BIG_ENDIAN or not.
282AC_TRY_COMPILE([#include <sys/types.h>
283#include <sys/param.h>], [
284#if BYTE_ORDER != BIG_ENDIAN
285 not big endian
286#endif], ac_cv_c_bigendian=yes, ac_cv_c_bigendian=no)])
287if test $ac_cv_c_bigendian = unknown; then
288AC_TRY_RUN([main () {
289 /* Are we little or big endian? From Harbison&Steele. */
290 union
291 {
292 long l;
293 char c[sizeof (long)];
294 } u;
295 u.l = 1;
296 exit (u.c[sizeof (long) - 1] == 1);
297}], ac_cv_c_bigendian=no, ac_cv_c_bigendian=yes, ac_cv_c_bigendian=unknown)
298fi])
299if 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])
301fi
302if test $ac_cv_c_bigendian = yes; then
303 AC_DEFINE(WORDS_BIGENDIAN)
304fi
305])
306
307dnl ---------------------------------------------------------------------------
308dnl override AC_ARG_ENABLE/WITH to cache the results in .cache file
309dnl ---------------------------------------------------------------------------
310
311AC_DEFUN(WX_ARG_CACHE_INIT,
312 [
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}
318 ])
319
320AC_DEFUN(WX_ARG_CACHE_FLUSH,
321 [
322 echo "saving argument cache $wx_arg_cache_file"
323 mv ${wx_arg_cache_file}.tmp ${wx_arg_cache_file}
324 ])
325
326dnl this macro checks for a command line argument and caches the result
327dnl usage: WX_ARG_WITH(option, helpmessage, variable-name)
328AC_DEFUN(WX_ARG_WITH,
329 [
330 AC_MSG_CHECKING("for --with-$1")
331 no_cache=0
332 AC_ARG_WITH($1, $2,
333 [
334 if test "$withval" = yes; then
335 ac_cv_use_$1='$3=yes'
336 else
337 ac_cv_use_$1='$3=no'
338 fi
339 ],
340 [
341 LINE=`grep "$3" ${wx_arg_cache_file}`
342 if test "x$LINE" != x ; then
343 eval "DEFAULT_$LINE"
344 else
345 no_cache=1
346 fi
347
348 ac_cv_use_$1='$3='$DEFAULT_$3
349 ])
350
351 eval "$ac_cv_use_$1"
352 if test "$no_cache" != 1; then
353 echo $ac_cv_use_$1 >> ${wx_arg_cache_file}.tmp
354 fi
355
356 if test "$$3" = yes; then
357 AC_MSG_RESULT(yes)
358 else
359 AC_MSG_RESULT(no)
360 fi
361 ])
362
363dnl like WX_ARG_WITH but uses AC_ARG_ENABLE instead of AC_ARG_WITH
364dnl usage: WX_ARG_ENABLE(option, helpmessage, variable-name)
365AC_DEFUN(WX_ARG_ENABLE,
366 [
367 AC_MSG_CHECKING("for --enable-$1")
368 no_cache=0
369 AC_ARG_ENABLE($1, $2,
370 [
371 if test "$enableval" = yes; then
372 ac_cv_use_$1='$3=yes'
373 else
374 ac_cv_use_$1='$3=no'
375 fi
376 ],
377 [
378 LINE=`grep "$3" ${wx_arg_cache_file}`
379 if test "x$LINE" != x ; then
380 eval "DEFAULT_$LINE"
381 else
382 no_cache=1
383 fi
384
385 ac_cv_use_$1='$3='$DEFAULT_$3
386 ])
387
388 eval "$ac_cv_use_$1"
389 if test "$no_cache" != 1; then
390 echo $ac_cv_use_$1 >> ${wx_arg_cache_file}.tmp
391 fi
392
393 if test "$$3" = yes; then
394 AC_MSG_RESULT(yes)
395 else
396 AC_MSG_RESULT(no)
397 fi
398 ])
399
400dnl -
401dnl - GNU libc extension (added by GL)
402dnl -
403
404AC_DEFUN(WX_GNU_EXTENSIONS,
405[
406AC_MSG_CHECKING([if you need GNU extensions])
407AC_CACHE_VAL(wx_cv_gnu_extensions,[
408 AC_TRY_COMPILE([#include <features.h>],[
409
410#ifndef __GNU_LIBRARY__
411 Compile error wanted
412#endif
413
414],
415 [wx_cv_gnu_extensions=yes],
416 [wx_cv_gnu_extensions=no])
417])
418
419AC_MSG_RESULT($wx_cv_gnu_extensions)
420if test "$wx_cv_gnu_extensions" = "yes"; then
421 AC_DEFINE_UNQUOTED(_GNU_SOURCE)
422fi
423])