We use autotools as our build infrastructure, and we use clang and gcc as compilers. Recently we hit a gcc warning that needed
--param max-vartrack-size=100000000
to silence (without completey disabling gcc's vartracking). Clang doesn't accept that option and produces
argument unused during compilation: '--param max-vartrack-size=100000000'
To silence that, clang needs
-Qunused-arguments
and that produces an error under gcc:
unrecognized command line option ‘-Qunused-arguments’
What is the best way to define compiler-specific flags in
configure.ac
, after a compiler has been selected with, e.g.AC_PROG_CXX
? WeAC_SUBST(AM_CXXFLAGS)
so I guess I'd be expanding a compiler specific variable withinAM_CXXFLAGS
.What is the right way to enable a per-target option in a
Makefile.am
for just one compiler? I'm thinking of:if HAVE_GCC SPECIFIC_CXXFLAGS = --param... endif if HAVE_CLANG SPECIFIC_CXXFLAGS = -Q... endif libfoo_la_CXXFLAGS = $(AM_CXXFLAGS) $(SPECIFIC_CXXFLAGS)
but I'd need the HAVE_*
vars subst'ed from configure.ac. Do AC_PROG_CXX/CC
perhaps already define something like this?