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