1 # This file is part of Autoconf. -*- Autoconf -*-
2 # Programming languages support.
3 # Copyright (C) 2001-2017, 2020-2022 Free Software Foundation, Inc.
5 # This file is part of Autoconf. This program is free
6 # software; you can redistribute it and/or modify it under the
7 # terms of the GNU General Public License as published by the
8 # Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
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 # Under Section 7 of GPL version 3, you are granted additional
17 # permissions described in the Autoconf Configure Script Exception,
18 # version 3.0, as published by the Free Software Foundation.
20 # You should have received a copy of the GNU General Public License
21 # and a copy of the Autoconf Configure Script Exception along with
22 # this program; see the files COPYINGv3 and COPYING.EXCEPTION
23 # respectively. If not, see <https://www.gnu.org/licenses/>.
25 # Written by David MacKenzie, with help from
26 # Akim Demaille, Paul Eggert,
27 # Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,
28 # Roland McGrath, Noah Friedman, david d zuhn, and many others.
33 # 1. Language selection
34 # 2. and routines to produce programs in a given language.
40 # 3. Looking for a compiler
41 # And possibly the associated preprocessor.
42 # 3a. C 3b. C++ 3c. Objective C 3d. Objective C++
44 # 4. Compilers' characteristics.
49 ## ----------------------- ##
50 ## 1a/2a. The C language. ##
51 ## ----------------------- ##
54 # ------------------------ #
55 # 1a. Language selection. #
56 # ------------------------ #
60 # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
61 AC_LANG_DEFINE([C], [c], [C], [CC], [],
63 ac_cpp='$CPP $CPPFLAGS'
64 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&AS_MESSAGE_LOG_FD'
65 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&AS_MESSAGE_LOG_FD'
66 ac_compiler_gnu=$ac_cv_c_compiler_gnu
72 AU_DEFUN([AC_LANG_C], [AC_LANG(C)])
75 # ------------------------ #
76 # 2a. Producing programs. #
77 # ------------------------ #
80 # AC_LANG_CONFTEST(C)(BODY)
81 # -------------------------
82 # We can't use '#line $LINENO "configure"' here, since
83 # Sun c89 (Sun WorkShop 6 update 2 C 5.3 Patch 111679-08 2002/05/09)
84 # rejects $LINENO greater than 32767, and some configure scripts
85 # are longer than 32767 lines.
86 m4_define([AC_LANG_CONFTEST(C)],
87 [cat confdefs.h - <<_ACEOF >conftest.$ac_ext
93 # AC_LANG_PROGRAM(C)([PROLOGUE], [BODY])
94 # --------------------------------------
95 m4_define([AC_LANG_PROGRAM(C)],
97 m4_ifdef([_AC_LANG_PROGRAM_C_F77_HOOKS], [_AC_LANG_PROGRAM_C_F77_HOOKS])[]dnl
98 m4_ifdef([_AC_LANG_PROGRAM_C_FC_HOOKS], [_AC_LANG_PROGRAM_C_FC_HOOKS])[]dnl
102 dnl Do *not* indent the following line: there may be CPP directives.
103 dnl Don't move the ';' right after for the same reason.
110 # _AC_LANG_IO_PROGRAM(C)
111 # ----------------------
112 # Produce source that performs I/O, necessary for proper
113 # cross-compiler detection.
114 m4_define([_AC_LANG_IO_PROGRAM(C)],
115 [AC_LANG_PROGRAM([@%:@include <stdio.h>],
116 [FILE *f = fopen ("conftest.out", "w");
117 return ferror (f) || fclose (f) != 0;
121 # AC_LANG_CALL(C)(PROLOGUE, FUNCTION)
122 # -----------------------------------
123 # Avoid conflicting decl of main.
124 m4_define([AC_LANG_CALL(C)],
126 m4_if([$2], [main], ,
127 [/* Override any GCC internal prototype to avoid an error.
128 Use char because int might match the return type of a GCC
129 builtin and then its argument prototype would still apply.
130 The 'extern "C"' is for builds by C++ compilers;
131 although this is not generally supported in C code supporting it here
132 has little cost and some practical benefit (sr 110532). */
136 char $2 (void);])], [return $2 ();])])
139 # AC_LANG_FUNC_LINK_TRY(C)(FUNCTION)
140 # ----------------------------------
141 # Don't include <ctype.h> because on OSF/1 3.0 it includes
142 # <sys/types.h> which includes <sys/select.h> which contains a
143 # prototype for select. Similarly for bzero.
145 # This test used to merely assign f=$1 in main(), but that was
146 # optimized away by HP unbundled cc A.05.36 for ia64 under +O3,
147 # presumably on the basis that there's no need to do that store if the
148 # program is about to exit. Conversely, the AIX linker optimizes an
149 # unused external declaration that initializes f=$1. So this test
150 # program has both an external initialization of f, and a use of f in
151 # main that affects the exit status.
153 m4_define([AC_LANG_FUNC_LINK_TRY(C)],
155 [/* Define $1 to an innocuous variant, in case <limits.h> declares $1.
156 For example, HP-UX 11i <limits.h> declares gettimeofday. */
157 #define $1 innocuous_$1
159 /* System header to define __stub macros and hopefully few prototypes,
160 which can conflict with char $1 (void); below. */
165 /* Override any GCC internal prototype to avoid an error.
166 Use char because int might match the return type of a GCC
167 builtin and then its argument prototype would still apply. */
172 /* The GNU C library defines this for functions which it implements
173 to always fail with ENOSYS. Some functions are actually named
174 something starting with __ and the normal name is an alias. */
175 #if defined __stub_$1 || defined __stub___$1
178 ], [return $1 ();])])
181 # AC_LANG_BOOL_COMPILE_TRY(C)(PROLOGUE, EXPRESSION)
182 # -------------------------------------------------
183 # Return a program that is valid if EXPRESSION is nonzero.
184 # EXPRESSION must be an integer constant expression.
185 # Be sure to use this array to avoid 'unused' warnings, which are even
186 # errors with '-W error'.
187 m4_define([AC_LANG_BOOL_COMPILE_TRY(C)],
188 [AC_LANG_PROGRAM([$1], [static int test_array @<:@1 - 2 * !($2)@:>@;
189 test_array @<:@0@:>@ = 0;
190 return test_array @<:@0@:>@;
194 # AC_LANG_INT_SAVE(C)(PROLOGUE, EXPRESSION)
195 # -----------------------------------------
196 # We need 'stdio.h' to open a 'FILE' and 'stdlib.h' for 'exit'.
197 # But we include them only after the EXPRESSION has been evaluated.
198 m4_define([AC_LANG_INT_SAVE(C)],
200 static long int longval (void) { return $2; }
201 static unsigned long int ulongval (void) { return $2; }
202 @%:@include <stdio.h>
203 @%:@include <stdlib.h>],
205 FILE *f = fopen ("conftest.val", "w");
210 long int i = longval ();
213 fprintf (f, "%ld", i);
217 unsigned long int i = ulongval ();
220 fprintf (f, "%lu", i);
222 /* Do not output a trailing newline, as this causes \r\n confusion
223 on some platforms. */
224 return ferror (f) || fclose (f) != 0;
229 ## ---------------------- ##
230 ## 1b. The C++ language. ##
231 ## ---------------------- ##
236 # CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
237 AC_LANG_DEFINE([C++], [cxx], [CXX], [CXX], [C],
239 ac_cpp='$CXXCPP $CPPFLAGS'
240 ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&AS_MESSAGE_LOG_FD'
241 ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&AS_MESSAGE_LOG_FD'
242 ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
246 # AC_LANG_CALL(C++)(PROLOGUE, FUNCTION)
247 # -------------------------------------
248 m4_define([AC_LANG_CALL(C++)],
249 dnl We do not know the function signature of the real $2.
250 dnl Declare it in a namespace so the compiler doesn't recognize it
251 dnl (with, most likely, a clashing prototype); the 'extern "C"' hides
252 dnl the namespace from the linker.
253 dnl Use 'int' for the return type, because some C++ compilers consider
254 dnl 'namespace conftest { extern "C" void main (); }' to be an
255 dnl erroneous redeclaration of ::main, namespace notwithstanding.
256 dnl The logic they're applying could be extended in the future to
257 dnl other built-in extern "C" functions, but let's worry about that
258 dnl when it actually happens.
259 [AC_LANG_PROGRAM([[$1
261 extern "C" int $2 ();
263 [[return conftest::$2 ();]])])
268 AU_DEFUN([AC_LANG_CPLUSPLUS], [AC_LANG(C++)])
272 ## ------------------------------ ##
273 ## 1c. The Objective C language. ##
274 ## ------------------------------ ##
277 # AC_LANG(Objective C)
278 # --------------------
279 AC_LANG_DEFINE([Objective C], [objc], [OBJC], [OBJC], [C],
281 ac_cpp='$OBJCPP $CPPFLAGS'
282 ac_compile='$OBJC -c $OBJCFLAGS $CPPFLAGS conftest.$ac_ext >&AS_MESSAGE_LOG_FD'
283 ac_link='$OBJC -o conftest$ac_exeext $OBJCFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&AS_MESSAGE_LOG_FD'
284 ac_compiler_gnu=$ac_cv_objc_compiler_gnu
290 AU_DEFUN([AC_LANG_OBJC], [AC_LANG(Objective C)])
294 ## -------------------------------- ##
295 ## 1d. The Objective C++ language. ##
296 ## -------------------------------- ##
299 # AC_LANG(Objective C++)
300 # ----------------------
301 AC_LANG_DEFINE([Objective C++], [objcxx], [OBJCXX], [OBJCXX], [C++],
303 ac_cpp='$OBJCXXCPP $CPPFLAGS'
304 ac_compile='$OBJCXX -c $OBJCXXFLAGS $CPPFLAGS conftest.$ac_ext >&AS_MESSAGE_LOG_FD'
305 ac_link='$OBJCXX -o conftest$ac_exeext $OBJCXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&AS_MESSAGE_LOG_FD'
306 ac_compiler_gnu=$ac_cv_objcxx_compiler_gnu
311 ## -------------------------------------------- ##
312 ## 3. Looking for Compilers and Preprocessors. ##
313 ## -------------------------------------------- ##
315 # -------------------- #
316 # 3a. The C compiler. #
317 # -------------------- #
320 # _AC_ARG_VAR_CPPFLAGS
321 # --------------------
322 # Document and register CPPFLAGS, which is used by
323 # AC_PROG_{CC, CPP, CXX, CXXCPP, OBJC, OBJCPP, OBJCXX, OBJCXXCPP}.
324 AC_DEFUN([_AC_ARG_VAR_CPPFLAGS],
325 [AC_ARG_VAR([CPPFLAGS],
326 [(Objective) C/C++ preprocessor flags, e.g. -I<include dir>
327 if you have headers in a nonstandard directory <include dir>])])
330 # _AC_ARG_VAR_LDFLAGS
331 # -------------------
332 # Document and register LDFLAGS, which is used by
333 # AC_PROG_{CC, CXX, F77, FC, OBJC, OBJCXX}.
334 AC_DEFUN([_AC_ARG_VAR_LDFLAGS],
335 [AC_ARG_VAR([LDFLAGS],
336 [linker flags, e.g. -L<lib dir> if you have libraries in a
337 nonstandard directory <lib dir>])])
342 # Document and register LIBS, which is used by
343 # AC_PROG_{CC, CXX, F77, FC, OBJC, OBJCXX}.
344 AC_DEFUN([_AC_ARG_VAR_LIBS],
346 [libraries to pass to the linker, e.g. -l<library>])])
351 # Find the C preprocessor. Must be AC_DEFUN'd to be AC_REQUIRE'able.
352 AC_DEFUN([AC_LANG_PREPROC(C)],
353 [AC_REQUIRE([AC_PROG_CPP])])
356 # _AC_PROG_PREPROC_WORKS_IFELSE(IF-WORKS, IF-NOT)
357 # -----------------------------------------------
358 # Check if $ac_cpp is a working preprocessor that can flag absent
359 # includes either by the exit status or by warnings.
360 # This macro is for all languages, not only C.
361 AC_DEFUN([_AC_PROG_PREPROC_WORKS_IFELSE],
363 for ac_[]_AC_LANG_ABBREV[]_preproc_warn_flag in '' yes
365 # Use a header file that comes with gcc, so configuring glibc
366 # with a fresh cross-compiler works.
367 # On the NeXT, cc -E runs the code through the compiler's parser,
368 # not just through cpp. "Syntax error" is here to catch this case.
369 _AC_PREPROC_IFELSE([AC_LANG_SOURCE([[@%:@include <limits.h>
372 [# Broken: fails on valid input.
375 # OK, works on sane cases. Now check whether nonexistent headers
376 # can be detected and how.
377 _AC_PREPROC_IFELSE([AC_LANG_SOURCE([[@%:@include <ac_nonexistent.h>]])],
378 [# Broken: success on invalid input.
380 [# Passes both tests.
385 # Because of 'break', _AC_PREPROC_IFELSE's cleaning code was skipped.
386 rm -f conftest.i conftest.err conftest.$ac_ext
387 AS_IF([$ac_preproc_ok], [$1], [$2])
388 ])# _AC_PROG_PREPROC_WORKS_IFELSE
393 # Find a working C preprocessor.
394 # We shouldn't have to require AC_PROG_CC, but this is due to the concurrency
395 # between the AC_LANG_COMPILER_REQUIRE family and that of AC_PROG_CC.
396 AN_MAKEVAR([CPP], [AC_PROG_CPP])
397 AN_PROGRAM([cpp], [AC_PROG_CPP])
398 AC_DEFUN([AC_PROG_CPP],
399 [AC_REQUIRE([AC_PROG_CC])dnl
400 AC_ARG_VAR([CPP], [C preprocessor])dnl
401 _AC_ARG_VAR_CPPFLAGS()dnl
403 AC_MSG_CHECKING([how to run the C preprocessor])
404 # On Suns, sometimes $CPP names a directory.
405 if test -n "$CPP" && test -d "$CPP"; then
408 if test -z "$CPP"; then
409 AC_CACHE_VAL([ac_cv_prog_CPP],
411 # Double quotes because $CC needs to be expanded
412 for CPP in "$CC -E" "$CC -E -traditional-cpp" cpp /lib/cpp
414 _AC_PROG_PREPROC_WORKS_IFELSE([break])
422 AC_MSG_RESULT([$CPP])
423 _AC_PROG_PREPROC_WORKS_IFELSE([],
424 [AC_MSG_FAILURE([C preprocessor "$CPP" fails sanity check])])
431 # Treat warnings from the preprocessor as errors.
432 AC_DEFUN([AC_PROG_CPP_WERROR],
433 [AC_REQUIRE([AC_PROG_CPP])dnl
434 ac_c_preproc_warn_flag=yes])# AC_PROG_CPP_WERROR
436 # AC_LANG_COMPILER(C)
437 # -------------------
438 # Find the C compiler. Must be AC_DEFUN'd to be AC_REQUIRE'able.
439 AC_DEFUN([AC_LANG_COMPILER(C)],
440 [AC_REQUIRE([AC_PROG_CC])])
445 # We used to name the cache variable this way.
446 AU_DEFUN([ac_cv_prog_gcc],
447 [ac_cv_c_compiler_gnu])
450 # AC_PROG_CC([COMPILER ...])
451 # --------------------------
452 # COMPILER ... is a space separated list of C compilers to search for.
453 # This just gives the user an opportunity to specify an alternative
454 # search list for the C compiler.
455 AN_MAKEVAR([CC], [AC_PROG_CC])
456 AN_PROGRAM([cc], [AC_PROG_CC])
457 AN_PROGRAM([gcc], [AC_PROG_CC])
458 AC_DEFUN([AC_PROG_CC],
460 AC_ARG_VAR([CC], [C compiler command])dnl
461 AC_ARG_VAR([CFLAGS], [C compiler flags])dnl
462 _AC_ARG_VAR_LDFLAGS()dnl
463 _AC_ARG_VAR_LIBS()dnl
464 _AC_ARG_VAR_CPPFLAGS()dnl
466 [AC_CHECK_TOOLS(CC, [$1])],
467 [AC_CHECK_TOOL(CC, gcc)
468 if test -z "$CC"; then
470 dnl AC_CHECK_TOOL(CC, cc)
471 dnl but without the check for a tool without the prefix.
472 dnl Until the check is removed from there, copy the code:
473 if test -n "$ac_tool_prefix"; then
474 AC_CHECK_PROG(CC, [${ac_tool_prefix}cc], [${ac_tool_prefix}cc])
477 if test -z "$CC"; then
478 AC_CHECK_PROG(CC, cc, cc, , , /usr/ucb/cc)
480 if test -z "$CC"; then
481 AC_CHECK_TOOLS(CC, cl.exe)
483 if test -z "$CC"; then
484 AC_CHECK_TOOL(CC, clang)
488 test -z "$CC" && AC_MSG_FAILURE([no acceptable C compiler found in \$PATH])
490 # Provide some information about the compiler.
491 _AS_ECHO_LOG([checking for _AC_LANG compiler version])
494 for ac_option in --version -v -V -qversion -version; do
495 _AC_DO_LIMIT([$ac_compiler $ac_option >&AS_MESSAGE_LOG_FD])
498 m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
499 m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl
500 _AC_LANG_COMPILER_GNU
501 if test $ac_compiler_gnu = yes; then
507 _AC_PROG_CC_STDC_EDITION
514 # Check whether -g works, even if CFLAGS is set, in case the package
515 # plays around with CFLAGS (such as to build both debugging and normal
516 # versions of a library), tasteless as that idea is.
517 # Don't consider -g to work if it generates warnings when plain compiles don't.
518 m4_define([_AC_PROG_CC_G],
519 [ac_test_CFLAGS=${CFLAGS+y}
520 ac_save_CFLAGS=$CFLAGS
521 AC_CACHE_CHECK(whether $CC accepts -g, ac_cv_prog_cc_g,
522 [ac_save_c_werror_flag=$ac_c_werror_flag
526 _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
527 [ac_cv_prog_cc_g=yes],
529 _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
531 [ac_c_werror_flag=$ac_save_c_werror_flag
533 _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
534 [ac_cv_prog_cc_g=yes])])])
535 ac_c_werror_flag=$ac_save_c_werror_flag])
536 if test $ac_test_CFLAGS; then
537 CFLAGS=$ac_save_CFLAGS
538 elif test $ac_cv_prog_cc_g = yes; then
539 if test "$GCC" = yes; then
545 if test "$GCC" = yes; then
554 # AC_PROG_GCC_TRADITIONAL
555 # -----------------------
556 AC_DEFUN([AC_PROG_GCC_TRADITIONAL],
557 [AC_REQUIRE([AC_PROG_CC])dnl
558 if test $ac_cv_c_compiler_gnu = yes; then
559 AC_CACHE_CHECK(whether $CC needs -traditional,
560 ac_cv_prog_gcc_traditional,
561 [ ac_pattern="Autoconf.*'x'"
562 AC_EGREP_CPP($ac_pattern, [#include <sgtty.h>
564 ac_cv_prog_gcc_traditional=yes, ac_cv_prog_gcc_traditional=no)
566 if test $ac_cv_prog_gcc_traditional = no; then
567 AC_EGREP_CPP($ac_pattern, [#include <termio.h>
569 ac_cv_prog_gcc_traditional=yes)
571 if test $ac_cv_prog_gcc_traditional = yes; then
572 CC="$CC -traditional"
575 ])# AC_PROG_GCC_TRADITIONAL
580 AC_DEFUN([AC_PROG_CC_C_O],
581 [AC_REQUIRE([AC_PROG_CC])dnl
582 if test "x$CC" != xcc; then
583 AC_MSG_CHECKING([whether $CC and cc understand -c and -o together])
585 AC_MSG_CHECKING([whether cc understands -c and -o together])
587 set dummy $CC; ac_cc=`AS_ECHO(["$[2]"]) |
588 sed 's/[[^a-zA-Z0-9_]]/_/g;s/^[[0-9]]/_/'`
589 AC_CACHE_VAL(ac_cv_prog_cc_${ac_cc}_c_o,
590 [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])])
591 # Make sure it works both with $CC and with simple cc.
592 # We do the test twice because some compilers refuse to overwrite an
593 # existing .o file with -o, though they will create one.
594 ac_try='$CC -c conftest.$ac_ext -o conftest2.$ac_objext >&AS_MESSAGE_LOG_FD'
596 if _AC_DO_VAR(ac_try) &&
597 test -f conftest2.$ac_objext && _AC_DO_VAR(ac_try);
599 eval ac_cv_prog_cc_${ac_cc}_c_o=yes
600 if test "x$CC" != xcc; then
601 # Test first that cc exists at all.
602 if _AC_DO_TOKENS(cc -c conftest.$ac_ext >&AS_MESSAGE_LOG_FD); then
603 ac_try='cc -c conftest.$ac_ext -o conftest2.$ac_objext >&AS_MESSAGE_LOG_FD'
605 if _AC_DO_VAR(ac_try) &&
606 test -f conftest2.$ac_objext && _AC_DO_VAR(ac_try);
611 # cc exists but doesn't like -o.
612 eval ac_cv_prog_cc_${ac_cc}_c_o=no
617 eval ac_cv_prog_cc_${ac_cc}_c_o=no
619 rm -rf core conftest*
621 if eval test \$ac_cv_prog_cc_${ac_cc}_c_o = yes; then
625 AC_DEFINE(NO_MINUS_C_MINUS_O, 1,
626 [Define to 1 if your C compiler doesn't accept -c and -o together.])
632 # ---------------------- #
633 # 3b. The C++ compiler. #
634 # ---------------------- #
637 # AC_LANG_PREPROC(C++)
638 # --------------------
639 # Find the C++ preprocessor. Must be AC_DEFUN'd to be AC_REQUIRE'able.
640 AC_DEFUN([AC_LANG_PREPROC(C++)],
641 [AC_REQUIRE([AC_PROG_CXXCPP])])
646 # Find a working C++ preprocessor.
647 # We shouldn't have to require AC_PROG_CC, but this is due to the concurrency
648 # between the AC_LANG_COMPILER_REQUIRE family and that of AC_PROG_CXX.
649 AC_DEFUN([AC_PROG_CXXCPP],
650 [AC_REQUIRE([AC_PROG_CXX])dnl
651 AC_ARG_VAR([CXXCPP], [C++ preprocessor])dnl
652 _AC_ARG_VAR_CPPFLAGS()dnl
654 AC_MSG_CHECKING([how to run the C++ preprocessor])
655 if test -z "$CXXCPP"; then
656 AC_CACHE_VAL(ac_cv_prog_CXXCPP,
658 # Double quotes because $CXX needs to be expanded
659 for CXXCPP in "$CXX -E" cpp /lib/cpp
661 _AC_PROG_PREPROC_WORKS_IFELSE([break])
663 ac_cv_prog_CXXCPP=$CXXCPP
665 CXXCPP=$ac_cv_prog_CXXCPP
667 ac_cv_prog_CXXCPP=$CXXCPP
669 AC_MSG_RESULT([$CXXCPP])
670 _AC_PROG_PREPROC_WORKS_IFELSE([],
671 [AC_MSG_FAILURE([C++ preprocessor "$CXXCPP" fails sanity check])])
677 # AC_LANG_COMPILER(C++)
678 # ---------------------
679 # Find the C++ compiler. Must be AC_DEFUN'd to be AC_REQUIRE'able.
680 AC_DEFUN([AC_LANG_COMPILER(C++)],
681 [AC_REQUIRE([AC_PROG_CXX])])
686 # We used to name the cache variable this way.
687 AU_DEFUN([ac_cv_prog_gxx],
688 [ac_cv_cxx_compiler_gnu])
691 # AC_PROG_CXX([LIST-OF-COMPILERS])
692 # --------------------------------
693 # LIST-OF-COMPILERS is a space separated list of C++ compilers to search
694 # for (if not specified, a default list is used). This just gives the
695 # user an opportunity to specify an alternative search list for the C++
697 # aCC HP-UX C++ compiler much better than 'CC', so test before.
698 # FCC Fujitsu C++ compiler
699 # KCC KAI C++ compiler
701 # xlC_r IBM XL C++ for AIX (with support for reentrant code)
702 # xlC IBM XL C++ for AIX
703 AN_MAKEVAR([CXX], [AC_PROG_CXX])
704 AN_PROGRAM([CC], [AC_PROG_CXX])
705 AN_PROGRAM([c++], [AC_PROG_CXX])
706 AN_PROGRAM([g++], [AC_PROG_CXX])
707 AC_DEFUN([AC_PROG_CXX],
708 [AC_LANG_PUSH(C++)dnl
709 AC_ARG_VAR([CXX], [C++ compiler command])dnl
710 AC_ARG_VAR([CXXFLAGS], [C++ compiler flags])dnl
711 _AC_ARG_VAR_LDFLAGS()dnl
712 _AC_ARG_VAR_LIBS()dnl
713 _AC_ARG_VAR_CPPFLAGS()dnl
714 _AC_ARG_VAR_PRECIOUS([CCC])dnl
715 if test -z "$CXX"; then
716 if test -n "$CCC"; then
721 [g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC clang++])],
725 # Provide some information about the compiler.
726 _AS_ECHO_LOG([checking for _AC_LANG compiler version])
729 for ac_option in --version -v -V -qversion; do
730 _AC_DO_LIMIT([$ac_compiler $ac_option >&AS_MESSAGE_LOG_FD])
733 m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
734 m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl
735 _AC_LANG_COMPILER_GNU
736 if test $ac_compiler_gnu = yes; then
742 _AC_PROG_CXX_STDCXX_EDITION
749 # Check whether -g works, even if CXXFLAGS is set, in case the package
750 # plays around with CXXFLAGS (such as to build both debugging and
751 # normal versions of a library), tasteless as that idea is.
752 # Don't consider -g to work if it generates warnings when plain compiles don't.
753 m4_define([_AC_PROG_CXX_G],
754 [ac_test_CXXFLAGS=${CXXFLAGS+y}
755 ac_save_CXXFLAGS=$CXXFLAGS
756 AC_CACHE_CHECK(whether $CXX accepts -g, ac_cv_prog_cxx_g,
757 [ac_save_cxx_werror_flag=$ac_cxx_werror_flag
758 ac_cxx_werror_flag=yes
761 _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
762 [ac_cv_prog_cxx_g=yes],
764 _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
766 [ac_cxx_werror_flag=$ac_save_cxx_werror_flag
768 _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
769 [ac_cv_prog_cxx_g=yes])])])
770 ac_cxx_werror_flag=$ac_save_cxx_werror_flag])
771 if test $ac_test_CXXFLAGS; then
772 CXXFLAGS=$ac_save_CXXFLAGS
773 elif test $ac_cv_prog_cxx_g = yes; then
774 if test "$GXX" = yes; then
780 if test "$GXX" = yes; then
791 # Test if the C++ compiler accepts the options '-c' and '-o'
792 # simultaneously, and define 'CXX_NO_MINUS_C_MINUS_O' if it does not.
793 AC_DEFUN([AC_PROG_CXX_C_O],
794 [AC_REQUIRE([AC_PROG_CXX])dnl
795 AC_LANG_PUSH([C++])dnl
796 AC_CACHE_CHECK([whether $CXX understands -c and -o together],
797 [ac_cv_prog_cxx_c_o],
798 [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])])
799 # We test twice because some compilers refuse to overwrite an existing
800 # '.o' file with '-o', although they will create one.
801 ac_try='$CXX $CXXFLAGS -c conftest.$ac_ext -o conftest2.$ac_objext >&AS_MESSAGE_LOG_FD'
803 if _AC_DO_VAR(ac_try) &&
804 test -f conftest2.$ac_objext &&
805 _AC_DO_VAR(ac_try); then
806 ac_cv_prog_cxx_c_o=yes
808 ac_cv_prog_cxx_c_o=no
811 if test $ac_cv_prog_cxx_c_o = no; then
812 AC_DEFINE(CXX_NO_MINUS_C_MINUS_O, 1,
813 [Define to 1 if your C++ compiler doesn't accept
814 -c and -o together.])
816 AC_LANG_POP([C++])dnl
821 # ------------------------------ #
822 # 3c. The Objective C compiler. #
823 # ------------------------------ #
826 # AC_LANG_PREPROC(Objective C)
827 # ----------------------------
828 # Find the Objective C preprocessor. Must be AC_DEFUN'd to be AC_REQUIRE'able.
829 AC_DEFUN([AC_LANG_PREPROC(Objective C)],
830 [AC_REQUIRE([AC_PROG_OBJCPP])])
835 # Find a working Objective C preprocessor.
836 AC_DEFUN([AC_PROG_OBJCPP],
837 [AC_REQUIRE([AC_PROG_OBJC])dnl
838 AC_ARG_VAR([OBJCPP], [Objective C preprocessor])dnl
839 _AC_ARG_VAR_CPPFLAGS()dnl
840 AC_LANG_PUSH(Objective C)dnl
841 AC_MSG_CHECKING([how to run the Objective C preprocessor])
842 if test -z "$OBJCPP"; then
843 AC_CACHE_VAL(ac_cv_prog_OBJCPP,
845 # Double quotes because $OBJC needs to be expanded
846 for OBJCPP in "$OBJC -E" cpp /lib/cpp
848 _AC_PROG_PREPROC_WORKS_IFELSE([break])
850 ac_cv_prog_OBJCPP=$OBJCPP
852 OBJCPP=$ac_cv_prog_OBJCPP
854 ac_cv_prog_OBJCPP=$OBJCPP
856 AC_MSG_RESULT([$OBJCPP])
857 _AC_PROG_PREPROC_WORKS_IFELSE([],
858 [AC_MSG_FAILURE([Objective C preprocessor "$OBJCPP" fails sanity check])])
860 AC_LANG_POP(Objective C)dnl
864 # AC_LANG_COMPILER(Objective C)
865 # -----------------------------
866 # Find the Objective C compiler. Must be AC_DEFUN'd to be AC_REQUIRE'able.
867 AC_DEFUN([AC_LANG_COMPILER(Objective C)],
868 [AC_REQUIRE([AC_PROG_OBJC])])
872 # AC_PROG_OBJC([LIST-OF-COMPILERS])
873 # ---------------------------------
874 # LIST-OF-COMPILERS is a space separated list of Objective C compilers to
875 # search for (if not specified, a default list is used). This just gives
876 # the user an opportunity to specify an alternative search list for the
877 # Objective C compiler.
878 # objcc StepStone Objective-C compiler (also "standard" name for OBJC)
879 # objc David Stes' POC. If you installed this, you likely want it.
880 # cc Native C compiler (for instance, Apple).
882 AN_MAKEVAR([OBJC], [AC_PROG_OBJC])
883 AN_PROGRAM([objcc], [AC_PROG_OBJC])
884 AN_PROGRAM([objc], [AC_PROG_OBJC])
885 AC_DEFUN([AC_PROG_OBJC],
886 [AC_LANG_PUSH(Objective C)dnl
887 AC_ARG_VAR([OBJC], [Objective C compiler command])dnl
888 AC_ARG_VAR([OBJCFLAGS], [Objective C compiler flags])dnl
889 _AC_ARG_VAR_LDFLAGS()dnl
890 _AC_ARG_VAR_LIBS()dnl
891 _AC_ARG_VAR_CPPFLAGS()dnl
892 _AC_ARG_VAR_PRECIOUS([OBJC])dnl
894 [m4_default([$1], [gcc objcc objc cc CC clang])],
896 # Provide some information about the compiler.
897 _AS_ECHO_LOG([checking for _AC_LANG compiler version])
900 for ac_option in --version -v -V -qversion; do
901 _AC_DO_LIMIT([$ac_compiler $ac_option >&AS_MESSAGE_LOG_FD])
904 m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
905 m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl
906 _AC_LANG_COMPILER_GNU
907 if test $ac_compiler_gnu = yes; then
913 AC_LANG_POP(Objective C)dnl
919 # Check whether -g works, even if OBJCFLAGS is set, in case the package
920 # plays around with OBJCFLAGS (such as to build both debugging and
921 # normal versions of a library), tasteless as that idea is.
922 # Don't consider -g to work if it generates warnings when plain compiles don't.
923 m4_define([_AC_PROG_OBJC_G],
924 [ac_test_OBJCFLAGS=${OBJCFLAGS+y}
925 ac_save_OBJCFLAGS=$OBJCFLAGS
926 AC_CACHE_CHECK(whether $OBJC accepts -g, ac_cv_prog_objc_g,
927 [ac_save_objc_werror_flag=$ac_objc_werror_flag
928 ac_objc_werror_flag=yes
931 _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
932 [ac_cv_prog_objc_g=yes],
934 _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
936 [ac_objc_werror_flag=$ac_save_objc_werror_flag
938 _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
939 [ac_cv_prog_objc_g=yes])])])
940 ac_objc_werror_flag=$ac_save_objc_werror_flag])
941 if test $ac_test_OBJCFLAGS; then
942 OBJCFLAGS=$ac_save_OBJCFLAGS
943 elif test $ac_cv_prog_objc_g = yes; then
944 if test "$GOBJC" = yes; then
950 if test "$GOBJC" = yes; then
960 # -------------------------------- #
961 # 3d. The Objective C++ compiler. #
962 # -------------------------------- #
965 # AC_LANG_PREPROC(Objective C++)
966 # ------------------------------
967 # Find the Objective C++ preprocessor. Must be AC_DEFUN'd to be AC_REQUIRE'able.
968 AC_DEFUN([AC_LANG_PREPROC(Objective C++)],
969 [AC_REQUIRE([AC_PROG_OBJCXXCPP])])
974 # Find a working Objective C++ preprocessor.
975 AC_DEFUN([AC_PROG_OBJCXXCPP],
976 [AC_REQUIRE([AC_PROG_OBJCXX])dnl
977 AC_ARG_VAR([OBJCXXCPP], [Objective C++ preprocessor])dnl
978 _AC_ARG_VAR_CPPFLAGS()dnl
979 AC_LANG_PUSH(Objective C++)dnl
980 AC_MSG_CHECKING([how to run the Objective C++ preprocessor])
981 if test -z "$OBJCXXCPP"; then
982 AC_CACHE_VAL(ac_cv_prog_OBJCXXCPP,
984 # Double quotes because $OBJCXX needs to be expanded
985 for OBJCXXCPP in "$OBJCXX -E" cpp /lib/cpp
987 _AC_PROG_PREPROC_WORKS_IFELSE([break])
989 ac_cv_prog_OBJCXXCPP=$OBJCXXCPP
991 OBJCXXCPP=$ac_cv_prog_OBJCXXCPP
993 ac_cv_prog_OBJCXXCPP=$OBJCXXCPP
995 AC_MSG_RESULT([$OBJCXXCPP])
996 _AC_PROG_PREPROC_WORKS_IFELSE([],
997 [AC_MSG_FAILURE([Objective C++ preprocessor "$OBJCXXCPP" fails sanity check])])
998 AC_SUBST(OBJCXXCPP)dnl
999 AC_LANG_POP(Objective C++)dnl
1000 ])# AC_PROG_OBJCXXCPP
1003 # AC_LANG_COMPILER(Objective C++)
1004 # -------------------------------
1005 # Find the Objective C++ compiler. Must be AC_DEFUN'd to be AC_REQUIRE'able.
1006 AC_DEFUN([AC_LANG_COMPILER(Objective C++)],
1007 [AC_REQUIRE([AC_PROG_OBJCXX])])
1011 # AC_PROG_OBJCXX([LIST-OF-COMPILERS])
1012 # -----------------------------------
1013 # LIST-OF-COMPILERS is a space separated list of Objective C++ compilers to
1014 # search for (if not specified, a default list is used). This just gives
1015 # the user an opportunity to specify an alternative search list for the
1016 # Objective C++ compiler.
1017 # FIXME: this list is pure guesswork
1018 # objc++ StepStone Objective-C++ compiler (also "standard" name for OBJCXX)
1019 # objcxx David Stes' POC. If you installed this, you likely want it.
1020 # c++ Native C++ compiler (for instance, Apple).
1021 # CXX You never know.
1022 AN_MAKEVAR([OBJCXX], [AC_PROG_OBJCXX])
1023 AN_PROGRAM([objcxx], [AC_PROG_OBJCXX])
1024 AC_DEFUN([AC_PROG_OBJCXX],
1025 [AC_LANG_PUSH(Objective C++)dnl
1026 AC_ARG_VAR([OBJCXX], [Objective C++ compiler command])dnl
1027 AC_ARG_VAR([OBJCXXFLAGS], [Objective C++ compiler flags])dnl
1028 _AC_ARG_VAR_LDFLAGS()dnl
1029 _AC_ARG_VAR_LIBS()dnl
1030 _AC_ARG_VAR_CPPFLAGS()dnl
1031 _AC_ARG_VAR_PRECIOUS([OBJCXX])dnl
1032 AC_CHECK_TOOLS(OBJCXX,
1033 [m4_default([$1], [g++ objc++ objcxx c++ CXX])],
1035 # Provide some information about the compiler.
1036 _AS_ECHO_LOG([checking for _AC_LANG compiler version])
1039 for ac_option in --version -v -V -qversion; do
1040 _AC_DO_LIMIT([$ac_compiler $ac_option >&AS_MESSAGE_LOG_FD])
1043 m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
1044 m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl
1045 _AC_LANG_COMPILER_GNU
1046 if test $ac_compiler_gnu = yes; then
1052 AC_LANG_POP(Objective C++)dnl
1058 # Check whether -g works, even if OBJCFLAGS is set, in case the package
1059 # plays around with OBJCFLAGS (such as to build both debugging and
1060 # normal versions of a library), tasteless as that idea is.
1061 # Don't consider -g to work if it generates warnings when plain compiles don't.
1062 m4_define([_AC_PROG_OBJCXX_G],
1063 [ac_test_OBJCXXFLAGS=${OBJCXXFLAGS+y}
1064 ac_save_OBJCXXFLAGS=$OBJCXXFLAGS
1065 AC_CACHE_CHECK(whether $OBJCXX accepts -g, ac_cv_prog_objcxx_g,
1066 [ac_save_objcxx_werror_flag=$ac_objcxx_werror_flag
1067 ac_objcxx_werror_flag=yes
1068 ac_cv_prog_objcxx_g=no
1070 _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
1071 [ac_cv_prog_objcxx_g=yes],
1073 _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
1075 [ac_objcxx_werror_flag=$ac_save_objcxx_werror_flag
1077 _AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
1078 [ac_cv_prog_objcxx_g=yes])])])
1079 ac_objcxx_werror_flag=$ac_save_objcx_werror_flag])
1080 if test $ac_test_OBJCXXFLAGS; then
1081 OBJCXXFLAGS=$ac_save_OBJCXXFLAGS
1082 elif test $ac_cv_prog_objcxx_g = yes; then
1083 if test "$GOBJCXX" = yes; then
1084 OBJCXXFLAGS="-g -O2"
1089 if test "$GOBJCXX" = yes; then
1095 ])# _AC_PROG_OBJCXX_G
1099 ## ------------------------------- ##
1100 ## 4. Compilers' characteristics. ##
1101 ## ------------------------------- ##
1103 # -------------------------------- #
1104 # 4a. C compiler characteristics. #
1105 # -------------------------------- #
1107 # Fragments of these programs are emitted as shell variables in the
1108 # INIT_PREPARE diversion, because they can get long and we want only
1109 # one copy of each fragment in the generated configure. This also
1110 # makes quoting control a bit easier. Try to avoid using ', however,
1111 # because putting single quotes into a single-quoted shell string is
1112 # awkward (you must write '\'' for each ' you want in the program).
1114 # Warning: to avoid incorrect answers due to unused-variable warnings
1115 # and/or overly aggressive optimizers, each variable (global or not)
1116 # in these programs should be used, and each function should be
1117 # called. Unlike how AC_LANG_PROGRAM(C) usually does it, we declare
1118 # main with its usual two arguments, to give the test fragments some
1119 # convenient non-compile-time-constant values to pass around. In main,
1120 # there is an int variable 'ok' which will eventually become the return
1121 # value; use 'ok |= ...' to consume the results of operations.
1123 # Warning: each test program may only use the headers required to
1124 # exist in the relevant standard's *freestanding* environment, in case
1125 # the C compiler targets such an environment. (Therefore, almost no
1126 # features of the C89/C99/C11 standard *library* are probed. Use
1127 # AC_CHECK_HEADER, AC_CHECK_FUNC, etc. for that.) However, these
1128 # programs are only compiled and not linked, so it is ok to declare
1129 # external functions and then call them without worrying about whether
1130 # they actually exist.
1132 # The C89 freestanding headers are:
1133 # <float.h> <limits.h> <stdarg.h> <stddef.h>
1135 # <iso646.h> <stdbool.h> <stdint.h>
1137 # <stdalign.h> <stdnoreturn.h>
1139 AC_DEFUN([_AC_C_C89_TEST_GLOBALS],
1140 [m4_divert_text([INIT_PREPARE],
1141 [[# Test code for whether the C compiler supports C89 (global declarations)
1142 ac_c_conftest_c89_globals='
1143 /* Does the compiler advertise C89 conformance?
1144 Do not test the value of __STDC__, because some compilers set it to 0
1145 while being otherwise adequately conformant. */
1146 #if !defined __STDC__
1147 # error "Compiler does not advertise C89 conformance"
1153 /* Most of the following tests are stolen from RCS 5.7 src/conf.sh. */
1154 struct buf { int x; };
1155 struct buf * (*rcsopen) (struct buf *, struct stat *, int);
1156 static char *e (char **p, int i)
1160 static char *f (char * (*g) (char **, int), char **p, ...)
1165 s = g (p, va_arg (v,int));
1170 /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has
1171 function prototypes and stuff, but not \xHH hex character constants.
1172 These do not provoke an error unfortunately, instead are silently treated
1173 as an "x". The following induces an error, until -std is added to get
1174 proper ANSI mode. Curiously \x00 != x always comes out true, for an
1175 array size at least. It is necessary to write \x00 == 0 to get something
1176 that is true only with -std. */
1177 int osf4_cc_array ['\''\x00'\'' == 0 ? 1 : -1];
1179 /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
1180 inside strings and character constants. */
1181 #define FOO(x) '\''x'\''
1182 int xlc6_cc_array[FOO(a) == '\''x'\'' ? 1 : -1];
1184 int test (int i, double x);
1185 struct s1 {int (*f) (int a);};
1186 struct s2 {int (*f) (double a);};
1187 int pairnames (int, char **, int *(*)(struct buf *, struct stat *, int),
1191 AC_DEFUN([_AC_C_C89_TEST_MAIN],
1192 [m4_divert_text([INIT_PREPARE],
1193 [[# Test code for whether the C compiler supports C89 (body of main).
1194 ac_c_conftest_c89_main='
1195 ok |= (argc == 0 || f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]);
1199 AC_DEFUN([_AC_C_C99_TEST_GLOBALS],
1200 [m4_divert_text([INIT_PREPARE],
1201 [[# Test code for whether the C compiler supports C99 (global declarations)
1202 ac_c_conftest_c99_globals='
1203 // Does the compiler advertise C99 conformance?
1204 #if !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L
1205 # error "Compiler does not advertise C99 conformance"
1208 #include <stdbool.h>
1209 extern int puts (const char *);
1210 extern int printf (const char *, ...);
1211 extern int dprintf (int, const char *, ...);
1212 extern void *malloc (size_t);
1213 extern void free (void *);
1215 // Check varargs macros. These examples are taken from C99 6.10.3.5.
1216 // dprintf is used instead of fprintf to avoid needing to declare
1218 #define debug(...) dprintf (2, __VA_ARGS__)
1219 #define showlist(...) puts (#__VA_ARGS__)
1220 #define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__))
1222 test_varargs_macros (void)
1227 debug ("X = %d\n", x);
1228 showlist (The first, second, and third items.);
1229 report (x>y, "x is %d but y is %d", x, y);
1232 // Check long long types.
1233 #define BIG64 18446744073709551615ull
1234 #define BIG32 4294967295ul
1235 #define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0)
1237 #error "your preprocessor is broken"
1241 #error "your preprocessor is broken"
1243 static long long int bignum = -9223372036854775807LL;
1244 static unsigned long long int ubignum = BIG64;
1246 struct incomplete_array
1254 const wchar_t *name;
1258 typedef const char *ccp;
1261 test_restrict (ccp restrict text)
1263 // See if C++-style comments work.
1264 // Iterate through items via the restricted pointer.
1265 // Also check for declarations in for loops.
1266 for (unsigned int i = 0; *(text+i) != '\''\0'\''; ++i)
1271 // Check varargs and va_copy.
1273 test_varargs (const char *format, ...)
1276 va_start (args, format);
1278 va_copy (args_copy, args);
1280 const char *str = "";
1288 case '\''s'\'': // string
1289 str = va_arg (args_copy, const char *);
1291 case '\''d'\'': // int
1292 number = va_arg (args_copy, int);
1294 case '\''f'\'': // float
1295 fnumber = va_arg (args_copy, double);
1304 return *str && number && fnumber;
1309 AC_DEFUN([_AC_C_C99_TEST_MAIN],
1310 [m4_divert_text([INIT_PREPARE],
1311 [[# Test code for whether the C compiler supports C99 (body of main).
1312 ac_c_conftest_c99_main='
1314 _Bool success = false;
1315 success |= (argc != 0);
1318 if (test_restrict ("String literal") == 0)
1320 char *restrict newvar = "Another string";
1323 success &= test_varargs ("s, d'\'' f .", "string", 65, 34.234);
1324 test_varargs_macros ();
1326 // Check flexible array members.
1327 struct incomplete_array *ia =
1328 malloc (sizeof (struct incomplete_array) + (sizeof (double) * 10));
1330 for (int i = 0; i < ia->datasize; ++i)
1331 ia->data[i] = i * 1.234;
1332 // Work around memory leak warnings.
1335 // Check named initializers.
1336 struct named_init ni = {
1338 .name = L"Test wide string",
1339 .average = 543.34343,
1344 int dynamic_array[ni.number];
1345 dynamic_array[0] = argv[0][0];
1346 dynamic_array[ni.number - 1] = 543;
1348 // work around unused variable warnings
1349 ok |= (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == '\''x'\''
1350 || dynamic_array[ni.number - 1] != 543);
1354 AC_DEFUN([_AC_C_C11_TEST_GLOBALS],
1355 [m4_divert_text([INIT_PREPARE],
1356 [[# Test code for whether the C compiler supports C11 (global declarations)
1357 ac_c_conftest_c11_globals='
1358 // Does the compiler advertise C11 conformance?
1359 #if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112L
1360 # error "Compiler does not advertise C11 conformance"
1364 char _Alignas (double) aligned_as_double;
1365 char _Alignas (0) no_special_alignment;
1366 extern char aligned_as_int;
1367 char _Alignas (0) _Alignas (int) aligned_as_int;
1372 int_alignment = _Alignof (int),
1373 int_array_alignment = _Alignof (int[100]),
1374 char_alignment = _Alignof (char)
1376 _Static_assert (0 < -_Alignof (int), "_Alignof is signed");
1379 int _Noreturn does_not_return (void) { for (;;) continue; }
1381 // Check _Static_assert.
1382 struct test_static_assert
1385 _Static_assert (sizeof (int) <= sizeof (long int),
1386 "_Static_assert does not work in struct");
1390 // Check UTF-8 literals.
1391 #define u8 syntax error!
1392 char const utf8_literal[] = u8"happens to be ASCII" "another string";
1394 // Check duplicate typedefs.
1395 typedef long *long_ptr;
1396 typedef long int *long_ptr;
1397 typedef long_ptr long_ptr;
1399 // Anonymous structures and unions -- taken from C11 6.7.2.1 Example 1.
1403 struct { int i; int j; };
1404 struct { int k; long int l; } w;
1411 AC_DEFUN([_AC_C_C11_TEST_MAIN],
1412 [m4_divert_text([INIT_PREPARE],
1413 [[# Test code for whether the C compiler supports C11 (body of main).
1414 ac_c_conftest_c11_main='
1415 _Static_assert ((offsetof (struct anonymous, i)
1416 == offsetof (struct anonymous, w.k)),
1417 "Anonymous union alignment botch");
1424 AC_DEFUN([_AC_C_C89_TEST_PROGRAM],
1425 [AC_REQUIRE([_AC_C_C89_TEST_GLOBALS])dnl
1426 AC_REQUIRE([_AC_C_C89_TEST_MAIN])dnl
1427 m4_divert_text([INIT_PREPARE],
1428 [[# Test code for whether the C compiler supports C89 (complete).
1429 ac_c_conftest_c89_program="${ac_c_conftest_c89_globals}
1432 main (int argc, char **argv)
1435 ${ac_c_conftest_c89_main}
1441 AC_DEFUN([_AC_C_C99_TEST_PROGRAM],
1442 [AC_REQUIRE([_AC_C_C89_TEST_GLOBALS])dnl
1443 AC_REQUIRE([_AC_C_C89_TEST_MAIN])dnl
1444 AC_REQUIRE([_AC_C_C99_TEST_GLOBALS])dnl
1445 AC_REQUIRE([_AC_C_C99_TEST_MAIN])dnl
1446 m4_divert_text([INIT_PREPARE],
1447 [[# Test code for whether the C compiler supports C99 (complete).
1448 ac_c_conftest_c99_program="${ac_c_conftest_c89_globals}
1449 ${ac_c_conftest_c99_globals}
1452 main (int argc, char **argv)
1455 ${ac_c_conftest_c89_main}
1456 ${ac_c_conftest_c99_main}
1462 AC_DEFUN([_AC_C_C11_TEST_PROGRAM],
1463 [AC_REQUIRE([_AC_C_C89_TEST_GLOBALS])dnl
1464 AC_REQUIRE([_AC_C_C89_TEST_MAIN])dnl
1465 AC_REQUIRE([_AC_C_C99_TEST_GLOBALS])dnl
1466 AC_REQUIRE([_AC_C_C99_TEST_MAIN])dnl
1467 AC_REQUIRE([_AC_C_C11_TEST_GLOBALS])dnl
1468 AC_REQUIRE([_AC_C_C11_TEST_MAIN])dnl
1469 m4_divert_text([INIT_PREPARE],
1470 [[# Test code for whether the C compiler supports C11 (complete).
1471 ac_c_conftest_c11_program="${ac_c_conftest_c89_globals}
1472 ${ac_c_conftest_c99_globals}
1473 ${ac_c_conftest_c11_globals}
1476 main (int argc, char **argv)
1479 ${ac_c_conftest_c89_main}
1480 ${ac_c_conftest_c99_main}
1481 ${ac_c_conftest_c11_main}
1490 # Whitespace-separated list of options that might put the C compiler
1491 # into a mode conforming to ISO C1990 with extensions. Do not try
1492 # "strictly conforming" modes (e.g. gcc's -std=c90); they break some
1493 # systems' header files. If more than one option is needed, put
1494 # shell quotes around the group.
1496 # AIX circa 2003 -qlanglvl=extc89
1497 # old AIX -qlanglvl=ansi
1498 # Ultrix, OSF/1, Tru64 -std
1499 # HP-UX 10.20 and later -Ae
1500 # HP-UX older versions -Aa -D_HPUX_SOURCE
1501 # SVR4 -Xc -D__EXTENSIONS__
1502 m4_define([_AC_C_C89_OPTIONS], [
1507 "-Aa -D_HPUX_SOURCE"
1508 "-Xc -D__EXTENSIONS__"
1514 # Whitespace-separated list of options that might put the C compiler
1515 # into a mode conforming to ISO C1999 with extensions. Do not try
1516 # "strictly conforming" modes (e.g. gcc's -std=c99); they break some
1517 # systems' header files. If more than one option is needed, put
1518 # shell quotes around the group.
1520 # GCC, Clang -std=gnu99
1521 # Intel ICC -std=c99, -c99 (deprecated)
1522 # Note: because -std=c99 puts GCC in strictly conforming mode,
1523 # this option must be tested *after* -std=gnu99.
1526 # IBM XL C -qlanglvl=extc1x (V12.1; does not pass C11 test)
1527 # IBM XL C -qlanglvl=extc99 (pre-V12.1)
1529 # Solaris -D_STDC_C99=
1530 # Note: acc's -xc99 option uses linker magic to define the external
1531 # symbol __xpg4 as if by "int __xpg4 = 1;", which enables C99
1532 # behavior for C library functions. This is not wanted here,
1533 # because it means that a single module compiled with -xc99 alters
1534 # C runtime behavior for the entire program, not for just the
1535 # module. Instead, define the (private) symbol _STDC_C99, which
1536 # suppresses a bogus failure in <stdbool.h>. The resulting compiler
1537 # passes the test case here, and that's good enough.
1538 # For more, please see the thread starting at:
1539 # https://lists.gnu.org/archive/html/autoconf/2010-12/msg00059.html
1540 m4_define([_AC_C_C99_OPTIONS], [
1553 # Whitespace-separated list of options that might put the C compiler
1554 # into a mode conforming to ISO C2011 with extensions. Do not try
1555 # "strictly conforming" modes (e.g. gcc's -std=c11); they break some
1556 # systems' header files. If more than one option is needed, put
1557 # shell quotes around the group.
1559 # GCC, Clang -std=gnu11
1561 # For IBM XL C for AIX V16.1 or later, '-std=gnu11' should work if
1562 # the user configured with CC='xlclang'. Otherwise, do not try
1563 # -qlanglvl=extc1x as xlc with IBM XL C V16.1 (the latest version as
1564 # of August 2020) does not pass the C11 test. Instead, try extc1x when
1565 # compiling the C99 test instead, since it enables _Static_assert and
1566 # _Noreturn, which is a win.
1567 m4_define([_AC_C_C11_OPTIONS], [
1572 # _AC_PROG_CC_STDC_EDITION_TRY(EDITION)
1573 # -------------------------------------
1574 # Subroutine of _AC_PROG_CC_STDC_EDITION. Not to be called directly.
1576 # Check whether the C compiler accepts features of EDITION of the
1577 # C standard. EDITION should be a two-digit year (e.g. 89, 99, 11).
1578 # (FIXME: Switch to four-digit years for futureproofing.)
1579 # This is done by compiling the test program defined by
1580 # _AC_C_C{EDITION}_TEST_PROGRAM, first with no additional
1581 # command-line options, and then with each of the options
1582 # in the space-separated list defined by _AC_C_C{EDITION}_OPTIONS.
1584 # If we find a way to make the test program compile, set cache variable
1585 # ac_cv_prog_cc_cEDITION to the options required (if any), and add those
1586 # options to $CC. Set shell variable ac_prog_cc_stdc to 'cEDITION',
1587 # and set shell variable ac_cv_prog_cc_stdc to the options required.
1588 # (Neither of these variables is AC_SUBSTed. ac_cv_prog_cc_stdc used
1589 # to be a cache variable and is preserved with this name for backward
1590 # compatibility.) Otherwise, ac_cv_prog_cc_cEDITION is set to 'no'
1591 # and the other variables are not changed.
1593 # If ac_prog_cc_stdc is already set to a value other than 'no',
1594 # the shell code produced by this macro does nothing. This is so
1595 # _AC_PROG_CC_STDC_EDITION can use m4_map to iterate through
1597 AC_DEFUN([_AC_PROG_CC_STDC_EDITION_TRY],
1598 [AC_LANG_ASSERT([C])]dnl
1599 [AC_REQUIRE([_AC_C_C$1_TEST_PROGRAM])]dnl
1600 [AS_IF([test x$ac_prog_cc_stdc = xno],
1601 [AC_MSG_CHECKING([for $CC option to enable C$1 features])
1602 AC_CACHE_VAL([ac_cv_prog_cc_c$1],
1603 [ac_cv_prog_cc_c$1=no
1605 AC_LANG_CONFTEST([AC_LANG_DEFINES_PROVIDED][$][ac_c_conftest_c$1_program])
1606 for ac_arg in '' m4_normalize(m4_defn([_AC_C_C$1_OPTIONS]))
1608 CC="$ac_save_CC $ac_arg"
1609 _AC_COMPILE_IFELSE([], [ac_cv_prog_cc_c$1=$ac_arg])
1610 test "x$ac_cv_prog_cc_c$1" != "xno" && break
1612 rm -f conftest.$ac_ext
1614 AS_IF([test "x$ac_cv_prog_cc_c$1" = xno],
1615 [AC_MSG_RESULT([unsupported])],
1616 [AS_IF([test "x$ac_cv_prog_cc_c$1" = x],
1617 [AC_MSG_RESULT([none needed])],
1618 [AC_MSG_RESULT([$ac_cv_prog_cc_c$1])
1619 CC="$CC $ac_cv_prog_cc_c$1"])
1620 ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c$1
1621 ac_prog_cc_stdc=c$1])])
1625 # _AC_PROG_CC_STDC_EDITION
1626 # ------------------------
1627 # Detect the most recent edition of the ISO C standard that is
1628 # supported by the C compiler. Add command-line options to $CC, if
1629 # necessary, to enable support for this edition. Set the shell
1630 # variable ac_prog_cc_stdc to indicate the edition.
1631 AC_DEFUN([_AC_PROG_CC_STDC_EDITION],
1633 m4_map([_AC_PROG_CC_STDC_EDITION_TRY], [[11], [99], [89]])])
1636 # _AC_PROG_CC_C89(ACTION-IF-SUPPORTED, ACTION-IF-NOT-SUPPORTED)
1637 # -------------------------------------------------------------
1638 # Obsolete internal macro. No longer used by Autoconf itself, but
1639 # preserved for backward compatibility with pre-December 2020 versions
1640 # of Gnulib's std-gnu11.m4, which replaced the entire definition of
1641 # AC_PROG_CC *except* for this macro. Can be removed once everyone is
1642 # using Autoconf 2.70 and/or a current std-gnu11.m4.
1643 AC_DEFUN([_AC_PROG_CC_C89],
1644 [AC_REQUIRE([_AC_C_C89_TEST_GLOBALS])]dnl
1645 [AC_REQUIRE([_AC_C_C89_TEST_MAIN])]dnl
1646 [_AC_C_STD_TRY([c89],
1647 [$ac_c_conftest_c89_globals], [$ac_c_conftest_c89_main],
1648 m4_quote(m4_normalize(m4_defn([_AC_C_C89_OPTIONS]))),
1656 # Do not use AU_ALIAS here and in AC_PROG_CC_C99 and AC_PROG_CC_STDC,
1657 # as that'd be incompatible with how Automake redefines AC_PROG_CC. See
1658 # <https://lists.gnu.org/archive/html/autoconf/2012-10/msg00048.html>.
1659 AU_DEFUN([AC_PROG_CC_C89],
1660 [AC_REQUIRE([AC_PROG_CC])],
1661 [$0 is obsolete; use AC_PROG_CC]
1666 AU_DEFUN([AC_PROG_CC_C99],
1667 [AC_REQUIRE([AC_PROG_CC])],
1668 [$0 is obsolete; use AC_PROG_CC]
1673 AU_DEFUN([AC_PROG_CC_STDC],
1674 [AC_REQUIRE([AC_PROG_CC])],
1675 [$0 is obsolete; use AC_PROG_CC]
1681 AC_DEFUN([AC_C_BACKSLASH_A],
1683 AC_CACHE_CHECK([whether backslash-a works in strings], ac_cv_c_backslash_a,
1684 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
1689 char buf['\a' == 'a' ? -1 : 1];
1691 return buf[0] != "\a"[0];
1693 [ac_cv_c_backslash_a=yes],
1694 [ac_cv_c_backslash_a=no])])
1695 if test $ac_cv_c_backslash_a = yes; then
1696 AC_DEFINE(HAVE_C_BACKSLASH_A, 1,
1697 [Define if backslash-a works in C strings.])
1704 # Has been merged into AC_PROG_CC.
1705 AU_DEFUN([AC_C_CROSS], [])
1708 # AC_C_CHAR_UNSIGNED
1709 # ------------------
1710 AC_DEFUN([AC_C_CHAR_UNSIGNED],
1711 [AH_VERBATIM([__CHAR_UNSIGNED__],
1712 [/* Define to 1 if type 'char' is unsigned and your compiler does not
1713 predefine this macro. */
1714 #ifndef __CHAR_UNSIGNED__
1715 # undef __CHAR_UNSIGNED__
1717 AC_CACHE_CHECK(whether char is unsigned, ac_cv_c_char_unsigned,
1718 [AC_COMPILE_IFELSE([AC_LANG_BOOL_COMPILE_TRY([AC_INCLUDES_DEFAULT([])],
1719 [((char) -1) < 0])],
1720 ac_cv_c_char_unsigned=no, ac_cv_c_char_unsigned=yes)])
1721 if test $ac_cv_c_char_unsigned = yes; then
1722 AC_DEFINE(__CHAR_UNSIGNED__)
1724 ])# AC_C_CHAR_UNSIGNED
1727 # AC_C_BIGENDIAN ([ACTION-IF-TRUE], [ACTION-IF-FALSE], [ACTION-IF-UNKNOWN],
1728 # [ACTION-IF-UNIVERSAL])
1729 # -------------------------------------------------------------------------
1730 AC_DEFUN([AC_C_BIGENDIAN],
1731 [AH_VERBATIM([WORDS_BIGENDIAN],
1732 [/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
1733 significant byte first (like Motorola and SPARC, unlike Intel). */
1734 #if defined AC_APPLE_UNIVERSAL_BUILD
1735 # if defined __BIG_ENDIAN__
1736 # define WORDS_BIGENDIAN 1
1739 # ifndef WORDS_BIGENDIAN
1740 # undef WORDS_BIGENDIAN
1743 AC_CACHE_CHECK([whether byte ordering is bigendian], [ac_cv_c_bigendian],
1744 [ac_cv_c_bigendian=unknown
1745 # See if we're dealing with a universal compiler.
1748 [[#ifndef __APPLE_CC__
1749 not a universal capable compiler
1754 # Check for potential -arch flags. It is not universal unless
1755 # there are at least two -arch flags with different values.
1758 for ac_word in $CC $CFLAGS $CPPFLAGS $LDFLAGS; do
1759 if test -n "$ac_prev"; then
1761 i?86 | x86_64 | ppc | ppc64)
1762 if test -z "$ac_arch" || test "$ac_arch" = "$ac_word"; then
1765 ac_cv_c_bigendian=universal
1771 elif test "x$ac_word" = "x-arch"; then
1775 if test $ac_cv_c_bigendian = unknown; then
1776 # See if sys/param.h defines the BYTE_ORDER macro.
1779 [[#include <sys/types.h>
1780 #include <sys/param.h>
1782 [[#if ! (defined BYTE_ORDER && defined BIG_ENDIAN \\
1783 && defined LITTLE_ENDIAN && BYTE_ORDER && BIG_ENDIAN \\
1788 [# It does; now see whether it defined to BIG_ENDIAN or not.
1791 [[#include <sys/types.h>
1792 #include <sys/param.h>
1794 [[#if BYTE_ORDER != BIG_ENDIAN
1798 [ac_cv_c_bigendian=yes],
1799 [ac_cv_c_bigendian=no])])
1801 if test $ac_cv_c_bigendian = unknown; then
1802 # See if <limits.h> defines _LITTLE_ENDIAN or _BIG_ENDIAN (e.g., Solaris).
1805 [[#include <limits.h>
1807 [[#if ! (defined _LITTLE_ENDIAN || defined _BIG_ENDIAN)
1811 [# It does; now see whether it defined to _BIG_ENDIAN or not.
1814 [[#include <limits.h>
1816 [[#ifndef _BIG_ENDIAN
1820 [ac_cv_c_bigendian=yes],
1821 [ac_cv_c_bigendian=no])])
1823 if test $ac_cv_c_bigendian = unknown; then
1824 # Compile a test program.
1826 [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
1828 /* Are we little or big endian? From Harbison&Steele. */
1832 char c[sizeof (long int)];
1835 return u.c[sizeof (long int) - 1] == 1;
1837 [ac_cv_c_bigendian=no],
1838 [ac_cv_c_bigendian=yes],
1839 [# Try to guess by grepping values from an object file.
1842 [[unsigned short int ascii_mm[] =
1843 { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 };
1844 unsigned short int ascii_ii[] =
1845 { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 };
1846 int use_ascii (int i) {
1847 return ascii_mm[i] + ascii_ii[i];
1849 unsigned short int ebcdic_ii[] =
1850 { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 };
1851 unsigned short int ebcdic_mm[] =
1852 { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 };
1853 int use_ebcdic (int i) {
1854 return ebcdic_mm[i] + ebcdic_ii[i];
1857 main (int argc, char **argv)
1859 /* Intimidate the compiler so that it does not
1860 optimize the arrays away. */
1862 ascii_mm[1] = *p++; ebcdic_mm[1] = *p++;
1863 ascii_ii[1] = *p++; ebcdic_ii[1] = *p++;
1864 return use_ascii (argc) == use_ebcdic (*p);
1866 [if grep BIGenDianSyS conftest$ac_exeext >/dev/null; then
1867 ac_cv_c_bigendian=yes
1869 if grep LiTTleEnDian conftest$ac_exeext >/dev/null ; then
1870 if test "$ac_cv_c_bigendian" = unknown; then
1871 ac_cv_c_bigendian=no
1873 # finding both strings is unlikely to happen, but who knows?
1874 ac_cv_c_bigendian=unknown
1878 case $ac_cv_c_bigendian in #(
1881 [AC_DEFINE([WORDS_BIGENDIAN], 1)]);; #(
1885 dnl Note that AC_APPLE_UNIVERSAL_BUILD sorts less than WORDS_BIGENDIAN;
1886 dnl this is a necessity for proper config header operation. Warn if
1887 dnl the user did not specify a config header but is relying on the
1888 dnl default behavior for universal builds.
1890 [AC_CONFIG_COMMANDS_PRE([m4_ifset([AH_HEADER], [],
1891 [m4_warn([obsolete],
1892 [AC_C_BIGENDIAN should be used with AC_CONFIG_HEADERS])])])dnl
1893 AC_DEFINE([AC_APPLE_UNIVERSAL_BUILD],1,
1894 [Define if building universal (internal helper macro)])])
1898 [AC_MSG_ERROR([unknown endianness
1899 presetting ac_cv_c_bigendian=no (or yes) will help])]) ;;
1906 # Define HAVE_C__GENERIC if _Generic works, a la C11.
1907 AN_IDENTIFIER([_Generic], [AC_C__GENERIC])
1908 AC_DEFUN([AC_C__GENERIC],
1909 [AC_CACHE_CHECK([for _Generic], ac_cv_c__Generic,
1913 main (int argc, char **argv)
1915 int a = _Generic (argc, int: argc = 1);
1916 int *b = &_Generic (argc, default: argc);
1917 char ***c = _Generic (argv, int: argc, default: argv ? &argv : 0);
1918 _Generic (1 ? 0 : b, int: a, default: b) = &argc;
1919 _Generic (a = 1, default: a) = 3;
1923 [ac_cv_c__Generic=yes],
1924 [ac_cv_c__Generic=no])])
1925 if test $ac_cv_c__Generic = yes; then
1926 AC_DEFINE([HAVE_C__GENERIC], 1,
1927 [Define to 1 if C11-style _Generic works.])
1933 # Do nothing if the compiler accepts the inline keyword.
1934 # Otherwise define inline to __inline__ or __inline if one of those work,
1935 # otherwise define inline to be empty.
1937 # HP C version B.11.11.04 doesn't allow a typedef as the return value for an
1938 # inline function, only builtin types.
1940 AN_IDENTIFIER([inline], [AC_C_INLINE])
1941 AC_DEFUN([AC_C_INLINE],
1942 [AC_CACHE_CHECK([for inline], ac_cv_c_inline,
1944 for ac_kw in inline __inline__ __inline; do
1945 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1946 [#ifndef __cplusplus
1948 static $ac_kw foo_t static_foo (void) {return 0; }
1949 $ac_kw foo_t foo (void) {return 0; }
1952 [ac_cv_c_inline=$ac_kw])
1953 test "$ac_cv_c_inline" != no && break
1956 AH_VERBATIM([inline],
1957 [/* Define to '__inline__' or '__inline' if that's what the C compiler
1958 calls it, or to nothing if 'inline' is not supported under any name. */
1962 case $ac_cv_c_inline in
1965 case $ac_cv_c_inline in
1967 *) ac_val=$ac_cv_c_inline;;
1969 cat >>confdefs.h <<_ACEOF
1971 #define inline $ac_val
1981 AC_DEFUN([AC_C_CONST],
1982 [AC_CACHE_CHECK([for an ANSI C-conforming const], ac_cv_c_const,
1983 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
1986 /* Ultrix mips cc rejects this sort of thing. */
1987 typedef int charset[2];
1988 const charset cs = { 0, 0 };
1989 /* SunOS 4.1.1 cc rejects this. */
1990 char const *const *pcpcc;
1992 /* NEC SVR4.0.2 mips cc rejects this. */
1993 struct point {int x, y;};
1994 static struct point const zero = {0,0};
1995 /* IBM XL C 1.02.0.0 rejects this.
1996 It does not let you subtract one const X* pointer from another in
1997 an arm of an if-expression whose if-part is not a constant
1999 const char *g = "string";
2000 pcpcc = &g + (g ? g-g : 0);
2001 /* HPUX 7.0 cc rejects these. */
2003 ppc = (char**) pcpcc;
2004 pcpcc = (char const *const *) ppc;
2005 { /* SCO 3.2v4 cc rejects this sort of thing. */
2008 char const *s = 0 ? (char *) 0 : (char const *) 0;
2013 { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */
2015 const int *foo = &x[0];
2018 { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
2019 typedef const int *iptr;
2023 { /* IBM XL C 1.02.0.0 rejects this sort of thing, saying
2024 "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
2025 struct s { int j; const int *ap[3]; } bx;
2026 struct s *b = &bx; b->j = 5;
2028 { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
2032 return !cs[0] && !zero.x;
2035 [ac_cv_c_const=yes],
2036 [ac_cv_c_const=no])])
2037 if test $ac_cv_c_const = no; then
2039 [Define to empty if 'const' does not conform to ANSI C.])
2046 # based on acx_restrict.m4, from the GNU Autoconf Macro Archive
2048 # Determine whether the C/C++ compiler supports the "restrict" keyword
2049 # introduced in ANSI C99, or an equivalent. Define "restrict" to the alternate
2050 # spelling, if any; these are more likely to work in both C and C++ compilers of
2051 # the same family, and in the presence of varying compiler options. If only
2052 # plain "restrict" works, do nothing. Here are some variants:
2053 # - GCC supports both __restrict and __restrict__
2054 # - older DEC Alpha C compilers support only __restrict
2055 # - _Restrict is the only spelling accepted by Sun WorkShop 6 update 2 C
2056 # Otherwise, define "restrict" to be empty.
2057 AN_IDENTIFIER([restrict], [AC_C_RESTRICT])
2058 AC_DEFUN([AC_C_RESTRICT],
2059 [AC_CACHE_CHECK([for C/C++ restrict keyword], [ac_cv_c_restrict],
2060 [ac_cv_c_restrict=no
2061 # Put '__restrict__' first, to avoid problems with glibc and non-GCC; see:
2062 # https://lists.gnu.org/archive/html/bug-autoconf/2016-02/msg00006.html
2063 # Put 'restrict' last, because C++ lacks it.
2064 for ac_kw in __restrict__ __restrict _Restrict restrict; do
2067 [[typedef int *int_ptr;
2068 int foo (int_ptr $ac_kw ip) { return ip[0]; }
2069 int bar (int [$ac_kw]); /* Catch GCC bug 14050. */
2070 int bar (int ip[$ac_kw]) { return ip[0]; }
2075 return foo (t) + bar (t);
2077 [ac_cv_c_restrict=$ac_kw])
2078 test "$ac_cv_c_restrict" != no && break
2081 AH_VERBATIM([restrict],
2082 [/* Define to the equivalent of the C99 'restrict' keyword, or to
2083 nothing if this is not supported. Do not define if restrict is
2084 supported only directly. */
2086 /* Work around a bug in older versions of Sun C++, which did not
2087 #define __restrict__ or support _Restrict or __restrict__
2088 even though the corresponding Sun C compiler ended up with
2089 "#define restrict _Restrict" or "#define restrict __restrict__"
2090 in the previous line. This workaround can be removed once
2091 we assume Oracle Developer Studio 12.5 (2016) or later. */
2092 #if defined __SUNPRO_CC && !defined __RESTRICT && !defined __restrict__
2094 # define __restrict__
2096 case $ac_cv_c_restrict in
2098 no) AC_DEFINE([restrict], []) ;;
2099 *) AC_DEFINE_UNQUOTED([restrict], [$ac_cv_c_restrict]) ;;
2106 # Note that, unlike const, #defining volatile to be the empty string can
2107 # actually turn a correct program into an incorrect one, since removing
2108 # uses of volatile actually grants the compiler permission to perform
2109 # optimizations that could break the user's code. So, do not #define
2110 # volatile away unless it is really necessary to allow the user's code
2111 # to compile cleanly. Benign compiler failures should be tolerated.
2112 AC_DEFUN([AC_C_VOLATILE],
2113 [AC_CACHE_CHECK([for working volatile], ac_cv_c_volatile,
2114 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
2116 int * volatile y = (int *) 0;
2117 return !x && !y;])],
2118 [ac_cv_c_volatile=yes],
2119 [ac_cv_c_volatile=no])])
2120 if test $ac_cv_c_volatile = no; then
2121 AC_DEFINE(volatile,,
2122 [Define to empty if the keyword 'volatile' does not work.
2123 Warning: valid code using 'volatile' can become incorrect
2124 without. Disable with care.])
2131 # Checks if '#' can be used to glue strings together at the CPP level.
2132 # Defines HAVE_STRINGIZE if positive.
2133 AC_DEFUN([AC_C_STRINGIZE],
2134 [AC_CACHE_CHECK([for preprocessor stringizing operator],
2135 [ac_cv_c_stringize],
2136 [AC_EGREP_CPP([@%:@teststring],
2139 char *s = x(teststring);],
2140 [ac_cv_c_stringize=no],
2141 [ac_cv_c_stringize=yes])])
2142 if test $ac_cv_c_stringize = yes; then
2143 AC_DEFINE(HAVE_STRINGIZE, 1,
2144 [Define to 1 if cpp supports the ANSI @%:@ stringizing operator.])
2151 # Check if the C compiler supports prototypes, included if it needs
2153 AC_DEFUN([AC_C_PROTOTYPES],
2154 [AC_REQUIRE([AC_PROG_CC])dnl
2155 if test "$ac_prog_cc_stdc" != no; then
2156 AC_DEFINE(PROTOTYPES, 1,
2157 [Define to 1 if the C compiler supports function prototypes.])
2158 AC_DEFINE(__PROTOTYPES, 1,
2159 [Define like PROTOTYPES; this can be used by system headers.])
2164 # AC_C_FLEXIBLE_ARRAY_MEMBER
2165 # --------------------------
2166 # Check whether the C compiler supports flexible array members.
2167 AC_DEFUN([AC_C_FLEXIBLE_ARRAY_MEMBER],
2169 AC_CACHE_CHECK([for flexible array members],
2173 [[#include <stdlib.h>
2176 struct s { int n; double d[]; };]],
2177 [[int m = getchar ();
2178 struct s *p = (struct s *) malloc (offsetof (struct s, d)
2179 + m * sizeof (double));
2181 m = p->d != (double *) NULL;
2184 [ac_cv_c_flexmember=yes],
2185 [ac_cv_c_flexmember=no])])
2186 if test $ac_cv_c_flexmember = yes; then
2187 AC_DEFINE([FLEXIBLE_ARRAY_MEMBER], [],
2188 [Define to nothing if C supports flexible array members, and to
2189 1 if it does not. That way, with a declaration like 'struct s
2190 { int n; double d@<:@FLEXIBLE_ARRAY_MEMBER@:>@; };', the struct hack
2191 can be used with pre-C99 compilers.
2192 When computing the size of such an object, don't use 'sizeof (struct s)'
2193 as it overestimates the size. Use 'offsetof (struct s, d)' instead.
2194 Don't use 'offsetof (struct s, d@<:@0@:>@)', as this doesn't work with
2195 MSVC and with C++ compilers.])
2197 AC_DEFINE([FLEXIBLE_ARRAY_MEMBER], 1)
2204 # Check whether the C compiler supports variable-length arrays.
2205 AC_DEFUN([AC_C_VARARRAYS],
2207 AC_CACHE_CHECK([for variable-length arrays],
2209 [AC_EGREP_CPP([defined],
2210 [#ifdef __STDC_NO_VLA__
2214 [ac_cv_c_vararrays='no: __STDC_NO_VLA__ is defined'],
2217 [[/* Test for VLA support. This test is partly inspired
2218 from examples in the C standard. Use at least two VLA
2219 functions to detect the GCC 3.4.3 bug described in:
2220 https://lists.gnu.org/archive/html/bug-gnulib/2014-08/msg00014.html
2222 #ifdef __STDC_NO_VLA__
2227 int fvla (int m, int C[m][m]);
2230 simple (int count, int all[static count])
2232 return all[count - 1];
2236 fvla (int m, int C[m][m])
2238 typedef int VLA[m][m];
2241 static int (*q)[m] = &B;
2243 return C && &x[0][0] == &D[0] && &D[0] == s[0];
2247 [ac_cv_c_vararrays=yes],
2248 [ac_cv_c_vararrays=no])])])
2249 if test "$ac_cv_c_vararrays" = yes; then
2250 dnl This is for compatibility with Autoconf 2.61-2.69.
2251 AC_DEFINE([HAVE_C_VARARRAYS], 1,
2252 [Define to 1 if C supports variable-length arrays.])
2253 elif test "$ac_cv_c_vararrays" = no; then
2254 AC_DEFINE([__STDC_NO_VLA__], 1,
2255 [Define to 1 if C does not support variable-length arrays, and
2256 if the compiler does not already define this.])
2263 # Check if the C compiler supports GCC's typeof syntax.
2264 # The test case provokes incompatibilities in the Sun C compilers
2265 # (both Solaris 8 and Solaris 10).
2266 AC_DEFUN([AC_C_TYPEOF],
2268 AC_CACHE_CHECK([for typeof syntax and keyword spelling], ac_cv_c_typeof,
2270 for ac_kw in typeof __typeof__ no; do
2271 test $ac_kw = no && break
2272 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
2277 + ! (($ac_kw (value))
2278 (($ac_kw (value)) 0 < ($ac_kw (value)) -1
2279 ? ($ac_kw (value)) - 1
2280 : ~ (~ ($ac_kw (value)) 0
2281 << sizeof ($ac_kw (value)))))]; }
2284 (! ((void) ((ac__typeof_type_ *) 0), 0));
2286 [ac_cv_c_typeof=$ac_kw])
2287 test $ac_cv_c_typeof != no && break
2289 if test $ac_cv_c_typeof != no; then
2290 AC_DEFINE([HAVE_TYPEOF], 1,
2291 [Define to 1 if typeof works with your compiler.])
2292 if test $ac_cv_c_typeof != typeof; then
2293 AC_DEFINE_UNQUOTED([typeof], [$ac_cv_c_typeof],
2294 [Define to __typeof__ if your compiler spells it that way.])
2302 # Expands to some language dependent source code for testing the presence of
2304 AC_DEFUN([_AC_LANG_OPENMP],
2305 [AC_LANG_SOURCE([_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])])
2307 # _AC_LANG_OPENMP(C)
2308 # ------------------
2309 m4_define([_AC_LANG_OPENMP(C)],
2312 #error "OpenMP not supported"
2315 int main (void) { return omp_get_num_threads (); }
2318 # _AC_LANG_OPENMP(C++)
2319 # --------------------
2320 m4_copy([_AC_LANG_OPENMP(C)], [_AC_LANG_OPENMP(C++)])
2322 # _AC_LANG_OPENMP(Fortran 77)
2323 # ---------------------------
2324 m4_define([_AC_LANG_OPENMP(Fortran 77)],
2330 call omp_set_num_threads(2)
2334 # _AC_LANG_OPENMP(Fortran)
2335 # ------------------------
2336 m4_copy([_AC_LANG_OPENMP(Fortran 77)], [_AC_LANG_OPENMP(Fortran)])
2340 # Check which options need to be passed to the C compiler to support OpenMP.
2341 # Set the OPENMP_CFLAGS / OPENMP_CXXFLAGS / OPENMP_FFLAGS variable to these
2343 # The options are necessary at compile time (so the #pragmas are understood)
2344 # and at link time (so the appropriate library is linked with).
2345 # This macro takes care to not produce redundant options if $CC $CFLAGS already
2348 # For each candidate option, we do a compile test first, then a link test;
2349 # if the compile test succeeds but the link test fails, that means we have
2350 # found the correct option but it doesn't work because the libraries are
2351 # broken. (This can happen, for instance, with SunPRO C and a bad combination
2352 # of operating system patches.)
2354 # Several of the options in our candidate list can be misinterpreted by
2355 # compilers that don't use them to activate OpenMP support; for example,
2356 # many compilers understand "-openmp" to mean "write output to a file
2357 # named 'penmp'" rather than "enable OpenMP". We can't completely avoid
2358 # the possibility of clobbering files named 'penmp' or 'mp' in configure's
2359 # working directory; therefore, this macro will bomb out if any such file
2360 # already exists when it's invoked.
2361 AC_DEFUN([AC_OPENMP],
2362 [AC_REQUIRE([_AC_OPENMP_SAFE_WD])]dnl
2363 [AC_ARG_ENABLE([openmp],
2364 [AS_HELP_STRING([--disable-openmp], [do not use OpenMP])])]dnl
2366 OPENMP_[]_AC_LANG_PREFIX[]FLAGS=
2367 if test "$enable_openmp" != no; then
2368 AC_CACHE_CHECK([for $[]_AC_CC[] option to support OpenMP],
2369 [ac_cv_prog_[]_AC_LANG_ABBREV[]_openmp],
2370 [ac_cv_prog_[]_AC_LANG_ABBREV[]_openmp='not found'
2371 dnl Try these flags:
2372 dnl (on by default) ''
2373 dnl GCC >= 4.2 -fopenmp
2374 dnl SunPRO C -xopenmp
2376 dnl SGI C, PGI C -mp
2377 dnl Tru64 Compaq C -omp
2378 dnl IBM XL C (AIX, Linux) -qsmp=omp
2381 dnl Lahey Fortran (Linux) --openmp
2382 for ac_option in '' -fopenmp -xopenmp -openmp -mp -omp -qsmp=omp -homp \
2383 -Popenmp --openmp; do
2385 ac_save_[]_AC_LANG_PREFIX[]FLAGS=$[]_AC_LANG_PREFIX[]FLAGS
2386 _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $ac_option"
2387 AC_COMPILE_IFELSE([_AC_LANG_OPENMP],
2388 [AC_LINK_IFELSE([_AC_LANG_OPENMP],
2389 [ac_cv_prog_[]_AC_LANG_ABBREV[]_openmp=$ac_option],
2390 [ac_cv_prog_[]_AC_LANG_ABBREV[]_openmp='unsupported'])])
2391 _AC_LANG_PREFIX[]FLAGS=$ac_save_[]_AC_LANG_PREFIX[]FLAGS
2393 if test "$ac_cv_prog_[]_AC_LANG_ABBREV[]_openmp" != 'not found'; then
2397 if test "$ac_cv_prog_[]_AC_LANG_ABBREV[]_openmp" = 'not found'; then
2398 ac_cv_prog_[]_AC_LANG_ABBREV[]_openmp='unsupported'
2399 elif test "$ac_cv_prog_[]_AC_LANG_ABBREV[]_openmp" = ''; then
2400 ac_cv_prog_[]_AC_LANG_ABBREV[]_openmp='none needed'
2402 dnl _AC_OPENMP_SAFE_WD checked that these files did not exist before we
2403 dnl started probing for OpenMP support, so if they exist now, they were
2404 dnl created by the probe loop and it's safe to delete them.
2406 if test "$ac_cv_prog_[]_AC_LANG_ABBREV[]_openmp" != 'unsupported' && \
2407 test "$ac_cv_prog_[]_AC_LANG_ABBREV[]_openmp" != 'none needed'; then
2408 OPENMP_[]_AC_LANG_PREFIX[]FLAGS="$ac_cv_prog_[]_AC_LANG_ABBREV[]_openmp"
2411 AC_SUBST([OPENMP_]_AC_LANG_PREFIX[FLAGS])
2414 # _AC_OPENMP_SAFE_WD
2415 # ------------------
2416 # AC_REQUIREd by AC_OPENMP. Checks both at autoconf time and at
2417 # configure time for files that AC_OPENMP clobbers.
2418 AC_DEFUN([_AC_OPENMP_SAFE_WD],
2419 [m4_syscmd([test ! -e penmp && test ! -e mp])]dnl
2420 [m4_if(sysval, [0], [], [m4_fatal(m4_normalize(
2421 [AC_OPENMP clobbers files named 'mp' and 'penmp'.
2422 To use AC_OPENMP you must not have either of these files
2423 at the top level of your source tree.]))])]dnl
2424 [if test -e penmp || test -e mp; then
2425 AC_MSG_ERROR(m4_normalize(
2426 [AC@&t@_OPENMP clobbers files named 'mp' and 'penmp'.
2427 Aborting configure because one of these files already exists.]))
2432 # ---------------------------------- #
2433 # 4b. C++ compiler characteristics. #
2434 # ---------------------------------- #
2436 # See the long comment at the beginning of section 4a for rationale
2437 # for these macros, and constraints on how the test programs should
2440 # The C++98 freestanding headers are:
2441 # <cstdarg> <cstddef> <cstdlib> <exception> <limits> <new> <typeinfo>
2443 # <atomic> <cfloat> <ciso646> <climits> <cstdalign> <cstdbool>
2444 # <cstdint> <initializer_list> <type_traits>
2446 # No other headers can safely be included. Therefore, almost no C++
2447 # standard library features are tested for. Use AC_CHECK_HEADER, etc.
2450 AC_DEFUN([_AC_CXX_CXX98_TEST_GLOBALS],
2451 [m4_divert_text([INIT_PREPARE],
2452 [[# Test code for whether the C++ compiler supports C++98 (global declarations)
2453 ac_cxx_conftest_cxx98_globals='
2454 // Does the compiler advertise C++98 conformance?
2455 #if !defined __cplusplus || __cplusplus < 199711L
2456 # error "Compiler does not advertise C++98 conformance"
2459 // These inclusions are to reject old compilers that
2460 // lack the unsuffixed header files.
2462 #include <exception>
2464 // <cassert> and <cstring> are *not* freestanding headers in C++98.
2465 extern void assert (int);
2467 extern int strcmp (const char *, const char *);
2470 // Namespaces, exceptions, and templates were all added after "C++ 2.0".
2471 using std::exception;
2476 void test_exception_syntax()
2480 } catch (const char *s) {
2481 // Extra parentheses suppress a warning when building autoconf itself,
2482 // due to lint rules shared with more typical C programs.
2483 assert (!(strcmp) (s, "test"));
2487 template <typename T> struct test_template
2490 explicit test_template(T t) : val(t) {}
2491 template <typename U> T add(U u) { return static_cast<T>(u) + val; }
2494 } // anonymous namespace
2498 AC_DEFUN([_AC_CXX_CXX98_TEST_MAIN],
2499 [m4_divert_text([INIT_PREPARE],
2500 [[# Test code for whether the C++ compiler supports C++98 (body of main)
2501 ac_cxx_conftest_cxx98_main='
2505 test_exception_syntax ();
2506 test_template<double> tt (2.0);
2507 assert (tt.add (4) == 6.0);
2508 assert (true && !false);
2513 AC_DEFUN([_AC_CXX_CXX11_TEST_GLOBALS],
2514 [m4_divert_text([INIT_PREPARE],
2515 [[# Test code for whether the C++ compiler supports C++11 (global declarations)
2516 ac_cxx_conftest_cxx11_globals='
2517 // Does the compiler advertise C++ 2011 conformance?
2518 #if !defined __cplusplus || __cplusplus < 201103L
2519 # error "Compiler does not advertise C++11 conformance"
2524 constexpr int get_val() { return 20; }
2535 delegate(int n) : n(n) {}
2536 delegate(): delegate(2354) {}
2538 virtual int getval() { return this->n; };
2543 class overridden : public delegate
2546 overridden(int n): delegate(n) {}
2547 virtual int getval() override final { return this->n * 2; }
2553 nocopy(int i): i(i) {}
2555 nocopy(const nocopy&) = delete;
2556 nocopy & operator=(const nocopy&) = delete;
2561 // for testing lambda expressions
2562 template <typename Ret, typename Fn> Ret eval(Fn f, Ret v)
2567 // for testing variadic templates and trailing return types
2568 template <typename V> auto sum(V first) -> V
2572 template <typename V, typename... Args> auto sum(V first, Args... rest) -> V
2574 return first + sum(rest...);
2580 AC_DEFUN([_AC_CXX_CXX11_TEST_MAIN],
2581 [m4_divert_text([INIT_PREPARE],
2582 [[# Test code for whether the C++ compiler supports C++11 (body of main)
2583 ac_cxx_conftest_cxx11_main='
2585 // Test auto and decltype
2587 auto a2 = 48573953.4;
2588 auto a3 = "String literal";
2591 for (auto i = a3; *i; ++i) { total += *i; }
2593 decltype(a2) a4 = 34895.034;
2597 short sa[cxx11test::get_val()] = { 0 };
2600 // Test initializer lists
2601 cxx11test::testinit il = { 4323, 435234.23544 };
2604 // Test range-based for
2605 int array[] = {9, 7, 13, 15, 4, 18, 12, 10, 5, 3,
2606 14, 19, 17, 8, 6, 20, 16, 2, 11, 1};
2607 for (auto &x : array) { x += 23; }
2610 // Test lambda expressions
2611 using cxx11test::eval;
2612 assert (eval ([](int x) { return x*2; }, 21) == 42);
2614 assert (eval ([&](double x) { return d += x; }, 3.0) == 5.0);
2616 assert (eval ([=](double x) mutable { return d += x; }, 4.0) == 9.0);
2620 // Test use of variadic templates
2621 using cxx11test::sum;
2624 auto c = sum(1.0, 2.0, 3.0);
2627 // Test constructor delegation
2628 cxx11test::delegate d1;
2629 cxx11test::delegate d2();
2630 cxx11test::delegate d3(45);
2633 // Test override and final
2634 cxx11test::overridden o1(55464);
2641 // Test template brackets
2642 test_template<::test_template<int>> v(test_template<int>(12));
2646 char const *utf8 = u8"UTF-8 string \u2500";
2647 char16_t const *utf16 = u"UTF-8 string \u2500";
2648 char32_t const *utf32 = U"UTF-32 string \u2500";
2653 AC_DEFUN([_AC_CXX_CXX98_TEST_PROGRAM],
2654 [AC_REQUIRE([_AC_CXX_CXX98_TEST_GLOBALS])dnl
2655 AC_REQUIRE([_AC_CXX_CXX98_TEST_MAIN])dnl
2656 m4_divert_text([INIT_PREPARE],
2657 [[# Test code for whether the C compiler supports C++98 (complete).
2658 ac_cxx_conftest_cxx98_program="${ac_cxx_conftest_cxx98_globals}
2660 main (int argc, char **argv)
2663 ${ac_cxx_conftest_cxx98_main}
2669 AC_DEFUN([_AC_CXX_CXX11_TEST_PROGRAM],
2670 [AC_REQUIRE([_AC_CXX_CXX98_TEST_GLOBALS])dnl
2671 AC_REQUIRE([_AC_CXX_CXX98_TEST_MAIN])dnl
2672 AC_REQUIRE([_AC_CXX_CXX11_TEST_GLOBALS])dnl
2673 AC_REQUIRE([_AC_CXX_CXX11_TEST_MAIN])dnl
2674 m4_divert_text([INIT_PREPARE],
2675 [[# Test code for whether the C compiler supports C++11 (complete).
2676 ac_cxx_conftest_cxx11_program="${ac_cxx_conftest_cxx98_globals}
2677 ${ac_cxx_conftest_cxx11_globals}
2680 main (int argc, char **argv)
2683 ${ac_cxx_conftest_cxx98_main}
2684 ${ac_cxx_conftest_cxx11_main}
2690 # _AC_CXX_CXX98_OPTIONS
2691 # ---------------------
2692 # Whitespace-separated list of options that might put the C++ compiler
2693 # into a mode conforming to ISO C++ 1998 with extensions. Do not try
2694 # "strictly conforming" modes (e.g. gcc's -std=c++98); they break some
2695 # systems' header files. If more than one option is needed, put
2696 # shell quotes around the group.
2699 # Intel ICC -std=c++98
2700 # Note: because -std=c++98 puts GCC in strictly conforming mode,
2701 # this option must be tested *after* -std=gnu++98.
2702 # IBM XL C -qlanglvl=extended
2704 # Solaris N/A (default)
2705 # Tru64 N/A (default, but -std gnu could be used)
2706 m4_define([_AC_CXX_CXX98_OPTIONS], [
2713 # _AC_CXX_CXX11_OPTIONS
2714 # ---------------------
2715 # Whitespace-separated list of options that might put the C++ compiler
2716 # into a mode conforming to ISO C++ 2011 with extensions. Do not try
2717 # "strictly conforming" modes (e.g. gcc's -std=c++11); they break some
2718 # systems' header files. If more than one option is needed, put
2719 # shell quotes around the group.
2721 # GCC -std=gnu++11, -std=gnu++0x
2722 # Intel ICC -std=c++11, -std=c++0x
2723 # Note: because -std=c++11 puts GCC in strictly conforming mode,
2724 # these options must be tested *after* -std=gnu++11.
2725 # IBM XL C -qlanglvl=extended0x (pre-V12.1)
2727 # Solaris N/A (no support)
2728 # Tru64 N/A (no support)
2729 m4_define([_AC_CXX_CXX11_OPTIONS], [
2734 -qlanglvl=extended0x
2738 # _AC_PROG_CXX_STDCXX_EDITION_TRY(EDITION)
2739 # ----------------------------------------
2740 # Subroutine of _AC_PROG_CXX_STDCXX_EDITION. Not to be called directly.
2742 # Check whether the C++ compiler accepts features of EDITION of the
2743 # C++ standard. EDITION should be a two-digit year (e.g. 98, 11).
2744 # (FIXME: Switch to four-digit years for futureproofing.)
2745 # This is done by compiling the test program defined by
2746 # _AC_C_CXX{EDITION}_TEST_PROGRAM, first with no additional
2747 # command-line options, and then with each of the options
2748 # in the space-separated list defined by _AC_C_CXX{EDITION}_OPTIONS.
2750 # If we find a way to make the test program compile, set cache variable
2751 # ac_cv_prog_cxx_cxxEDITION to the options required (if any), and add those
2752 # options to $CXX. Set shell variable ac_prog_cxx_stdcxx to 'cxxEDITION',
2753 # and set shell variable ac_cv_prog_cxx_stdcxx to the options required.
2754 # (Neither of these variables is AC_SUBSTed. ac_cv_prog_cxx_stdcxx used
2755 # to be a cache variable and is preserved with this name for backward
2756 # compatibility.) Otherwise, ac_cv_prog_cxx_cxxEDITION is set to 'no'
2757 # and the other variables are not changed.
2759 # If ac_prog_cxx_stdcxx is already set to a value other than 'no',
2760 # the shell code produced by this macro does nothing. This is so
2761 # _AC_PROG_CXX_STDCXX_EDITION can use m4_map to iterate through
2763 AC_DEFUN([_AC_PROG_CXX_STDCXX_EDITION_TRY],
2764 [AC_LANG_ASSERT([C++])]dnl
2765 [AC_REQUIRE([_AC_CXX_CXX$1_TEST_PROGRAM])]dnl
2766 [AS_IF([test x$ac_prog_cxx_stdcxx = xno],
2767 [AC_MSG_CHECKING([for $CXX option to enable C++$1 features])
2768 AC_CACHE_VAL(ac_cv_prog_cxx_cxx$1,
2769 [ac_cv_prog_cxx_cxx$1=no
2771 AC_LANG_CONFTEST([AC_LANG_DEFINES_PROVIDED][$][ac_cxx_conftest_cxx$1_program])
2772 for ac_arg in '' m4_normalize(m4_defn([_AC_CXX_CXX$1_OPTIONS]))
2774 CXX="$ac_save_CXX $ac_arg"
2775 _AC_COMPILE_IFELSE([], [ac_cv_prog_cxx_cxx$1=$ac_arg])
2776 test "x$ac_cv_prog_cxx_cxx$1" != "xno" && break
2778 rm -f conftest.$ac_ext
2780 AS_IF([test "x$ac_cv_prog_cxx_cxx$1" = xno],
2781 [AC_MSG_RESULT([unsupported])],
2782 [AS_IF([test "x$ac_cv_prog_cxx_cxx$1" = x],
2783 [AC_MSG_RESULT([none needed])],
2784 [AC_MSG_RESULT([$ac_cv_prog_cxx_cxx$1])
2785 CXX="$CXX $ac_cv_prog_cxx_cxx$1"])
2786 ac_cv_prog_cxx_stdcxx=$ac_cv_prog_cxx_cxx$1
2787 ac_prog_cxx_stdcxx=cxx$1])])
2790 # _AC_PROG_CXX_STDCXX_EDITION
2791 # ---------------------------
2792 # Detect the most recent edition of the ISO C++ standard that is
2793 # supported by the C++ compiler. Add command-line options to $CXX,
2794 # if necessary, to enable support for this edition. Set the shell
2795 # variable ac_prog_cxx_stdcxx to indicate the edition.
2796 AC_DEFUN([_AC_PROG_CXX_STDCXX_EDITION],
2797 [ac_prog_cxx_stdcxx=no
2798 m4_map([_AC_PROG_CXX_STDCXX_EDITION_TRY], [[11], [98]])])