make mrproper及mrproper的含义

来源:互联网 发布:拯救 孙楠 知乎 编辑:程序博客网 时间:2024/06/03 18:27

make mrproper及mrproper的含义

make mrproper及mrproper的含义

           Linux下面去编译项目之前,一般常会用make mrproper去先删除之前编译所生成的文件和配置文件,备份文件等,其中,mrproper和distclean,clean之间的区别,Linux内核源码根目录下面的makefile中,有很清晰的解释:
help:
 @echo  'Cleaning targets:'
 @echo  '  clean    - Remove most generated files but keep the config and'
 @echo  '                    enough build support to build external modules'
 @echo  '  mrproper   - Remove all generated files + config + various backup files'

 @echo  '  distclean   - mrproper + remove editor backup and patch files'


          mrproper到底是什么意思呢?为什么起了个这么个看起来如此诡异的名字。


            在英文wiki对Mr. Clean的解释提到了此点;
 http://en.wikipedia.org/wiki/Mr._Clean
  "make mrproper" is a command in the Linux kernel build system, used to "clean up" all files from past builds and restore the build directory to its original clean state. The reason "make mrproper" is used instead of "make mrclean" is because Linus Torvalds, the father of Linux, was familiar with the name "Mr. Proper" as this is the brand widely known in Europe."

          总的来说,就是:首先,我们要知道的是make mrproper想要做的事情是,清理旧的编译生成的文件及其他配置等文件,所以,相当于Clean,即我们在现实世界中用清洁剂去清洁卫生,清理旧的,不再需要的,脏东西。而现实世界中,保洁(P&G)公司的,有一个清洁产品方面的品牌,在美国叫做Mr.Clean,在欧洲叫做Mr.Proper,所以编译之前的清理旧东西的命令,原先是用的make mrclean,即make Mr.Clean。只是后来被Linux之父Linus Torvalds改成了make mrproper,即make Mr.Proper。所以,现在就变成了用make mrproper来清理之前的东西了。

make mrproper与make clean

 
编译内核时,我常用到make clean,把之前编译产生的.o文件清除,进行一些配置修改后,再重新编译。

在编译内核模块时,会用到make mrproper,目的是把下载的内核还原到初始状态(清除掉.o文件,清除掉一些在make之后生成的备份文件,甚至还清除了.config配置文件)。

在make mrproper时,会首先调用make clean。

至于要清除些什么东西,要查看内核源文件中的Makefile,仅仅一个Makefile就有1500行,不得不感慨它的强大。

Makefile里这么描述mrproper的:
“Delete all generated files, including .config”
对应的规则为:
Java代码  收藏代码
  1. mrproper: rm-dirs  := $(wildcard $(MRPROPER_DIRS))  
  2. mrproper: rm-files := $(wildcard $(MRPROPER_FILES))  
  3. mrproper-dirs      := $(addprefix _mrproper_,Documentation/DocBook scripts)  
  4.   
  5. PHONY += $(mrproper-dirs) mrproper archmrproper  
  6. $(mrproper-dirs):  
  7.     $(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@)  
  8.   
  9. mrproper: clean archmrproper $(mrproper-dirs)  
  10.     $(call cmd,rmdirs)  
  11.     $(call cmd,rmfiles)  

虽然前面几条,看不懂,但最后一条:
mrproper: clean archmrproper $(mrproper-dirs)
明确的说明了在执行make mrproper之前会先make clean、make archmrproper及make $(mrproper-dirs)。

还有扩展一下:
make distclean
Makefile里有这么几行:
Java代码  收藏代码
  1. distclean: mrproper  
  2.     @find $(srctree) $(RCS_FIND_IGNORE) \  
  3.         \( -name '*.orig' -o -name '*.rej' -o -name '*~' \  
  4.         -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \  
  5.         -o -name '.*.rej' -o -size 0 \  
  6.         -o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \  
  7.         -type f -print | xargs rm -f  

说明,在执行make distclean时,会先make mrproper。


至于make clean、make mrproper及make distclean的作用是什么,查到再添加。


more:
1、make clean、make mrproer 以及make distclean的区别
2、make mrproper及mrproper的含义
3、Linux内核——make mrproper与make clean的区别
4、Build Your Own Kernel Modules

0 0
原创粉丝点击