I am new to makefile, I am trying to add a make debug mode.
I have the following:
CXXFLAGS=-Wall -c
debug: $(EXECUTABLE)
CXXFLAGS+=-pg
all:
....
for some reason it assigns it and when I put make debug it give me
CXXFLAGS+=-pg
/bin/sh: CXXFLAGS+=-pg: not found
make: *** [debug] Error 127
Is there any way to do and avoid writing the entire all command again in the debug except with -pg flags?
I tried to remove debug: target
and CXXFLAGS was concatenated with -pg flags successfully
If you are using gnumake, just add:
Note that it is typical to define
allfirst so that it is the default. If the rules fordebugappear beforeallin the Makefile,debugbecomes the default (if it is first).