>From f673f2ef9802857421133a96c801882b8dba9b9c Mon Sep 17 00:00:00 2001
From: Roger Leigh
Date: Sun, 20 Jan 2013 18:50:49 +0000
Subject: [PATCH] AC_PROG_CXX: Add checks for C++11, C++98TR1 and C++98
These checks are the C++ equivalent of the existing C
standards checks.
---
lib/autoconf/c.m4 | 446 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 446 insertions(+)
diff --git a/lib/autoconf/c.m4 b/lib/autoconf/c.m4
index affd765..7575ead 100644
--- a/lib/autoconf/c.m4
+++ b/lib/autoconf/c.m4
@@ -749,6 +749,18 @@ else
GXX=
fi
_AC_PROG_CXX_G
+dnl
+dnl Set ac_prog_cc_stdc to the supported C version.
+dnl Also set the documented variable ac_cv_prog_cc_stdc;
+dnl its name was chosen when it was cached, but it is no longer cached.
+_AC_PROG_CXX_CXX11([ac_prog_cxx_stdcxx=c11
+ ac_cv_prog_cxx_stdcxx=$ac_cv_prog_cxx_cxx11],
+ [_AC_PROG_CXX_CXX98TR1([ac_prog_cxx_stdcxx=c99
+ ac_cv_prog_cxx_stdcxx=$ac_cv_prog_cxx_cxx98tr1],
+ [_AC_PROG_CXX_CXX98([ac_prog_cxx_stdcxx=c89
+ ac_cv_prog_cxx_stdcxx=$ac_cv_prog_cxx_cxx98],
+ [ac_prog_cxx_stdcxx=no
+ ac_cv_prog_cxx_stdcxx=no])])])
AC_LANG_POP(C++)dnl
])# AC_PROG_CXX
@@ -2158,3 +2170,437 @@ AC_DEFUN([AC_OPENMP],
fi
AC_SUBST([OPENMP_]_AC_LANG_PREFIX[FLAGS])
])
+
+# _AC_CXX_STD_TRY(STANDARD, TEST-PROLOGUE, TEST-BODY, OPTION-LIST,
+# ACTION-IF-AVAILABLE, ACTION-IF-UNAVAILABLE)
+# --------------------------------------------------------------
+# Check whether the C++ compiler accepts features of STANDARD (e.g
+# `c++98', `c++11') by trying to compile a program of TEST-PROLOGUE
+# and TEST-BODY. If this fails, try again with each compiler option
+# in the space-separated OPTION-LIST; if one helps, append it to CXX.
+# If eventually successful, run ACTION-IF-AVAILABLE, else
+# ACTION-IF-UNAVAILABLE.
+AC_DEFUN([_AC_CXX_STD_TRY],
+[AC_MSG_CHECKING([for $CXX option to enable ]m4_translit(m4_translit($1, [x], [+]), [a-z], [A-Z])[ features])
+AC_CACHE_VAL(ac_cv_prog_cxx_$1,
+[ac_cv_prog_cxx_$1=no
+ac_save_CXX=$CXX
+AC_LANG_CONFTEST([AC_LANG_PROGRAM([$2], [$3])])
+for ac_arg in '' $4
+do
+ CXX="$ac_save_CXX $ac_arg"
+ _AC_COMPILE_IFELSE([], [ac_cv_prog_cxx_$1=$ac_arg])
+ test "x$ac_cv_prog_cxx_$1" != "xno" && break
+done
+rm -f conftest.$ac_ext
+CXX=$ac_save_CXX
+])# AC_CACHE_VAL
+ac_prog_cxx_stdcxx_options=
+case "x$ac_cv_prog_cxx_$1" in
+ x)
+ AC_MSG_RESULT([none needed]) ;;
+ xno)
+ AC_MSG_RESULT([unsupported]) ;;
+ *)
+ ac_prog_cxx_stdcxx_options=" $ac_cv_prog_cxx_$1"
+ CXX=$CXX$ac_prog_cxx_stdcxx_options
+ AC_MSG_RESULT([$ac_cv_prog_cxx_$1]) ;;
+esac
+AS_IF([test "x$ac_cv_prog_cxx_$1" != xno], [$5], [$6])
+])# _AC_CXX_STD_TRY
+
+# _AC_CXX_CXX98_TEST_HEADER
+# -------------------------
+# A C++ header suitable for testing for CXX98.
+AC_DEFUN([_AC_CXX_CXX98_TEST_HEADER],
+[[
+#include
+#include
+#include
+#include
+#include
+#include
+#include