Makefile 取得目標列表

Makefile 取得目標列表

我使用下面的程式碼來獲得makefile targets list在大多數情況下都可以正常工作的程式碼,但是當您像這樣使用 makefile 時,您只會獲得兩個目標,而不是全部。

另一個命令不顯示

Makefile

command: ## Command description
    @echo "Execution log"

another-command: ## Command description
    @echo "Execution log"

command2: ## Command description
    @echo "Execution log" 

輸出是:

command
command2

我不明白為什麼我沒有收到命令another-command,這是代碼

`make -qp | awk -F':' '/^[a-zA-Z0-9][^$#\\\/t=]*:([^=]|$)/ {split($1,A,/ /);for(i in A)print A[i]}' `;

可能是什麼問題呢 ?

我用這個當參考 如何列出make中的所有目標?

在此輸入影像描述

答案1

$ make -qp | awk -F':' '/^[a-zA-Z0-9][^$#\\\t=]*:([^=]|$)/ {split($1,A,/ /);for(i in A)print A[i]}'
command
Makefile
command2
another-command

在我的字元集中是反斜線和製表符,在你的字元集中是反斜線、斜線和“t”。

而「另一個」包含一個「t」;-)

歸功於 Steeldriver

相關內容