I'm just starting to really grok the inner workings of make. Yet I do not understand why the following doesn't work:
test%: test%.foo
@echo $@
@echo $<
all: test1 test2
.PHONY: all test1 test2
Expected behavior:
$ make
test1
test1.foo
test2
test2.foo
# 1,2 Order not important
However, I get:
$ make
make: Nothing to be done for `all'.
("make all", "make test1", etc make no difference).
Can someone explain why the PHONY test rules aren't being executed?
Excerpt from the GNU make manual.
Since it knows that phony targets do not name actual files that could be remade from other files, make skips the implicit rule search for phony targets (see section Using Implicit Rules). This is why declaring a target phony is good for performance, even if you are not worried about the actual file existing.
This means that as your test1
and test2
targets are phony, make does not search for implicit rules for them. Even if what you use is more accurately named pattern rules, all pattern rules are implicit rules.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With