Is this the intended behaviour?

% cat Makefile
.PHONY: all foobar
all: foobar
foo%:; echo $@
% cat foobar
cat: foobar: No such file or directory
% make
make: Nothing to be done for 'all'.

(Wherease when "foobar" is not listed as .PHONY, echo is run.)

"make -d" reveals:

Considering target file 'foobar'.
File 'foobar' does not exist.
Finished prerequisites of target file 'foobar'.
Must remake target 'foobar'.
Successfully remade target file 'foobar'.

So make thinks foobar has an empty recipe, instead of using the
pattern rule.

I know that specific rules take precendence over pattern rules (e.g.
if I had a rule "foobar:;", I wouldn't expect the echo to run), as
the documentation says: "The rules you write take precedence over
those that are built in." But here foobar has no specific rule, just
appears as a pseudo-prerequisite of ".PHONY".

Apparently this is enough to prevent make from using the pattern
rule as well, but I couldn't find this mentioned in the
documentation, so I wonder whether it's meant to be so or a bug?

_______________________________________________
Bug-make mailing list
Bug-make@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-make

Reply via email to