Skip to content

Commit

Permalink
[m4] Update m4 macro files to latest versions.
Browse files Browse the repository at this point in the history
  • Loading branch information
mywave82 committed Dec 20, 2024
1 parent 5b85813 commit c1111ac
Show file tree
Hide file tree
Showing 3 changed files with 132 additions and 50 deletions.
16 changes: 13 additions & 3 deletions m4/ax_check_compile_flag.m4
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,24 @@
# and this notice are preserved. This file is offered as-is, without any
# warranty.

#serial 6
#serial 11

AC_DEFUN([AX_CHECK_COMPILE_FLAG],
[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
AC_CACHE_CHECK([whether the _AC_LANG compiler accepts $1], CACHEVAR, [
ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
_AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
if test x"m4_case(_AC_LANG,
[C], [$GCC],
[C++], [$GXX],
[Fortran], [$GFC],
[Fortran 77], [$G77],
[Objective C], [$GOBJC],
[Objective C++], [$GOBJCXX],
[no])" = xyes ; then
add_gnu_werror="-Werror"
fi
_AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1 $add_gnu_werror"
AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
[AS_VAR_SET(CACHEVAR,[yes])],
[AS_VAR_SET(CACHEVAR,[no])])
Expand Down
88 changes: 70 additions & 18 deletions m4/ax_cxx_compile_stdcxx.m4
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
#
# Check for baseline language coverage in the compiler for the specified
# version of the C++ standard. If necessary, add switches to CXX and
# CXXCPP to enable support. VERSION may be '11', '14', '17', or '20' for
# the respective C++ standard version.
# CXXCPP to enable support. VERSION may be '11', '14', '17', '20', or
# '23' for the respective C++ standard version.
#
# The second argument, if specified, indicates whether you insist on an
# extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g.
Expand All @@ -36,14 +36,15 @@
# Copyright (c) 2016, 2018 Krzesimir Nowak <[email protected]>
# Copyright (c) 2019 Enji Cooper <[email protected]>
# Copyright (c) 2020 Jason Merrill <[email protected]>
# Copyright (c) 2021 Jörn Heusipp <[email protected]>
# Copyright (c) 2021, 2024 Jörn Heusipp <[email protected]>
# Copyright (c) 2015, 2022, 2023, 2024 Olly Betts
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.

#serial 18
#serial 25

dnl This macro is based on the code from the AX_CXX_COMPILE_STDCXX_11 macro
dnl (serial version number 13).
Expand All @@ -53,6 +54,7 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl
[$1], [14], [ax_cxx_compile_alternatives="14 1y"],
[$1], [17], [ax_cxx_compile_alternatives="17 1z"],
[$1], [20], [ax_cxx_compile_alternatives="20"],
[$1], [23], [ax_cxx_compile_alternatives="23"],
[m4_fatal([invalid first argument `$1' to AX_CXX_COMPILE_STDCXX])])dnl
m4_if([$2], [], [],
[$2], [ext], [],
Expand Down Expand Up @@ -159,31 +161,41 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl
dnl Test body for checking C++11 support

m4_define([_AX_CXX_COMPILE_STDCXX_testbody_11],
_AX_CXX_COMPILE_STDCXX_testbody_new_in_11
[_AX_CXX_COMPILE_STDCXX_testbody_new_in_11]
)

dnl Test body for checking C++14 support

m4_define([_AX_CXX_COMPILE_STDCXX_testbody_14],
_AX_CXX_COMPILE_STDCXX_testbody_new_in_11
_AX_CXX_COMPILE_STDCXX_testbody_new_in_14
[_AX_CXX_COMPILE_STDCXX_testbody_new_in_11
_AX_CXX_COMPILE_STDCXX_testbody_new_in_14]
)

dnl Test body for checking C++17 support

m4_define([_AX_CXX_COMPILE_STDCXX_testbody_17],
_AX_CXX_COMPILE_STDCXX_testbody_new_in_11
_AX_CXX_COMPILE_STDCXX_testbody_new_in_14
_AX_CXX_COMPILE_STDCXX_testbody_new_in_17
[_AX_CXX_COMPILE_STDCXX_testbody_new_in_11
_AX_CXX_COMPILE_STDCXX_testbody_new_in_14
_AX_CXX_COMPILE_STDCXX_testbody_new_in_17]
)

dnl Test body for checking C++20 support

m4_define([_AX_CXX_COMPILE_STDCXX_testbody_20],
_AX_CXX_COMPILE_STDCXX_testbody_new_in_11
_AX_CXX_COMPILE_STDCXX_testbody_new_in_14
_AX_CXX_COMPILE_STDCXX_testbody_new_in_17
_AX_CXX_COMPILE_STDCXX_testbody_new_in_20
[_AX_CXX_COMPILE_STDCXX_testbody_new_in_11
_AX_CXX_COMPILE_STDCXX_testbody_new_in_14
_AX_CXX_COMPILE_STDCXX_testbody_new_in_17
_AX_CXX_COMPILE_STDCXX_testbody_new_in_20]
)

dnl Test body for checking C++23 support

m4_define([_AX_CXX_COMPILE_STDCXX_testbody_23],
[_AX_CXX_COMPILE_STDCXX_testbody_new_in_11
_AX_CXX_COMPILE_STDCXX_testbody_new_in_14
_AX_CXX_COMPILE_STDCXX_testbody_new_in_17
_AX_CXX_COMPILE_STDCXX_testbody_new_in_20
_AX_CXX_COMPILE_STDCXX_testbody_new_in_23]
)


Expand All @@ -201,7 +213,17 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_11], [[
// MSVC always sets __cplusplus to 199711L in older versions; newer versions
// only set it correctly if /Zc:__cplusplus is specified as well as a
// /std:c++NN switch:
//
// https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/
//
// The value __cplusplus ought to have is available in _MSVC_LANG since
// Visual Studio 2015 Update 3:
//
// https://learn.microsoft.com/en-us/cpp/preprocessor/predefined-macros
//
// This was also the first MSVC version to support C++14 so we can't use the
// value of either __cplusplus or _MSVC_LANG to quickly rule out MSVC having
// C++11 or C++14 support, but we can check _MSVC_LANG for C++17 and later.
#elif __cplusplus < 201103L && !defined _MSC_VER
#error "This is not a C++11 compiler"
Expand Down Expand Up @@ -617,7 +639,7 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_17], [[
#error "This is not a C++ compiler"
#elif __cplusplus < 201703L && !defined _MSC_VER
#elif (defined _MSVC_LANG ? _MSVC_LANG : __cplusplus) < 201703L
#error "This is not a C++17 compiler"
Expand Down Expand Up @@ -983,7 +1005,7 @@ namespace cxx17
} // namespace cxx17
#endif // __cplusplus < 201703L && !defined _MSC_VER
#endif // (defined _MSVC_LANG ? _MSVC_LANG : __cplusplus) < 201703L
]])

Expand All @@ -996,7 +1018,7 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_20], [[
#error "This is not a C++ compiler"
#elif __cplusplus < 202002L && !defined _MSC_VER
#elif (defined _MSVC_LANG ? _MSVC_LANG : __cplusplus) < 202002L
#error "This is not a C++20 compiler"
Expand All @@ -1013,6 +1035,36 @@ namespace cxx20
} // namespace cxx20
#endif // __cplusplus < 202002L && !defined _MSC_VER
#endif // (defined _MSVC_LANG ? _MSVC_LANG : __cplusplus) < 202002L
]])


dnl Tests for new features in C++23

m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_23], [[
#ifndef __cplusplus
#error "This is not a C++ compiler"
#elif (defined _MSVC_LANG ? _MSVC_LANG : __cplusplus) < 202302L
#error "This is not a C++23 compiler"
#else
#include <version>
namespace cxx23
{
// As C++23 supports feature test macros in the standard, there is no
// immediate need to actually test for feature availability on the
// Autoconf side.
} // namespace cxx23
#endif // (defined _MSVC_LANG ? _MSVC_LANG : __cplusplus) < 202302L
]])
78 changes: 49 additions & 29 deletions m4/ax_prog_cc_for_build.m4
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
# and this notice are preserved. This file is offered as-is, without any
# warranty.

#serial 21
#serial 26

AU_ALIAS([AC_PROG_CC_FOR_BUILD], [AX_PROG_CC_FOR_BUILD])
AC_DEFUN([AX_PROG_CC_FOR_BUILD], [dnl
Expand All @@ -43,26 +43,24 @@ AC_REQUIRE([AC_CANONICAL_BUILD])dnl
dnl Use the standard macros, but make them use other variable names
dnl
pushdef([ac_cv_prog_CPP], ac_cv_build_prog_CPP)dnl
pushdef([ac_cv_prog_gcc], ac_cv_build_prog_gcc)dnl
pushdef([ac_cv_prog_cc_c89], ac_cv_build_prog_cc_c89)dnl
pushdef([ac_cv_prog_cc_c99], ac_cv_build_prog_cc_c99)dnl
pushdef([ac_cv_prog_cc_c11], ac_cv_build_prog_cc_c11)dnl
pushdef([ac_cv_prog_gcc], ac_cv_build_prog_gcc)dnl
pushdef([ac_cv_prog_cc_c23], ac_cv_build_prog_cc_c23)dnl
pushdef([ac_cv_prog_cc_stdc], ac_cv_build_prog_cc_stdc)dnl
pushdef([ac_cv_prog_cc_works], ac_cv_build_prog_cc_works)dnl
pushdef([ac_cv_prog_cc_cross], ac_cv_build_prog_cc_cross)dnl
pushdef([ac_cv_prog_cc_g], ac_cv_build_prog_cc_g)dnl
pushdef([ac_cv_c_compiler_gnu], ac_cv_build_c_compiler_gnu)dnl
pushdef([ac_cv_exeext], ac_cv_build_exeext)dnl
pushdef([ac_cv_objext], ac_cv_build_objext)dnl
pushdef([ac_prog_cc_stdc], ac_build_prog_cc_stdc)dnl
pushdef([ac_exeext], ac_build_exeext)dnl
pushdef([ac_objext], ac_build_objext)dnl
pushdef([CC], CC_FOR_BUILD)dnl
pushdef([CPP], CPP_FOR_BUILD)dnl
pushdef([GCC], GCC_FOR_BUILD)dnl
pushdef([CFLAGS], CFLAGS_FOR_BUILD)dnl
pushdef([CPPFLAGS], CPPFLAGS_FOR_BUILD)dnl
pushdef([EXEEXT], BUILD_EXEEXT)dnl
pushdef([LDFLAGS], LDFLAGS_FOR_BUILD)dnl
pushdef([OBJEXT], BUILD_OBJEXT)dnl
pushdef([host], build)dnl
pushdef([host_alias], build_alias)dnl
pushdef([host_cpu], build_cpu)dnl
Expand All @@ -77,6 +75,32 @@ pushdef([ac_tool_prefix], ac_build_tool_prefix)dnl
pushdef([am_cv_CC_dependencies_compiler_type], am_cv_build_CC_dependencies_compiler_type)dnl
pushdef([am_cv_prog_cc_c_o], am_cv_build_prog_cc_c_o)dnl
pushdef([cross_compiling], cross_compiling_build)dnl
dnl
dnl These variables are problematic to rename by M4 macros, so we save
dnl their values in alternative names, and restore the values later.
dnl
dnl _AC_COMPILER_EXEEXT and _AC_COMPILER_OBJEXT internally call
dnl AC_SUBST which prevents the renaming of EXEEXT and OBJEXT
dnl variables. It's not a good idea to rename ac_cv_exeext and
dnl ac_cv_objext either as they're related.
dnl Renaming ac_exeext and ac_objext is safe though.
dnl
ac_cv_host_exeext=$ac_cv_exeext
AS_VAR_SET_IF([ac_cv_build_exeext],
[ac_cv_exeext=$ac_cv_build_exeext],
[AS_UNSET([ac_cv_exeext])])
ac_cv_host_objext=$ac_cv_objext
AS_VAR_SET_IF([ac_cv_build_objext],
[ac_cv_objext=$ac_cv_build_objext],
[AS_UNSET([ac_cv_objext])])
dnl
dnl ac_cv_c_compiler_gnu is used in _AC_LANG_COMPILER_GNU (called by
dnl AC_PROG_CC) indirectly.
dnl
ac_cv_host_c_compiler_gnu=$ac_cv_c_compiler_gnu
AS_VAR_SET_IF([ac_cv_build_c_compiler_gnu],
[ac_cv_c_compiler_gnu=$ac_cv_build_c_compiler_gnu],
[AS_UNSET([ac_cv_c_compiler_gnu])])
cross_compiling_build=no
Expand All @@ -85,25 +109,14 @@ AS_IF([test -n "$build"], [ac_build_tool_prefix="$build-"],
[test -n "$build_alias"],[ac_build_tool_prefix="$build_alias-"])
AC_LANG_PUSH([C])
dnl The pushdef([ac_cv_c_compiler_gnu], ...) currently does not cover
dnl the use of this variable in _AC_LANG_COMPILER_GNU called by
dnl AC_PROG_CC. Unset this cache variable temporarily as a workaround.
was_set_c_compiler_gnu=${[ac_cv_c_compiler_gnu]+y}
AS_IF([test ${was_set_c_compiler_gnu}],
[saved_c_compiler_gnu=$[ac_cv_c_compiler_gnu]
AS_UNSET([[ac_cv_c_compiler_gnu]])])
AC_PROG_CC
dnl Restore ac_cv_c_compiler_gnu
AS_IF([test ${was_set_c_compiler_gnu}],
[[ac_cv_c_compiler_gnu]=$[saved_c_compiler_gnu]])
_AC_COMPILER_EXEEXT
_AC_COMPILER_OBJEXT
AC_PROG_CPP
BUILD_EXEEXT=$ac_cv_exeext
BUILD_OBJEXT=$ac_cv_objext
dnl Restore the old definitions
dnl
popdef([cross_compiling])dnl
Expand All @@ -120,35 +133,42 @@ popdef([host_vendor])dnl
popdef([host_cpu])dnl
popdef([host_alias])dnl
popdef([host])dnl
popdef([OBJEXT])dnl
popdef([LDFLAGS])dnl
popdef([EXEEXT])dnl
popdef([CPPFLAGS])dnl
popdef([CFLAGS])dnl
popdef([GCC])dnl
popdef([CPP])dnl
popdef([CC])dnl
popdef([ac_objext])dnl
popdef([ac_exeext])dnl
popdef([ac_cv_objext])dnl
popdef([ac_cv_exeext])dnl
popdef([ac_cv_c_compiler_gnu])dnl
popdef([ac_prog_cc_stdc])dnl
popdef([ac_cv_prog_cc_g])dnl
popdef([ac_cv_prog_cc_cross])dnl
popdef([ac_cv_prog_cc_works])dnl
popdef([ac_cv_prog_cc_stdc])dnl
popdef([ac_cv_prog_cc_c23])dnl
popdef([ac_cv_prog_cc_c11])dnl
popdef([ac_cv_prog_cc_c99])dnl
popdef([ac_cv_prog_cc_c89])dnl
popdef([ac_cv_prog_gcc])dnl
popdef([ac_cv_prog_CPP])dnl
dnl
ac_cv_exeext=$ac_cv_host_exeext
EXEEXT=$ac_cv_host_exeext
ac_cv_objext=$ac_cv_host_objext
OBJEXT=$ac_cv_host_objext
ac_cv_c_compiler_gnu=$ac_cv_host_c_compiler_gnu
ac_compiler_gnu=$ac_cv_host_c_compiler_gnu
dnl restore global variables ac_ext, ac_cpp, ac_compile,
dnl ac_link, ac_compiler_gnu (dependant on the current
dnl ac_link, ac_compiler_gnu (dependent on the current
dnl language after popping):
AC_LANG_POP([C])
dnl Finally, set Makefile variables
dnl
AC_SUBST(BUILD_EXEEXT)dnl
AC_SUBST(BUILD_OBJEXT)dnl
AC_SUBST([BUILD_EXEEXT])dnl
AC_SUBST([BUILD_OBJEXT])dnl
AC_SUBST([CFLAGS_FOR_BUILD])dnl
AC_SUBST([CPPFLAGS_FOR_BUILD])dnl
AC_SUBST([LDFLAGS_FOR_BUILD])dnl
Expand Down

0 comments on commit c1111ac

Please sign in to comment.