title: Where to put things (CFLAGS or CXXFLAGS) on Makefile?
body: <p>First the <code>Makefile</code> here had</p>
  
  <pre><code>CFLAGS   = -g -Wall -lm
  </code></pre>
  
  <p>I was playing with <code>C</code> that time. Now I'm on <code>C++</code> and I have to add <code>-I eigen</code>, quick google on it and found <code>CXXFLAGS</code> exist for the <code>C++</code> world, while <code>CFLAGS</code> exist for the <code>C</code> world. So I updated <code>Makefile</code> to </p>
  
  <pre><code>CFLAGS   = -g -Wall -lm
  CXXFLAGS = -I eigen
  </code></pre>
  
  <p>Then I found <a href="https://wiki.gentoo.org/wiki/GCC_optimization" rel="nofollow noreferrer">https://wiki.gentoo.org/wiki/GCC_optimization</a>, and was inspired to updated it again</p>
  
  <pre><code>CFLAGS   = -g -Wall -lm
  CXXFLAGS = ${CFLAGS} -I eigen
  </code></pre>
  
  <p>The complete thing:</p>
  
  <pre><code>CC       = g++
  CFLAGS   = -g -Wall -lm
  CXXFLAGS = ${CFLAGS} -I eigen
  OBJS     = main.o multiply.o 
  PROGRAM  = multitply
  $(PROGRAM): $(OBJS)
      $(CC) $(OBJS) $(CFLAGS) -o $(PROGRAM)
  </code></pre>
  
  <p>Should I add <code>-I eigen</code> to <code>CXXFLAGS</code> or <code>CFLAGS</code>? </p>
  
  <p>Also noticed the existence of <code>CPPFLAGS</code>.</p>
  
  <p>Should I change to <code>$(CC) $(OBJS) $(CXXFLAGS) $(CPPFLAGS) -o $(PROGRAM)</code> 
  or to <code>$(CC) $(OBJS) -o $(PROGRAM)</code>?</p>
  
  <p>Should I change to <code>$(PROGRAM): $(OBJS) *.h</code>,  so it rebuilds whenever <code>.h</code> files get changes?</p>
  
  <p>Any other improvements to it?</p>