Makefile:
SHELL := /bin/bash
all:
.PHONY: /home/% /home/dhp
/home/%:
@echo do user $* USERRRRRR
plop: /home/dhp
@echo plop
Shell:
# ll /home/
total 4
drwxr-xr-x 3 dhp dhp 4096 Mar 22 08:53 dhp
# make plop
plop
I know the topic have been asked many times, and the answer is in https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html https://www.gnu.org/software/make/manual/html_node/Special-Targets.html https://www.gnu.org/software/make/manual/html_node/Chained-Rules.html#Chained-Rules but I don't understand why in my case USERRRRRR string is not printed. /home/dhp is a direct dep of my target, and, due to .PHONY it should be run even if file exists.
If I have no other choice, I may accept to make /home/%: depend on a very fresh file (which will be always more recent than /home/% by using, for example, the lock of PID file of current process, or depend on a virtual target which will never create anny file), but I would consider that as dirty. I don't think .INTERMEDIATE can help here.
EDIT: more tests:
SHELL := /bin/bash
all:
.PHONY: FORCE
.PHONY: /home/%
.PHONY: /home/dhp
FORCE:
/home/%: FORCE
@echo do user $* USERRRRRR
plop: /home/dhp
@echo plop
=>
# make plop
plop
...
SHELL := /bin/bash
all:
.PHONY: FORCE
FORCE:
/home/%: FORCE
@echo do user $* USERRRRRR
plop: /home/dhp
@echo plop
=>
# make plop
do user dhp USERRRRRR
plop
so, making my target phony prevents from running it ? This is strictly the opposite of what the documentation states:
When it is time to consider such a target, make will run its recipe unconditionally, regardless of whether a file with that name exists or what its last-modification time is.