News for hackers. Stuff that matters.
Re:Makefiles – Best Practices by aaaaaaaaaaab on Friday February 01, 2019 @11:40AM (#19055644)

    CFLAGS := ${CFLAGS}
    CFLAGS += -ansi -std=99
What's the point of the first line? Why not just:

    CFLAGS += -ansi -std=99
Re:Makefiles – Best Practices by jgrahamc on Friday February 01, 2019 @12:07PM (#19055951)
If 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.
Re:Makefiles – Best Practices by smitherfield on Friday February 01, 2019 @02:52PM (#19057812)
Speaking of, why both -ansi and -std=99 [sic[1]]?

[1] should be -std=c99

Re:Makefiles – Best Practices by danyspin97 on Saturday February 02, 2019 @09:57AM (#19063261)
I've used these comments[1] as source for writing the CFLAGS. Did I misunderstood?

[1] https://stackoverflow.com/a/2193647

Re:Makefiles – Best Practices by dewhelmed on Friday February 01, 2019 @12:00PM (#19055869)
Because CFLAGS may not be set in the environment, resulting in concatenation to an undefined variable error.
Re:Makefiles – Best Practices by jgrahamc on Friday February 01, 2019 @12:04PM (#19055912)
No such error occurs.

    $ cat Makefile
    FOO += foo

    all: ; @echo $(FOO)
    $ make
    foo
Re:Makefiles – Best Practices by dewhelmed on Monday February 04, 2019 @09:54PM (#19082713)
My bad, I felt like I've seen that error pop up before in my Makefiles, but I should have double-checked before commenting.
Re:Makefiles – Best Practices by jschwartzi on Friday February 01, 2019 @05:26PM (#19059368)
There'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.
Re:Makefiles – Best Practices by dewhelmed on Monday February 04, 2019 @09:54PM (#19082715)
My bad, I felt like I've seen that error pop up before in my Makefiles, but I should have double-checked before commenting.
Re:Makefiles – Best Practices by pooya13 on Friday February 01, 2019 @11:52AM (#19055784)
My 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?...
Re:Makefiles – Best Practices by pooya13 on Saturday February 09, 2019 @01:19PM (#19123727)
This 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...”.