I've got the below simple Makefile which I use for compiling a C program:
all:
gcc -Wall -o myfile myfile.c lol_dht22/dht22.c lol_dht22/locking.c -lwiringPi -lcurl -lm
I want to add in a debug option so I can compile with -DDEBUG, so if I run
make
it compiles as normal. and if I run
make debug
it compliles with the debug flag.
I have read through a few tutorial but seems to be getting more and more confused.
Here's an example makefile that has the two options you are looking for.
You just needed to add a debug option, which is done in similar fashion to the 'all' option you had already declared.
If you want to know how to do it well, here it is. You don't do
make debug
, instead, you should callor
or
In addition to normal Make rebuild criteria, the following Makefile recognizes rebuilds based on
DEFS
.