Makefile

PHONY

.phony 簡單來說就是告訴 makefile 這個 target 不是真實的檔案

這樣做的好處是:

  1. 不會因為建立同名的檔案而無法執行
# --- Makefile ----
.PHONY: file1

file1:
    echo "file1 "

這樣就算資料夾裡面產生了檔名為 file1 的檔案,也依然會執行 echo

  1. 提高 makefile 的執行效率,因為不用做檔案比對

參考

https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html

There are two reasons to use a phony target: 
1. to avoid a conflict with a file of the same name
2. to improve performance.

http://make.mad-scientist.net/constructed-macro-names/