|
|
|
@ -4,12 +4,16 @@ |
|
|
|
|
# |
|
|
|
|
# SYNOPSIS |
|
|
|
|
# |
|
|
|
|
# AX_REQUIRE_STDCXX_11 |
|
|
|
|
# AX_REQUIRE_STDCXX_14 |
|
|
|
|
# AX_CXX_COMPILE_STDCXX_11([ext|noext],[mandatory|optional]) |
|
|
|
|
# AX_CXX_COMPILE_STDCXX_14([ext|noext],[mandatory|optional]) |
|
|
|
|
# |
|
|
|
|
# DESCRIPTION |
|
|
|
|
# |
|
|
|
|
# Check for baseline language coverage in the compiler for the C++11 |
|
|
|
|
# standard; if necessary, add switches to CXXFLAGS to enable support. |
|
|
|
|
# or C++14 standard; if necessary, add switches to CXXFLAGS to |
|
|
|
|
# enable support. |
|
|
|
|
# |
|
|
|
|
# The first argument, if specified, indicates whether you insist on an |
|
|
|
|
# extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g. |
|
|
|
@ -131,3 +135,95 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [dnl |
|
|
|
|
AC_SUBST(HAVE_CXX11) |
|
|
|
|
fi |
|
|
|
|
]) |
|
|
|
|
|
|
|
|
|
AC_DEFUN([AX_CXX_COMPILE_STDCXX_14], [dnl |
|
|
|
|
m4_if([$1], [], [], |
|
|
|
|
[$1], [ext], [], |
|
|
|
|
[$1], [noext], [], |
|
|
|
|
[m4_fatal([invalid argument `$1' to AX_CXX_COMPILE_STDCXX_14])])dnl |
|
|
|
|
m4_if([$2], [], [ax_cxx_compile_cxx14_required=true], |
|
|
|
|
[$2], [mandatory], [ax_cxx_compile_cxx14_required=true], |
|
|
|
|
[$2], [optional], [ax_cxx_compile_cxx14_required=false], |
|
|
|
|
[m4_fatal([invalid second argument `$2' to AX_CXX_COMPILE_STDCXX_14])])dnl |
|
|
|
|
AC_LANG_PUSH([C++])dnl |
|
|
|
|
ac_success=no |
|
|
|
|
AC_CACHE_CHECK(whether $CXX supports C++14 features by default, |
|
|
|
|
ax_cv_cxx_compile_cxx14, |
|
|
|
|
[AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])], |
|
|
|
|
[ax_cv_cxx_compile_cxx14=yes], |
|
|
|
|
[ax_cv_cxx_compile_cxx14=no])]) |
|
|
|
|
if test x$ax_cv_cxx_compile_cxx14 = xyes; then |
|
|
|
|
ac_success=yes |
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
m4_if([$1], [noext], [], [dnl |
|
|
|
|
if test x$ac_success = xno; then |
|
|
|
|
for switch in -std=gnu++14 -std=gnu++0y; do |
|
|
|
|
cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx14_$switch]) |
|
|
|
|
AC_CACHE_CHECK(whether $CXX supports C++14 features with $switch, |
|
|
|
|
$cachevar, |
|
|
|
|
[ac_save_CXXFLAGS="$CXXFLAGS" |
|
|
|
|
CXXFLAGS="$CXXFLAGS $switch" |
|
|
|
|
AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])], |
|
|
|
|
[eval $cachevar=yes], |
|
|
|
|
[eval $cachevar=no]) |
|
|
|
|
CXXFLAGS="$ac_save_CXXFLAGS"]) |
|
|
|
|
if eval test x\$$cachevar = xyes; then |
|
|
|
|
CXXFLAGS="$CXXFLAGS $switch" |
|
|
|
|
ac_success=yes |
|
|
|
|
break |
|
|
|
|
fi |
|
|
|
|
done |
|
|
|
|
fi]) |
|
|
|
|
|
|
|
|
|
m4_if([$1], [ext], [], [dnl |
|
|
|
|
if test x$ac_success = xno; then |
|
|
|
|
for switch in -std=c++14 -std=c++0y; do |
|
|
|
|
cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx14_$switch]) |
|
|
|
|
AC_CACHE_CHECK(whether $CXX supports C++14 features with $switch, |
|
|
|
|
$cachevar, |
|
|
|
|
[ac_save_CXXFLAGS="$CXXFLAGS" |
|
|
|
|
CXXFLAGS="$CXXFLAGS $switch" |
|
|
|
|
AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])], |
|
|
|
|
[eval $cachevar=yes], |
|
|
|
|
[eval $cachevar=no]) |
|
|
|
|
CXXFLAGS="$ac_save_CXXFLAGS"]) |
|
|
|
|
if eval test x\$$cachevar = xyes; then |
|
|
|
|
CXXFLAGS="$CXXFLAGS $switch" |
|
|
|
|
ac_success=yes |
|
|
|
|
break |
|
|
|
|
fi |
|
|
|
|
done |
|
|
|
|
fi]) |
|
|
|
|
AC_LANG_POP([C++]) |
|
|
|
|
if test x$ax_cxx_compile_cxx14_required = xtrue; then |
|
|
|
|
if test x$ac_success = xno; then |
|
|
|
|
AC_MSG_ERROR([*** A compiler with support for C++14 language features is required.]) |
|
|
|
|
fi |
|
|
|
|
else |
|
|
|
|
HAVE_CXX11=${HAVE_CXX14} |
|
|
|
|
if test x$ac_success = xno; then |
|
|
|
|
HAVE_CXX14=0 |
|
|
|
|
AC_MSG_NOTICE([No compiler with C++14 support was found]) |
|
|
|
|
AX_CXX_COMPILE_STDCXX_11([$1], [optional]) |
|
|
|
|
else |
|
|
|
|
HAVE_CXX14=1 |
|
|
|
|
AC_DEFINE(HAVE_CXX14,1, |
|
|
|
|
[define if the compiler supports basic C++14 syntax]) |
|
|
|
|
fi |
|
|
|
|
AC_SUBST(HAVE_CXX11) |
|
|
|
|
AC_SUBST(HAVE_CXX14) |
|
|
|
|
fi |
|
|
|
|
]) |
|
|
|
|
|
|
|
|
|
AC_DEFUN([AX_REQUIRE_STDCXX_11], [ |
|
|
|
|
if test x${HAVE_CXX11} != x1; then |
|
|
|
|
AC_MSG_ERROR([*** A compiler with support for C++11 language features is required.]) |
|
|
|
|
fi |
|
|
|
|
]) |
|
|
|
|
|
|
|
|
|
AC_DEFUN([AX_REQUIRE_STDCXX_14], [ |
|
|
|
|
if test x${HAVE_CXX14} != x1; then |
|
|
|
|
AC_MSG_ERROR([*** A compiler with support for C++14 language features is required.]) |
|
|
|
|
fi |
|
|
|
|
]) |
|
|
|
|