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