Hacker News new | ask | show | jobs
by voigt 1324 days ago
I’m using Make for years now but usually only for very basic things. I always feel like it can do much more. Are there any good docs/books/articles about advanced usage of make?
6 comments

John Graham-Cumming (who's in this thread) wrote this book which I recommend:

https://nostarch.com/gnumake

I just noticed he did some screencasts that make up a course:

https://cloudflare.tv/shows/the-gnu-make-course

And here's links to a bunch of blog posts, from which I learned a lot:

https://blog.jgc.org/2013/02/updated-list-of-my-gnu-make-art...

Of course, the manual itself is really very good!

> Of course, the manual itself is really very good!

I actually don't agree with this. It's really good as a "user guide", but it's not the best as a "reference manual". It does not always clearly define terms, it freely mixes technical terms and hand-waving language, the writing style tends toward an "expository prose" that makes it hard to find specific pieces of information. In general, it could do with some reorganization using the Diátaxis principles: https://diataxis.fr/

It does have pretty good indices, and the quick reference is very helpful. However the HTML version (can't speak for the others) needs a lot more anchors, to make it easy to cross-link to individual elements, rather than just to chapter headings.

Huh. I actually thought the manual was great, but you make excellent points that I happen to agree with.

I'm very comfortable with the manual now, when I need to look something up, but that's because I've spent years looking things up in it, so I have a fairly good idea where to find things. Even so, it's sometimes confusing, e.g. where to find the definition of automatic variables like `$@`, `$^` and the like? When I started learning Make I remember it being infuriatingly hard to find the entry about a topic of interest.

While the manual is great (as are most of GNU's major works!) compared to most of the software ecosystem [1], you're quite right that it can still improve a lot.

[1] It's kind of amazing how even a company like Apple can have some pretty underwhelming documentation, see today's post about ExtensionKit https://news.ycombinator.com/item?id=33409558

The GNU make manual is well written and worth a read: > https://www.gnu.org/software/make/manual/make.html

My last workplace was very Makefile heavy and I used that as an excuse to read it. 10/10, would recommend/do it again.

I'm a big fan of using a standalone Makefile to manage the build of a project rather than having the IDE do it by "magic." Makefiles can also be used to handle a lot of repetitive processes or tasks that have to happen in a certain order based on dependencies -- they aren't limited to running compilers.
Very much agree.

[small plug] I've just done a presentation at $Work saying just that:

> By using Makefiles in your repos, you document and automate common "build" tasks.[1]

[1]: https://jiby.tech/presentation/makefiles/makefiles

I do this too. I can do anything with vim, Go and a Makefile.
Managing Projects with GNU Make, 3rd Edition

https://www.oreilly.com/library/view/managing-projects-with/...

O'Reilly is free via my public library. Yours might have the same

One thing that's helpful is to study how real-world projects use Make. Try to understand them, and look up pieces you're missing from the reference material. You'll probably end up having to dive into autotools, too, for some of it.
I recommend reading the GNU Make manual in its entirety.