Re: How do I pass compiler switches into a Make file?



On 16 June, 19:51, General Schvantzkoph <schvantzk...@xxxxxxxxx>
wrote:

Is there a way to set a default value for the flags in the Makefile which
would be overwritten by the command line argument?

RTFM. Here's a quick example that you might find enlightening:

bash-3.2$ make clean a
rm -f a.o b.o c.o
cc -pg -Dbubba -c -o b.o b.c
cc -pg -Dbubba -c -o c.o c.c
cc -pg -Dbubba a.c b.o c.o -o a
bash-3.2$ make clean a CFLAGS=-g
rm -f a.o b.o c.o
cc -g -Dbubba -c -o b.o b.c
cc -g -Dbubba -c -o c.o c.c
cc -g -Dbubba a.c b.o c.o -o a
bash-3.2$ make clean a CFLAGS=-g CPPFLAGS=-Dfoo
rm -f a.o b.o c.o
cc -g -Dfoo -c -o b.o b.c
cc -g -Dfoo -c -o c.o c.c
cc -g -Dfoo a.c b.o c.o -o a
bash-3.2$ cat Makefile

CPPFLAGS = -Dbubba
CFLAGS = -pg
a: b.o c.o
clean:
rm -f a.o b.o c.o
.