看了一些文章,对伪目标的描述也不尽相同,下面有两个示例和解释:
示例1:
.PHONY: install
install:
cp hello /usr/local/bin/hello
伪目标 install 表示即使当前文件夹内有 install 这个文件,但是 make 执行的仍然是 Makefile 内部的 install,不会使用外部的文件,相当于进行了一个内部封装。
示例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
上面的 Makefile 文件中,.PHONY 是个伪目标,形式上是一个目标,但是不需要依赖,伪目标一般只是为了执行目标下面的命令(比如 clean 就是伪目标)。
问题:
没有太理解上面说的伪目标,请大佬再帮解释一下,谢谢大佬。
https://blog.csdn.net/haoel/a...