title: CFLAGS, CCFLAGS, CXXFLAGS - what exactly do these variables control?
body: <p>I am using GNU make to compile my C++ code, and i would like to understand how to make my compilations customizable.</p>
  
  <p>I read in different places that <code>CFLAGS</code>, <code>CCFLAGS</code> and <code>CXXFLAGS</code> are used for this purpose. So how should i use them? If i have additional command-line arguments to the compiler, should i append them to <code>CFLAGS</code> or prepend them? Is there a common practice?</p>
  
  <p>Why the three different variables? I suppose the C compiler should get <code>CFLAGS</code> and <code>CCFLAGS</code>, while the C++ compiler should get <code>CFLAGS</code> and <code>CXXFLAGS</code> - did i get it right?</p>
  
  <p>Is the human user supposed to set these variables at all? Do any automatic tools (<code>automake</code>, <code>autoconf</code>, etc) set them? The linux system that i am supposed to use doesn't define any of these variables - is this typical?</p>
  
  <p>Currently my Makefile looks like this, and i feel it's a bit dirty:</p>
  
  <pre><code>ifdef code_coverage
      GCOV_FLAG := -fprofile-arcs -ftest-coverage
  else
      GCOV_FLAG :=
  endif
  
  WFLAGS := -Wall
  
  INC_FLAGS := -Istuff -Imore_stuff -Ietc
  
  CCFLAGSINT := -O3 $(WFLAGS) $(INC_FLAGS) $(CCFLAGS)
  
  ... (somewhere in the makefile, the command-line for compilation looks like this)
      $(CC) $(CCFLAGSINT) -c $&lt; -o $@
  
  ... (somewhere in the makefile, the command-line for linking looks like this)
      $(CC) $(GCOV_FLAG) $(CCFLAGSINT) $(OBJLIST) $(LDFLAGS) -o $@
  </code></pre>
  
  <p>I am pretty sure there are no bugs here; the Makefile works very well. But is there anything that goes against conventions (like <code>CCFLAGSINT</code> - should i just overwrite <code>CCFLAGS</code> instead? Or <code>CXXFLAGS</code>? FUD!)</p>
  
  <p>Sorry for so many questions; you will obviously not answer them all but i hope the answers will help me understand the general idea behind these settings.</p>