For generating src/speedtest.h, try a sequence of command-line options until (or unless) one of them works:
-dM: gcc, clang and derived compilers, icc classic -xdumpmacros: Sun Studio (writes to stderr!) -qshowmacros: IBM XL classic -PD: MSVC (usable with a wrapper such as cccl from the SWIG project) Because Sun Studio -xdumpmacros unconditionally writes to stderr, capture stderr output instead of sending it to /dev/null. This is perfectly safe, even in the presence of stray stderr output, because: 1. speedgen ignores input that is not of the form #define B<number> 2. even if a line of that format would somehow spuriously appear, the only outcome is that the generated C code will probe for a few more macros. Signed-off-by: H. Peter Anvin (Intel) <h...@zytor.com> --- src/local.mk | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/local.mk b/src/local.mk index 45dffd8bf624..e0860ee06a0f 100644 --- a/src/local.mk +++ b/src/local.mk @@ -694,15 +694,26 @@ src/version.h: Makefile $(AM_V_at)chmod a-w $@t $(AM_V_at)mv $@t $@ -# Target-specific termios baud rate file. This is opportunistic; -# if cc -E doesn't support -dM, the speedgen script still includes -# an extensive fallback list of common constants. +# Target-specific termios baud rate file. This is opportunistic; if cc +# -E doesn't support any of the macro extraction options, the speedgen +# script still includes an extensive fallback list of common +# constants. + +# List of options used by various compilers to extract macro definitions; +# these are tried in the order listed until the compiler exits successfully. +# -dM: gcc, clang and derived compilers, icc classic +# -xdumpmacros: Sun Studio (writes to stderr!) +# -qshowmacros: IBM XL classic +# -PD: MSVC (usable with a wrapper such as cccl from the SWIG project) +getmacopts = -dM -xdumpmacros -qshowmacros -PD + CLEANFILES += src/speedlist.h src/speedlist.h: src/termios.c lib/config.h src/speedgen $(AM_V_GEN)rm -f $@ $(AM_V_at)${MKDIR_P} src - $(AM_V_at)$(COMPILE) -E -dM $< 2>/dev/null | \ - $(SHELL) $(srcdir)/src/speedgen $@t + $(AM_V_at)( for opt in $(getmacopts); do \ + $(COMPILE) -E $$opt $< 2>&1 && break; \ + done ) | $(SHELL) $(srcdir)/src/speedgen $@t $(AM_V_at)chmod a-w $@t $(AM_V_at)mv $@t $@ -- 2.49.0