makefilegnu-make

Does makefile .PHONY apply to the target alias names?


Consider the Makefile below, the command clean is declared as PHONY and has an alternative name c.

Does the PHONY attribute apply also to make c or just to make clean?

.PHONY: clean

clean c:
  rm -rf *.o

Solution

  • GMU Make doesn't have aliases; c and clean are separate targets that execute the same recipe but that could have different prerequisites. In this case, clean is a .PHONY prerequisite and c is not.

    (It's also easy to verify this yourself by creating a file named c and seeing if make c executes the recipe.)