4 ms·
CFLAGS := ${CFLAGS} CFLAGS += -ansi -std=99 What's the point of the first line? Why not just: CFLAGS += -ansi -std=99
by aaaaaaaaaaab 8y ago
CFLAGS := ${CFLAGS}
CFLAGS += -ansi -std=99
What's the point of the first line? Why not just:
CFLAGS += -ansi -std=99
- pooya13 8y agoMy guess is that the left hand side is a make variable while the right hand side is an environment variable. However the make manual says “Every environment variable that make sees when it starts up is transformed into a make variable with the same name and value.“ so maybe it’s not necessary?...
- pooya13 8y agoThis reminds me why I stopped visiting HN. People down vote you for trying to help! Screw whoever asshole that downvoted me even though I prefixed my answer with “My GUESS is...”.
- dewhelmed 8y agoBecause CFLAGS may not be set in the environment, resulting in concatenation to an undefined variable error.
- jgrahamc 8y agoNo such error occurs. $ cat Makefile FOO += foo all: ; @echo $(FOO) $ make foo
- dewhelmed 8y agoMy bad, I felt like I've seen that error pop up before in my Makefiles, but I should have double-checked before commenting.
- jschwartzi 8y agoThere's no such thing as an undefined variable in Make. The variable expands to text. Variables which are not defined by definition expand to no text.
- dewhelmed 8y agoMy bad, I felt like I've seen that error pop up before in my Makefiles, but I should have double-checked before commenting.
- jgrahamc 8y agoIf turns CFLAGS from a recursive variable to a simple one. Hence it will not be re-expanded every time it is used. This is a speed optimization. $ cat Makefile CFLAGS = -Wall $(info $(flavor CFLAGS)) CFLAGS := $(CFLAGS) $(info $(flavor CFLAGS)) $ make recursive simple But TFA says that the author is using := to prevent a recursive definition. It's unclear why the author doesn't just += without doing = or := (unless they want the recursive to simple conversion I talk about above). My guess is the author sligthly misunderstood the handling of the environment inside a Makefile.
- smitherfield 8y agoSpeaking of, why both -ansi and -std=99 [sic[1]]? [1] should be -std=c99
- danyspin97 8y agoI've used these comments[1] as source for writing the CFLAGS. Did I misunderstood? [1] https://stackoverflow.com/a/2193647 https://stackoverflow.com/a/2193647