On Wed, 2023-10-04 at 07:40 -0700, Bahman Movaqar wrote: > To make matters more complicated, in the previous snippet, if I > declare `echo.%' as below (w/o any pattern-rule prerequisite) then > Make behaves as expected.
Sorry but I don't really understand the problem. Maybe you can explain it more clearly: provide the shortest, simplest repro case and show both what happened and what you expected to see, and explain why you expected it. However, I want to push back on this understanding of .PHONY: > To my mind, whenever a target is marked as PHONY it is supposed to > simply ignore files with the same name. That's not really right. What .PHONY means is that make will _always_ rebuild that target (if it is considered), regardless of whether or not the file exists on the disk or whether it's out of date with respect to its prerequisites. It also means that implicit rules are not searched, for PHONY targets. See: https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html > Prerequisites of .PHONY are always interpreted as literal target > names, never as patterns (even if they contain ‘%’ characters). To > always rebuild a pattern rule consider using a “force target” (see > Rules without Recipes or Prerequisites). and: > The implicit rule search (see Using Implicit Rules) is skipped for > .PHONY targets. This is why declaring a target as .PHONY is good for > performance, even if you are not worried about the actual file > existing. I don't know if this information helps you understand the behavior you're seeing.