Commit 3a406dc3 authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz
Browse files

c++11: improve configure.

* configure.ac, m4/ax_check_compile_flag.m4: Update from
Vaucanson 2.  (Thank you Akim.)
parent ea6a34b0
......@@ -72,26 +72,11 @@ AX_CHECK_COMPILE_FLAG([-Werror -fvisibility=hidden],
CXXFLAGS="$CXXFLAGS -DSPOT_BUILD"
# Turn on C++11 support
AX_CHECK_COMPILE_FLAG([-std=c++11 -stdlib=libc++],
[CXXFLAGS="$CXXFLAGS -std=c++11 -stdlib=libc++"
stdpass=true])
if ! "${stdpass-false}"; then
AX_CHECK_COMPILE_FLAG([-std=c++11],
[CXXFLAGS="$CXXFLAGS -std=c++11"
stdpass=true])
fi
if ! "${stdpass-false}"; then
AX_CHECK_COMPILE_FLAG([-std=c++0x],
[CXXFLAGS="$CXXFLAGS -std=c++0x"
stdpass=true])
fi
if ! "${stdpass-false}"; then
AC_ERROR([unable to turn on C++11 mode with this compiler])
fi
m4_define([_AX_CXX_COMPILE_STDCXX_11_testbody],
[AC_LANG_SOURCE([#include <memory>
#include <string>
m4_define([_AX_CXX_COMPILE_STDCXX_11_testbody], [
template <typename T>
template <typename T>
struct check
{
static_assert(sizeof(int) <= sizeof(T), "not big enough");
......@@ -99,6 +84,8 @@ m4_define([_AX_CXX_COMPILE_STDCXX_11_testbody], [
typedef check<check<bool>> right_angle_brackets;
auto f = std::make_shared<std::string>("shared_ptr");
int a;
decltype(a) b;
......@@ -107,16 +94,17 @@ m4_define([_AX_CXX_COMPILE_STDCXX_11_testbody], [
check_type&& cr = static_cast<check_type&&>(c);
auto d = a;
])
AC_CACHE_CHECK([whether $CXX $CXXFLAGS supports C++11 features],
[ax_cv_cxx_compile_cxx11],
[AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
[ax_cv_cxx_compile_cxx11=yes],
[ax_cv_cxx_compile_cxx11=no])])
test "x$ax_cv_cxx_compile_cxx11" = xyes ||
AC_ERROR([unable to compile C++11 with this compiler])
])])
for f in -std=c++11 '-std=c++11 -stdlib=libc++' -std=c++0x
do
AX_CHECK_COMPILE_FLAG([$f], [CXXFLAGS="$CXXFLAGS $f" stdpass=true], [], [],
[_AX_CXX_COMPILE_STDCXX_11_testbody])
${stdpass-false} && break
done
if ! "${stdpass-false}"; then
AC_ERROR([unable to turn on C++11 mode with this compiler])
fi
AX_CHECK_BUDDY
AX_CHECK_GSPNLIB
......
......@@ -61,12 +61,10 @@ AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
_AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
AC_COMPILE_IFELSE([m4_default([$5], [AC_LANG_PROGRAM()])],
[AS_VAR_SET(CACHEVAR,[yes])],
[AS_VAR_SET(CACHEVAR,[no])])
_AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
AS_IF([test x"AS_VAR_GET(CACHEVAR)" = xyes],
[m4_default([$2], :)],
[m4_default([$3], :)])
AS_IF([test x"AS_VAR_GET(CACHEVAR)" = xyes], [$2], [$3])
AS_VAR_POPDEF([CACHEVAR])dnl
])dnl AX_CHECK_COMPILE_FLAGS
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment