]> git.saurik.com Git - wxWidgets.git/blob - build/autoconf_prepend-include/autoconf/c.m4
copy wxAutohacks into main tree
[wxWidgets.git] / build / autoconf_prepend-include / autoconf / c.m4
1 # This file is part of Autoconf. -*- Autoconf -*-
2 # Programming languages support.
3 # Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2, or (at your option)
8 # any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
18 # 02111-1307, USA.
19 #
20 # As a special exception, the Free Software Foundation gives unlimited
21 # permission to copy, distribute and modify the configure scripts that
22 # are the output of Autoconf. You need not follow the terms of the GNU
23 # General Public License when using or distributing such scripts, even
24 # though portions of the text of Autoconf appear in them. The GNU
25 # General Public License (GPL) does govern all other use of the material
26 # that constitutes the Autoconf program.
27 #
28 # Certain portions of the Autoconf source text are designed to be copied
29 # (in certain cases, depending on the input) into the output of
30 # Autoconf. We call these the "data" portions. The rest of the Autoconf
31 # source text consists of comments plus executable code that decides which
32 # of the data portions to output in any given case. We call these
33 # comments and executable code the "non-data" portions. Autoconf never
34 # copies any of the non-data portions into its output.
35 #
36 # This special exception to the GPL applies to versions of Autoconf
37 # released by the Free Software Foundation. When you make and
38 # distribute a modified version of Autoconf, you may extend this special
39 # exception to the GPL to apply to your modified version as well, *unless*
40 # your modified version has the potential to copy into its output some
41 # of the text that was the non-data portion of the version that you started
42 # with. (In other words, unless your change moves or copies text from
43 # the non-data portions to the data portions.) If your modification has
44 # such potential, you must delete any notice of this special exception
45 # to the GPL from your modified version.
46 #
47 # Written by David MacKenzie, with help from
48 # Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,
49 # Roland McGrath, Noah Friedman, david d zuhn, and many others.
50
51
52 # -------------------- #
53 # 1b. The C language. #
54 # -------------------- #
55
56
57 # AC_LANG(C)
58 # ----------
59 # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
60 m4_define([AC_LANG(C)],
61 [ac_ext=c
62 ac_cpp='$CPP $CPPFLAGS'
63 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&AS_MESSAGE_LOG_FD'
64 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&AS_MESSAGE_LOG_FD'
65 ac_compiler_gnu=$ac_cv_c_compiler_gnu
66 ])
67
68
69 # AC_LANG_C
70 # ---------
71 AU_DEFUN([AC_LANG_C], [AC_LANG(C)])
72
73
74 # _AC_LANG_ABBREV(C)
75 # ------------------
76 m4_define([_AC_LANG_ABBREV(C)], [c])
77
78
79 # _AC_LANG_PREFIX(C)
80 # ------------------
81 m4_define([_AC_LANG_PREFIX(C)], [C])
82
83
84 # ---------------------- #
85 # 1c. The C++ language. #
86 # ---------------------- #
87
88
89 # AC_LANG(C++)
90 # ------------
91 # CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
92 m4_define([AC_LANG(C++)],
93 [ac_ext=cc
94 ac_cpp='$CXXCPP $CPPFLAGS'
95 ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&AS_MESSAGE_LOG_FD'
96 ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&AS_MESSAGE_LOG_FD'
97 ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
98 ])
99
100
101 # AC_LANG_CPLUSPLUS
102 # -----------------
103 AU_DEFUN([AC_LANG_CPLUSPLUS], [AC_LANG(C++)])
104
105
106 # _AC_LANG_ABBREV(C++)
107 # --------------------
108 m4_define([_AC_LANG_ABBREV(C++)], [cxx])
109
110
111 # _AC_LANG_PREFIX(C++)
112 # --------------------
113 m4_define([_AC_LANG_PREFIX(C++)], [CXX])
114
115
116
117 ## ---------------------- ##
118 ## 2.Producing programs. ##
119 ## ---------------------- ##
120
121
122 # --------------- #
123 # 2b. C sources. #
124 # --------------- #
125
126 # AC_LANG_SOURCE(C)(BODY)
127 # -----------------------
128 # This sometimes fails to find confdefs.h, for some reason.
129 # We can't use '#line $LINENO "configure"' here, since
130 # Sun c89 (Sun WorkShop 6 update 2 C 5.3 Patch 111679-08 2002/05/09)
131 # rejects $LINENO greater than 32767, and some configure scripts
132 # are longer than 32767 lines.
133 m4_define([AC_LANG_SOURCE(C)],
134 [/* confdefs.h. */
135 _ACEOF
136 cat confdefs.h >>conftest.$ac_ext
137 cat >>conftest.$ac_ext <<_ACEOF
138 /* end confdefs.h. */
139 $1])
140
141
142 # AC_LANG_PROGRAM(C)([PROLOGUE], [BODY])
143 # --------------------------------------
144 m4_define([AC_LANG_PROGRAM(C)],
145 [$1
146 m4_ifdef([_AC_LANG_PROGRAM_C_F77_HOOKS], [_AC_LANG_PROGRAM_C_F77_HOOKS])[]dnl
147 m4_ifdef([_AC_LANG_PROGRAM_C_FC_HOOKS], [_AC_LANG_PROGRAM_C_FC_HOOKS])[]dnl
148 int
149 main ()
150 {
151 dnl Do *not* indent the following line: there may be CPP directives.
152 dnl Don't move the `;' right after for the same reason.
153 $2
154 ;
155 return 0;
156 }])
157
158
159 # AC_LANG_CALL(C)(PROLOGUE, FUNCTION)
160 # -----------------------------------
161 # Avoid conflicting decl of main.
162 m4_define([AC_LANG_CALL(C)],
163 [AC_LANG_PROGRAM([$1
164 m4_if([$2], [main], ,
165 [/* Override any gcc2 internal prototype to avoid an error. */
166 #ifdef __cplusplus
167 extern "C"
168 #endif
169 /* We use char because int might match the return type of a gcc2
170 builtin and then its argument prototype would still apply. */
171 char $2 ();])], [$2 ();])])
172
173
174 # AC_LANG_FUNC_LINK_TRY(C)(FUNCTION)
175 # ----------------------------------
176 # Don't include <ctype.h> because on OSF/1 3.0 it includes
177 # <sys/types.h> which includes <sys/select.h> which contains a
178 # prototype for select. Similarly for bzero.
179 #
180 # This test used to merely assign f=$1 in main(), but that was
181 # optimized away by HP unbundled cc A.05.36 for ia64 under +O3,
182 # presumably on the basis that there's no need to do that store if the
183 # program is about to exit. Conversely, the AIX linker optimizes an
184 # unused external declaration that initializes f=$1. So this test
185 # program has both an external initialization of f, and a use of f in
186 # main that affects the exit status.
187 #
188 m4_define([AC_LANG_FUNC_LINK_TRY(C)],
189 [AC_LANG_PROGRAM(
190 [/* Define $1 to an innocuous variant, in case <limits.h> declares $1.
191 For example, HP-UX 11i <limits.h> declares gettimeofday. */
192 #define $1 innocuous_$1
193
194 /* System header to define __stub macros and hopefully few prototypes,
195 which can conflict with char $1 (); below.
196 Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
197 <limits.h> exists even on freestanding compilers. */
198
199 #ifdef __STDC__
200 # include <limits.h>
201 #else
202 # include <assert.h>
203 #endif
204
205 #undef $1
206
207 /* Override any gcc2 internal prototype to avoid an error. */
208 #ifdef __cplusplus
209 extern "C"
210 {
211 #endif
212 /* We use char because int might match the return type of a gcc2
213 builtin and then its argument prototype would still apply. */
214 char $1 ();
215 /* The GNU C library defines this for functions which it implements
216 to always fail with ENOSYS. Some functions are actually named
217 something starting with __ and the normal name is an alias. */
218 #if defined (__stub_$1) || defined (__stub___$1)
219 choke me
220 #else
221 char (*f) () = $1;
222 #endif
223 #ifdef __cplusplus
224 }
225 #endif
226 ], [return f != $1;])])
227
228
229 # AC_LANG_BOOL_COMPILE_TRY(C)(PROLOGUE, EXPRESSION)
230 # -------------------------------------------------
231 # Be sure to use this array to avoid `unused' warnings, which are even
232 # errors with `-W error'.
233 m4_define([AC_LANG_BOOL_COMPILE_TRY(C)],
234 [AC_LANG_PROGRAM([$1], [static int test_array @<:@1 - 2 * !($2)@:>@;
235 test_array @<:@0@:>@ = 0
236 ])])
237
238
239 # AC_LANG_INT_SAVE(C)(PROLOGUE, EXPRESSION)
240 # -----------------------------------------
241 # We need `stdio.h' to open a `FILE' and `stdlib.h' for `exit'.
242 # But we include them only after the EXPRESSION has been evaluated.
243 m4_define([AC_LANG_INT_SAVE(C)],
244 [AC_LANG_PROGRAM([$1
245 long longval () { return $2; }
246 unsigned long ulongval () { return $2; }
247 @%:@include <stdio.h>
248 @%:@include <stdlib.h>],
249 [
250 FILE *f = fopen ("conftest.val", "w");
251 if (! f)
252 exit (1);
253 if (($2) < 0)
254 {
255 long i = longval ();
256 if (i != ($2))
257 exit (1);
258 fprintf (f, "%ld\n", i);
259 }
260 else
261 {
262 unsigned long i = ulongval ();
263 if (i != ($2))
264 exit (1);
265 fprintf (f, "%lu\n", i);
266 }
267 exit (ferror (f) || fclose (f) != 0);
268 ])])
269
270
271 # ----------------- #
272 # 2c. C++ sources. #
273 # ----------------- #
274
275 # AC_LANG_SOURCE(C++)(BODY)
276 # -------------------------
277 m4_copy([AC_LANG_SOURCE(C)], [AC_LANG_SOURCE(C++)])
278
279
280 # AC_LANG_PROGRAM(C++)([PROLOGUE], [BODY])
281 # ----------------------------------------
282 m4_copy([AC_LANG_PROGRAM(C)], [AC_LANG_PROGRAM(C++)])
283
284
285 # AC_LANG_CALL(C++)(PROLOGUE, FUNCTION)
286 # -------------------------------------
287 m4_copy([AC_LANG_CALL(C)], [AC_LANG_CALL(C++)])
288
289
290 # AC_LANG_FUNC_LINK_TRY(C++)(FUNCTION)
291 # ------------------------------------
292 m4_copy([AC_LANG_FUNC_LINK_TRY(C)], [AC_LANG_FUNC_LINK_TRY(C++)])
293
294
295 # AC_LANG_BOOL_COMPILE_TRY(C++)(PROLOGUE, EXPRESSION)
296 # ---------------------------------------------------
297 m4_copy([AC_LANG_BOOL_COMPILE_TRY(C)], [AC_LANG_BOOL_COMPILE_TRY(C++)])
298
299
300 # AC_LANG_INT_SAVE(C++)(PROLOGUE, EXPRESSION)
301 # -------------------------------------------
302 m4_copy([AC_LANG_INT_SAVE(C)], [AC_LANG_INT_SAVE(C++)])
303
304
305
306 ## -------------------------------------------- ##
307 ## 3. Looking for Compilers and Preprocessors. ##
308 ## -------------------------------------------- ##
309
310 # -------------------- #
311 # 3b. The C compiler. #
312 # -------------------- #
313
314
315 # _AC_ARG_VAR_CPPFLAGS
316 # --------------------
317 # Document and register CPPFLAGS, which is used by
318 # AC_PROG_{CC, CPP, CXX, CXXCPP}.
319 AC_DEFUN([_AC_ARG_VAR_CPPFLAGS],
320 [AC_ARG_VAR([CPPFLAGS],
321 [C/C++ preprocessor flags, e.g. -I<include dir> if you have
322 headers in a nonstandard directory <include dir>])])
323
324
325 # _AC_ARG_VAR_LDFLAGS
326 # -------------------
327 # Document and register LDFLAGS, which is used by
328 # AC_PROG_{CC, CXX, F77}.
329 AC_DEFUN([_AC_ARG_VAR_LDFLAGS],
330 [AC_ARG_VAR([LDFLAGS],
331 [linker flags, e.g. -L<lib dir> if you have libraries in a
332 nonstandard directory <lib dir>])])
333
334
335
336 # AC_LANG_PREPROC(C)
337 # -------------------
338 # Find the C preprocessor. Must be AC_DEFUN'd to be AC_REQUIRE'able.
339 AC_DEFUN([AC_LANG_PREPROC(C)],
340 [AC_REQUIRE([AC_PROG_CPP])])
341
342
343 # _AC_PROG_PREPROC_WORKS_IFELSE(IF-WORKS, IF-NOT)
344 # -----------------------------------------------
345 # Check if $ac_cpp is a working preprocessor that can flag absent
346 # includes either by the exit status or by warnings.
347 # Set ac_cpp_err to a non-empty value if the preprocessor failed.
348 # This macro is for all languages, not only C.
349 AC_DEFUN([_AC_PROG_PREPROC_WORKS_IFELSE],
350 [ac_preproc_ok=false
351 for ac_[]_AC_LANG_ABBREV[]_preproc_warn_flag in '' yes
352 do
353 # Use a header file that comes with gcc, so configuring glibc
354 # with a fresh cross-compiler works.
355 # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
356 # <limits.h> exists even on freestanding compilers.
357 # On the NeXT, cc -E runs the code through the compiler's parser,
358 # not just through cpp. "Syntax error" is here to catch this case.
359 _AC_PREPROC_IFELSE([AC_LANG_SOURCE([[@%:@ifdef __STDC__
360 @%:@ include <limits.h>
361 @%:@else
362 @%:@ include <assert.h>
363 @%:@endif
364 Syntax error]])],
365 [],
366 [# Broken: fails on valid input.
367 continue])
368
369 # OK, works on sane cases. Now check whether non-existent headers
370 # can be detected and how.
371 _AC_PREPROC_IFELSE([AC_LANG_SOURCE([[@%:@include <ac_nonexistent.h>]])],
372 [# Broken: success on invalid input.
373 continue],
374 [# Passes both tests.
375 ac_preproc_ok=:
376 break])
377
378 done
379 # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
380 rm -f conftest.err conftest.$ac_ext
381 AS_IF([$ac_preproc_ok], [$1], [$2])])# _AC_PROG_PREPROC_WORKS_IFELSE
382
383
384 # AC_PROG_CPP
385 # -----------
386 # Find a working C preprocessor.
387 # We shouldn't have to require AC_PROG_CC, but this is due to the concurrency
388 # between the AC_LANG_COMPILER_REQUIRE family and that of AC_PROG_CC.
389 AN_MAKEVAR([CPP], [AC_PROG_CPP])
390 AN_PROGRAM([cpp], [AC_PROG_CPP])
391 AC_DEFUN([AC_PROG_CPP],
392 [AC_REQUIRE([AC_PROG_CC])dnl
393 AC_ARG_VAR([CPP], [C preprocessor])dnl
394 _AC_ARG_VAR_CPPFLAGS()dnl
395 AC_LANG_PUSH(C)dnl
396 AC_MSG_CHECKING([how to run the C preprocessor])
397 # On Suns, sometimes $CPP names a directory.
398 if test -n "$CPP" && test -d "$CPP"; then
399 CPP=
400 fi
401 if test -z "$CPP"; then
402 AC_CACHE_VAL([ac_cv_prog_CPP],
403 [dnl
404 # Double quotes because CPP needs to be expanded
405 for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
406 do
407 _AC_PROG_PREPROC_WORKS_IFELSE([break])
408 done
409 ac_cv_prog_CPP=$CPP
410 ])dnl
411 CPP=$ac_cv_prog_CPP
412 else
413 ac_cv_prog_CPP=$CPP
414 fi
415 AC_MSG_RESULT([$CPP])
416 _AC_PROG_PREPROC_WORKS_IFELSE([],
417 [AC_MSG_FAILURE([C preprocessor "$CPP" fails sanity check])])
418 AC_SUBST(CPP)dnl
419 AC_LANG_POP(C)dnl
420 ])# AC_PROG_CPP
421
422 # AC_PROG_CPP_WERROR
423 # ------------------
424 # Treat warnings from the preprocessor as errors.
425 AC_DEFUN([AC_PROG_CPP_WERROR],
426 [AC_REQUIRE([AC_PROG_CPP])dnl
427 ac_c_preproc_warn_flag=yes])# AC_PROG_CPP_WERROR
428
429 # AC_LANG_COMPILER(C)
430 # -------------------
431 # Find the C compiler. Must be AC_DEFUN'd to be AC_REQUIRE'able.
432 AC_DEFUN([AC_LANG_COMPILER(C)],
433 [AC_REQUIRE([AC_PROG_CC])])
434
435
436 # ac_cv_prog_gcc
437 # --------------
438 # We used to name the cache variable this way.
439 AU_DEFUN([ac_cv_prog_gcc],
440 [ac_cv_c_compiler_gnu])
441
442
443 # AC_PROG_CC([COMPILER ...])
444 # --------------------------
445 # COMPILER ... is a space separated list of C compilers to search for.
446 # This just gives the user an opportunity to specify an alternative
447 # search list for the C compiler.
448 AN_MAKEVAR([CC], [AC_PROG_CC])
449 AN_PROGRAM([cc], [AC_PROG_CC])
450 AN_PROGRAM([gcc], [AC_PROG_CC])
451 AC_DEFUN([AC_PROG_CC],
452 [AC_LANG_PUSH(C)dnl
453 AC_ARG_VAR([CC], [C compiler command])dnl
454 AC_ARG_VAR([CFLAGS], [C compiler flags])dnl
455 _AC_ARG_VAR_LDFLAGS()dnl
456 _AC_ARG_VAR_CPPFLAGS()dnl
457 m4_ifval([$1],
458 [AC_CHECK_TOOLS(CC, [$1])],
459 [AC_CHECK_TOOL(CC, gcc)
460 if test -z "$CC"; then
461 AC_CHECK_TOOL(CC, cc)
462 fi
463 if test -z "$CC"; then
464 AC_CHECK_PROG(CC, cc, cc, , , /usr/ucb/cc)
465 fi
466 if test -z "$CC"; then
467 AC_CHECK_TOOLS(CC, cl)
468 fi
469 ])
470
471 test -z "$CC" && AC_MSG_FAILURE([no acceptable C compiler found in \$PATH])
472
473 # Provide some information about the compiler.
474 echo "$as_me:$LINENO:" \
475 "checking for _AC_LANG compiler version" >&AS_MESSAGE_LOG_FD
476 ac_compiler=`set X $ac_compile; echo $[2]`
477 _AC_EVAL([$ac_compiler --version </dev/null >&AS_MESSAGE_LOG_FD])
478 _AC_EVAL([$ac_compiler -v </dev/null >&AS_MESSAGE_LOG_FD])
479 _AC_EVAL([$ac_compiler -V </dev/null >&AS_MESSAGE_LOG_FD])
480
481 m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
482 m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl
483 _AC_LANG_COMPILER_GNU
484 GCC=`test $ac_compiler_gnu = yes && echo yes`
485 _AC_PROG_CC_G
486 _AC_PROG_CC_STDC
487 # Some people use a C++ compiler to compile C. Since we use `exit',
488 # in C++ we need to declare it. In case someone uses the same compiler
489 # for both compiling C and C++ we need to have the C++ compiler decide
490 # the declaration of exit, since it's the most demanding environment.
491 _AC_COMPILE_IFELSE([@%:@ifndef __cplusplus
492 choke me
493 @%:@endif],
494 [_AC_PROG_CXX_EXIT_DECLARATION])
495 AC_LANG_POP(C)dnl
496 ])# AC_PROG_CC
497
498
499 # _AC_PROG_CC_G
500 # -------------
501 # Check whether -g works, even if CFLAGS is set, in case the package
502 # plays around with CFLAGS (such as to build both debugging and normal
503 # versions of a library), tasteless as that idea is.
504 m4_define([_AC_PROG_CC_G],
505 [ac_test_CFLAGS=${CFLAGS+set}
506 ac_save_CFLAGS=$CFLAGS
507 CFLAGS="$CFLAGS -g"
508 AC_CACHE_CHECK(whether $CC accepts -g, ac_cv_prog_cc_g,
509 [_AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [ac_cv_prog_cc_g=yes],
510 [ac_cv_prog_cc_g=no])])
511 if test "$ac_test_CFLAGS" = set; then
512 CFLAGS=$ac_save_CFLAGS
513 elif test $ac_cv_prog_cc_g = yes; then
514 if test "$GCC" = yes; then
515 CFLAGS="-g -O2"
516 else
517 CFLAGS="-g"
518 fi
519 else
520 if test "$GCC" = yes; then
521 CFLAGS="-O2"
522 else
523 CFLAGS=
524 fi
525 fi[]dnl
526 ])# _AC_PROG_CC_G
527
528
529 # AC_PROG_GCC_TRADITIONAL
530 # -----------------------
531 AN_FUNCTION([ioctl], [AC_PROG_GCC_TRADITIONAL])
532 AC_DEFUN([AC_PROG_GCC_TRADITIONAL],
533 [if test $ac_cv_c_compiler_gnu = yes; then
534 AC_CACHE_CHECK(whether $CC needs -traditional,
535 ac_cv_prog_gcc_traditional,
536 [ ac_pattern="Autoconf.*'x'"
537 AC_EGREP_CPP($ac_pattern, [#include <sgtty.h>
538 Autoconf TIOCGETP],
539 ac_cv_prog_gcc_traditional=yes, ac_cv_prog_gcc_traditional=no)
540
541 if test $ac_cv_prog_gcc_traditional = no; then
542 AC_EGREP_CPP($ac_pattern, [#include <termio.h>
543 Autoconf TCGETA],
544 ac_cv_prog_gcc_traditional=yes)
545 fi])
546 if test $ac_cv_prog_gcc_traditional = yes; then
547 CC="$CC -traditional"
548 fi
549 fi
550 ])# AC_PROG_GCC_TRADITIONAL
551
552
553 # AC_PROG_CC_C_O
554 # --------------
555 AC_DEFUN([AC_PROG_CC_C_O],
556 [AC_REQUIRE([AC_PROG_CC])dnl
557 if test "x$CC" != xcc; then
558 AC_MSG_CHECKING([whether $CC and cc understand -c and -o together])
559 else
560 AC_MSG_CHECKING([whether cc understands -c and -o together])
561 fi
562 set dummy $CC; ac_cc=`echo $[2] |
563 sed 's/[[^a-zA-Z0-9_]]/_/g;s/^[[0-9]]/_/'`
564 AC_CACHE_VAL(ac_cv_prog_cc_${ac_cc}_c_o,
565 [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])])
566 # Make sure it works both with $CC and with simple cc.
567 # We do the test twice because some compilers refuse to overwrite an
568 # existing .o file with -o, though they will create one.
569 ac_try='$CC -c conftest.$ac_ext -o conftest.$ac_objext >&AS_MESSAGE_LOG_FD'
570 if AC_TRY_EVAL(ac_try) &&
571 test -f conftest.$ac_objext && AC_TRY_EVAL(ac_try);
572 then
573 eval ac_cv_prog_cc_${ac_cc}_c_o=yes
574 if test "x$CC" != xcc; then
575 # Test first that cc exists at all.
576 if AC_TRY_COMMAND(cc -c conftest.$ac_ext >&AS_MESSAGE_LOG_FD); then
577 ac_try='cc -c conftest.$ac_ext -o conftest.$ac_objext >&AS_MESSAGE_LOG_FD'
578 if AC_TRY_EVAL(ac_try) &&
579 test -f conftest.$ac_objext && AC_TRY_EVAL(ac_try);
580 then
581 # cc works too.
582 :
583 else
584 # cc exists but doesn't like -o.
585 eval ac_cv_prog_cc_${ac_cc}_c_o=no
586 fi
587 fi
588 fi
589 else
590 eval ac_cv_prog_cc_${ac_cc}_c_o=no
591 fi
592 rm -f conftest*
593 ])dnl
594 if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = yes"; then
595 AC_MSG_RESULT([yes])
596 else
597 AC_MSG_RESULT([no])
598 AC_DEFINE(NO_MINUS_C_MINUS_O, 1,
599 [Define to 1 if your C compiler doesn't accept -c and -o together.])
600 fi
601 ])# AC_PROG_CC_C_O
602
603
604 # ---------------------- #
605 # 3c. The C++ compiler. #
606 # ---------------------- #
607
608
609 # AC_LANG_PREPROC(C++)
610 # ---------------------
611 # Find the C++ preprocessor. Must be AC_DEFUN'd to be AC_REQUIRE'able.
612 AC_DEFUN([AC_LANG_PREPROC(C++)],
613 [AC_REQUIRE([AC_PROG_CXXCPP])])
614
615
616 # AC_PROG_CXXCPP
617 # --------------
618 # Find a working C++ preprocessor.
619 # We shouldn't have to require AC_PROG_CC, but this is due to the concurrency
620 # between the AC_LANG_COMPILER_REQUIRE family and that of AC_PROG_CXX.
621 AC_DEFUN([AC_PROG_CXXCPP],
622 [AC_REQUIRE([AC_PROG_CXX])dnl
623 AC_ARG_VAR([CXXCPP], [C++ preprocessor])dnl
624 _AC_ARG_VAR_CPPFLAGS()dnl
625 AC_LANG_PUSH(C++)dnl
626 AC_MSG_CHECKING([how to run the C++ preprocessor])
627 if test -z "$CXXCPP"; then
628 AC_CACHE_VAL(ac_cv_prog_CXXCPP,
629 [dnl
630 # Double quotes because CXXCPP needs to be expanded
631 for CXXCPP in "$CXX -E" "/lib/cpp"
632 do
633 _AC_PROG_PREPROC_WORKS_IFELSE([break])
634 done
635 ac_cv_prog_CXXCPP=$CXXCPP
636 ])dnl
637 CXXCPP=$ac_cv_prog_CXXCPP
638 else
639 ac_cv_prog_CXXCPP=$CXXCPP
640 fi
641 AC_MSG_RESULT([$CXXCPP])
642 _AC_PROG_PREPROC_WORKS_IFELSE([],
643 [AC_MSG_FAILURE([C++ preprocessor "$CXXCPP" fails sanity check])])
644 AC_SUBST(CXXCPP)dnl
645 AC_LANG_POP(C++)dnl
646 ])# AC_PROG_CXXCPP
647
648
649 # AC_LANG_COMPILER(C++)
650 # ---------------------
651 # Find the C++ compiler. Must be AC_DEFUN'd to be AC_REQUIRE'able.
652 AC_DEFUN([AC_LANG_COMPILER(C++)],
653 [AC_REQUIRE([AC_PROG_CXX])])
654
655
656 # ac_cv_prog_gxx
657 # --------------
658 # We used to name the cache variable this way.
659 AU_DEFUN([ac_cv_prog_gxx],
660 [ac_cv_cxx_compiler_gnu])
661
662
663 # AC_PROG_CXX([LIST-OF-COMPILERS])
664 # --------------------------------
665 # LIST-OF-COMPILERS is a space separated list of C++ compilers to search
666 # for (if not specified, a default list is used). This just gives the
667 # user an opportunity to specify an alternative search list for the C++
668 # compiler.
669 # aCC HP-UX C++ compiler much better than `CC', so test before.
670 # FCC Fujitsu C++ compiler
671 # KCC KAI C++ compiler
672 # RCC Rational C++
673 # xlC_r AIX C Set++ (with support for reentrant code)
674 # xlC AIX C Set++
675 AN_MAKEVAR([CXX], [AC_PROG_CXX])
676 AN_PROGRAM([CC], [AC_PROG_CXX])
677 AN_PROGRAM([c++], [AC_PROG_CXX])
678 AN_PROGRAM([g++], [AC_PROG_CXX])
679 AC_DEFUN([AC_PROG_CXX],
680 [AC_LANG_PUSH(C++)dnl
681 AC_ARG_VAR([CXX], [C++ compiler command])dnl
682 AC_ARG_VAR([CXXFLAGS], [C++ compiler flags])dnl
683 _AC_ARG_VAR_LDFLAGS()dnl
684 _AC_ARG_VAR_CPPFLAGS()dnl
685 AC_CHECK_TOOLS(CXX,
686 [$CCC m4_default([$1],
687 [g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC])],
688 g++)
689
690 # Provide some information about the compiler.
691 echo "$as_me:$LINENO:" \
692 "checking for _AC_LANG compiler version" >&AS_MESSAGE_LOG_FD
693 ac_compiler=`set X $ac_compile; echo $[2]`
694 _AC_EVAL([$ac_compiler --version </dev/null >&AS_MESSAGE_LOG_FD])
695 _AC_EVAL([$ac_compiler -v </dev/null >&AS_MESSAGE_LOG_FD])
696 _AC_EVAL([$ac_compiler -V </dev/null >&AS_MESSAGE_LOG_FD])
697
698 m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
699 m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl
700 _AC_LANG_COMPILER_GNU
701 GXX=`test $ac_compiler_gnu = yes && echo yes`
702 _AC_PROG_CXX_G
703 _AC_PROG_CXX_EXIT_DECLARATION
704 AC_LANG_POP(C++)dnl
705 ])# AC_PROG_CXX
706
707
708 # _AC_PROG_CXX_G
709 # --------------
710 # Check whether -g works, even if CXXFLAGS is set, in case the package
711 # plays around with CXXFLAGS (such as to build both debugging and
712 # normal versions of a library), tasteless as that idea is.
713 m4_define([_AC_PROG_CXX_G],
714 [ac_test_CXXFLAGS=${CXXFLAGS+set}
715 ac_save_CXXFLAGS=$CXXFLAGS
716 CXXFLAGS="-g"
717 AC_CACHE_CHECK(whether $CXX accepts -g, ac_cv_prog_cxx_g,
718 [_AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
719 [ac_cv_prog_cxx_g=yes],
720 [ac_cv_prog_cxx_g=no])])
721 if test "$ac_test_CXXFLAGS" = set; then
722 CXXFLAGS=$ac_save_CXXFLAGS
723 elif test $ac_cv_prog_cxx_g = yes; then
724 if test "$GXX" = yes; then
725 CXXFLAGS="$CXXFLAGS -g -O2"
726 else
727 CXXFLAGS="$CXXFLAGS -g"
728 fi
729 else
730 if test "$GXX" = yes; then
731 CXXFLAGS="-O2"
732 else
733 CXXFLAGS=
734 fi
735 fi[]dnl
736 ])# _AC_PROG_CXX_G
737
738
739 # _AC_PROG_CXX_EXIT_DECLARATION
740 # -----------------------------
741 # If <stdlib.h> doesn't already provide a valid prototype for exit,
742 # determine the appropriate prototype and put it in confdefs.h.
743 # This macro is run only when testing a C++ compiler, but it generates
744 # a prototype that is also appropriate for C compilers in order to
745 # support a mixed C/C++ configuration environment.
746 # We don't need to worry about this for C, since we include <stdlib.h>
747 # if it is available, and that method works for all C compilers.
748 m4_define([_AC_PROG_CXX_EXIT_DECLARATION],
749 [for ac_declaration in \
750 '' \
751 'extern "C" void std::exit (int) throw (); using std::exit;' \
752 'extern "C" void std::exit (int); using std::exit;' \
753 'extern "C" void exit (int) throw ();' \
754 'extern "C" void exit (int);' \
755 'void exit (int);'
756 do
757 _AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$ac_declaration
758 @%:@include <stdlib.h>],
759 [exit (42);])],
760 [],
761 [continue])
762 _AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$ac_declaration],
763 [exit (42);])],
764 [break])
765 done
766 rm -f conftest*
767 if test -n "$ac_declaration"; then
768 echo '#ifdef __cplusplus' >>confdefs.h
769 echo $ac_declaration >>confdefs.h
770 echo '#endif' >>confdefs.h
771 fi
772 ])# _AC_PROG_CXX_EXIT_DECLARATION
773
774
775
776
777
778
779 ## ------------------------------- ##
780 ## 4. Compilers' characteristics. ##
781 ## ------------------------------- ##
782
783
784 # -------------------------------- #
785 # 4b. C compiler characteristics. #
786 # -------------------------------- #
787
788 # _AC_PROG_CC_STDC
789 # ----------------
790 # If the C compiler in not in ANSI C mode by default, try to add an
791 # option to output variable @code{CC} to make it so. This macro tries
792 # various options that select ANSI C on some system or another. It
793 # considers the compiler to be in ANSI C mode if it handles function
794 # prototypes correctly.
795 AC_DEFUN([_AC_PROG_CC_STDC],
796 [AC_MSG_CHECKING([for $CC option to accept ANSI C])
797 AC_CACHE_VAL(ac_cv_prog_cc_stdc,
798 [ac_cv_prog_cc_stdc=no
799 ac_save_CC=$CC
800 AC_LANG_CONFTEST([AC_LANG_PROGRAM(
801 [[#include <stdarg.h>
802 #include <stdio.h>
803 #include <sys/types.h>
804 #include <sys/stat.h>
805 /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
806 struct buf { int x; };
807 FILE * (*rcsopen) (struct buf *, struct stat *, int);
808 static char *e (p, i)
809 char **p;
810 int i;
811 {
812 return p[i];
813 }
814 static char *f (char * (*g) (char **, int), char **p, ...)
815 {
816 char *s;
817 va_list v;
818 va_start (v,p);
819 s = g (p, va_arg (v,int));
820 va_end (v);
821 return s;
822 }
823
824 /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has
825 function prototypes and stuff, but not '\xHH' hex character constants.
826 These don't provoke an error unfortunately, instead are silently treated
827 as 'x'. The following induces an error, until -std1 is added to get
828 proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an
829 array size at least. It's necessary to write '\x00'==0 to get something
830 that's true only with -std1. */
831 int osf4_cc_array ['\x00' == 0 ? 1 : -1];
832
833 int test (int i, double x);
834 struct s1 {int (*f) (int a);};
835 struct s2 {int (*f) (double a);};
836 int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
837 int argc;
838 char **argv;]],
839 [[return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];]])])
840 # Don't try gcc -ansi; that turns off useful extensions and
841 # breaks some systems' header files.
842 # AIX -qlanglvl=ansi
843 # Ultrix and OSF/1 -std1
844 # HP-UX 10.20 and later -Ae
845 # HP-UX older versions -Aa -D_HPUX_SOURCE
846 # SVR4 -Xc -D__EXTENSIONS__
847 for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
848 do
849 CC="$ac_save_CC $ac_arg"
850 _AC_COMPILE_IFELSE([],
851 [ac_cv_prog_cc_stdc=$ac_arg
852 break])
853 done
854 rm -f conftest.$ac_ext conftest.$ac_objext
855 CC=$ac_save_CC
856 ])
857 case "x$ac_cv_prog_cc_stdc" in
858 x|xno)
859 AC_MSG_RESULT([none needed]) ;;
860 *)
861 AC_MSG_RESULT([$ac_cv_prog_cc_stdc])
862 CC="$CC $ac_cv_prog_cc_stdc" ;;
863 esac
864 ])# _AC_PROG_CC_STDC
865
866
867 # AC_PROG_CC_STDC
868 # ---------------
869 # Has been merged into AC_PROG_CC.
870 AU_DEFUN([AC_PROG_CC_STDC], [])
871
872
873 # AC_C_BACKSLASH_A
874 # ----------------
875 AC_DEFUN([AC_C_BACKSLASH_A],
876 [
877 AC_CACHE_CHECK([whether backslash-a works in strings], ac_cv_c_backslash_a,
878 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
879 [[
880 #if '\a' == 'a'
881 syntax error;
882 #endif
883 char buf['\a' == 'a' ? -1 : 1];
884 buf[0] = '\a';
885 return buf[0] != "\a"[0];
886 ]])],
887 [ac_cv_c_backslash_a=yes],
888 [ac_cv_c_backslash_a=no])])
889 if test $ac_cv_c_backslash_a = yes; then
890 AC_DEFINE(HAVE_C_BACKSLASH_A, 1,
891 [Define if backslash-a works in C strings.])
892 fi
893 ])
894
895
896 # AC_C_CROSS
897 # ----------
898 # Has been merged into AC_PROG_CC.
899 AU_DEFUN([AC_C_CROSS], [])
900
901
902 # AC_C_CHAR_UNSIGNED
903 # ------------------
904 AC_DEFUN([AC_C_CHAR_UNSIGNED],
905 [AH_VERBATIM([__CHAR_UNSIGNED__],
906 [/* Define to 1 if type `char' is unsigned and you are not using gcc. */
907 #ifndef __CHAR_UNSIGNED__
908 # undef __CHAR_UNSIGNED__
909 #endif])dnl
910 AC_CACHE_CHECK(whether char is unsigned, ac_cv_c_char_unsigned,
911 [AC_COMPILE_IFELSE([AC_LANG_BOOL_COMPILE_TRY([AC_INCLUDES_DEFAULT([])],
912 [((char) -1) < 0])],
913 ac_cv_c_char_unsigned=no, ac_cv_c_char_unsigned=yes)])
914 if test $ac_cv_c_char_unsigned = yes && test "$GCC" != yes; then
915 AC_DEFINE(__CHAR_UNSIGNED__)
916 fi
917 ])# AC_C_CHAR_UNSIGNED
918
919
920 # AC_C_LONG_DOUBLE
921 # ----------------
922 AC_DEFUN([AC_C_LONG_DOUBLE],
923 [AC_CACHE_CHECK(
924 [for working long double with more range or precision than double],
925 [ac_cv_c_long_double],
926 [AC_COMPILE_IFELSE(
927 [AC_LANG_BOOL_COMPILE_TRY(
928 [#include <float.h>
929 long double foo = 0.0;],
930 [/* Using '|' rather than '||' catches a GCC 2.95.2 x86 bug. */
931 (DBL_MAX < LDBL_MAX) | (LDBL_EPSILON < DBL_EPSILON)
932 | (DBL_MAX_EXP < LDBL_MAX_EXP) | (DBL_MANT_DIG < LDBL_MANT_DIG)])],
933 ac_cv_c_long_double=yes,
934 ac_cv_c_long_double=no)])
935 if test $ac_cv_c_long_double = yes; then
936 AC_DEFINE(HAVE_LONG_DOUBLE, 1,
937 [Define to 1 if long double works and has more range or precision than double.])
938 fi
939 ])# AC_C_LONG_DOUBLE
940
941
942 # AC_C_BIGENDIAN ([ACTION-IF-TRUE], [ACTION-IF-FALSE], [ACTION-IF-UNKNOWN])
943 # -------------------------------------------------------------------------
944 AC_DEFUN([AC_C_BIGENDIAN],
945 [AC_CACHE_CHECK(whether byte ordering is bigendian, ac_cv_c_bigendian,
946 [# See if sys/param.h defines the BYTE_ORDER macro.
947 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>
948 #include <sys/param.h>
949 ],
950 [#if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
951 bogus endian macros
952 #endif
953 ])],
954 [# It does; now see whether it defined to BIG_ENDIAN or not.
955 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>
956 #include <sys/param.h>
957 ], [#if BYTE_ORDER != BIG_ENDIAN
958 not big endian
959 #endif
960 ])], [ac_cv_c_bigendian=yes], [ac_cv_c_bigendian=no])],
961 [# It does not; compile a test program.
962 AC_RUN_IFELSE(
963 [AC_LANG_SOURCE([[int
964 main ()
965 {
966 /* Are we little or big endian? From Harbison&Steele. */
967 union
968 {
969 long l;
970 char c[sizeof (long)];
971 } u;
972 u.l = 1;
973 exit (u.c[sizeof (long) - 1] == 1);
974 }]])],
975 [ac_cv_c_bigendian=no],
976 [ac_cv_c_bigendian=yes],
977 [# try to guess the endianness by grepping values into an object file
978 ac_cv_c_bigendian=unknown
979 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
980 [[short ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 };
981 short ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 };
982 void _ascii () { char *s = (char *) ascii_mm; s = (char *) ascii_ii; }
983 short ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 };
984 short ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 };
985 void _ebcdic () { char *s = (char *) ebcdic_mm; s = (char *) ebcdic_ii; }]],
986 [[ _ascii (); _ebcdic (); ]])],
987 [if grep BIGenDianSyS conftest.$ac_objext >/dev/null ; then
988 ac_cv_c_bigendian=yes
989 fi
990 if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then
991 if test "$ac_cv_c_bigendian" = unknown; then
992 ac_cv_c_bigendian=no
993 else
994 # finding both strings is unlikely to happen, but who knows?
995 ac_cv_c_bigendian=unknown
996 fi
997 fi])])])])
998 case $ac_cv_c_bigendian in
999 yes)
1000 m4_default([$1],
1001 [AC_DEFINE([WORDS_BIGENDIAN], 1,
1002 [Define to 1 if your processor stores words with the most significant
1003 byte first (like Motorola and SPARC, unlike Intel and VAX).])]) ;;
1004 no)
1005 $2 ;;
1006 *)
1007 m4_default([$3],
1008 [AC_MSG_ERROR([unknown endianness
1009 presetting ac_cv_c_bigendian=no (or yes) will help])]) ;;
1010 esac
1011 ])# AC_C_BIGENDIAN
1012
1013
1014 # AC_C_INLINE
1015 # -----------
1016 # Do nothing if the compiler accepts the inline keyword.
1017 # Otherwise define inline to __inline__ or __inline if one of those work,
1018 # otherwise define inline to be empty.
1019 #
1020 # HP C version B.11.11.04 doesn't allow a typedef as the return value for an
1021 # inline function, only builtin types.
1022 #
1023 AN_IDENTIFIER([inline], [AC_C_INLINE])
1024 AC_DEFUN([AC_C_INLINE],
1025 [AC_CACHE_CHECK([for inline], ac_cv_c_inline,
1026 [ac_cv_c_inline=no
1027 for ac_kw in inline __inline__ __inline; do
1028 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1029 [#ifndef __cplusplus
1030 typedef int foo_t;
1031 static $ac_kw foo_t static_foo () {return 0; }
1032 $ac_kw foo_t foo () {return 0; }
1033 #endif
1034 ])],
1035 [ac_cv_c_inline=$ac_kw; break])
1036 done
1037 ])
1038 AH_VERBATIM([inline],
1039 [/* Define to `__inline__' or `__inline' if that's what the C compiler
1040 calls it, or to nothing if 'inline' is not supported under any name. */
1041 #ifndef __cplusplus
1042 #undef inline
1043 #endif])
1044 case $ac_cv_c_inline in
1045 inline | yes) ;;
1046 *)
1047 case $ac_cv_c_inline in
1048 no) ac_val=;;
1049 *) ac_val=$ac_cv_c_inline;;
1050 esac
1051 cat >>confdefs.h <<_ACEOF
1052 #ifndef __cplusplus
1053 #define inline $ac_val
1054 #endif
1055 _ACEOF
1056 ;;
1057 esac
1058 ])# AC_C_INLINE
1059
1060
1061 # AC_C_CONST
1062 # ----------
1063 AN_IDENTIFIER([const], [AC_C_CONST])
1064 AC_DEFUN([AC_C_CONST],
1065 [AC_CACHE_CHECK([for an ANSI C-conforming const], ac_cv_c_const,
1066 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
1067 [[/* FIXME: Include the comments suggested by Paul. */
1068 #ifndef __cplusplus
1069 /* Ultrix mips cc rejects this. */
1070 typedef int charset[2];
1071 const charset x;
1072 /* SunOS 4.1.1 cc rejects this. */
1073 char const *const *ccp;
1074 char **p;
1075 /* NEC SVR4.0.2 mips cc rejects this. */
1076 struct point {int x, y;};
1077 static struct point const zero = {0,0};
1078 /* AIX XL C 1.02.0.0 rejects this.
1079 It does not let you subtract one const X* pointer from another in
1080 an arm of an if-expression whose if-part is not a constant
1081 expression */
1082 const char *g = "string";
1083 ccp = &g + (g ? g-g : 0);
1084 /* HPUX 7.0 cc rejects these. */
1085 ++ccp;
1086 p = (char**) ccp;
1087 ccp = (char const *const *) p;
1088 { /* SCO 3.2v4 cc rejects this. */
1089 char *t;
1090 char const *s = 0 ? (char *) 0 : (char const *) 0;
1091
1092 *t++ = 0;
1093 }
1094 { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */
1095 int x[] = {25, 17};
1096 const int *foo = &x[0];
1097 ++foo;
1098 }
1099 { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
1100 typedef const int *iptr;
1101 iptr p = 0;
1102 ++p;
1103 }
1104 { /* AIX XL C 1.02.0.0 rejects this saying
1105 "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
1106 struct s { int j; const int *ap[3]; };
1107 struct s *b; b->j = 5;
1108 }
1109 { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
1110 const int foo = 10;
1111 }
1112 #endif
1113 ]])],
1114 [ac_cv_c_const=yes],
1115 [ac_cv_c_const=no])])
1116 if test $ac_cv_c_const = no; then
1117 AC_DEFINE(const,,
1118 [Define to empty if `const' does not conform to ANSI C.])
1119 fi
1120 ])# AC_C_CONST
1121
1122
1123 # AC_C_RESTRICT
1124 # -------------
1125 # based on acx_restrict.m4, from the GNU Autoconf Macro Archive at:
1126 # http://www.gnu.org/software/ac-archive/htmldoc/acx_restrict.html
1127 #
1128 # Determine whether the C/C++ compiler supports the "restrict" keyword
1129 # introduced in ANSI C99, or an equivalent. Do nothing if the compiler
1130 # accepts it. Otherwise, if the compiler supports an equivalent,
1131 # define "restrict" to be that. Here are some variants:
1132 # - GCC supports both __restrict and __restrict__
1133 # - older DEC Alpha C compilers support only __restrict
1134 # - _Restrict is the only spelling accepted by Sun WorkShop 6 update 2 C
1135 # Otherwise, define "restrict" to be empty.
1136 AN_IDENTIFIER([restrict], [AC_C_RESTRICT])
1137 AC_DEFUN([AC_C_RESTRICT],
1138 [AC_CACHE_CHECK([for C/C++ restrict keyword], ac_cv_c_restrict,
1139 [ac_cv_c_restrict=no
1140 # Try the official restrict keyword, then gcc's __restrict, and
1141 # the less common variants.
1142 for ac_kw in restrict __restrict __restrict__ _Restrict; do
1143 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1144 [float * $ac_kw x;])],
1145 [ac_cv_c_restrict=$ac_kw; break])
1146 done
1147 ])
1148 case $ac_cv_c_restrict in
1149 restrict) ;;
1150 no) AC_DEFINE(restrict,,
1151 [Define to equivalent of C99 restrict keyword, or to nothing if this
1152 is not supported. Do not define if restrict is supported directly.]) ;;
1153 *) AC_DEFINE_UNQUOTED(restrict, $ac_cv_c_restrict) ;;
1154 esac
1155 ])# AC_C_RESTRICT
1156
1157
1158 # AC_C_VOLATILE
1159 # -------------
1160 # Note that, unlike const, #defining volatile to be the empty string can
1161 # actually turn a correct program into an incorrect one, since removing
1162 # uses of volatile actually grants the compiler permission to perform
1163 # optimizations that could break the user's code. So, do not #define
1164 # volatile away unless it is really necessary to allow the user's code
1165 # to compile cleanly. Benign compiler failures should be tolerated.
1166 AN_IDENTIFIER([volatile], [AC_C_VOLATILE])
1167 AC_DEFUN([AC_C_VOLATILE],
1168 [AC_CACHE_CHECK([for working volatile], ac_cv_c_volatile,
1169 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
1170 volatile int x;
1171 int * volatile y;])],
1172 [ac_cv_c_volatile=yes],
1173 [ac_cv_c_volatile=no])])
1174 if test $ac_cv_c_volatile = no; then
1175 AC_DEFINE(volatile,,
1176 [Define to empty if the keyword `volatile' does not work.
1177 Warning: valid code using `volatile' can become incorrect
1178 without. Disable with care.])
1179 fi
1180 ])# AC_C_VOLATILE
1181
1182
1183 # AC_C_STRINGIZE
1184 # --------------
1185 # Checks if `#' can be used to glue strings together at the CPP level.
1186 # Defines HAVE_STRINGIZE if positive.
1187 AC_DEFUN([AC_C_STRINGIZE],
1188 [AC_CACHE_CHECK([for preprocessor stringizing operator],
1189 [ac_cv_c_stringize],
1190 [AC_EGREP_CPP([@%:@teststring],
1191 [@%:@define x(y) #y
1192
1193 char *s = x(teststring);],
1194 [ac_cv_c_stringize=no],
1195 [ac_cv_c_stringize=yes])])
1196 if test $ac_cv_c_stringize = yes; then
1197 AC_DEFINE(HAVE_STRINGIZE, 1,
1198 [Define to 1 if cpp supports the ANSI @%:@ stringizing operator.])
1199 fi
1200 ])# AC_C_STRINGIZE
1201
1202
1203 # AC_C_PROTOTYPES
1204 # ---------------
1205 # Check if the C compiler supports prototypes, included if it needs
1206 # options.
1207 AC_DEFUN([AC_C_PROTOTYPES],
1208 [AC_REQUIRE([AC_PROG_CC])dnl
1209 AC_MSG_CHECKING([for function prototypes])
1210 if test "$ac_cv_prog_cc_stdc" != no; then
1211 AC_MSG_RESULT([yes])
1212 AC_DEFINE(PROTOTYPES, 1,
1213 [Define to 1 if the C compiler supports function prototypes.])
1214 AC_DEFINE(__PROTOTYPES, 1,
1215 [Define like PROTOTYPES; this can be used by system headers.])
1216 else
1217 AC_MSG_RESULT([no])
1218 fi
1219 ])# AC_C_PROTOTYPES