Declare all targets PHONY

前端 未结 2 1826
耶瑟儿~
耶瑟儿~ 2021-02-18 13:25

Consider a long makefile with numerous targets, all of which are PHONY (meaning that the target name does not represent an existing file).

I can do either:<

2条回答
  •  情书的邮戳
    2021-02-18 13:45

    One way to do it:

    .PHONY: $(shell sed -n -e '/^$$/ { n ; /^[^ .\#][^ ]*:/ { s/:.*$$// ; p ; } ; }' $(MAKEFILE_LIST))
    

    Works perfectly even for targets mentioned as dependencies.

提交回复
热议问题