Linux

為什麼同時使用 make cleanmake mrproper

  • February 23, 2022

它是寫在linux核心Makefile中的

clean - Remove most generated files but keep the config and
       enough build support to build external modules
mrproper - Remove all generated files + config + various backup files

並且在拱形文件中指出

要完成準備工作,請確保核心樹絕對乾淨;

$ make clean && make mrproper

那麼如果make mrproper做一個更徹底的刪除,為什麼要make clean使用呢?

如Linux 核心 Makefile中的註釋所述,清理分三個級別進行:

###
# Cleaning is done on three levels.
# make clean     Delete most generated files
#                Leave enough to build external modules
# make mrproper  Delete the current configuration, and all generated files
# make distclean Remove editor backup files, patch leftover files and the like

根據 Makefile,mrproper目標取決於clean目標(參見第 1421 行)。此外,distclean目標取決於mrproper.

因此,執行make mrproper就足夠了,因為它還會刪除與clean目標所做的相同的事情(以及更多)。

目標是在 1993 年添加的mrproper(Linux 0.97.7)並且一直依賴於clean目標。意味著永遠不需要像在make clean && make mrproper.

歷史參考:https ://archive.org/details/git-history-of-linux

引用自:https://unix.stackexchange.com/questions/387640