在编译内核模块时,会用到make mrproper,目的是把下载的内核还原到初始状态(清除掉.o文件,清除掉一些在make之后生成的备份文件,甚至还清除了.config配置文件)。
在make mrproper时,会首先调用make clean。
至于要清除些什么东西,要查看内核源文件中的Makefile,仅仅一个Makefile就有1500行,不得不感慨它的强大。
Makefile里这么描述mrproper的:
“Delete all generated files, including .config”
对应的规则为:
mrproper: rm-dirs := $(wildcard $(MRPROPER_DIRS)) mrproper: rm-files := $(wildcard $(MRPROPER_FILES)) mrproper-dirs := $(addprefix _mrproper_,Documentation/DocBook scripts) PHONY += $(mrproper-dirs) mrproper archmrproper $(mrproper-dirs): $(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@) mrproper: clean archmrproper $(mrproper-dirs) $(call cmd,rmdirs) $(call cmd,rmfiles)
虽然前面几条,看不懂,但最后一条:
mrproper: clean archmrproper $(mrproper-dirs)
明确的说明了在执行make mrproper之前会先make clean、make archmrproper及make $(mrproper-dirs)。
还有扩展一下:
make distclean
Makefile里有这么几行:
distclean: mrproper @find $(srctree) $(RCS_FIND_IGNORE) \ \( -name '*.orig' -o -name '*.rej' -o -name '*~' \ -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \ -o -name '.*.rej' -o -size 0 \ -o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \ -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