Sideshow Bob
Sideshow Bob

Reputation: 4716

No rule to make (phony) target

I am trying to create a pattern rule for a phony target foo-test which should build an actual file foo-test1:

%-test: %-test1

%-test1:
    touch $@

When I call make --just-print foo-test I get No rule to make target: foo-test.

Yet I would expect make to see that foo-test depends on foo-test1 and apply the second rule to make foo-test1. How can achieve this behaviour? (I have tried declaring %-test and %-test1 as .PHONY; it doesn't help).

Upvotes: 0

Views: 493

Answers (1)

MadScientist
MadScientist

Reputation: 101061

This:

%-test: %-test1

does not define a pattern rule. It deletes a pattern rule. See https://www.gnu.org/software/make/manual/html_node/Canceling-Rules.html

You have to give it a recipe if you want to make a pattern rule. Something like this is sufficient:

%-test: %-test1 ;

Upvotes: 1

Related Questions