2 dnl Copyright (C) 2002-2003, 2010 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
9 # gl_PROG_ANSI_CXX([ANSICXX_VARIABLE], [ANSICXX_CONDITIONAL])
10 # Sets ANSICXX_VARIABLE to the name of a sufficiently ANSI C++ compliant
11 # compiler, or to ":" if none is found.
12 # Defines the Automake condition ANSICXX_CONDITIONAL to true if such a compiler
13 # was found, or to false if not.
15 AC_DEFUN([gl_PROG_ANSI_CXX],
17 m4_if([$1], [CXX], [],
19 if test -z "$CXX"; then
20 if test -n "$CCC"; then
23 AC_CHECK_PROGS([CXX], [g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC], [:])
26 if test "$CXX" != ":"; then
27 dnl Use a modified version of AC_PROG_CXX_WORKS that does not exit
29 AC_MSG_CHECKING([whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works])
31 AC_ARG_VAR([CXX], [C++ compiler command])
32 AC_ARG_VAR([CXXFLAGS], [C++ compiler flags])
33 echo 'int main () { return 0; }' > conftest.$ac_ext
34 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
35 gl_cv_prog_ansicxx_works=yes
36 if (./conftest; exit) 2>/dev/null; then
37 gl_cv_prog_ansicxx_cross=no
39 gl_cv_prog_ansicxx_cross=yes
42 gl_cv_prog_ansicxx_works=no
46 AC_MSG_RESULT([$gl_cv_prog_ansicxx_works])
47 if test $gl_cv_prog_ansicxx_works = no; then
50 dnl Test for namespaces.
51 dnl We don't bother supporting pre-ANSI-C++ compilers.
52 AC_MSG_CHECKING([whether the C++ compiler supports namespaces])
54 cat <<EOF > conftest.$ac_ext
56 namespace test { using namespace std; }
58 int main () { return 0; }
60 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
61 gl_cv_prog_ansicxx_namespaces=yes
63 gl_cv_prog_ansicxx_namespaces=no
67 AC_MSG_RESULT([$gl_cv_prog_ansicxx_namespaces])
68 if test $gl_cv_prog_ansicxx_namespaces = no; then
73 m4_if([$1], [CXX], [],
78 AM_CONDITIONAL([$2], [test "$$1" != ":"])
80 dnl This macro invocation resolves an automake error:
81 dnl /usr/local/share/automake-1.11/am/depend2.am: am__fastdepCXX does not appear in AM_CONDITIONAL
82 dnl /usr/local/share/automake-1.11/am/depend2.am: The usual way to define `am__fastdepCXX' is to add `AC_PROG_CXX'
83 dnl /usr/local/share/automake-1.11/am/depend2.am: to `configure.ac' and run `aclocal' and `autoconf' again.
84 _AM_DEPENDENCIES([CXX])