3 ms·
You don't even need to specify that rule with GNU Make: building %.o is a built-in rule[1]. Personally, I tend to prefer specifying the files individually - it
by seabass-labrax 3y ago
You don't even need to specify that rule with GNU Make: building %.o is a built-in rule[1].
Personally, I tend to prefer specifying the files individually - it doesn't take up that much developer time nor much space in your Makefile, and makes it considerably easier to debug building issues when using a sandboxed environment (such as Nix or Bazel).
[1]: https://www.gnu.org/software/make/manual/html_node/Catalogue-of-Rules.html#index-C_002c-rule-to-compile https://www.gnu.org/software/make/manual/html_node/Catalogue...
- Joker_vD 3y agoDoesn't the built-in rule put files in the wrong folder? That is, the same folder the source file is in?
- seabass-labrax 3y agoYes; I've just tested it on GNU Make 4.3 and you are quite right. It only works when the *.c files are in the directory where object files are referenced. E.g.: example: build/blah.o echo nothing special .PHONY: example ...requires blah.c to be in build/.
- cozzyd 3y agoYou can probably use VPATH as a hack