3 ms·
Why do we need to add `.PHONY` for every target ? This is one of the things I utterly despise about make.
by lenkite 3y ago
Why do we need to add `.PHONY` for every target ? This is one of the things I utterly despise about make.
- jbverschoor 3y agoBecause make is misused Make is a tool to make files based on dependencies It was not created as a scripting language. It understands trees. It is not to “make” your project. It “makes” “files”
- jbverschoor 3y agoIf 'make' was called makefile, I don't think it'd be so popular. Naming is important
- paulddraper 3y ago.PHONY is how you distinguish between targets that are actual files vs targets that are virtual. Seems like useful information to me.... It's best practice, though the only time you need it is when a virtual target happens to have the same name as an actual file.
- tpoacher 3y agoYou don't. You can specify this in a single line. Unless the question was, why do I have to mark targets as PHONY more generally. In which case the answer is, you don't. You only do this when you want the recipe to always run when invoked, as opposed to the standard mode where invocation is conditional on the file being out-of-date.
- zie 3y agoIt's a GNU thing :P