Reputation: 21
I am writing a simple Makefile for practicing .PHONY target
#!/bin/make
dir/%/compile:
@echo "The target '$@ had been built'"
In my working directory, the directory layout is as below
├── dir
│ └── subdir
│ └── compile
└── Makefile
When I type make dir/subdir/compile, it claimed the target is up to date as below
make: `dir/subdir/compile' is up to date.
It's right. But it still claimed the target is up to date even a .PHONY target is added as below
#/bin/make
.PHONY: dir/%/compile
dir/%/compile:
@echo "The target '$@ had been built'"
As I know .PHONY can build the target unconditionally no matter the target exists or not However, it seemed not works as it should be. Could anyone help me figure it out? Thanks
Upvotes: 1
Views: 521
Reputation: 100836
You cannot use patterns with .PHONY
. Only true target names will work. You're just saying that the literal target named dir/%/compile
is phony.
Upvotes: 3