Chris G.
Chris G.

Reputation: 25974

Do you need .PHONY if no prerequisites

When using make for just commands, do you then need to add .PHONY targets?

Note: I do not have a file called "all"

# Do I need this, if no prerequisites
.PHONY somecommands

# Taget with no prerequisites
somecommands:
    @echo hello

Upvotes: 0

Views: 58

Answers (1)

uzsolt
uzsolt

Reputation: 6027

.PHONY is needed when the target isn't a file.

This is the Makefile:

all:
    @echo DONE

Try to test:

$ make all                                                                                                                               
DONE
$ touch all
$ make
`all' is up to date.

Upvotes: 1

Related Questions