1 # This file is part of Autoconf. -*- Autoconf -*-
2 # Programming languages support.
3 # Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2, or (at your option)
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20 # As a special exception, the Free Software Foundation gives unlimited
21 # permission to copy, distribute and modify the configure scripts that
22 # are the output of Autoconf. You need not follow the terms of the GNU
23 # General Public License when using or distributing such scripts, even
24 # though portions of the text of Autoconf appear in them. The GNU
25 # General Public License (GPL) does govern all other use of the material
26 # that constitutes the Autoconf program.
28 # Certain portions of the Autoconf source text are designed to be copied
29 # (in certain cases, depending on the input) into the output of
30 # Autoconf. We call these the "data" portions. The rest of the Autoconf
31 # source text consists of comments plus executable code that decides which
32 # of the data portions to output in any given case. We call these
33 # comments and executable code the "non-data" portions. Autoconf never
34 # copies any of the non-data portions into its output.
36 # This special exception to the GPL applies to versions of Autoconf
37 # released by the Free Software Foundation. When you make and
38 # distribute a modified version of Autoconf, you may extend this special
39 # exception to the GPL to apply to your modified version as well, *unless*
40 # your modified version has the potential to copy into its output some
41 # of the text that was the non-data portion of the version that you started
42 # with. (In other words, unless your change moves or copies text from
43 # the non-data portions to the data portions.) If your modification has
44 # such potential, you must delete any notice of this special exception
45 # to the GPL from your modified version.
47 # Written by David MacKenzie, with help from
48 # Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,
49 # Roland McGrath, Noah Friedman, david d zuhn, and many others.
52 # -------------------- #
53 # 1b. The C language. #
54 # -------------------- #
59 # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
60 m4_define([AC_LANG(C)],
62 ac_cpp='$CPP $CPPFLAGS'
63 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&AS_MESSAGE_LOG_FD'
64 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&AS_MESSAGE_LOG_FD'
65 ac_compiler_gnu=$ac_cv_c_compiler_gnu
71 AU_DEFUN([AC_LANG_C], [AC_LANG(C)])
76 m4_define([_AC_LANG_ABBREV(C)], [c])
81 m4_define([_AC_LANG_PREFIX(C)], [C])
84 # ---------------------- #
85 # 1c. The C++ language. #
86 # ---------------------- #
91 # CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
92 m4_define([AC_LANG(C++)],
94 ac_cpp='$CXXCPP $CPPFLAGS'
95 ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&AS_MESSAGE_LOG_FD'
96 ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&AS_MESSAGE_LOG_FD'
97 ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
103 AU_DEFUN([AC_LANG_CPLUSPLUS], [AC_LANG(C++)])
106 # _AC_LANG_ABBREV(C++)
107 # --------------------
108 m4_define([_AC_LANG_ABBREV(C++)], [cxx])
111 # _AC_LANG_PREFIX(C++)
112 # --------------------
113 m4_define([_AC_LANG_PREFIX(C++)], [CXX])
117 ## ---------------------- ##
118 ## 2.Producing programs. ##
119 ## ---------------------- ##
126 # AC_LANG_SOURCE(C)(BODY)
127 # -----------------------
128 # This sometimes fails to find confdefs.h, for some reason.
129 # We can't use '#line $LINENO "configure"' here, since
130 # Sun c89 (Sun WorkShop 6 update 2 C 5.3 Patch 111679-08 2002/05/09)
131 # rejects $LINENO greater than 32767, and some configure scripts
132 # are longer than 32767 lines.
133 m4_define([AC_LANG_SOURCE(C)],
136 cat confdefs.h >>conftest.$ac_ext
137 cat >>conftest.$ac_ext <<_ACEOF
138 /* end confdefs.h. */
142 # AC_LANG_PROGRAM(C)([PROLOGUE], [BODY])
143 # --------------------------------------
144 m4_define([AC_LANG_PROGRAM(C)],
146 m4_ifdef([_AC_LANG_PROGRAM_C_F77_HOOKS], [_AC_LANG_PROGRAM_C_F77_HOOKS])[]dnl
147 m4_ifdef([_AC_LANG_PROGRAM_C_FC_HOOKS], [_AC_LANG_PROGRAM_C_FC_HOOKS])[]dnl
151 dnl Do *not* indent the following line: there may be CPP directives.
152 dnl Don't move the `;' right after for the same reason.
159 # AC_LANG_CALL(C)(PROLOGUE, FUNCTION)
160 # -----------------------------------
161 # Avoid conflicting decl of main.
162 m4_define([AC_LANG_CALL(C)],
164 m4_if([$2], [main], ,
165 [/* Override any gcc2 internal prototype to avoid an error. */
169 /* We use char because int might match the return type of a gcc2
170 builtin and then its argument prototype would still apply. */
171 char $2 ();])], [$2 ();])])
174 # AC_LANG_FUNC_LINK_TRY(C)(FUNCTION)
175 # ----------------------------------
176 # Don't include <ctype.h> because on OSF/1 3.0 it includes
177 # <sys/types.h> which includes <sys/select.h> which contains a
178 # prototype for select. Similarly for bzero.
180 # This test used to merely assign f=$1 in main(), but that was
181 # optimized away by HP unbundled cc A.05.36 for ia64 under +O3,
182 # presumably on the basis that there's no need to do that store if the
183 # program is about to exit. Conversely, the AIX linker optimizes an
184 # unused external declaration that initializes f=$1. So this test
185 # program has both an external initialization of f, and a use of f in
186 # main that affects the exit status.
188 m4_define([AC_LANG_FUNC_LINK_TRY(C)],
190 [/* Define $1 to an innocuous variant, in case <limits.h> declares $1.
191 For example, HP-UX 11i <limits.h> declares gettimeofday. */
192 #define $1 innocuous_$1
194 /* System header to define __stub macros and hopefully few prototypes,
195 which can conflict with char $1 (); below.
196 Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
197 <limits.h> exists even on freestanding compilers. */
207 /* Override any gcc2 internal prototype to avoid an error. */
212 /* We use char because int might match the return type of a gcc2
213 builtin and then its argument prototype would still apply. */
215 /* The GNU C library defines this for functions which it implements
216 to always fail with ENOSYS. Some functions are actually named
217 something starting with __ and the normal name is an alias. */
218 #if defined (__stub_$1) || defined (__stub___$1)
226 ], [return f != $1;])])
229 # AC_LANG_BOOL_COMPILE_TRY(C)(PROLOGUE, EXPRESSION)
230 # -------------------------------------------------
231 # Be sure to use this array to avoid `unused' warnings, which are even
232 # errors with `-W error'.
233 m4_define([AC_LANG_BOOL_COMPILE_TRY(C)],
234 [AC_LANG_PROGRAM([$1], [static int test_array @<:@1 - 2 * !($2)@:>@;
235 test_array @<:@0@:>@ = 0
239 # AC_LANG_INT_SAVE(C)(PROLOGUE, EXPRESSION)
240 # -----------------------------------------
241 # We need `stdio.h' to open a `FILE' and `stdlib.h' for `exit'.
242 # But we include them only after the EXPRESSION has been evaluated.
243 m4_define([AC_LANG_INT_SAVE(C)],
245 long longval () { return $2; }
246 unsigned long ulongval () { return $2; }
247 @%:@include <stdio.h>
248 @%:@include <stdlib.h>],
250 FILE *f = fopen ("conftest.val", "w");
258 fprintf (f, "%ld\n", i);
262 unsigned long i = ulongval ();
265 fprintf (f, "%lu\n", i);
267 exit (ferror (f) || fclose (f) != 0);
271 # ----------------- #
273 # ----------------- #
275 # AC_LANG_SOURCE(C++)(BODY)
276 # -------------------------
277 m4_copy([AC_LANG_SOURCE(C)], [AC_LANG_SOURCE(C++)])
280 # AC_LANG_PROGRAM(C++)([PROLOGUE], [BODY])
281 # ----------------------------------------
282 m4_copy([AC_LANG_PROGRAM(C)], [AC_LANG_PROGRAM(C++)])
285 # AC_LANG_CALL(C++)(PROLOGUE, FUNCTION)
286 # -------------------------------------
287 m4_copy([AC_LANG_CALL(C)], [AC_LANG_CALL(C++)])
290 # AC_LANG_FUNC_LINK_TRY(C++)(FUNCTION)
291 # ------------------------------------
292 m4_copy([AC_LANG_FUNC_LINK_TRY(C)], [AC_LANG_FUNC_LINK_TRY(C++)])
295 # AC_LANG_BOOL_COMPILE_TRY(C++)(PROLOGUE, EXPRESSION)
296 # ---------------------------------------------------
297 m4_copy([AC_LANG_BOOL_COMPILE_TRY(C)], [AC_LANG_BOOL_COMPILE_TRY(C++)])
300 # AC_LANG_INT_SAVE(C++)(PROLOGUE, EXPRESSION)
301 # -------------------------------------------
302 m4_copy([AC_LANG_INT_SAVE(C)], [AC_LANG_INT_SAVE(C++)])
306 ## -------------------------------------------- ##
307 ## 3. Looking for Compilers and Preprocessors. ##
308 ## -------------------------------------------- ##
310 # -------------------- #
311 # 3b. The C compiler. #
312 # -------------------- #
315 # _AC_ARG_VAR_CPPFLAGS
316 # --------------------
317 # Document and register CPPFLAGS, which is used by
318 # AC_PROG_{CC, CPP, CXX, CXXCPP}.
319 AC_DEFUN([_AC_ARG_VAR_CPPFLAGS],
320 [AC_ARG_VAR([CPPFLAGS],
321 [C/C++ preprocessor flags, e.g. -I<include dir> if you have
322 headers in a nonstandard directory <include dir>])])
325 # _AC_ARG_VAR_LDFLAGS
326 # -------------------
327 # Document and register LDFLAGS, which is used by
328 # AC_PROG_{CC, CXX, F77}.
329 AC_DEFUN([_AC_ARG_VAR_LDFLAGS],
330 [AC_ARG_VAR([LDFLAGS],
331 [linker flags, e.g. -L<lib dir> if you have libraries in a
332 nonstandard directory <lib dir>])])
337 # -------------------
338 # Find the C preprocessor. Must be AC_DEFUN'd to be AC_REQUIRE'able.
339 AC_DEFUN([AC_LANG_PREPROC(C)],
340 [AC_REQUIRE([AC_PROG_CPP])])
343 # _AC_PROG_PREPROC_WORKS_IFELSE(IF-WORKS, IF-NOT)
344 # -----------------------------------------------
345 # Check if $ac_cpp is a working preprocessor that can flag absent
346 # includes either by the exit status or by warnings.
347 # Set ac_cpp_err to a non-empty value if the preprocessor failed.
348 # This macro is for all languages, not only C.
349 AC_DEFUN([_AC_PROG_PREPROC_WORKS_IFELSE],
351 for ac_[]_AC_LANG_ABBREV[]_preproc_warn_flag in '' yes
353 # Use a header file that comes with gcc, so configuring glibc
354 # with a fresh cross-compiler works.
355 # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
356 # <limits.h> exists even on freestanding compilers.
357 # On the NeXT, cc -E runs the code through the compiler's parser,
358 # not just through cpp. "Syntax error" is here to catch this case.
359 _AC_PREPROC_IFELSE([AC_LANG_SOURCE([[@%:@ifdef __STDC__
360 @%:@ include <limits.h>
362 @%:@ include <assert.h>
366 [# Broken: fails on valid input.
369 # OK, works on sane cases. Now check whether non-existent headers
370 # can be detected and how.
371 _AC_PREPROC_IFELSE([AC_LANG_SOURCE([[@%:@include <ac_nonexistent.h>]])],
372 [# Broken: success on invalid input.
374 [# Passes both tests.
379 # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
380 rm -f conftest.err conftest.$ac_ext
381 AS_IF([$ac_preproc_ok], [$1], [$2])])# _AC_PROG_PREPROC_WORKS_IFELSE
386 # Find a working C preprocessor.
387 # We shouldn't have to require AC_PROG_CC, but this is due to the concurrency
388 # between the AC_LANG_COMPILER_REQUIRE family and that of AC_PROG_CC.
389 AN_MAKEVAR([CPP], [AC_PROG_CPP])
390 AN_PROGRAM([cpp], [AC_PROG_CPP])
391 AC_DEFUN([AC_PROG_CPP],
392 [AC_REQUIRE([AC_PROG_CC])dnl
393 AC_ARG_VAR([CPP], [C preprocessor])dnl
394 _AC_ARG_VAR_CPPFLAGS()dnl
396 AC_MSG_CHECKING([how to run the C preprocessor])
397 # On Suns, sometimes $CPP names a directory.
398 if test -n "$CPP" && test -d "$CPP"; then
401 if test -z "$CPP"; then
402 AC_CACHE_VAL([ac_cv_prog_CPP],
404 # Double quotes because CPP needs to be expanded
405 for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
407 _AC_PROG_PREPROC_WORKS_IFELSE([break])
415 AC_MSG_RESULT([$CPP])
416 _AC_PROG_PREPROC_WORKS_IFELSE([],
417 [AC_MSG_FAILURE([C preprocessor "$CPP" fails sanity check])])
424 # Treat warnings from the preprocessor as errors.
425 AC_DEFUN([AC_PROG_CPP_WERROR],
426 [AC_REQUIRE([AC_PROG_CPP])dnl
427 ac_c_preproc_warn_flag=yes])# AC_PROG_CPP_WERROR
429 # AC_LANG_COMPILER(C)
430 # -------------------
431 # Find the C compiler. Must be AC_DEFUN'd to be AC_REQUIRE'able.
432 AC_DEFUN([AC_LANG_COMPILER(C)],
433 [AC_REQUIRE([AC_PROG_CC])])
438 # We used to name the cache variable this way.
439 AU_DEFUN([ac_cv_prog_gcc],
440 [ac_cv_c_compiler_gnu])
443 # AC_PROG_CC([COMPILER ...])
444 # --------------------------
445 # COMPILER ... is a space separated list of C compilers to search for.
446 # This just gives the user an opportunity to specify an alternative
447 # search list for the C compiler.
448 AN_MAKEVAR([CC], [AC_PROG_CC])
449 AN_PROGRAM([cc], [AC_PROG_CC])
450 AN_PROGRAM([gcc], [AC_PROG_CC])
451 AC_DEFUN([AC_PROG_CC],
453 AC_ARG_VAR([CC], [C compiler command])dnl
454 AC_ARG_VAR([CFLAGS], [C compiler flags])dnl
455 _AC_ARG_VAR_LDFLAGS()dnl
456 _AC_ARG_VAR_CPPFLAGS()dnl
458 [AC_CHECK_TOOLS(CC, [$1])],
459 [AC_CHECK_TOOL(CC, gcc)
460 if test -z "$CC"; then
461 AC_CHECK_TOOL(CC, cc)
463 if test -z "$CC"; then
464 AC_CHECK_PROG(CC, cc, cc, , , /usr/ucb/cc)
466 if test -z "$CC"; then
467 AC_CHECK_TOOLS(CC, cl)
471 test -z "$CC" && AC_MSG_FAILURE([no acceptable C compiler found in \$PATH])
473 # Provide some information about the compiler.
474 echo "$as_me:$LINENO:" \
475 "checking for _AC_LANG compiler version" >&AS_MESSAGE_LOG_FD
476 ac_compiler=`set X $ac_compile; echo $[2]`
477 _AC_EVAL([$ac_compiler --version </dev/null >&AS_MESSAGE_LOG_FD])
478 _AC_EVAL([$ac_compiler -v </dev/null >&AS_MESSAGE_LOG_FD])
479 _AC_EVAL([$ac_compiler -V </dev/null >&AS_MESSAGE_LOG_FD])
481 m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
482 m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl
483 _AC_LANG_COMPILER_GNU
484 GCC=`test $ac_compiler_gnu = yes && echo yes`
487 # Some people use a C++ compiler to compile C. Since we use `exit',
488 # in C++ we need to declare it. In case someone uses the same compiler
489 # for both compiling C and C++ we need to have the C++ compiler decide
490 # the declaration of exit, since it's the most demanding environment.
491 _AC_COMPILE_IFELSE([@%:@ifndef __cplusplus
494 [_AC_PROG_CXX_EXIT_DECLARATION])
501 # Check whether -g works, even if CFLAGS is set, in case the package
502 # plays around with CFLAGS (such as to build both debugging and normal
503 # versions of a library), tasteless as that idea is.
504 m4_define([_AC_PROG_CC_G],
505 [ac_test_CFLAGS=${CFLAGS+set}
506 ac_save_CFLAGS=$CFLAGS
508 AC_CACHE_CHECK(whether $CC accepts -g, ac_cv_prog_cc_g,
509 [_AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [ac_cv_prog_cc_g=yes],
510 [ac_cv_prog_cc_g=no])])
511 if test "$ac_test_CFLAGS" = set; then
512 CFLAGS=$ac_save_CFLAGS
513 elif test $ac_cv_prog_cc_g = yes; then
514 if test "$GCC" = yes; then
520 if test "$GCC" = yes; then
529 # AC_PROG_GCC_TRADITIONAL
530 # -----------------------
531 AN_FUNCTION([ioctl], [AC_PROG_GCC_TRADITIONAL])
532 AC_DEFUN([AC_PROG_GCC_TRADITIONAL],
533 [if test $ac_cv_c_compiler_gnu = yes; then
534 AC_CACHE_CHECK(whether $CC needs -traditional,
535 ac_cv_prog_gcc_traditional,
536 [ ac_pattern="Autoconf.*'x'"
537 AC_EGREP_CPP($ac_pattern, [#include <sgtty.h>
539 ac_cv_prog_gcc_traditional=yes, ac_cv_prog_gcc_traditional=no)
541 if test $ac_cv_prog_gcc_traditional = no; then
542 AC_EGREP_CPP($ac_pattern, [#include <termio.h>
544 ac_cv_prog_gcc_traditional=yes)
546 if test $ac_cv_prog_gcc_traditional = yes; then
547 CC="$CC -traditional"
550 ])# AC_PROG_GCC_TRADITIONAL
555 AC_DEFUN([AC_PROG_CC_C_O],
556 [AC_REQUIRE([AC_PROG_CC])dnl
557 if test "x$CC" != xcc; then
558 AC_MSG_CHECKING([whether $CC and cc understand -c and -o together])
560 AC_MSG_CHECKING([whether cc understands -c and -o together])
562 set dummy $CC; ac_cc=`echo $[2] |
563 sed 's/[[^a-zA-Z0-9_]]/_/g;s/^[[0-9]]/_/'`
564 AC_CACHE_VAL(ac_cv_prog_cc_${ac_cc}_c_o,
565 [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])])
566 # Make sure it works both with $CC and with simple cc.
567 # We do the test twice because some compilers refuse to overwrite an
568 # existing .o file with -o, though they will create one.
569 ac_try='$CC -c conftest.$ac_ext -o conftest.$ac_objext >&AS_MESSAGE_LOG_FD'
570 if AC_TRY_EVAL(ac_try) &&
571 test -f conftest.$ac_objext && AC_TRY_EVAL(ac_try);
573 eval ac_cv_prog_cc_${ac_cc}_c_o=yes
574 if test "x$CC" != xcc; then
575 # Test first that cc exists at all.
576 if AC_TRY_COMMAND(cc -c conftest.$ac_ext >&AS_MESSAGE_LOG_FD); then
577 ac_try='cc -c conftest.$ac_ext -o conftest.$ac_objext >&AS_MESSAGE_LOG_FD'
578 if AC_TRY_EVAL(ac_try) &&
579 test -f conftest.$ac_objext && AC_TRY_EVAL(ac_try);
584 # cc exists but doesn't like -o.
585 eval ac_cv_prog_cc_${ac_cc}_c_o=no
590 eval ac_cv_prog_cc_${ac_cc}_c_o=no
594 if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = yes"; then
598 AC_DEFINE(NO_MINUS_C_MINUS_O, 1,
599 [Define to 1 if your C compiler doesn't accept -c and -o together.])
604 # ---------------------- #
605 # 3c. The C++ compiler. #
606 # ---------------------- #
609 # AC_LANG_PREPROC(C++)
610 # ---------------------
611 # Find the C++ preprocessor. Must be AC_DEFUN'd to be AC_REQUIRE'able.
612 AC_DEFUN([AC_LANG_PREPROC(C++)],
613 [AC_REQUIRE([AC_PROG_CXXCPP])])
618 # Find a working C++ preprocessor.
619 # We shouldn't have to require AC_PROG_CC, but this is due to the concurrency
620 # between the AC_LANG_COMPILER_REQUIRE family and that of AC_PROG_CXX.
621 AC_DEFUN([AC_PROG_CXXCPP],
622 [AC_REQUIRE([AC_PROG_CXX])dnl
623 AC_ARG_VAR([CXXCPP], [C++ preprocessor])dnl
624 _AC_ARG_VAR_CPPFLAGS()dnl
626 AC_MSG_CHECKING([how to run the C++ preprocessor])
627 if test -z "$CXXCPP"; then
628 AC_CACHE_VAL(ac_cv_prog_CXXCPP,
630 # Double quotes because CXXCPP needs to be expanded
631 for CXXCPP in "$CXX -E" "/lib/cpp"
633 _AC_PROG_PREPROC_WORKS_IFELSE([break])
635 ac_cv_prog_CXXCPP=$CXXCPP
637 CXXCPP=$ac_cv_prog_CXXCPP
639 ac_cv_prog_CXXCPP=$CXXCPP
641 AC_MSG_RESULT([$CXXCPP])
642 _AC_PROG_PREPROC_WORKS_IFELSE([],
643 [AC_MSG_FAILURE([C++ preprocessor "$CXXCPP" fails sanity check])])
649 # AC_LANG_COMPILER(C++)
650 # ---------------------
651 # Find the C++ compiler. Must be AC_DEFUN'd to be AC_REQUIRE'able.
652 AC_DEFUN([AC_LANG_COMPILER(C++)],
653 [AC_REQUIRE([AC_PROG_CXX])])
658 # We used to name the cache variable this way.
659 AU_DEFUN([ac_cv_prog_gxx],
660 [ac_cv_cxx_compiler_gnu])
663 # AC_PROG_CXX([LIST-OF-COMPILERS])
664 # --------------------------------
665 # LIST-OF-COMPILERS is a space separated list of C++ compilers to search
666 # for (if not specified, a default list is used). This just gives the
667 # user an opportunity to specify an alternative search list for the C++
669 # aCC HP-UX C++ compiler much better than `CC', so test before.
670 # FCC Fujitsu C++ compiler
671 # KCC KAI C++ compiler
673 # xlC_r AIX C Set++ (with support for reentrant code)
675 AN_MAKEVAR([CXX], [AC_PROG_CXX])
676 AN_PROGRAM([CC], [AC_PROG_CXX])
677 AN_PROGRAM([c++], [AC_PROG_CXX])
678 AN_PROGRAM([g++], [AC_PROG_CXX])
679 AC_DEFUN([AC_PROG_CXX],
680 [AC_LANG_PUSH(C++)dnl
681 AC_ARG_VAR([CXX], [C++ compiler command])dnl
682 AC_ARG_VAR([CXXFLAGS], [C++ compiler flags])dnl
683 _AC_ARG_VAR_LDFLAGS()dnl
684 _AC_ARG_VAR_CPPFLAGS()dnl
686 [$CCC m4_default([$1],
687 [g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC])],
690 # Provide some information about the compiler.
691 echo "$as_me:$LINENO:" \
692 "checking for _AC_LANG compiler version" >&AS_MESSAGE_LOG_FD
693 ac_compiler=`set X $ac_compile; echo $[2]`
694 _AC_EVAL([$ac_compiler --version </dev/null >&AS_MESSAGE_LOG_FD])
695 _AC_EVAL([$ac_compiler -v </dev/null >&AS_MESSAGE_LOG_FD])
696 _AC_EVAL([$ac_compiler -V </dev/null >&AS_MESSAGE_LOG_FD])
698 m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
699 m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl
700 _AC_LANG_COMPILER_GNU
701 GXX=`test $ac_compiler_gnu = yes && echo yes`
703 _AC_PROG_CXX_EXIT_DECLARATION
710 # Check whether -g works, even if CXXFLAGS is set, in case the package
711 # plays around with CXXFLAGS (such as to build both debugging and
712 # normal versions of a library), tasteless as that idea is.
713 m4_define([_AC_PROG_CXX_G],
714 [ac_test_CXXFLAGS=${CXXFLAGS+set}
715 ac_save_CXXFLAGS=$CXXFLAGS
717 AC_CACHE_CHECK(whether $CXX accepts -g, ac_cv_prog_cxx_g,
718 [_AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
719 [ac_cv_prog_cxx_g=yes],
720 [ac_cv_prog_cxx_g=no])])
721 if test "$ac_test_CXXFLAGS" = set; then
722 CXXFLAGS=$ac_save_CXXFLAGS
723 elif test $ac_cv_prog_cxx_g = yes; then
724 if test "$GXX" = yes; then
725 CXXFLAGS="$CXXFLAGS -g -O2"
727 CXXFLAGS="$CXXFLAGS -g"
730 if test "$GXX" = yes; then
739 # _AC_PROG_CXX_EXIT_DECLARATION
740 # -----------------------------
741 # If <stdlib.h> doesn't already provide a valid prototype for exit,
742 # determine the appropriate prototype and put it in confdefs.h.
743 # This macro is run only when testing a C++ compiler, but it generates
744 # a prototype that is also appropriate for C compilers in order to
745 # support a mixed C/C++ configuration environment.
746 # We don't need to worry about this for C, since we include <stdlib.h>
747 # if it is available, and that method works for all C compilers.
748 m4_define([_AC_PROG_CXX_EXIT_DECLARATION],
749 [for ac_declaration in \
751 'extern "C" void std::exit (int) throw (); using std::exit;' \
752 'extern "C" void std::exit (int); using std::exit;' \
753 'extern "C" void exit (int) throw ();' \
754 'extern "C" void exit (int);' \
757 _AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$ac_declaration
758 @%:@include <stdlib.h>],
762 _AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$ac_declaration],
767 if test -n "$ac_declaration"; then
768 echo '#ifdef __cplusplus' >>confdefs.h
769 echo $ac_declaration >>confdefs.h
770 echo '#endif' >>confdefs.h
772 ])# _AC_PROG_CXX_EXIT_DECLARATION
779 ## ------------------------------- ##
780 ## 4. Compilers' characteristics. ##
781 ## ------------------------------- ##
784 # -------------------------------- #
785 # 4b. C compiler characteristics. #
786 # -------------------------------- #
790 # If the C compiler in not in ANSI C mode by default, try to add an
791 # option to output variable @code{CC} to make it so. This macro tries
792 # various options that select ANSI C on some system or another. It
793 # considers the compiler to be in ANSI C mode if it handles function
794 # prototypes correctly.
795 AC_DEFUN([_AC_PROG_CC_STDC],
796 [AC_MSG_CHECKING([for $CC option to accept ANSI C])
797 AC_CACHE_VAL(ac_cv_prog_cc_stdc,
798 [ac_cv_prog_cc_stdc=no
800 AC_LANG_CONFTEST([AC_LANG_PROGRAM(
801 [[#include <stdarg.h>
803 #include <sys/types.h>
804 #include <sys/stat.h>
805 /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
806 struct buf { int x; };
807 FILE * (*rcsopen) (struct buf *, struct stat *, int);
808 static char *e (p, i)
814 static char *f (char * (*g) (char **, int), char **p, ...)
819 s = g (p, va_arg (v,int));
824 /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has
825 function prototypes and stuff, but not '\xHH' hex character constants.
826 These don't provoke an error unfortunately, instead are silently treated
827 as 'x'. The following induces an error, until -std1 is added to get
828 proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an
829 array size at least. It's necessary to write '\x00'==0 to get something
830 that's true only with -std1. */
831 int osf4_cc_array ['\x00' == 0 ? 1 : -1];
833 int test (int i, double x);
834 struct s1 {int (*f) (int a);};
835 struct s2 {int (*f) (double a);};
836 int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
839 [[return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];]])])
840 # Don't try gcc -ansi; that turns off useful extensions and
841 # breaks some systems' header files.
843 # Ultrix and OSF/1 -std1
844 # HP-UX 10.20 and later -Ae
845 # HP-UX older versions -Aa -D_HPUX_SOURCE
846 # SVR4 -Xc -D__EXTENSIONS__
847 for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
849 CC="$ac_save_CC $ac_arg"
850 _AC_COMPILE_IFELSE([],
851 [ac_cv_prog_cc_stdc=$ac_arg
854 rm -f conftest.$ac_ext conftest.$ac_objext
857 case "x$ac_cv_prog_cc_stdc" in
859 AC_MSG_RESULT([none needed]) ;;
861 AC_MSG_RESULT([$ac_cv_prog_cc_stdc])
862 CC="$CC $ac_cv_prog_cc_stdc" ;;
869 # Has been merged into AC_PROG_CC.
870 AU_DEFUN([AC_PROG_CC_STDC], [])
875 AC_DEFUN([AC_C_BACKSLASH_A],
877 AC_CACHE_CHECK([whether backslash-a works in strings], ac_cv_c_backslash_a,
878 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
883 char buf['\a' == 'a' ? -1 : 1];
885 return buf[0] != "\a"[0];
887 [ac_cv_c_backslash_a=yes],
888 [ac_cv_c_backslash_a=no])])
889 if test $ac_cv_c_backslash_a = yes; then
890 AC_DEFINE(HAVE_C_BACKSLASH_A, 1,
891 [Define if backslash-a works in C strings.])
898 # Has been merged into AC_PROG_CC.
899 AU_DEFUN([AC_C_CROSS], [])
904 AC_DEFUN([AC_C_CHAR_UNSIGNED],
905 [AH_VERBATIM([__CHAR_UNSIGNED__],
906 [/* Define to 1 if type `char' is unsigned and you are not using gcc. */
907 #ifndef __CHAR_UNSIGNED__
908 # undef __CHAR_UNSIGNED__
910 AC_CACHE_CHECK(whether char is unsigned, ac_cv_c_char_unsigned,
911 [AC_COMPILE_IFELSE([AC_LANG_BOOL_COMPILE_TRY([AC_INCLUDES_DEFAULT([])],
913 ac_cv_c_char_unsigned=no, ac_cv_c_char_unsigned=yes)])
914 if test $ac_cv_c_char_unsigned = yes && test "$GCC" != yes; then
915 AC_DEFINE(__CHAR_UNSIGNED__)
917 ])# AC_C_CHAR_UNSIGNED
922 AC_DEFUN([AC_C_LONG_DOUBLE],
924 [for working long double with more range or precision than double],
925 [ac_cv_c_long_double],
927 [AC_LANG_BOOL_COMPILE_TRY(
929 long double foo = 0.0;],
930 [/* Using '|' rather than '||' catches a GCC 2.95.2 x86 bug. */
931 (DBL_MAX < LDBL_MAX) | (LDBL_EPSILON < DBL_EPSILON)
932 | (DBL_MAX_EXP < LDBL_MAX_EXP) | (DBL_MANT_DIG < LDBL_MANT_DIG)])],
933 ac_cv_c_long_double=yes,
934 ac_cv_c_long_double=no)])
935 if test $ac_cv_c_long_double = yes; then
936 AC_DEFINE(HAVE_LONG_DOUBLE, 1,
937 [Define to 1 if long double works and has more range or precision than double.])
942 # AC_C_BIGENDIAN ([ACTION-IF-TRUE], [ACTION-IF-FALSE], [ACTION-IF-UNKNOWN])
943 # -------------------------------------------------------------------------
944 AC_DEFUN([AC_C_BIGENDIAN],
945 [AC_CACHE_CHECK(whether byte ordering is bigendian, ac_cv_c_bigendian,
946 [# See if sys/param.h defines the BYTE_ORDER macro.
947 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>
948 #include <sys/param.h>
950 [#if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
954 [# It does; now see whether it defined to BIG_ENDIAN or not.
955 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>
956 #include <sys/param.h>
957 ], [#if BYTE_ORDER != BIG_ENDIAN
960 ])], [ac_cv_c_bigendian=yes], [ac_cv_c_bigendian=no])],
961 [# It does not; compile a test program.
963 [AC_LANG_SOURCE([[int
966 /* Are we little or big endian? From Harbison&Steele. */
970 char c[sizeof (long)];
973 exit (u.c[sizeof (long) - 1] == 1);
975 [ac_cv_c_bigendian=no],
976 [ac_cv_c_bigendian=yes],
977 [# try to guess the endianness by grepping values into an object file
978 ac_cv_c_bigendian=unknown
979 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
980 [[short ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 };
981 short ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 };
982 void _ascii () { char *s = (char *) ascii_mm; s = (char *) ascii_ii; }
983 short ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 };
984 short ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 };
985 void _ebcdic () { char *s = (char *) ebcdic_mm; s = (char *) ebcdic_ii; }]],
986 [[ _ascii (); _ebcdic (); ]])],
987 [if grep BIGenDianSyS conftest.$ac_objext >/dev/null ; then
988 ac_cv_c_bigendian=yes
990 if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then
991 if test "$ac_cv_c_bigendian" = unknown; then
994 # finding both strings is unlikely to happen, but who knows?
995 ac_cv_c_bigendian=unknown
998 case $ac_cv_c_bigendian in
1001 [AC_DEFINE([WORDS_BIGENDIAN], 1,
1002 [Define to 1 if your processor stores words with the most significant
1003 byte first (like Motorola and SPARC, unlike Intel and VAX).])]) ;;
1008 [AC_MSG_ERROR([unknown endianness
1009 presetting ac_cv_c_bigendian=no (or yes) will help])]) ;;
1016 # Do nothing if the compiler accepts the inline keyword.
1017 # Otherwise define inline to __inline__ or __inline if one of those work,
1018 # otherwise define inline to be empty.
1020 # HP C version B.11.11.04 doesn't allow a typedef as the return value for an
1021 # inline function, only builtin types.
1023 AN_IDENTIFIER([inline], [AC_C_INLINE])
1024 AC_DEFUN([AC_C_INLINE],
1025 [AC_CACHE_CHECK([for inline], ac_cv_c_inline,
1027 for ac_kw in inline __inline__ __inline; do
1028 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1029 [#ifndef __cplusplus
1031 static $ac_kw foo_t static_foo () {return 0; }
1032 $ac_kw foo_t foo () {return 0; }
1035 [ac_cv_c_inline=$ac_kw; break])
1038 AH_VERBATIM([inline],
1039 [/* Define to `__inline__' or `__inline' if that's what the C compiler
1040 calls it, or to nothing if 'inline' is not supported under any name. */
1044 case $ac_cv_c_inline in
1047 case $ac_cv_c_inline in
1049 *) ac_val=$ac_cv_c_inline;;
1051 cat >>confdefs.h <<_ACEOF
1053 #define inline $ac_val
1063 AN_IDENTIFIER([const], [AC_C_CONST])
1064 AC_DEFUN([AC_C_CONST],
1065 [AC_CACHE_CHECK([for an ANSI C-conforming const], ac_cv_c_const,
1066 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
1067 [[/* FIXME: Include the comments suggested by Paul. */
1069 /* Ultrix mips cc rejects this. */
1070 typedef int charset[2];
1072 /* SunOS 4.1.1 cc rejects this. */
1073 char const *const *ccp;
1075 /* NEC SVR4.0.2 mips cc rejects this. */
1076 struct point {int x, y;};
1077 static struct point const zero = {0,0};
1078 /* AIX XL C 1.02.0.0 rejects this.
1079 It does not let you subtract one const X* pointer from another in
1080 an arm of an if-expression whose if-part is not a constant
1082 const char *g = "string";
1083 ccp = &g + (g ? g-g : 0);
1084 /* HPUX 7.0 cc rejects these. */
1087 ccp = (char const *const *) p;
1088 { /* SCO 3.2v4 cc rejects this. */
1090 char const *s = 0 ? (char *) 0 : (char const *) 0;
1094 { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */
1096 const int *foo = &x[0];
1099 { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
1100 typedef const int *iptr;
1104 { /* AIX XL C 1.02.0.0 rejects this saying
1105 "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
1106 struct s { int j; const int *ap[3]; };
1107 struct s *b; b->j = 5;
1109 { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
1114 [ac_cv_c_const=yes],
1115 [ac_cv_c_const=no])])
1116 if test $ac_cv_c_const = no; then
1118 [Define to empty if `const' does not conform to ANSI C.])
1125 # based on acx_restrict.m4, from the GNU Autoconf Macro Archive at:
1126 # http://www.gnu.org/software/ac-archive/htmldoc/acx_restrict.html
1128 # Determine whether the C/C++ compiler supports the "restrict" keyword
1129 # introduced in ANSI C99, or an equivalent. Do nothing if the compiler
1130 # accepts it. Otherwise, if the compiler supports an equivalent,
1131 # define "restrict" to be that. Here are some variants:
1132 # - GCC supports both __restrict and __restrict__
1133 # - older DEC Alpha C compilers support only __restrict
1134 # - _Restrict is the only spelling accepted by Sun WorkShop 6 update 2 C
1135 # Otherwise, define "restrict" to be empty.
1136 AN_IDENTIFIER([restrict], [AC_C_RESTRICT])
1137 AC_DEFUN([AC_C_RESTRICT],
1138 [AC_CACHE_CHECK([for C/C++ restrict keyword], ac_cv_c_restrict,
1139 [ac_cv_c_restrict=no
1140 # Try the official restrict keyword, then gcc's __restrict, and
1141 # the less common variants.
1142 for ac_kw in restrict __restrict __restrict__ _Restrict; do
1143 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
1144 [float * $ac_kw x;])],
1145 [ac_cv_c_restrict=$ac_kw; break])
1148 case $ac_cv_c_restrict in
1150 no) AC_DEFINE(restrict,,
1151 [Define to equivalent of C99 restrict keyword, or to nothing if this
1152 is not supported. Do not define if restrict is supported directly.]) ;;
1153 *) AC_DEFINE_UNQUOTED(restrict, $ac_cv_c_restrict) ;;
1160 # Note that, unlike const, #defining volatile to be the empty string can
1161 # actually turn a correct program into an incorrect one, since removing
1162 # uses of volatile actually grants the compiler permission to perform
1163 # optimizations that could break the user's code. So, do not #define
1164 # volatile away unless it is really necessary to allow the user's code
1165 # to compile cleanly. Benign compiler failures should be tolerated.
1166 AN_IDENTIFIER([volatile], [AC_C_VOLATILE])
1167 AC_DEFUN([AC_C_VOLATILE],
1168 [AC_CACHE_CHECK([for working volatile], ac_cv_c_volatile,
1169 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
1171 int * volatile y;])],
1172 [ac_cv_c_volatile=yes],
1173 [ac_cv_c_volatile=no])])
1174 if test $ac_cv_c_volatile = no; then
1175 AC_DEFINE(volatile,,
1176 [Define to empty if the keyword `volatile' does not work.
1177 Warning: valid code using `volatile' can become incorrect
1178 without. Disable with care.])
1185 # Checks if `#' can be used to glue strings together at the CPP level.
1186 # Defines HAVE_STRINGIZE if positive.
1187 AC_DEFUN([AC_C_STRINGIZE],
1188 [AC_CACHE_CHECK([for preprocessor stringizing operator],
1189 [ac_cv_c_stringize],
1190 [AC_EGREP_CPP([@%:@teststring],
1193 char *s = x(teststring);],
1194 [ac_cv_c_stringize=no],
1195 [ac_cv_c_stringize=yes])])
1196 if test $ac_cv_c_stringize = yes; then
1197 AC_DEFINE(HAVE_STRINGIZE, 1,
1198 [Define to 1 if cpp supports the ANSI @%:@ stringizing operator.])
1205 # Check if the C compiler supports prototypes, included if it needs
1207 AC_DEFUN([AC_C_PROTOTYPES],
1208 [AC_REQUIRE([AC_PROG_CC])dnl
1209 AC_MSG_CHECKING([for function prototypes])
1210 if test "$ac_cv_prog_cc_stdc" != no; then
1211 AC_MSG_RESULT([yes])
1212 AC_DEFINE(PROTOTYPES, 1,
1213 [Define to 1 if the C compiler supports function prototypes.])
1214 AC_DEFINE(__PROTOTYPES, 1,
1215 [Define like PROTOTYPES; this can be used by system headers.])