The .PHONY rule in a Makefile is used to declare that certain targets are not associated with actual files. This is important for targets that perform actions rather than produce files, such as clean, install, or test. By declaring a target as .PHONY, you ensure that Make will always execute the commands associated with that target, regardless of whether a file with the same name exists.
Here’s an example of how to use the .PHONY rule:
.PHONY: clean
clean:
rm -f hello hello.o utils.o
In this example, the clean target is marked as phony, so running make clean will always execute the rm command, even if a file named clean exists in the directory.
