File Targets and Phony Make Targets
A file target names a result whose existence and prerequisites can support a freshness decision. A phony target names an action in GNU Make.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Trace a name collision
A target named test can run a set of checks. If a filesystem entry also uses that name, an ordinary file-target rule can be treated as current under some conditions. Marking the action phony conveys its purpose. Compare directory entry types.
Express real artifacts separately
An archive target should normally describe the file it produces and what makes it stale. Build freshness decisions then apply to the archive without forcing every invocation to rebuild it.[1]
Distinguish a path output from a command goal
A target named report.txt can represent a concrete file updated when inputs require it. A goal named check may stand for running validations. A file that happens to be called check could otherwise affect whether the goal runs. GNU Make's phony declaration expresses that command goal. See build targets and results.
report.txt → compare file and prerequisite freshness
check declared phony → execute as a goal even if a file named check exists
Test both with the coinciding filename
Avoid attaching a phony requirement to ordinary freshness by accident
A phony prerequisite can cause its dependent target to be considered repeatedly. Make sure that is the intended behavior. Observe a no-change invocation of both the file target and command goal.