title: How to change default values of variables like CC in Makefile
body: <p>(GNU) make uses several <a href="http://www.gnu.org/software/make/manual/make.html#Implicit-Variables">variables</a> like:<br /></p>
  
  <ul>
  <li><code>CC</code> -- C compiler, by default <code>cc</code></li>
  <li><code>CFLAGS</code> -- flags for the C compiler, by default empty</li>
  </ul>
  
  <p>I would like to specify my own default values of some of them in my <code>Makefile</code>. In the example below I used the conditional assignment operator <code>?=</code> to be able to override my defaults when running <code>make</code>:</p>
  
  <pre><code>CFLAGS ?= CFLAGS_my_default
  CC ?= CC_my_default
  
  print:
      echo CC=$(CC) CFLAGS=$(CFLAGS)
  </code></pre>
  
  <p>Unfortunately this does not change the value of the <code>CC</code> variable as the original default value stays there. <code>CFLAGS</code> are set by my assignment as the variable was originally empty:</p>
  
  <pre><code>$ make print
  echo CC=cc CFLAGS=CFLAGS_my_default
  CC=cc CFLAGS=CFLAGS_my_default
  </code></pre>
  
  <p>Overriding from environment variables works as expected:</p>
  
  <pre><code>$ CC=CC_from_env CFLAGS=CFLAGS_from_env make print
  echo CC=CC_from_env CFLAGS=CFLAGS_from_env
  CC=CC_from_env CFLAGS=CFLAGS_from_env
  </code></pre>
  
  <p>How can I change the default values of variables and still be able to override them when invoking <code>make</code>?</p>