3 ms·
For one-line recipes you can use semicolon foo.o: foo.c ; $(CC) $< If you find $(@D) hard to remember then do $(dir $@) instead. I wrote a book about GNU
by jgrahamc 7y ago
For one-line recipes you can use semicolon
foo.o: foo.c ; $(CC) $<
If you find $(@D) hard to remember then do $(dir $@) instead.
I wrote a book about GNU Make stuff (https://nostarch.com/gnumake https://nostarch.com/gnumake). If (and only if) you've read the GNU Make Manual from the FSF my book may help you. It's not for newbies. Don't want the book? All the articles are here: https://blog.jgc.org/2013/02/updated-list-of-my-gnu-make-articles.html https://blog.jgc.org/2013/02/updated-list-of-my-gnu-make-art...
- mbrock 7y agoWith backslashes before newlines you can do “multiline oneliners” too.
- jgrahamc 7y agoYep. One of the reasons I recommend the FSF manual is that it's a great introduction: https://www.gnu.org/software/make/manual/make.html#Splitting-Recipe-Lines https://www.gnu.org/software/make/manual/make.html#Splitting...
- dvdkhlng 7y agoYou can also do "multiline multiliners" by adding a target .ONESHELL. By overriding the variable SHELL, this allows you to put arbitrary multi-line scripts of your preferred programming language into makefile recipes. https://www.gnu.org/software/make/manual/html_node/One-Shell.html#One-Shell https://www.gnu.org/software/make/manual/html_node/One-Shell...
- sweettea 7y agoI can attest that it's a great book. It took my Make savvy from "pretty average" to "can build Makefiles that conform pretty decently to DRY". Not all of the book is useful to me, but it's a pleasant read and also a good well-indexed reference manual and I consult it at least monthly for fun.