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