4 ms·
That Makefile is... weird. Why issue a "make sub-target" command? Makefiles are all about understanding dependencies, so you should actually be doing targe
by rcarmo 11y ago
That Makefile is... weird. Why issue a "make sub-target" command? Makefiles are all about understanding dependencies, so you should actually be doing
target: dependency
<commands>
...instead of
target:
make dependency
<commands>
Doing it this way actually breaks dependency checks. It's just plain wrong.
Here's a "proper" Makefile, complete with conditionals, expansion, etc.:
https://github.com/rcarmo/sushy/blob/master/Makefile https://github.com/rcarmo/sushy/blob/master/Makefile
...and here's one of my Go Makefiles (no sub-targets here, but does vendoring in a way that's quite similar to what Go 1.5 turned out to adopt)
https://github.com/rcarmo/go-rss2imap/blob/master/Makefile https://github.com/rcarmo/go-rss2imap/blob/master/Makefile
(edit: whitespace)
- johannesboyne 11y agoThanks rcarmo for bringing this up. You're right, it is a better, and the only right, approach to declare the dependencies like you proposed. I've updated the code!
- austinpray 11y agoOne thing to point out specifically about "proper" Makefiles: the author should be marking his `.PHONY` targets (https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html https://www.gnu.org/software/make/manual/html_node/Phony-Tar...) and giving sources. This gives you incremental builds for free. One of my Makefiles: https://github.com/liveplant/liveplant-server/blob/master/Makefile https://github.com/liveplant/liveplant-server/blob/master/Ma... Definitely open to feedback on the above. Seems like my Makefile doing pretty much the same thing as yours @rcarmo.
- rcarmo 11y agogood call on the .PHONY.