I still don't understand why "phony" rules in Makefiles have ".PHONY" as their target. It would be much more logical as a prerequisite.
Do I have to elaborate on this? If A
depends on B
and B
is phony, then A
is phony too. So the dependency graph .PHONY
←B
→A
is waay surprising compared to .PHONY
→B
→A
. (Another argument is that an implementation of make
must handle the .PHONY
target very special.)
While this critique may seem rather theoretical (to pointless) - "since make is so ancient, its syntax is here to stay". But I am not proposing any syntax change, there is an alternative:
With GNU Make (at least), the following Makefile declares a phony target_A
:
target_A: _PHONY
touch target_A
_PHONY:
#noop
Question 1: This is so simple and clean, surely I am not its first inventor. In fact, given this alternative, why did make
ever need the special syntax?
It seems to me that this would also quite nicely solve questions about wildcards in phony targets, and could even shed some light on .PHONY's meaning when beginners doubt.
Question 2: Can you think of any circumstance where this approach is inferior? (Is invoking make .PHONY
of any use?)
(I should mention that while I have invoked other make
s, GNU Make is the only implementation that I have some experience with - reading and writing Makefiles.)