From c92bd5876c260315af5513570689b6fd53331b88 Mon Sep 17 00:00:00 2001 From: Sergey Kosukhin Date: Mon, 11 Dec 2023 19:36:29 +0100 Subject: [PATCH] m4: ACX_COMPILER_*_VENDOR/VERSION: extract to separate files. --- aclocal.m4 | 3 +- m4/acx_compiler_vendor.m4 | 164 ++++++++++++++++ ...cx_compiler.m4 => acx_compiler_version.m4} | 175 +----------------- 3 files changed, 173 insertions(+), 169 deletions(-) create mode 100644 m4/acx_compiler_vendor.m4 rename m4/{acx_compiler.m4 => acx_compiler_version.m4} (64%) diff --git a/aclocal.m4 b/aclocal.m4 index 21d6a01..ee44e69 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -13,8 +13,9 @@ m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])]) m4_include([m4/acx_build_environment.m4]) -m4_include([m4/acx_compiler.m4]) m4_include([m4/acx_compiler_cross.m4]) +m4_include([m4/acx_compiler_vendor.m4]) +m4_include([m4/acx_compiler_version.m4]) m4_include([m4/acx_fc_endianness.m4]) m4_include([m4/acx_fc_include.m4]) m4_include([m4/acx_fc_line_length.m4]) diff --git a/m4/acx_compiler_vendor.m4 b/m4/acx_compiler_vendor.m4 new file mode 100644 index 0000000..efac04f --- /dev/null +++ b/m4/acx_compiler_vendor.m4 @@ -0,0 +1,164 @@ +# If you need to add support for a new vendor, add it to the language-specific +# version of the list _ACX_COMPILER_KNOWN_VENDORS. If the vendor sets +# additional preprocessor macros, put them in the list too, otherwise, you will +# have to implement additional detection algorithm (see the case of NAG in +# ACX_COMPILER_CC_VENDOR). +# +# If these macros look like an overkill to you, consider using +# ACX_COMPILER_*_VENDOR_SIMPLE macros. + +# ACX_COMPILER_FC_VENDOR() +# ----------------------------------------------------------------------------- +# Detects the vendor of the Fortran compiler. The result is "unknown" or one of +# the vendor IDs (see _ACX_COMPILER_KNOWN_VENDORS(Fortran)). +# +# The result is cached in the acx_cv_fc_compiler_vendor variable. +# +AC_DEFUN([ACX_COMPILER_FC_VENDOR], + [AC_LANG_ASSERT([Fortran])dnl + AC_PROVIDE_IFELSE([AC_FC_PP_SRCEXT], [], + [m4_warn([syntax], + [ACX_COMPILER_FC_VENDOR requires calling the Fortran compiler with ]dnl +[a preprocessor but no call to AC_FC_PP_SRCEXT is detected])])dnl + AC_CACHE_CHECK([for Fortran compiler vendor], [acx_cv_fc_compiler_vendor], + [AS_IF( + [AS_VAR_GET([_AC_CC]) --version 2>&1 | dnl +grep '^AMD clang version' >/dev/null 2>&1], + [acx_cv_fc_compiler_vendor=amd], + [_ACX_COMPILER_VENDOR])])]) + +# ACX_COMPILER_CC_VENDOR() +# ----------------------------------------------------------------------------- +# Detects the vendor of the C compiler. The result is "unknown" or one of +# the vendor IDs (see _ACX_COMPILER_KNOWN_VENDORS(C)). +# +# The result is cached in the acx_cv_c_compiler_vendor variable. +# +AC_DEFUN([ACX_COMPILER_CC_VENDOR], + [AC_LANG_ASSERT([C])dnl + AC_CACHE_CHECK([for C compiler vendor], [acx_cv_c_compiler_vendor], + [AS_IF( + [AS_VAR_GET([_AC_CC]) -V 2>&1 | dnl +grep '^NAG Fortran Compiler Release' >/dev/null 2>&1], + [acx_cv_c_compiler_vendor=nag], + [AS_VAR_GET([_AC_CC]) --version 2>&1 | dnl +grep '^AMD clang version' >/dev/null 2>&1], + [acx_cv_c_compiler_vendor=amd], + [_ACX_COMPILER_VENDOR])])]) + +# ACX_COMPILER_CXX_VENDOR() +# ----------------------------------------------------------------------------- +# Detects the vendor of the C++ compiler. The result is "unknown" or one of +# the vendor IDs (see _ACX_COMPILER_KNOWN_VENDORS(C)). +# +# The result is cached in the acx_cv_cxx_compiler_vendor variable. +# +AC_DEFUN([ACX_COMPILER_CXX_VENDOR], + [AC_LANG_ASSERT([C++])dnl + AC_CACHE_CHECK([for C++ compiler vendor], [acx_cv_cxx_compiler_vendor], + [AS_IF( + [AS_VAR_GET([_AC_CC]) --version 2>&1 | dnl +grep '^AMD clang version' >/dev/null 2>&1], + [acx_cv_cxx_compiler_vendor=amd], + [_ACX_COMPILER_VENDOR])])]) + +# _ACX_COMPILER_KNOWN_VENDORS() +# ----------------------------------------------------------------------------- +# Expands into a language-specific m4-quoted comma-separated list of pairs. The +# first value in each pair is the compiler vendor ID, the second value is a +# comma-separated list of the vendor-specific intrinsic preprocessor macros. +# By default, expands to m4_fatal with the message saying that _AC_LANG is not +# supported. +# +m4_define([_ACX_COMPILER_KNOWN_VENDORS], + [m4_ifdef([$0(]_AC_LANG[)], + [m4_indir([$0(]_AC_LANG[)], $@)], + [m4_fatal([the list of ]_AC_LANG[ compiler vendors is undefined])])]) + +# _ACX_COMPILER_KNOWN_VENDORS(Fortran)() +# ----------------------------------------------------------------------------- +# Implementation of _ACX_COMPILER_KNOWN_VENDORS for Fortran language. +# +m4_define([_ACX_COMPILER_KNOWN_VENDORS(Fortran)], +[[[intel, [__INTEL_COMPILER,__INTEL_LLVM_COMPILER]], + [cray, [_CRAYFTN]], + [nec, [__NEC__]], + [portland, [__PGI]], + [nag, [NAGFOR]], + [sun, [__SUNPRO_F95]], + [gnu, [__GFORTRAN__]], + [ibm, [__xlC__]], + [amd], + [flang, [__FLANG,__flang__]]]]) + +# _ACX_COMPILER_KNOWN_VENDORS(C)() +# ----------------------------------------------------------------------------- +# Implementation of _ACX_COMPILER_KNOWN_VENDORS for C language. +# +m4_define([_ACX_COMPILER_KNOWN_VENDORS(C)], +[[[intel, [__ICC,__ECC,__INTEL_COMPILER,__INTEL_LLVM_COMPILER]], + [cray, [_CRAYC,__cray__]], + [nec, [__NEC__]], + [portland, [__PGI,__NVCOMPILER]], + [amd], + [ibm, [__xlc__,__xlC__,__IBMC__,__IBMCPP__]], + [pathscale, [__PATHCC__,__PATHSCALE__]], + [apple, [__apple_build_version__]], + [clang, [__clang__]], + [fujitsu, [__FUJITSU]], + [sdcc, [SDCC,__SDCC]], + [nag], + [gnu, [__GNUC__]], + [sun, [__SUNPRO_C,__SUNPRO_CC]], + [hp, [__HP_cc,__HP_aCC]], + [dec, [__DECC,__DECCXX,__DECC_VER,__DECCXX_VER]], + [borland, [__BORLANDC__,__CODEGEARC__,__TURBOC__]], + [comeau, [__COMO__]], + [kai, [__KCC]], + [lcc, [__LCC__]], + [sgi, [__sgi,sgi]], + [microsoft, [_MSC_VER]], + [metrowerks, [__MWERKS__]], + [watcom, [__WATCOMC__]], + [tcc, [__TINYC__]]]]) + +# _ACX_COMPILER_KNOWN_VENDORS(C++)() +# ----------------------------------------------------------------------------- +# Implementation of _ACX_COMPILER_KNOWN_VENDORS for C++ language. +# +m4_copy([_ACX_COMPILER_KNOWN_VENDORS(C)], [_ACX_COMPILER_KNOWN_VENDORS(C++)]) + +# _ACX_COMPILER_VENDOR() +# ----------------------------------------------------------------------------- +# Originally taken from Autoconf Archive where it is known as +# AX_COMPILER_VENDOR. +# ----------------------------------------------------------------------------- +# Detects the vendor of the compiler based on its intrinsic preprocessor +# macro. The result is "unknown" or one of the vendor IDs +# (see _ACX_COMPILER_KNOWN_VENDORS). +# +# The result is stored in the acx_cv_[]_AC_LANG_ABBREV[]_compiler_vendor +# variable. +# +m4_define([_ACX_COMPILER_VENDOR], + [acx_compiler_vendor_options=dnl +"m4_foreach([pair], _ACX_COMPILER_KNOWN_VENDORS, + [m4_ifnblank(m4_quote(m4_shift(pair)), m4_n(m4_car(pair): m4_cdr(pair)))])dnl +unknown: CHOKEME" + acx_success=no + for acx_compiler_vendor_test in $acx_compiler_vendor_options; do + AS_CASE([$acx_compiler_vendor_test], + [*:], [acx_compiler_vendor_candidate=$acx_compiler_vendor_test + continue], + [acx_compiler_vendor_macro_defs=dnl +"defined("`echo $acx_compiler_vendor_test | sed 's%,%) || defined(%g'`")"]) + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([], +[[#if !($acx_compiler_vendor_macro_defs) + choke me +#endif]])], + [acx_success=yes]) + test "x$acx_success" = xyes && break + done + AS_VAR_SET([acx_cv_[]_AC_LANG_ABBREV[]_compiler_vendor], + [`echo $acx_compiler_vendor_candidate | cut -d: -f1`])]) diff --git a/m4/acx_compiler.m4 b/m4/acx_compiler_version.m4 similarity index 64% rename from m4/acx_compiler.m4 rename to m4/acx_compiler_version.m4 index 7c5a3c6..db90254 100644 --- a/m4/acx_compiler.m4 +++ b/m4/acx_compiler_version.m4 @@ -1,14 +1,9 @@ -# If you need to add support for a new vendor, add it to the language-specific -# version of the list _ACX_COMPILER_KNOWN_VENDORS. If the vendor sets -# additional preprocessor macros, put them in the list too, otherwise, you will -# have to implement additional detection algorithm (see the case of NAG in -# ACX_COMPILER_CC_VENDOR). All the language-specific version detection macros -# (ACX_COMPILER_FC_VERSION, ACX_COMPILER_CC_VERSION, etc.) expand the same -# macro _ACX_COMPILER_VERSION, which goes through 's in the relevant -# version of _ACX_COMPILER_KNOWN_VENDORS and checks whether -# _ACX_COMPILER_VERSION_ or -# _ACX_COMPILER_VERSION_() is defined. If either of -# them (the language-specific version has higher priority) is defined, +# All the language-specific version detection macros (ACX_COMPILER_FC_VERSION, +# ACX_COMPILER_CC_VERSION, etc.) expand the same macro _ACX_COMPILER_VERSION, +# which goes through 's in the relevant version of +# _ACX_COMPILER_KNOWN_VENDORS and checks whether _ACX_COMPILER_VERSION_ +# or _ACX_COMPILER_VERSION_() is defined. If either +# of them (the language-specific version has higher priority) is defined, # _ACX_COMPILER_VERSION will expand it. For example, Tiny CC (has vendor ID # 'tcc') is only a C compiler and only _ACX_COMPILER_VERSION_TCC(C) is defined, # which means that this option is added to the configure script only if the @@ -19,27 +14,7 @@ # in the case of Fortran and C, respectively. # # If these macros look like an overkill to you, consider using -# ACX_COMPILER_*_SIMPLE macros. - -# ACX_COMPILER_FC_VENDOR() -# ----------------------------------------------------------------------------- -# Detects the vendor of the Fortran compiler. The result is "unknown" or one of -# the vendor IDs (see _ACX_COMPILER_KNOWN_VENDORS(Fortran)). -# -# The result is cached in the acx_cv_fc_compiler_vendor variable. -# -AC_DEFUN([ACX_COMPILER_FC_VENDOR], - [AC_LANG_ASSERT([Fortran])dnl - AC_PROVIDE_IFELSE([AC_FC_PP_SRCEXT], [], - [m4_warn([syntax], - [ACX_COMPILER_FC_VENDOR requires calling the Fortran compiler with ]dnl -[a preprocessor but no call to AC_FC_PP_SRCEXT is detected])])dnl - AC_CACHE_CHECK([for Fortran compiler vendor], [acx_cv_fc_compiler_vendor], - [AS_IF( - [AS_VAR_GET([_AC_CC]) --version 2>&1 | dnl -grep '^AMD clang version' >/dev/null 2>&1], - [acx_cv_fc_compiler_vendor=amd], - [_ACX_COMPILER_VENDOR])])]) +# ACX_COMPILER_*_VERSION_SIMPLE macros. # ACX_COMPILER_FC_VERSION() # ----------------------------------------------------------------------------- @@ -54,25 +29,6 @@ AC_DEFUN([ACX_COMPILER_FC_VERSION], [AC_LANG_ASSERT([Fortran])dnl AC_REQUIRE([ACX_COMPILER_FC_VENDOR])_ACX_COMPILER_VERSION]) -# ACX_COMPILER_CC_VENDOR() -# ----------------------------------------------------------------------------- -# Detects the vendor of the C compiler. The result is "unknown" or one of -# the vendor IDs (see _ACX_COMPILER_KNOWN_VENDORS(C)). -# -# The result is cached in the acx_cv_c_compiler_vendor variable. -# -AC_DEFUN([ACX_COMPILER_CC_VENDOR], - [AC_LANG_ASSERT([C])dnl - AC_CACHE_CHECK([for C compiler vendor], [acx_cv_c_compiler_vendor], - [AS_IF( - [AS_VAR_GET([_AC_CC]) -V 2>&1 | dnl -grep '^NAG Fortran Compiler Release' >/dev/null 2>&1], - [acx_cv_c_compiler_vendor=nag], - [AS_VAR_GET([_AC_CC]) --version 2>&1 | dnl -grep '^AMD clang version' >/dev/null 2>&1], - [acx_cv_c_compiler_vendor=amd], - [_ACX_COMPILER_VENDOR])])]) - # ACX_COMPILER_CC_VERSION() # ----------------------------------------------------------------------------- # Detects the version of the C compiler. The result is either "unknown" @@ -86,22 +42,6 @@ AC_DEFUN([ACX_COMPILER_CC_VERSION], [AC_LANG_ASSERT([C])dnl AC_REQUIRE([ACX_COMPILER_CC_VENDOR])_ACX_COMPILER_VERSION]) -# ACX_COMPILER_CXX_VENDOR() -# ----------------------------------------------------------------------------- -# Detects the vendor of the C++ compiler. The result is "unknown" or one of -# the vendor IDs (see _ACX_COMPILER_KNOWN_VENDORS(C)). -# -# The result is cached in the acx_cv_cxx_compiler_vendor variable. -# -AC_DEFUN([ACX_COMPILER_CXX_VENDOR], - [AC_LANG_ASSERT([C++])dnl - AC_CACHE_CHECK([for C++ compiler vendor], [acx_cv_cxx_compiler_vendor], - [AS_IF( - [AS_VAR_GET([_AC_CC]) --version 2>&1 | dnl -grep '^AMD clang version' >/dev/null 2>&1], - [acx_cv_cxx_compiler_vendor=amd], - [_ACX_COMPILER_VENDOR])])]) - # ACX_COMPILER_CXX_VERSION() # ----------------------------------------------------------------------------- # Detects the version of the C compiler. The result is either "unknown" @@ -115,107 +55,6 @@ AC_DEFUN([ACX_COMPILER_CXX_VERSION], [AC_LANG_ASSERT([C++])dnl AC_REQUIRE([ACX_COMPILER_CXX_VENDOR])_ACX_COMPILER_VERSION]) -# _ACX_COMPILER_KNOWN_VENDORS() -# ----------------------------------------------------------------------------- -# Expands into a language-specific m4-quoted comma-separated list of pairs. The -# first value in each pair is the compiler vendor ID, the second value is a -# comma-separated list of the vendor-specific intrinsic preprocessor macros. -# By default, expands to m4_fatal with the message saying that _AC_LANG is not -# supported. -# -m4_define([_ACX_COMPILER_KNOWN_VENDORS], - [m4_ifdef([$0(]_AC_LANG[)], - [m4_indir([$0(]_AC_LANG[)], $@)], - [m4_fatal([the list of ]_AC_LANG[ compiler vendors is undefined])])]) - -# _ACX_COMPILER_KNOWN_VENDORS(Fortran)() -# ----------------------------------------------------------------------------- -# Implementation of _ACX_COMPILER_KNOWN_VENDORS for Fortran language. -# -m4_define([_ACX_COMPILER_KNOWN_VENDORS(Fortran)], -[[[intel, [__INTEL_COMPILER,__INTEL_LLVM_COMPILER]], - [cray, [_CRAYFTN]], - [nec, [__NEC__]], - [portland, [__PGI]], - [nag, [NAGFOR]], - [sun, [__SUNPRO_F95]], - [gnu, [__GFORTRAN__]], - [ibm, [__xlC__]], - [amd], - [flang, [__FLANG,__flang__]]]]) - -# _ACX_COMPILER_KNOWN_VENDORS(C)() -# ----------------------------------------------------------------------------- -# Implementation of _ACX_COMPILER_KNOWN_VENDORS for C language. -# -m4_define([_ACX_COMPILER_KNOWN_VENDORS(C)], -[[[intel, [__ICC,__ECC,__INTEL_COMPILER,__INTEL_LLVM_COMPILER]], - [cray, [_CRAYC,__cray__]], - [nec, [__NEC__]], - [portland, [__PGI,__NVCOMPILER]], - [amd], - [ibm, [__xlc__,__xlC__,__IBMC__,__IBMCPP__]], - [pathscale, [__PATHCC__,__PATHSCALE__]], - [apple, [__apple_build_version__]], - [clang, [__clang__]], - [fujitsu, [__FUJITSU]], - [sdcc, [SDCC,__SDCC]], - [nag], - [gnu, [__GNUC__]], - [sun, [__SUNPRO_C,__SUNPRO_CC]], - [hp, [__HP_cc,__HP_aCC]], - [dec, [__DECC,__DECCXX,__DECC_VER,__DECCXX_VER]], - [borland, [__BORLANDC__,__CODEGEARC__,__TURBOC__]], - [comeau, [__COMO__]], - [kai, [__KCC]], - [lcc, [__LCC__]], - [sgi, [__sgi,sgi]], - [microsoft, [_MSC_VER]], - [metrowerks, [__MWERKS__]], - [watcom, [__WATCOMC__]], - [tcc, [__TINYC__]]]]) - -# _ACX_COMPILER_KNOWN_VENDORS(C++)() -# ----------------------------------------------------------------------------- -# Implementation of _ACX_COMPILER_KNOWN_VENDORS for C++ language. -# -m4_copy([_ACX_COMPILER_KNOWN_VENDORS(C)], [_ACX_COMPILER_KNOWN_VENDORS(C++)]) - -# _ACX_COMPILER_VENDOR() -# ----------------------------------------------------------------------------- -# Originally taken from Autoconf Archive where it is known as -# AX_COMPILER_VENDOR. -# ----------------------------------------------------------------------------- -# Detects the vendor of the compiler based on its intrinsic preprocessor -# macro. The result is "unknown" or one of the vendor IDs -# (see _ACX_COMPILER_KNOWN_VENDORS). -# -# The result is stored in the acx_cv_[]_AC_LANG_ABBREV[]_compiler_vendor -# variable. -# -m4_define([_ACX_COMPILER_VENDOR], - [acx_compiler_vendor_options=dnl -"m4_foreach([pair], _ACX_COMPILER_KNOWN_VENDORS, - [m4_ifnblank(m4_quote(m4_shift(pair)), m4_n(m4_car(pair): m4_cdr(pair)))])dnl -unknown: CHOKEME" - acx_success=no - for acx_compiler_vendor_test in $acx_compiler_vendor_options; do - AS_CASE([$acx_compiler_vendor_test], - [*:], [acx_compiler_vendor_candidate=$acx_compiler_vendor_test - continue], - [acx_compiler_vendor_macro_defs=dnl -"defined("`echo $acx_compiler_vendor_test | sed 's%,%) || defined(%g'`")"]) - AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM([], -[[#if !($acx_compiler_vendor_macro_defs) - choke me -#endif]])], - [acx_success=yes]) - test "x$acx_success" = xyes && break - done - AS_VAR_SET([acx_cv_[]_AC_LANG_ABBREV[]_compiler_vendor], - [`echo $acx_compiler_vendor_candidate | cut -d: -f1`])]) - # _ACX_COMPILER_VERSION() # ----------------------------------------------------------------------------- # Originally taken from Autoconf Archive where it is known as