xref: /netbsd-src/external/gpl2/gettext/dist/gettext-runtime/m4/ansi-c++.m4 (revision 946379e7b37692fc43f68eb0d1c10daa0a7f3b6c)
1# ansi-c++.m4 serial 1 (gettext-0.12)
2dnl Copyright (C) 2002-2003 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Bruno Haible.
8
9# Sets CXX to the name of a sufficiently ANSI C++ compliant compiler,
10# or to ":" if none is found.
11
12AC_DEFUN([gt_PROG_ANSI_CXX],
13[
14AC_CHECK_PROGS(CXX, $CCC g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC, :)
15if test "$CXX" != ":"; then
16  dnl Use a modified version of AC_PROG_CXX_WORKS that does not exit
17  dnl upon failure.
18  AC_MSG_CHECKING([whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) works])
19  AC_LANG_PUSH(C++)
20  AC_ARG_VAR([CXX], [C++ compiler command])
21  AC_ARG_VAR([CXXFLAGS], [C++ compiler flags])
22  echo 'int main () { return 0; }' > conftest.$ac_ext
23  if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
24    ac_cv_prog_cxx_works=yes
25    if (./conftest; exit) 2>/dev/null; then
26      ac_cv_prog_cxx_cross=no
27    else
28      ac_cv_prog_cxx_cross=yes
29    fi
30  else
31    ac_cv_prog_cxx_works=no
32  fi
33  rm -fr conftest*
34  AC_LANG_POP(C++)
35  AC_MSG_RESULT($ac_cv_prog_cxx_works)
36  if test $ac_cv_prog_cxx_works = no; then
37    CXX=:
38  else
39    dnl Test for namespaces. Both libasprintf and tests/lang-c++ need it.
40    dnl We don't bother supporting pre-ANSI-C++ compilers.
41    AC_MSG_CHECKING([whether the C++ compiler supports namespaces])
42    AC_LANG_PUSH(C++)
43    cat <<EOF > conftest.$ac_ext
44#include <iostream>
45namespace test { using namespace std; }
46std::ostream* ptr;
47int main () { return 0; }
48EOF
49    if AC_TRY_EVAL([ac_link]) && test -s conftest$ac_exeext; then
50      gt_cv_prog_cxx_namespaces=yes
51    else
52      gt_cv_prog_cxx_namespaces=no
53    fi
54    rm -fr conftest*
55    AC_LANG_POP(C++)
56    AC_MSG_RESULT($gt_cv_prog_cxx_namespaces)
57    if test $gt_cv_prog_cxx_namespaces = no; then
58      CXX=:
59    fi
60  fi
61fi
62])
63