title: Makefile: change compiler flags based on CC/CXX/FC values
body: <p>It seems absurd that there wouldn't already be a question about this, but I can't find one. Anyway, I am writing a makefile, and I just want to have a conditional statement that sets different CFLAGS depending on whether GNU or Intel compilers are being used to compile the program, set by the envrionment variable CC.</p>
  
  <p>Now, there is a section in the GNU make manual on this, and it says to do something like the following:</p>
  
  <p><a href="https://ftp.gnu.org/old-gnu/Manuals/make-3.79.1/html_chapter/make_7.html" rel="nofollow">https://ftp.gnu.org/old-gnu/Manuals/make-3.79.1/html_chapter/make_7.html</a></p>
  
  <pre><code>ifeq ($(CC),gcc)
    libs=$(libs_for_gcc)
  else
    libs=$(normal_libs)
  endif
  </code></pre>
  
  <p>(ok setting libraries not flags, but whatever, same idea). Ok fine, but surely this is just an example of how conditionals work, because in practice this is obviously a stupid way to do this. The CC variable can contain all manner of things besides 'gcc' and still be effectively using a GNU C compiler. Even just specifying the absolute path to the compiler in CC will break this example.</p>
  
  <p>So what is the sensible, robust, way to do this? Also, in case it matters, I want to do the same thing for C++ and Fortran compiler choices as well.</p>