Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

A far better way to learn about GNU make would be to read the actual manual.

https://www.gnu.org/software/make/manual/

This doesn't seem like a well thought out introduction. There's quite a lot of randomness. For example, the first makefile says:

    This makefile will always run. The default target is some_binary,    
    because it is first.

    some_binary:
	echo "nothing"
Actually, it's not true that that will always echo nothing because some_binary isn't declared as phony and so if some_binary exists on the CWD echo "nothing" will not happen.

Also, the language here is weird. The tutorial talks about makefiles running and targets calling targets.

4.8 states:

    1) We do not use *.o, because that is just the string *.o, 
    which might be useful in the commands, but is only one 
    target and does not expand."
That's not true. Consider the following

    *.foo: ; @echo $@
If there are any files in the CWD that match *.foo then it is expanded and rules created for each file.


I appreciate what the person is trying to do, just quickly jot down some notes for new people.

For the first concern, phony is mentioned a bit later, likely did not want to start-off with added complexity for the reader.

For the second point, but then bar.foo and baz.foo are already there and would be up to date, so what's the point in that? Most cases it's not what you want, that note is pointing-out a common gotcha.

So though precisely you are totally correct, it's not what the author was going for.

Some opinion of mine now. I do not like GNU make document linked. It goes into too much detail and then close to the end is just a short warnings about how so much of the above was GNU specific. I prefer the BSD make man page, but obviously that is not a good starting point for someone new to make. I recommend the book "Managing Projects with make" personally.


Another case of "there's so much more than it appear". People should really RThisFM.


Related: "recursive make considered harmful" (http://aegis.sourceforge.net/auug97.pdf)


Yeah, RTFM! :)


Not sure if your comment was meant to be sarcasm, but I do find the GNU Make Manual very clear and well written.

For example, it starts with a rough description of what a Makefile is composed of:

https://www.gnu.org/software/make/manual/html_node/Rule-Intr...

And then directly jumps into nice a real-world example:

https://www.gnu.org/software/make/manual/html_node/Simple-Ma...

This is a good compromise between abstract and concrete knowledge.

Most manuals either cover only some special cases and leave you alone to find out what's more. Then they cover only the whole syntax as BNF, or a whole API doc, or something. But nothing in between, drawing the connection between practical usage and abstract description of what's all possible.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: