1 # This file is part of Autoconf. -*- Autoconf -*-
2 # Programming languages support.
3 # Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 Free Software
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2, or (at your option)
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 # As a special exception, the Free Software Foundation gives unlimited
22 # permission to copy, distribute and modify the configure scripts that
23 # are the output of Autoconf. You need not follow the terms of the GNU
24 # General Public License when using or distributing such scripts, even
25 # though portions of the text of Autoconf appear in them. The GNU
26 # General Public License (GPL) does govern all other use of the material
27 # that constitutes the Autoconf program.
29 # Certain portions of the Autoconf source text are designed to be copied
30 # (in certain cases, depending on the input) into the output of
31 # Autoconf. We call these the "data" portions. The rest of the Autoconf
32 # source text consists of comments plus executable code that decides which
33 # of the data portions to output in any given case. We call these
34 # comments and executable code the "non-data" portions. Autoconf never
35 # copies any of the non-data portions into its output.
37 # This special exception to the GPL applies to versions of Autoconf
38 # released by the Free Software Foundation. When you make and
39 # distribute a modified version of Autoconf, you may extend this special
40 # exception to the GPL to apply to your modified version as well, *unless*
41 # your modified version has the potential to copy into its output some
42 # of the text that was the non-data portion of the version that you started
43 # with. (In other words, unless your change moves or copies text from
44 # the non-data portions to the data portions.) If your modification has
45 # such potential, you must delete any notice of this special exception
46 # to the GPL from your modified version.
48 # Written by David MacKenzie, with help from
49 # Akim Demaille, Paul Eggert,
50 # Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,
51 # Roland McGrath, Noah Friedman, david d zuhn, and many others.
54 # -------------------- #
55 # 1b. The C language. #
56 # -------------------- #
61 # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
62 m4_define([AC_LANG(C)],
64 ac_cpp='$CPP $CPPFLAGS'
65 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&AS_MESSAGE_LOG_FD'
66 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&AS_MESSAGE_LOG_FD'
67 ac_compiler_gnu=$ac_cv_c_compiler_gnu
73 AU_DEFUN([AC_LANG_C], [AC_LANG(C)])
78 m4_define([_AC_LANG_ABBREV(C)], [c])
83 m4_define([_AC_LANG_PREFIX(C)], [C])
86 # ---------------------- #
87 # 1c. The C++ language. #
88 # ---------------------- #
93 # CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
94 m4_define([AC_LANG(C++)],
96 ac_cpp='$CXXCPP $CPPFLAGS'
97 ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&AS_MESSAGE_LOG_FD'
98 ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&AS_MESSAGE_LOG_FD'
99 ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
105 AU_DEFUN([AC_LANG_CPLUSPLUS], [AC_LANG(C++)])
108 # _AC_LANG_ABBREV(C++)
109 # --------------------
110 m4_define([_AC_LANG_ABBREV(C++)], [cxx])
113 # _AC_LANG_PREFIX(C++)
114 # --------------------
115 m4_define([_AC_LANG_PREFIX(C++)], [CXX])
119 # ------------------------------ #
120 # 1d. The Objective C language. #
121 # ------------------------------ #
124 # AC_LANG(Objective C)
125 # --------------------
126 m4_define([AC_LANG(Objective C)],
128 ac_cpp='$OBJCPP $CPPFLAGS'
129 ac_compile='$OBJC -c $OBJCFLAGS $CPPFLAGS conftest.$ac_ext >&AS_MESSAGE_LOG_FD'
130 ac_link='$OBJC -o conftest$ac_exeext $OBJCFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&AS_MESSAGE_LOG_FD'
131 ac_compiler_gnu=$ac_cv_objc_compiler_gnu
137 AU_DEFUN([AC_LANG_OBJC], [AC_LANG(Objective C)])
140 # _AC_LANG_ABBREV(Objective C)
141 # ----------------------------
142 m4_define([_AC_LANG_ABBREV(Objective C)], [objc])
145 # _AC_LANG_PREFIX(Objective C)
146 # ----------------------------
147 m4_define([_AC_LANG_PREFIX(Objective C)], [OBJC])
151 ## ---------------------- ##
152 ## 2.Producing programs. ##
153 ## ---------------------- ##
160 # AC_LANG_SOURCE(C)(BODY)
161 # -----------------------
162 # We can't use '#line $LINENO "configure"' here, since
163 # Sun c89 (Sun WorkShop 6 update 2 C 5.3 Patch 111679-08 2002/05/09)
164 # rejects $LINENO greater than 32767, and some configure scripts
165 # are longer than 32767 lines.
166 m4_define([AC_LANG_SOURCE(C)],
169 cat confdefs.h >>conftest.$ac_ext
170 cat >>conftest.$ac_ext <<_ACEOF
171 /* end confdefs.h. */
175 # AC_LANG_PROGRAM(C)([PROLOGUE], [BODY])
176 # --------------------------------------
177 m4_define([AC_LANG_PROGRAM(C)],
179 m4_ifdef([_AC_LANG_PROGRAM_C_F77_HOOKS], [_AC_LANG_PROGRAM_C_F77_HOOKS])[]dnl
180 m4_ifdef([_AC_LANG_PROGRAM_C_FC_HOOKS], [_AC_LANG_PROGRAM_C_FC_HOOKS])[]dnl
184 dnl Do *not* indent the following line: there may be CPP directives.
185 dnl Don't move the `;' right after for the same reason.
192 # AC_LANG_CALL(C)(PROLOGUE, FUNCTION)
193 # -----------------------------------
194 # Avoid conflicting decl of main.
195 m4_define([AC_LANG_CALL(C)],
197 m4_if([$2], [main], ,
198 [/* Override any GCC internal prototype to avoid an error.
199 Use char because int might match the return type of a GCC
200 builtin and then its argument prototype would still apply. */
204 char $2 ();])], [return $2 ();])])
207 # AC_LANG_FUNC_LINK_TRY(C)(FUNCTION)
208 # ----------------------------------
209 # Don't include <ctype.h> because on OSF/1 3.0 it includes
210 # <sys/types.h> which includes <sys/select.h> which contains a
211 # prototype for select. Similarly for bzero.
213 # This test used to merely assign f=$1 in main(), but that was
214 # optimized away by HP unbundled cc A.05.36 for ia64 under +O3,
215 # presumably on the basis that there's no need to do that store if the
216 # program is about to exit. Conversely, the AIX linker optimizes an
217 # unused external declaration that initializes f=$1. So this test
218 # program has both an external initialization of f, and a use of f in
219 # main that affects the exit status.
221 m4_define([AC_LANG_FUNC_LINK_TRY(C)],
223 [/* Define $1 to an innocuous variant, in case <limits.h> declares $1.
224 For example, HP-UX 11i <limits.h> declares gettimeofday. */
225 #define $1 innocuous_$1
227 /* System header to define __stub macros and hopefully few prototypes,
228 which can conflict with char $1 (); below.
229 Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
230 <limits.h> exists even on freestanding compilers. */
240 /* Override any GCC internal prototype to avoid an error.
241 Use char because int might match the return type of a GCC
242 builtin and then its argument prototype would still apply. */
247 /* The GNU C library defines this for functions which it implements
248 to always fail with ENOSYS. Some functions are actually named
249 something starting with __ and the normal name is an alias. */
250 #if defined __stub_$1 || defined __stub___$1
253 ], [return $1 ();])])
256 # AC_LANG_BOOL_COMPILE_TRY(C)(PROLOGUE, EXPRESSION)
257 # -------------------------------------------------
258 # Return a program that is valid if EXPRESSION is nonzero.
259 # EXPRESSION must be an integer constant expression.
260 # Be sure to use this array to avoid `unused' warnings, which are even
261 # errors with `-W error'.
262 m4_define([AC_LANG_BOOL_COMPILE_TRY(C)],
263 [AC_LANG_PROGRAM([$1], [static int test_array @<:@1 - 2 * !($2)@:>@;
264 test_array @<:@0@:>@ = 0
268 # AC_LANG_INT_SAVE(C)(PROLOGUE, EXPRESSION)
269 # -----------------------------------------
270 # We need `stdio.h' to open a `FILE' and `stdlib.h' for `exit'.
271 # But we include them only after the EXPRESSION has been evaluated.
272 m4_define([AC_LANG_INT_SAVE(C)],
274 static long int longval () { return $2; }
275 static unsigned long int ulongval () { return $2; }
276 @%:@include <stdio.h>
277 @%:@include <stdlib.h>],
279 FILE *f = fopen ("conftest.val", "w");
284 long int i = longval ();
287 fprintf (f, "%ld\n", i);
291 unsigned long int i = ulongval ();
294 fprintf (f, "%lu\n", i);
296 return ferror (f) || fclose (f) != 0;
300 # ----------------- #
302 # ----------------- #
304 # AC_LANG_SOURCE(C++)(BODY)
305 # -------------------------
306 m4_copy([AC_LANG_SOURCE(C)], [AC_LANG_SOURCE(C++)])
309 # AC_LANG_PROGRAM(C++)([PROLOGUE], [BODY])
310 # ----------------------------------------
311 m4_copy([AC_LANG_PROGRAM(C)], [AC_LANG_PROGRAM(C++)])
314 # AC_LANG_CALL(C++)(PROLOGUE, FUNCTION)
315 # -------------------------------------
316 m4_copy([AC_LANG_CALL(C)], [AC_LANG_CALL(C++)])
319 # AC_LANG_FUNC_LINK_TRY(C++)(FUNCTION)
320 # ------------------------------------
321 m4_copy([AC_LANG_FUNC_LINK_TRY(C)], [AC_LANG_FUNC_LINK_TRY(C++)])
324 # AC_LANG_BOOL_COMPILE_TRY(C++)(PROLOGUE, EXPRESSION)
325 # ---------------------------------------------------
326 m4_copy([AC_LANG_BOOL_COMPILE_TRY(C)], [AC_LANG_BOOL_COMPILE_TRY(C++)])
329 # AC_LANG_INT_SAVE(C++)(PROLOGUE, EXPRESSION)
330 # -------------------------------------------
331 m4_copy([AC_LANG_INT_SAVE(C)], [AC_LANG_INT_SAVE(C++)])
335 # ------------------------- #
336 # 2d. Objective C sources. #
337 # ------------------------- #
339 # AC_LANG_SOURCE(Objective C)(BODY)
340 # ---------------------------------
341 m4_copy([AC_LANG_SOURCE(C)], [AC_LANG_SOURCE(Objective C)])
344 # AC_LANG_PROGRAM(Objective C)([PROLOGUE], [BODY])
345 # ------------------------------------------------
346 m4_copy([AC_LANG_PROGRAM(C)], [AC_LANG_PROGRAM(Objective C)])
349 # AC_LANG_CALL(Objective C)(PROLOGUE, FUNCTION)
350 # ---------------------------------------------
351 m4_copy([AC_LANG_CALL(C)], [AC_LANG_CALL(Objective C)])
354 # AC_LANG_FUNC_LINK_TRY(Objective C)(FUNCTION)
355 # --------------------------------------------
356 m4_copy([AC_LANG_FUNC_LINK_TRY(C)], [AC_LANG_FUNC_LINK_TRY(Objective C)])
359 # AC_LANG_BOOL_COMPILE_TRY(Objective C)(PROLOGUE, EXPRESSION)
360 # -----------------------------------------------------------
361 m4_copy([AC_LANG_BOOL_COMPILE_TRY(C)], [AC_LANG_BOOL_COMPILE_TRY(Objective C)])
364 # AC_LANG_INT_SAVE(Objective C)(PROLOGUE, EXPRESSION)
365 # ---------------------------------------------------
366 m4_copy([AC_LANG_INT_SAVE(C)], [AC_LANG_INT_SAVE(Objective C)])
370 ## -------------------------------------------- ##
371 ## 3. Looking for Compilers and Preprocessors. ##
372 ## -------------------------------------------- ##
374 # -------------------- #
375 # 3b. The C compiler. #
376 # -------------------- #
379 # _AC_ARG_VAR_CPPFLAGS
380 # --------------------
381 # Document and register CPPFLAGS, which is used by
382 # AC_PROG_{CC, CPP, CXX, CXXCPP, OBJC, OBJCPP}.
383 AC_DEFUN([_AC_ARG_VAR_CPPFLAGS],
384 [AC_ARG_VAR([CPPFLAGS],
385 [C/C++/Objective C preprocessor flags, e.g. -I<include dir>
386 if you have headers in a nonstandard directory <include dir>])])
389 # _AC_ARG_VAR_LDFLAGS
390 # -------------------
391 # Document and register LDFLAGS, which is used by
392 # AC_PROG_{CC, CXX, F77, FC, OBJC}.
393 AC_DEFUN([_AC_ARG_VAR_LDFLAGS],
394 [AC_ARG_VAR([LDFLAGS],
395 [linker flags, e.g. -L<lib dir> if you have libraries in a
396 nonstandard directory <lib dir>])])
401 # Document and register LIBS, which is used by
402 # AC_PROG_{CC, CXX, F77, FC, OBJS}.
403 AC_DEFUN([_AC_ARG_VAR_LIBS],
405 [libraries to pass to the linker, e.g. -l<library>])])
409 # -------------------
410 # Find the C preprocessor. Must be AC_DEFUN'd to be AC_REQUIRE'able.
411 AC_DEFUN([AC_LANG_PREPROC(C)],
412 [AC_REQUIRE([AC_PROG_CPP])])
415 # _AC_PROG_PREPROC_WORKS_IFELSE(IF-WORKS, IF-NOT)
416 # -----------------------------------------------
417 # Check if $ac_cpp is a working preprocessor that can flag absent
418 # includes either by the exit status or by warnings.
419 # This macro is for all languages, not only C.
420 AC_DEFUN([_AC_PROG_PREPROC_WORKS_IFELSE],
422 for ac_[]_AC_LANG_ABBREV[]_preproc_warn_flag in '' yes
424 # Use a header file that comes with gcc, so configuring glibc
425 # with a fresh cross-compiler works.
426 # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
427 # <limits.h> exists even on freestanding compilers.
428 # On the NeXT, cc -E runs the code through the compiler's parser,
429 # not just through cpp. "Syntax error" is here to catch this case.
430 _AC_PREPROC_IFELSE([AC_LANG_SOURCE([[@%:@ifdef __STDC__
431 @%:@ include <limits.h>
433 @%:@ include <assert.h>
437 [# Broken: fails on valid input.
440 # OK, works on sane cases. Now check whether nonexistent headers
441 # can be detected and how.
442 _AC_PREPROC_IFELSE([AC_LANG_SOURCE([[@%:@include <ac_nonexistent.h>]])],
443 [# Broken: success on invalid input.
445 [# Passes both tests.
450 # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
451 rm -f conftest.err conftest.$ac_ext
452 AS_IF([$ac_preproc_ok], [$1], [$2])])# _AC_PROG_PREPROC_WORKS_IFELSE
457 # Find a working C preprocessor.
458 # We shouldn't have to require AC_PROG_CC, but this is due to the concurrency
459 # between the AC_LANG_COMPILER_REQUIRE family and that of AC_PROG_CC.
460 AN_MAKEVAR([CPP], [AC_PROG_CPP])
461 AN_PROGRAM([cpp], [AC_PROG_CPP])
462 AC_DEFUN([AC_PROG_CPP],
463 [AC_REQUIRE([AC_PROG_CC])dnl
464 AC_ARG_VAR([CPP], [C preprocessor])dnl
465 _AC_ARG_VAR_CPPFLAGS()dnl
467 AC_MSG_CHECKING([how to run the C preprocessor])
468 # On Suns, sometimes $CPP names a directory.
469 if test -n "$CPP" && test -d "$CPP"; then
472 if test -z "$CPP"; then
473 AC_CACHE_VAL([ac_cv_prog_CPP],
475 # Double quotes because CPP needs to be expanded
476 for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
478 _AC_PROG_PREPROC_WORKS_IFELSE([break])
486 AC_MSG_RESULT([$CPP])
487 _AC_PROG_PREPROC_WORKS_IFELSE([],
488 [AC_MSG_FAILURE([C preprocessor "$CPP" fails sanity check])])
495 # Treat warnings from the preprocessor as errors.
496 AC_DEFUN([AC_PROG_CPP_WERROR],
497 [AC_REQUIRE([AC_PROG_CPP])dnl
498 ac_c_preproc_warn_flag=yes])# AC_PROG_CPP_WERROR
500 # AC_LANG_COMPILER(C)
501 # -------------------
502 # Find the C compiler. Must be AC_DEFUN'd to be AC_REQUIRE'able.
503 AC_DEFUN([AC_LANG_COMPILER(C)],
504 [AC_REQUIRE([AC_PROG_CC])])
509 # We used to name the cache variable this way.
510 AU_DEFUN([ac_cv_prog_gcc],
511 [ac_cv_c_compiler_gnu])
514 # AC_PROG_CC([COMPILER ...])
515 # --------------------------
516 # COMPILER ... is a space separated list of C compilers to search for.
517 # This just gives the user an opportunity to specify an alternative
518 # search list for the C compiler.
519 AN_MAKEVAR([CC], [AC_PROG_CC])
520 AN_PROGRAM([cc], [AC_PROG_CC])
521 AN_PROGRAM([gcc], [AC_PROG_CC])
522 AC_DEFUN([AC_PROG_CC],
524 AC_ARG_VAR([CC], [C compiler command])dnl
525 AC_ARG_VAR([CFLAGS], [C compiler flags])dnl
526 _AC_ARG_VAR_LDFLAGS()dnl
527 _AC_ARG_VAR_LIBS()dnl
528 _AC_ARG_VAR_CPPFLAGS()dnl
530 [AC_CHECK_TOOLS(CC, [$1])],
531 [AC_CHECK_TOOL(CC, gcc)
532 if test -z "$CC"; then
534 dnl AC_CHECK_TOOL(CC, cc)
535 dnl but without the check for a tool without the prefix.
536 dnl Until the check is removed from there, copy the code:
537 if test -n "$ac_tool_prefix"; then
538 AC_CHECK_PROG(CC, [${ac_tool_prefix}cc], [${ac_tool_prefix}cc])
541 if test -z "$CC"; then
542 AC_CHECK_PROG(CC, cc, cc, , , /usr/ucb/cc)
544 if test -z "$CC"; then
545 AC_CHECK_TOOLS(CC, cl.exe)
549 test -z "$CC" && AC_MSG_FAILURE([no acceptable C compiler found in \$PATH])
551 # Provide some information about the compiler.
552 _AS_ECHO_LOG([checking for _AC_LANG compiler version])
555 _AC_DO([$ac_compiler --version >&AS_MESSAGE_LOG_FD])
556 _AC_DO([$ac_compiler -v >&AS_MESSAGE_LOG_FD])
557 _AC_DO([$ac_compiler -V >&AS_MESSAGE_LOG_FD])
559 m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
560 m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl
561 _AC_LANG_COMPILER_GNU
562 if test $ac_compiler_gnu = yes; then
575 # Check whether -g works, even if CFLAGS is set, in case the package
576 # plays around with CFLAGS (such as to build both debugging and normal
577 # versions of a library), tasteless as that idea is.
578 # Don't consider -g to work if it generates warnings when plain compiles don't.
579 m4_define([_AC_PROG_CC_G],
580 [ac_test_CFLAGS=${CFLAGS+set}
581 ac_save_CFLAGS=$CFLAGS
582 AC_CACHE_CHECK(whether $CC accepts -g, ac_cv_prog_cc_g,
583 [ac_save_c_werror_flag=$ac_c_werror_flag
587 _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
588 [ac_cv_prog_cc_g=yes],
590 _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
592 [ac_c_werror_flag=$ac_save_c_werror_flag
594 _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
595 [ac_cv_prog_cc_g=yes])])])
596 ac_c_werror_flag=$ac_save_c_werror_flag])
597 if test "$ac_test_CFLAGS" = set; then
598 CFLAGS=$ac_save_CFLAGS
599 elif test $ac_cv_prog_cc_g = yes; then
600 if test "$GCC" = yes; then
606 if test "$GCC" = yes; then
615 # AC_PROG_GCC_TRADITIONAL
616 # -----------------------
617 AC_DEFUN([AC_PROG_GCC_TRADITIONAL],
618 [AC_REQUIRE([AC_PROG_CC])dnl
619 if test $ac_cv_c_compiler_gnu = yes; then
620 AC_CACHE_CHECK(whether $CC needs -traditional,
621 ac_cv_prog_gcc_traditional,
622 [ ac_pattern="Autoconf.*'x'"
623 AC_EGREP_CPP($ac_pattern, [#include <sgtty.h>
625 ac_cv_prog_gcc_traditional=yes, ac_cv_prog_gcc_traditional=no)
627 if test $ac_cv_prog_gcc_traditional = no; then
628 AC_EGREP_CPP($ac_pattern, [#include <termio.h>
630 ac_cv_prog_gcc_traditional=yes)
632 if test $ac_cv_prog_gcc_traditional = yes; then
633 CC="$CC -traditional"
636 ])# AC_PROG_GCC_TRADITIONAL
641 AC_DEFUN([AC_PROG_CC_C_O],
642 [AC_REQUIRE([AC_PROG_CC])dnl
643 if test "x$CC" != xcc; then
644 AC_MSG_CHECKING([whether $CC and cc understand -c and -o together])
646 AC_MSG_CHECKING([whether cc understands -c and -o together])
648 set dummy $CC; ac_cc=`AS_ECHO(["$[2]"]) |
649 sed 's/[[^a-zA-Z0-9_]]/_/g;s/^[[0-9]]/_/'`
650 AC_CACHE_VAL(ac_cv_prog_cc_${ac_cc}_c_o,
651 [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])])
652 # Make sure it works both with $CC and with simple cc.
653 # We do the test twice because some compilers refuse to overwrite an
654 # existing .o file with -o, though they will create one.
655 ac_try='$CC -c conftest.$ac_ext -o conftest2.$ac_objext >&AS_MESSAGE_LOG_FD'
657 if _AC_DO_VAR(ac_try) &&
658 test -f conftest2.$ac_objext && _AC_DO_VAR(ac_try);
660 eval ac_cv_prog_cc_${ac_cc}_c_o=yes
661 if test "x$CC" != xcc; then
662 # Test first that cc exists at all.
663 if _AC_DO_TOKENS(cc -c conftest.$ac_ext >&AS_MESSAGE_LOG_FD); then
664 ac_try='cc -c conftest.$ac_ext -o conftest2.$ac_objext >&AS_MESSAGE_LOG_FD'
666 if _AC_DO_VAR(ac_try) &&
667 test -f conftest2.$ac_objext && _AC_DO_VAR(ac_try);
672 # cc exists but doesn't like -o.
673 eval ac_cv_prog_cc_${ac_cc}_c_o=no
678 eval ac_cv_prog_cc_${ac_cc}_c_o=no
682 if eval test \$ac_cv_prog_cc_${ac_cc}_c_o = yes; then
686 AC_DEFINE(NO_MINUS_C_MINUS_O, 1,
687 [Define to 1 if your C compiler doesn't accept -c and -o together.])
692 # ---------------------- #
693 # 3c. The C++ compiler. #
694 # ---------------------- #
697 # AC_LANG_PREPROC(C++)
698 # ---------------------
699 # Find the C++ preprocessor. Must be AC_DEFUN'd to be AC_REQUIRE'able.
700 AC_DEFUN([AC_LANG_PREPROC(C++)],
701 [AC_REQUIRE([AC_PROG_CXXCPP])])
706 # Find a working C++ preprocessor.
707 # We shouldn't have to require AC_PROG_CC, but this is due to the concurrency
708 # between the AC_LANG_COMPILER_REQUIRE family and that of AC_PROG_CXX.
709 AC_DEFUN([AC_PROG_CXXCPP],
710 [AC_REQUIRE([AC_PROG_CXX])dnl
711 AC_ARG_VAR([CXXCPP], [C++ preprocessor])dnl
712 _AC_ARG_VAR_CPPFLAGS()dnl
714 AC_MSG_CHECKING([how to run the C++ preprocessor])
715 if test -z "$CXXCPP"; then
716 AC_CACHE_VAL(ac_cv_prog_CXXCPP,
718 # Double quotes because CXXCPP needs to be expanded
719 for CXXCPP in "$CXX -E" "/lib/cpp"
721 _AC_PROG_PREPROC_WORKS_IFELSE([break])
723 ac_cv_prog_CXXCPP=$CXXCPP
725 CXXCPP=$ac_cv_prog_CXXCPP
727 ac_cv_prog_CXXCPP=$CXXCPP
729 AC_MSG_RESULT([$CXXCPP])
730 _AC_PROG_PREPROC_WORKS_IFELSE([],
731 [AC_MSG_FAILURE([C++ preprocessor "$CXXCPP" fails sanity check])])
737 # AC_LANG_COMPILER(C++)
738 # ---------------------
739 # Find the C++ compiler. Must be AC_DEFUN'd to be AC_REQUIRE'able.
740 AC_DEFUN([AC_LANG_COMPILER(C++)],
741 [AC_REQUIRE([AC_PROG_CXX])])
746 # We used to name the cache variable this way.
747 AU_DEFUN([ac_cv_prog_gxx],
748 [ac_cv_cxx_compiler_gnu])
751 # AC_PROG_CXX([LIST-OF-COMPILERS])
752 # --------------------------------
753 # LIST-OF-COMPILERS is a space separated list of C++ compilers to search
754 # for (if not specified, a default list is used). This just gives the
755 # user an opportunity to specify an alternative search list for the C++
757 # aCC HP-UX C++ compiler much better than `CC', so test before.
758 # FCC Fujitsu C++ compiler
759 # KCC KAI C++ compiler
761 # xlC_r AIX C Set++ (with support for reentrant code)
763 AN_MAKEVAR([CXX], [AC_PROG_CXX])
764 AN_PROGRAM([CC], [AC_PROG_CXX])
765 AN_PROGRAM([c++], [AC_PROG_CXX])
766 AN_PROGRAM([g++], [AC_PROG_CXX])
767 AC_DEFUN([AC_PROG_CXX],
768 [AC_LANG_PUSH(C++)dnl
769 AC_ARG_VAR([CXX], [C++ compiler command])dnl
770 AC_ARG_VAR([CXXFLAGS], [C++ compiler flags])dnl
771 _AC_ARG_VAR_LDFLAGS()dnl
772 _AC_ARG_VAR_LIBS()dnl
773 _AC_ARG_VAR_CPPFLAGS()dnl
774 _AC_ARG_VAR_PRECIOUS([CCC])dnl
775 if test -z "$CXX"; then
776 if test -n "$CCC"; then
781 [g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC])],
785 # Provide some information about the compiler.
786 _AS_ECHO_LOG([checking for _AC_LANG compiler version])
789 _AC_DO([$ac_compiler --version >&AS_MESSAGE_LOG_FD])
790 _AC_DO([$ac_compiler -v >&AS_MESSAGE_LOG_FD])
791 _AC_DO([$ac_compiler -V >&AS_MESSAGE_LOG_FD])
793 m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
794 m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl
795 _AC_LANG_COMPILER_GNU
796 if test $ac_compiler_gnu = yes; then
808 # Check whether -g works, even if CXXFLAGS is set, in case the package
809 # plays around with CXXFLAGS (such as to build both debugging and
810 # normal versions of a library), tasteless as that idea is.
811 # Don't consider -g to work if it generates warnings when plain compiles don't.
812 m4_define([_AC_PROG_CXX_G],
813 [ac_test_CXXFLAGS=${CXXFLAGS+set}
814 ac_save_CXXFLAGS=$CXXFLAGS
815 AC_CACHE_CHECK(whether $CXX accepts -g, ac_cv_prog_cxx_g,
816 [ac_save_cxx_werror_flag=$ac_cxx_werror_flag
817 ac_cxx_werror_flag=yes
820 _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
821 [ac_cv_prog_cxx_g=yes],
823 _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
825 [ac_cxx_werror_flag=$ac_save_cxx_werror_flag
827 _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
828 [ac_cv_prog_cxx_g=yes])])])
829 ac_cxx_werror_flag=$ac_save_cxx_werror_flag])
830 if test "$ac_test_CXXFLAGS" = set; then
831 CXXFLAGS=$ac_save_CXXFLAGS
832 elif test $ac_cv_prog_cxx_g = yes; then
833 if test "$GXX" = yes; then
839 if test "$GXX" = yes; then
850 # Test if the C++ compiler accepts the options `-c' and `-o'
851 # simultaneously, and define `CXX_NO_MINUS_C_MINUS_O' if it does not.
852 AC_DEFUN([AC_PROG_CXX_C_O],
853 [AC_REQUIRE([AC_PROG_CXX])dnl
854 AC_LANG_PUSH([C++])dnl
855 AC_CACHE_CHECK([whether $CXX understands -c and -o together],
856 [ac_cv_prog_cxx_c_o],
857 [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])])
858 # We test twice because some compilers refuse to overwrite an existing
859 # `.o' file with `-o', although they will create one.
860 ac_try='$CXX $CXXFLAGS -c conftest.$ac_ext -o conftest2.$ac_objext >&AS_MESSAGE_LOG_FD'
862 if _AC_DO_VAR(ac_try) &&
863 test -f conftest2.$ac_objext &&
864 _AC_DO_VAR(ac_try); then
865 ac_cv_prog_cxx_c_o=yes
867 ac_cv_prog_cxx_c_o=no
870 if test $ac_cv_prog_cxx_c_o = no; then
871 AC_DEFINE(CXX_NO_MINUS_C_MINUS_O, 1,
872 [Define to 1 if your C++ compiler doesn't accept
873 -c and -o together.])
875 AC_LANG_POP([C++])dnl
879 # ------------------------------ #
880 # 3d. The Objective C compiler. #
881 # ------------------------------ #
884 # AC_LANG_PREPROC(Objective C)
885 # ----------------------------
886 # Find the Objective C preprocessor. Must be AC_DEFUN'd to be AC_REQUIRE'able.
887 AC_DEFUN([AC_LANG_PREPROC(Objective C)],
888 [AC_REQUIRE([AC_PROG_OBJCPP])])
893 # Find a working Objective C preprocessor.
894 AC_DEFUN([AC_PROG_OBJCPP],
895 [AC_REQUIRE([AC_PROG_OBJC])dnl
896 AC_ARG_VAR([OBJCPP], [Objective C preprocessor])dnl
897 _AC_ARG_VAR_CPPFLAGS()dnl
898 AC_LANG_PUSH(Objective C)dnl
899 AC_MSG_CHECKING([how to run the Objective C preprocessor])
900 if test -z "$OBJCPP"; then
901 AC_CACHE_VAL(ac_cv_prog_OBJCPP,
903 # Double quotes because OBJCPP needs to be expanded
904 for OBJCPP in "$OBJC -E" "/lib/cpp"
906 _AC_PROG_PREPROC_WORKS_IFELSE([break])
908 ac_cv_prog_OBJCPP=$OBJCPP
910 OBJCPP=$ac_cv_prog_OBJCPP
912 ac_cv_prog_OBJCPP=$OBJCPP
914 AC_MSG_RESULT([$OBJCPP])
915 _AC_PROG_PREPROC_WORKS_IFELSE([],
916 [AC_MSG_FAILURE([Objective C preprocessor "$OBJCPP" fails sanity check])])
918 AC_LANG_POP(Objective C)dnl
922 # AC_LANG_COMPILER(Objective C)
923 # -----------------------------
924 # Find the Objective C compiler. Must be AC_DEFUN'd to be AC_REQUIRE'able.
925 AC_DEFUN([AC_LANG_COMPILER(Objective C)],
926 [AC_REQUIRE([AC_PROG_OBJC])])
930 # AC_PROG_OBJC([LIST-OF-COMPILERS])
931 # ---------------------------------
932 # LIST-OF-COMPILERS is a space separated list of Objective C compilers to
933 # search for (if not specified, a default list is used). This just gives
934 # the user an opportunity to specify an alternative search list for the
935 # Objective C compiler.
936 # objcc StepStone Objective-C compiler (also "standard" name for OBJC)
937 # objc David Stes' POC. If you installed this, you likely want it.
938 # cc Native C compiler (for instance, Apple).
940 AN_MAKEVAR([OBJC], [AC_PROG_OBJC])
941 AN_PROGRAM([objcc], [AC_PROG_OBJC])
942 AN_PROGRAM([objc], [AC_PROG_OBJC])
943 AC_DEFUN([AC_PROG_OBJC],
944 [AC_LANG_PUSH(Objective C)dnl
945 AC_ARG_VAR([OBJC], [Objective C compiler command])dnl
946 AC_ARG_VAR([OBJCFLAGS], [Objective C compiler flags])dnl
947 _AC_ARG_VAR_LDFLAGS()dnl
948 _AC_ARG_VAR_LIBS()dnl
949 _AC_ARG_VAR_CPPFLAGS()dnl
950 _AC_ARG_VAR_PRECIOUS([OBJC])dnl
952 [m4_default([$1], [gcc objcc objc cc CC])],
954 # Provide some information about the compiler.
955 _AS_ECHO_LOG([checking for _AC_LANG compiler version])
958 _AC_DO([$ac_compiler --version >&AS_MESSAGE_LOG_FD])
959 _AC_DO([$ac_compiler -v >&AS_MESSAGE_LOG_FD])
960 _AC_DO([$ac_compiler -V >&AS_MESSAGE_LOG_FD])
962 m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
963 m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl
964 _AC_LANG_COMPILER_GNU
965 if test $ac_compiler_gnu = yes; then
971 AC_LANG_POP(Objective C)dnl
977 # Check whether -g works, even if OBJCFLAGS is set, in case the package
978 # plays around with OBJCFLAGS (such as to build both debugging and
979 # normal versions of a library), tasteless as that idea is.
980 # Don't consider -g to work if it generates warnings when plain compiles don't.
981 m4_define([_AC_PROG_OBJC_G],
982 [ac_test_OBJCFLAGS=${OBJCFLAGS+set}
983 ac_save_OBJCFLAGS=$OBJCFLAGS
984 AC_CACHE_CHECK(whether $OBJC accepts -g, ac_cv_prog_objc_g,
985 [ac_save_objc_werror_flag=$ac_objc_werror_flag
986 ac_objc_werror_flag=yes
989 _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
990 [ac_cv_prog_objc_g=yes],
992 _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
994 [ac_objc_werror_flag=$ac_save_objc_werror_flag
996 _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
997 [ac_cv_prog_objc_g=yes])])])
998 ac_objc_werror_flag=$ac_save_objc_werror_flag])
999 if test "$ac_test_OBJCFLAGS" = set; then
1000 OBJCFLAGS=$ac_save_OBJCFLAGS
1001 elif test $ac_cv_prog_objc_g = yes; then
1002 if test "$GOBJC" = yes; then
1008 if test "$GOBJC" = yes; then
1021 ## ------------------------------- ##
1022 ## 4. Compilers' characteristics. ##
1023 ## ------------------------------- ##
1026 # -------------------------------- #
1027 # 4b. C compiler characteristics. #
1028 # -------------------------------- #
1030 # _AC_PROG_CC_C89 ([ACTION-IF-AVAILABLE], [ACTION-IF-UNAVAILABLE])
1031 # ----------------------------------------------------------------
1032 # If the C compiler is not in ANSI C89 (ISO C90) mode by default, try
1033 # to add an option to output variable CC to make it so. This macro
1034 # tries various options that select ANSI C89 on some system or
1035 # another. It considers the compiler to be in ANSI C89 mode if it
1036 # handles function prototypes correctly.
1037 AC_DEFUN([_AC_PROG_CC_C89],
1038 [_AC_C_STD_TRY([c89],
1039 [[#include <stdarg.h>
1041 #include <sys/types.h>
1042 #include <sys/stat.h>
1043 /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
1044 struct buf { int x; };
1045 FILE * (*rcsopen) (struct buf *, struct stat *, int);
1046 static char *e (p, i)
1052 static char *f (char * (*g) (char **, int), char **p, ...)
1057 s = g (p, va_arg (v,int));
1062 /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has
1063 function prototypes and stuff, but not '\xHH' hex character constants.
1064 These don't provoke an error unfortunately, instead are silently treated
1065 as 'x'. The following induces an error, until -std is added to get
1066 proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an
1067 array size at least. It's necessary to write '\x00'==0 to get something
1068 that's true only with -std. */
1069 int osf4_cc_array ['\x00' == 0 ? 1 : -1];
1071 /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
1072 inside strings and character constants. */
1074 int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
1076 int test (int i, double x);
1077 struct s1 {int (*f) (int a);};
1078 struct s2 {int (*f) (double a);};
1079 int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
1082 [[return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];]],
1083 dnl Don't try gcc -ansi; that turns off useful extensions and
1084 dnl breaks some systems' header files.
1085 dnl AIX circa 2003 -qlanglvl=extc89
1086 dnl old AIX -qlanglvl=ansi
1087 dnl Ultrix, OSF/1, Tru64 -std
1088 dnl HP-UX 10.20 and later -Ae
1089 dnl HP-UX older versions -Aa -D_HPUX_SOURCE
1090 dnl SVR4 -Xc -D__EXTENSIONS__
1091 [-qlanglvl=extc89 -qlanglvl=ansi -std \
1092 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"], [$1], [$2])[]dnl
1096 # _AC_C_STD_TRY(STANDARD, TEST-PROLOGUE, TEST-BODY, OPTION-LIST,
1097 # ACTION-IF-AVAILABLE, ACTION-IF-UNAVAILABLE)
1098 # --------------------------------------------------------------
1099 # Check whether the C compiler accepts features of STANDARD (e.g `c89', `c99')
1100 # by trying to compile a program of TEST-PROLOGUE and TEST-BODY. If this fails,
1101 # try again with each compiler option in the space-separated OPTION-LIST; if one
1102 # helps, append it to CC. If eventually successful, run ACTION-IF-AVAILABLE,
1103 # else ACTION-IF-UNAVAILABLE.
1104 AC_DEFUN([_AC_C_STD_TRY],
1105 [AC_MSG_CHECKING([for $CC option to accept ISO ]m4_translit($1, [c], [C]))
1106 AC_CACHE_VAL(ac_cv_prog_cc_$1,
1107 [ac_cv_prog_cc_$1=no
1109 AC_LANG_CONFTEST([AC_LANG_PROGRAM([$2], [$3])])
1112 CC="$ac_save_CC $ac_arg"
1113 _AC_COMPILE_IFELSE([], [ac_cv_prog_cc_$1=$ac_arg])
1114 test "x$ac_cv_prog_cc_$1" != "xno" && break
1116 rm -f conftest.$ac_ext
1119 case "x$ac_cv_prog_cc_$1" in
1121 AC_MSG_RESULT([none needed]) ;;
1123 AC_MSG_RESULT([unsupported]) ;;
1125 CC="$CC $ac_cv_prog_cc_$1"
1126 AC_MSG_RESULT([$ac_cv_prog_cc_$1]) ;;
1128 AS_IF([test "x$ac_cv_prog_cc_$1" != xno], [$5], [$6])
1132 # _AC_PROG_CC_C99 ([ACTION-IF-AVAILABLE], [ACTION-IF-UNAVAILABLE])
1133 # ----------------------------------------------------------------
1134 # If the C compiler is not in ISO C99 mode by default, try to add an
1135 # option to output variable CC to make it so. This macro tries
1136 # various options that select ISO C99 on some system or another. It
1137 # considers the compiler to be in ISO C99 mode if it handles _Bool,
1138 # // comments, flexible array members, inline, long long int, mixed
1139 # code and declarations, named initialization of structs, restrict,
1140 # va_copy, varargs macros, variable declarations in for loops and
1141 # variable length arrays.
1142 AC_DEFUN([_AC_PROG_CC_C99],
1143 [_AC_C_STD_TRY([c99],
1144 [[#include <stdarg.h>
1145 #include <stdbool.h>
1150 // Check varargs macros. These examples are taken from C99 6.10.3.5.
1151 #define debug(...) fprintf (stderr, __VA_ARGS__)
1152 #define showlist(...) puts (#__VA_ARGS__)
1153 #define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__))
1155 test_varargs_macros (void)
1160 debug ("X = %d\n", x);
1161 showlist (The first, second, and third items.);
1162 report (x>y, "x is %d but y is %d", x, y);
1165 // Check long long types.
1166 #define BIG64 18446744073709551615ull
1167 #define BIG32 4294967295ul
1168 #define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0)
1170 your preprocessor is broken;
1174 your preprocessor is broken;
1176 static long long int bignum = -9223372036854775807LL;
1177 static unsigned long long int ubignum = BIG64;
1179 struct incomplete_array
1187 const wchar_t *name;
1191 typedef const char *ccp;
1194 test_restrict (ccp restrict text)
1196 // See if C++-style comments work.
1197 // Iterate through items via the restricted pointer.
1198 // Also check for declarations in for loops.
1199 for (unsigned int i = 0; *(text+i) != '\0'; ++i)
1204 // Check varargs and va_copy.
1206 test_varargs (const char *format, ...)
1209 va_start (args, format);
1211 va_copy (args_copy, args);
1222 str = va_arg (args_copy, const char *);
1225 number = va_arg (args_copy, int);
1228 fnumber = va_arg (args_copy, double);
1240 _Bool success = false;
1243 if (test_restrict ("String literal") == 0)
1245 char *restrict newvar = "Another string";
1248 test_varargs ("s, d' f .", "string", 65, 34.234);
1249 test_varargs_macros ();
1251 // Check flexible array members.
1252 struct incomplete_array *ia =
1253 malloc (sizeof (struct incomplete_array) + (sizeof (double) * 10));
1255 for (int i = 0; i < ia->datasize; ++i)
1256 ia->data[i] = i * 1.234;
1258 // Check named initializers.
1259 struct named_init ni = {
1261 .name = L"Test wide string",
1262 .average = 543.34343,
1267 int dynamic_array[ni.number];
1268 dynamic_array[ni.number - 1] = 543;
1270 // work around unused variable warnings
1271 return (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == 'x'
1272 || dynamic_array[ni.number - 1] != 543);
1275 dnl GCC -std=gnu99 (unused restrictive modes: -std=c99 -std=iso9899:1999)
1276 dnl AIX -qlanglvl=extc99 (unused restrictive mode: -qlanglvl=stdc99)
1279 dnl Solaris (unused because it causes the compiler to assume C99 semantics for
1280 dnl library functions, and this is invalid before Solaris 10: -xc99)
1282 dnl with extended modes being tried first.
1283 [[-std=gnu99 -c99 -qlanglvl=extc99]], [$1], [$2])[]dnl
1289 AC_DEFUN([AC_PROG_CC_C89],
1290 [ AC_REQUIRE([AC_PROG_CC])dnl
1297 AC_DEFUN([AC_PROG_CC_C99],
1298 [ AC_REQUIRE([AC_PROG_CC])dnl
1305 AC_DEFUN([AC_PROG_CC_STDC],
1306 [ AC_REQUIRE([AC_PROG_CC])dnl
1307 AS_CASE([$ac_cv_prog_cc_stdc],
1308 [no], [ac_cv_prog_cc_c99=no; ac_cv_prog_cc_c89=no],
1309 [_AC_PROG_CC_C99([ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c99],
1310 [_AC_PROG_CC_C89([ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c89],
1311 [ac_cv_prog_cc_stdc=no])])])dnl
1312 AC_MSG_CHECKING([for $CC option to accept ISO Standard C])
1313 AC_CACHE_VAL([ac_cv_prog_cc_stdc], [])
1314 AS_CASE([$ac_cv_prog_cc_stdc],
1315 [no], [AC_MSG_RESULT([unsupported])],
1316 [''], [AC_MSG_RESULT([none needed])],
1317 [AC_MSG_RESULT([$ac_cv_prog_cc_stdc])])
1323 AC_DEFUN([AC_C_BACKSLASH_A],
1325 AC_CACHE_CHECK([whether backslash-a works in strings], ac_cv_c_backslash_a,
1326 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
1331 char buf['\a' == 'a' ? -1 : 1];
1333 return buf[0] != "\a"[0];
1335 [ac_cv_c_backslash_a=yes],
1336 [ac_cv_c_backslash_a=no])])
1337 if test $ac_cv_c_backslash_a = yes; then
1338 AC_DEFINE(HAVE_C_BACKSLASH_A, 1,
1339 [Define if backslash-a works in C strings.])
1346 # Has been merged into AC_PROG_CC.
1347 AU_DEFUN([AC_C_CROSS], [])
1350 # AC_C_CHAR_UNSIGNED
1351 # ------------------
1352 AC_DEFUN([AC_C_CHAR_UNSIGNED],
1353 [AH_VERBATIM([__CHAR_UNSIGNED__],
1354 [/* Define to 1 if type `char' is unsigned and you are not using gcc. */
1355 #ifndef __CHAR_UNSIGNED__
1356 # undef __CHAR_UNSIGNED__
1358 AC_CACHE_CHECK(whether char is unsigned, ac_cv_c_char_unsigned,
1359 [AC_COMPILE_IFELSE([AC_LANG_BOOL_COMPILE_TRY([AC_INCLUDES_DEFAULT([])],
1360 [((char) -1) < 0])],
1361 ac_cv_c_char_unsigned=no, ac_cv_c_char_unsigned=yes)])
1362 if test $ac_cv_c_char_unsigned = yes && test "$GCC" != yes; then
1363 AC_DEFINE(__CHAR_UNSIGNED__)
1365 ])# AC_C_CHAR_UNSIGNED
1368 # AC_C_BIGENDIAN ([ACTION-IF-TRUE], [ACTION-IF-FALSE], [ACTION-IF-UNKNOWN])
1369 # -------------------------------------------------------------------------
1370 AC_DEFUN([AC_C_BIGENDIAN],
1371 [AC_CACHE_CHECK(whether byte ordering is bigendian, ac_cv_c_bigendian,
1372 [# See if sys/param.h defines the BYTE_ORDER macro.
1373 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>
1374 #include <sys/param.h>
1376 [#if ! (defined BYTE_ORDER && defined BIG_ENDIAN && defined LITTLE_ENDIAN \
1377 && BYTE_ORDER && BIG_ENDIAN && LITTLE_ENDIAN)
1381 [# It does; now see whether it defined to BIG_ENDIAN or not.
1382 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>
1383 #include <sys/param.h>
1384 ], [#if BYTE_ORDER != BIG_ENDIAN
1387 ])], [ac_cv_c_bigendian=yes], [ac_cv_c_bigendian=no])],
1388 [# It does not; compile a test program.
1390 [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], [[
1391 /* Are we little or big endian? From Harbison&Steele. */
1395 char c[sizeof (long int)];
1398 return u.c[sizeof (long int) - 1] == 1;
1400 [ac_cv_c_bigendian=no],
1401 [ac_cv_c_bigendian=yes],
1402 [# try to guess the endianness by grepping values into an object file
1403 ac_cv_c_bigendian=unknown
1404 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
1405 [[short int ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 };
1406 short int ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 };
1407 void _ascii () { char *s = (char *) ascii_mm; s = (char *) ascii_ii; }
1408 short int ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 };
1409 short int ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 };
1410 void _ebcdic () { char *s = (char *) ebcdic_mm; s = (char *) ebcdic_ii; }]],
1411 [[ _ascii (); _ebcdic (); ]])],
1412 [if grep BIGenDianSyS conftest.$ac_objext >/dev/null ; then
1413 ac_cv_c_bigendian=yes
1415 if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then
1416 if test "$ac_cv_c_bigendian" = unknown; then
1417 ac_cv_c_bigendian=no
1419 # finding both strings is unlikely to happen, but who knows?
1420 ac_cv_c_bigendian=unknown
1423 case $ac_cv_c_bigendian in
1426 [AC_DEFINE([WORDS_BIGENDIAN], 1,
1427 [Define to 1 if your processor stores words with the most significant
1428 byte first (like Motorola and SPARC, unlike Intel and VAX).])]) ;;
1433 [AC_MSG_ERROR([unknown endianness
1434 presetting ac_cv_c_bigendian=no (or yes) will help])]) ;;
1441 # Do nothing if the compiler accepts the inline keyword.
1442 # Otherwise define inline to __inline__ or __inline if one of those work,
1443 # otherwise define inline to be empty.
1445 # HP C version B.11.11.04 doesn't allow a typedef as the return value for an
1446 # inline function, only builtin types.
1448 AN_IDENTIFIER([inline], [AC_C_INLINE])
1449 AC_DEFUN([AC_C_INLINE],
1450 [AC_CACHE_CHECK([for inline], ac_cv_c_inline,
1452 for ac_kw in inline __inline__ __inline; do
1453 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1454 [#ifndef __cplusplus
1456 static $ac_kw foo_t static_foo () {return 0; }
1457 $ac_kw foo_t foo () {return 0; }
1460 [ac_cv_c_inline=$ac_kw])
1461 test "$ac_cv_c_inline" != no && break
1464 AH_VERBATIM([inline],
1465 [/* Define to `__inline__' or `__inline' if that's what the C compiler
1466 calls it, or to nothing if 'inline' is not supported under any name. */
1470 case $ac_cv_c_inline in
1473 case $ac_cv_c_inline in
1475 *) ac_val=$ac_cv_c_inline;;
1477 cat >>confdefs.h <<_ACEOF
1479 #define inline $ac_val
1489 AC_DEFUN([AC_C_CONST],
1490 [AC_CACHE_CHECK([for an ANSI C-conforming const], ac_cv_c_const,
1491 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
1492 [[/* FIXME: Include the comments suggested by Paul. */
1494 /* Ultrix mips cc rejects this. */
1495 typedef int charset[2];
1497 /* SunOS 4.1.1 cc rejects this. */
1498 char const *const *pcpcc;
1500 /* NEC SVR4.0.2 mips cc rejects this. */
1501 struct point {int x, y;};
1502 static struct point const zero = {0,0};
1503 /* AIX XL C 1.02.0.0 rejects this.
1504 It does not let you subtract one const X* pointer from another in
1505 an arm of an if-expression whose if-part is not a constant
1507 const char *g = "string";
1508 pcpcc = &g + (g ? g-g : 0);
1509 /* HPUX 7.0 cc rejects these. */
1511 ppc = (char**) pcpcc;
1512 pcpcc = (char const *const *) ppc;
1513 { /* SCO 3.2v4 cc rejects this. */
1515 char const *s = 0 ? (char *) 0 : (char const *) 0;
1520 { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */
1522 const int *foo = &x[0];
1525 { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
1526 typedef const int *iptr;
1530 { /* AIX XL C 1.02.0.0 rejects this saying
1531 "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
1532 struct s { int j; const int *ap[3]; };
1533 struct s *b; b->j = 5;
1535 { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
1539 return !cs[0] && !zero.x;
1542 [ac_cv_c_const=yes],
1543 [ac_cv_c_const=no])])
1544 if test $ac_cv_c_const = no; then
1546 [Define to empty if `const' does not conform to ANSI C.])
1553 # based on acx_restrict.m4, from the GNU Autoconf Macro Archive at:
1554 # http://autoconf-archive.cryp.to/acx_restrict.html
1556 # Determine whether the C/C++ compiler supports the "restrict" keyword
1557 # introduced in ANSI C99, or an equivalent. Do nothing if the compiler
1558 # accepts it. Otherwise, if the compiler supports an equivalent,
1559 # define "restrict" to be that. Here are some variants:
1560 # - GCC supports both __restrict and __restrict__
1561 # - older DEC Alpha C compilers support only __restrict
1562 # - _Restrict is the only spelling accepted by Sun WorkShop 6 update 2 C
1563 # Otherwise, define "restrict" to be empty.
1564 AN_IDENTIFIER([restrict], [AC_C_RESTRICT])
1565 AC_DEFUN([AC_C_RESTRICT],
1566 [AC_CACHE_CHECK([for C/C++ restrict keyword], ac_cv_c_restrict,
1567 [ac_cv_c_restrict=no
1568 # Try the official restrict keyword, then gcc's __restrict, and
1569 # the less common variants.
1570 for ac_kw in restrict __restrict __restrict__ _Restrict; do
1571 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
1572 [[typedef int * int_ptr;
1573 int foo (int_ptr $ac_kw ip) {
1580 [ac_cv_c_restrict=$ac_kw])
1581 test "$ac_cv_c_restrict" != no && break
1584 case $ac_cv_c_restrict in
1586 no) AC_DEFINE(restrict,,
1587 [Define to equivalent of C99 restrict keyword, or to nothing if this
1588 is not supported. Do not define if restrict is supported directly.]) ;;
1589 *) AC_DEFINE_UNQUOTED(restrict, $ac_cv_c_restrict) ;;
1596 # Note that, unlike const, #defining volatile to be the empty string can
1597 # actually turn a correct program into an incorrect one, since removing
1598 # uses of volatile actually grants the compiler permission to perform
1599 # optimizations that could break the user's code. So, do not #define
1600 # volatile away unless it is really necessary to allow the user's code
1601 # to compile cleanly. Benign compiler failures should be tolerated.
1602 AC_DEFUN([AC_C_VOLATILE],
1603 [AC_CACHE_CHECK([for working volatile], ac_cv_c_volatile,
1604 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
1606 int * volatile y = (int *) 0;
1607 return !x && !y;])],
1608 [ac_cv_c_volatile=yes],
1609 [ac_cv_c_volatile=no])])
1610 if test $ac_cv_c_volatile = no; then
1611 AC_DEFINE(volatile,,
1612 [Define to empty if the keyword `volatile' does not work.
1613 Warning: valid code using `volatile' can become incorrect
1614 without. Disable with care.])
1621 # Checks if `#' can be used to glue strings together at the CPP level.
1622 # Defines HAVE_STRINGIZE if positive.
1623 AC_DEFUN([AC_C_STRINGIZE],
1624 [AC_CACHE_CHECK([for preprocessor stringizing operator],
1625 [ac_cv_c_stringize],
1626 [AC_EGREP_CPP([@%:@teststring],
1629 char *s = x(teststring);],
1630 [ac_cv_c_stringize=no],
1631 [ac_cv_c_stringize=yes])])
1632 if test $ac_cv_c_stringize = yes; then
1633 AC_DEFINE(HAVE_STRINGIZE, 1,
1634 [Define to 1 if cpp supports the ANSI @%:@ stringizing operator.])
1641 # Check if the C compiler supports prototypes, included if it needs
1643 AC_DEFUN([AC_C_PROTOTYPES],
1644 [AC_REQUIRE([AC_PROG_CC])dnl
1645 AC_MSG_CHECKING([for function prototypes])
1646 if test "$ac_cv_prog_cc_c89" != no; then
1647 AC_MSG_RESULT([yes])
1648 AC_DEFINE(PROTOTYPES, 1,
1649 [Define to 1 if the C compiler supports function prototypes.])
1650 AC_DEFINE(__PROTOTYPES, 1,
1651 [Define like PROTOTYPES; this can be used by system headers.])
1658 # AC_C_FLEXIBLE_ARRAY_MEMBER
1659 # --------------------------
1660 # Check whether the C compiler supports flexible array members.
1661 AC_DEFUN([AC_C_FLEXIBLE_ARRAY_MEMBER],
1663 AC_CACHE_CHECK([for flexible array members],
1667 [[#include <stdlib.h>
1670 struct s { int n; double d[]; };]],
1671 [[int m = getchar ();
1672 struct s *p = malloc (offsetof (struct s, d)
1673 + m * sizeof (double));
1675 return p->d != (double *) NULL;]])],
1676 [ac_cv_c_flexmember=yes],
1677 [ac_cv_c_flexmember=no])])
1678 if test $ac_cv_c_flexmember = yes; then
1679 AC_DEFINE([FLEXIBLE_ARRAY_MEMBER], [],
1680 [Define to nothing if C supports flexible array members, and to
1681 1 if it does not. That way, with a declaration like `struct s
1682 { int n; double d@<:@FLEXIBLE_ARRAY_MEMBER@:>@; };', the struct hack
1683 can be used with pre-C99 compilers.
1684 When computing the size of such an object, don't use 'sizeof (struct s)'
1685 as it overestimates the size. Use 'offsetof (struct s, d)' instead.
1686 Don't use 'offsetof (struct s, d@<:@0@:>@)', as this doesn't work with
1687 MSVC and with C++ compilers.])
1689 AC_DEFINE([FLEXIBLE_ARRAY_MEMBER], 1)
1696 # Check whether the C compiler supports variable-length arrays.
1697 AC_DEFUN([AC_C_VARARRAYS],
1699 AC_CACHE_CHECK([for variable-length arrays],
1702 [AC_LANG_PROGRAM([],
1703 [[static int x; char a[++x]; a[sizeof a - 1] = 0; return a[0];]])],
1704 [ac_cv_c_vararrays=yes],
1705 [ac_cv_c_vararrays=no])])
1706 if test $ac_cv_c_vararrays = yes; then
1707 AC_DEFINE([HAVE_C_VARARRAYS], 1,
1708 [Define to 1 if C supports variable-length arrays.])
1715 # Check if the C compiler supports GCC's typeof syntax.
1716 # The test case provokes incompatibilities in the Sun C compilers
1717 # (both Solaris 8 and Solaris 10).
1718 AC_DEFUN([AC_C_TYPEOF],
1720 AC_CACHE_CHECK([for typeof syntax and keyword spelling], ac_cv_c_typeof,
1722 for ac_kw in typeof __typeof__ no; do
1723 test $ac_kw = no && break
1724 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
1729 + ! (($ac_kw (value))
1730 (($ac_kw (value)) 0 < ($ac_kw (value)) -1
1731 ? ($ac_kw (value)) - 1
1732 : ~ (~ ($ac_kw (value)) 0
1733 << sizeof ($ac_kw (value)))))]; }
1736 (! ((void) ((ac__typeof_type_ *) 0), 0));
1738 [ac_cv_c_typeof=$ac_kw])
1739 test $ac_cv_c_typeof != no && break
1741 if test $ac_cv_c_typeof != no; then
1742 AC_DEFINE([HAVE_TYPEOF], 1,
1743 [Define to 1 if typeof works with your compiler.])
1744 if test $ac_cv_c_typeof != typeof; then
1745 AC_DEFINE_UNQUOTED([typeof], [$ac_cv_c_typeof],
1746 [Define to __typeof__ if your compiler spells it that way.])