列出Makefile(包括被include的子目录下的Makefile)中所有的target

https://stackoverflow.com/questions/4219255/how-do-you-get-the-list-of-targets-in-a-makefile

 

方法1: make [space] [tab] [tab]

 

方法2:

.PHONY: list
list:
    @LC_ALL=C $(MAKE) -pRrq -f $(firstword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/(^|\n)# Files(\n|$$)/,/(^|\n)# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$'
posted @ 2022-07-22 15:01  yinhuachen  阅读(137)  评论(0编辑  收藏  举报