[Mac/Linux] 讓 make 指令顯示更多除錯訊息

[Mac/Linux] 讓 make 指令顯示更多除錯訊息

有時候在執行 make 編譯專案時,

會突然遇到莫名其妙的錯誤,

從簡短的錯誤訊息裡,可能也未必理解問題發生的原因:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
make: *** No rule to make target `/test/kernal.zip', needed by `/test/output/dep.zip'. Stop.
make: *** No rule to make target `/test/kernal.zip', needed by `/test/output/dep.zip'. Stop.
make: *** No rule to make target `/test/kernal.zip', needed by `/test/output/dep.zip'.  Stop.

 

有沒有辦法讓 make 指令可以顯示更多資訊呢?

查了一下,可以用

make --debug
make --debug或是
make -d
make -d

後者通常會顯示更多的資料,類似每個 makefile 的規則都會顯示出來,

像下面是執行

make -d
make -d的結果:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
Considering target file `publish'.
File `publish' does not exist.
Considering target file `/test/output/dep.zip'.
File `/test/output/dep.zip' does not exist.
Considering target file `/test/kernal.zip'.
File `/test/kernal.zip' does not exist.
Looking for an implicit rule for `/test/kernal.zip'.
No implicit rule found for `/test/kernal.zip'.
Finished prerequisites of target file `/test/kernal.zip'.
Must remake target `/test/kernal.zip'.
make: *** No rule to make target `/test/kernal.zip', needed by `/test/output/dep.zip'. Stop.
Considering target file `publish'. File `publish' does not exist. Considering target file `/test/output/dep.zip'. File `/test/output/dep.zip' does not exist. Considering target file `/test/kernal.zip'. File `/test/kernal.zip' does not exist. Looking for an implicit rule for `/test/kernal.zip'. No implicit rule found for `/test/kernal.zip'. Finished prerequisites of target file `/test/kernal.zip'. Must remake target `/test/kernal.zip'. make: *** No rule to make target `/test/kernal.zip', needed by `/test/output/dep.zip'. Stop.
  Considering target file `publish'.
   File `publish' does not exist.
    Considering target file `/test/output/dep.zip'.
     File `/test/output/dep.zip' does not exist.
      Considering target file `/test/kernal.zip'.
       File `/test/kernal.zip' does not exist.
       Looking for an implicit rule for `/test/kernal.zip'.
       No implicit rule found for `/test/kernal.zip'.
       Finished prerequisites of target file `/test/kernal.zip'.
      Must remake target `/test/kernal.zip'.
make: *** No rule to make target `/test/kernal.zip', needed by `/test/output/dep.zip'.  Stop.

 

這些資訊有可能可以輔助找出錯誤,

不過有時也會因為資訊過多,更難找出有用的資訊。

因此,就當作一個輔助用的除錯技能吧~

 

參考資料:12. Debugging Makefiles – Managing Projects with GNU Make, 3rd Edition [Book]

(本頁面已被瀏覽過 827 次)

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料