What does Makefile pseudo-target mean?

read some articles, and the descriptions of pseudo-targets are not the same. Here are two examples and explanations:

example 1:

.PHONY: install
install:
    cp hello /usr/local/bin/hello

pseudo-target install means that even if there is an install file in the current folder, the make still executes the install, inside the Makefile and will not use the external file, which is equivalent to an internal encapsulation.

example 2:

all: gotool
    @go build -v .
clean:
    rm -f apiserver
    find . -name "[._]*.s[a-w][a-z]" | xargs -i rm -f {}
gotool:
    gofmt -w .
    go tool vet . |& grep -v vendor;true
ca:
    openssl req -new -nodes -x509 -out conf/server.crt -keyout conf/server.key -days 3650 -subj "/C=DE/ST=NRW/L=Earth/O=Random Company/OU=IT/CN=127.0.0.1/emailAddress=xxxxx@qq.com"

help:
    @echo "make - compile the source code"
    @echo "make clean - remove binary file and vim swp files"
    @echo "make gotool - run go tool "fmt" and "vet""
    @echo "make ca - generate ca files"

.PHONY: clean gotool ca help



the,. PHONY in the Makefile file above is a pseudo-target, formally a target, but does not need to be dependent, and the pseudo-target is usually just to execute the command under the target (for example, clean is a pseudo-target).

question:
I don"t quite understand the false target mentioned above. Please explain it again. Thank you, boss.

Oct.31,2021

By default,

Makefile assumes that the target should correspond to a file. What's the problem?

suppose we have a Makefile:

  https://blog.csdn.net/haoel/a.

Menu