2 dnl Copyright (C) 2002-2003, 2005, 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 # Sets CXX_CHOICE to 'yes' or 'no', depending on the preferred use of C++.
11 AC_DEFUN([gl_CXX_CHOICE],
13 AC_MSG_CHECKING([whether to use C++])
14 dnl It would be so nice if plus signs were supported in AC_ARG_ENABLE.
15 dnl Feature request submitted on 2010-03-13.
17 [ --disable-cxx do not build C++ sources],
18 [CXX_CHOICE="$enableval"],
20 AC_MSG_RESULT([$CXX_CHOICE])
21 AC_SUBST([CXX_CHOICE])
24 # gl_PROG_ANSI_CXX([ANSICXX_VARIABLE], [ANSICXX_CONDITIONAL])
25 # Sets ANSICXX_VARIABLE to the name of a sufficiently ANSI C++ compliant
26 # compiler, or to ":" if none is found.
27 # Defines the Automake condition ANSICXX_CONDITIONAL to true if such a compiler
28 # was found, or to false if not.
30 AC_DEFUN([gl_PROG_ANSI_CXX],
32 AC_REQUIRE([gl_CXX_CHOICE])
33 m4_if([$1], [CXX], [],
35 if test "$CXX_CHOICE" = no; then
38 if test -z "$CXX"; then
39 if test -n "$CCC"; then
42 AC_CHECK_PROGS([CXX], [g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC], [:])
45 if test "$CXX" != ":"; then
46 dnl Use a modified version of AC_PROG_CXX_WORKS that does not exit
48 AC_MSG_CHECKING([whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works])
50 AC_ARG_VAR([CXX], [C++ compiler command])
51 AC_ARG_VAR([CXXFLAGS], [C++ compiler flags])
52 echo 'int main () { return 0; }' > conftest.$ac_ext
53 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
54 gl_cv_prog_ansicxx_works=yes
55 if (./conftest; exit) 2>/dev/null; then
56 gl_cv_prog_ansicxx_cross=no
58 gl_cv_prog_ansicxx_cross=yes
61 gl_cv_prog_ansicxx_works=no
65 AC_MSG_RESULT([$gl_cv_prog_ansicxx_works])
66 if test $gl_cv_prog_ansicxx_works = no; then
69 dnl Test for namespaces.
70 dnl We don't bother supporting pre-ANSI-C++ compilers.
71 AC_MSG_CHECKING([whether the C++ compiler supports namespaces])
73 cat <<EOF > conftest.$ac_ext
75 namespace test { using namespace std; }
77 int main () { return 0; }
79 if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
80 gl_cv_prog_ansicxx_namespaces=yes
82 gl_cv_prog_ansicxx_namespaces=no
86 AC_MSG_RESULT([$gl_cv_prog_ansicxx_namespaces])
87 if test $gl_cv_prog_ansicxx_namespaces = no; then
92 m4_if([$1], [CXX], [],
97 AM_CONDITIONAL([$2], [test "$$1" != ":"])
99 dnl This macro invocation resolves an automake error:
100 dnl /usr/local/share/automake-1.11/am/depend2.am: am__fastdepCXX does not appear in AM_CONDITIONAL
101 dnl /usr/local/share/automake-1.11/am/depend2.am: The usual way to define `am__fastdepCXX' is to add `AC_PROG_CXX'
102 dnl /usr/local/share/automake-1.11/am/depend2.am: to `configure.ac' and run `aclocal' and `autoconf' again.
103 _AM_DEPENDENCIES([CXX])