What is the intended use of EXTRA_CFLAGS
?
I see it in some contexts but I've never understood why one wouldn't just append flags to CFLAGS
instead of EXTRA_CFLAGS
.
I first thought there was something to do with how make has defined its implicit rules, but this did not seem to be the case. As I understand it, there are no uses of EXTRA_CFLAGS
in the make implicit rules, correct?
I would appreciate any enlightenment.
Well, that's not any part of standard make or built-in make rules, so it's just a convention that some of the makefiles you're used to have used. The reason why it's done as a separate flag is so you can use it on the command line:
make EXTRA_CFLAGS=-O3
Command line variable assignments override any setting of the variable inside the makefile, so appending doesn't work. That is:
$ cat Makefile
CFLAGS += -Dfoo
all: ; @echo '$(CFLAGS)'
$ make CFLAGS=-Dbar
-Dbar
$ make CFLAGS+=-Dbar
-Dbar
both will show -Dbar
, not -Dfoo -Dbar
.
That's why it's a separate flag. In automake environments, they explicitly preserve CFLAGS
for the user to provide on the command line and all "normal" flags are put into other variables.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With