Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Why do we need to add `.PHONY` for every target ? This is one of the things I utterly despise about make.


.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.


Because 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”


If 'make' was called makefile, I don't think it'd be so popular. Naming is important


You 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.


It's a GNU thing :P




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: