The Phony marker in a make script #35
pwgit-create
announced in
File-Integrity-Scanner
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
The
.PHONYmarker in a Makefile is used to explicitly declare that certain targets are not actual files, butrather "phony" or fake targets. These targets represent actions or commands to be executed rather than file names.
When you declare a target with
.PHONY, it tellsmakethat the target should always be considered out-of-dateand therefore should always run its associated commands when invoked. This is important for targets like
clean,build, orhelpwhich are not tied to any specific files but represent actions.Here's an example explanation with one of the
.PHONYdeclarations from one of our Make files :In this case,
buildis marked as a phony target. This means that no matter what files exist in the project, whenyou run
make build, it will always execute the command to build the project using Maven.If
buildwere not declared as.PHONY,makemight think there's an actual file namedbuildand would onlyrun the commands if the file didn't exist or was outdated compared to its dependencies. This isn't what you want
for targets that represent actions, like cleaning or building a project.
Using
.PHONYhelps avoid potential confusBeta Was this translation helpful? Give feedback.
All reactions