Compile kernel: kuconfig/kdconfig/make clean/mrproper/distclean/menuconfig

来源:互联网 发布:昆士兰会计硕士知乎 编辑:程序博客网 时间:2024/05/20 11:25

1. compilation

内核编译时, 到底用make clean, make mrproper还是make distclean

在编译内核时,  被make clean, make mrproer 和 make distclean搞的纠结, 稍微总结一下这三者之间的区别:
 
解压内核源码包后, 到内核源代码目录树的顶层目录, 执行
# make help
Cleaning targets:
  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
  distclean       - mrproper + remove editor backup and patch files
看帮助可以发现删除的文件范围从小到大依次为: make clean < make mrproper < make distclean, 查看源码目录树的顶层目录下的Makefile求证, 可以发现:
clean: archclean $(clean-dirs)
        $(call cmd,rmdirs)
        $(call cmd,rmfiles)
        @find . $(RCS_FIND_IGNORE) \
                \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
                -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
                -o -name '*.symtypes' -o -name 'modules.order' \
                -o -name 'Module.markers' \) \
                -type f -print | xargs rm -f
 
mrproper: clean archmrproper $(mrproper-dirs)
        $(call cmd,rmdirs)
        $(call cmd,rmfiles)
 
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 mrproper, 会先执行make clean, 执行make distclean之前, 会先执行make mrproper。
再回到make help的结果:
make clean      删除大多数的编译生成文件, 但是会保留内核的配置文件.config, 还有足够的编译支持来建立扩展模块
make mrproper   删除所有的编译生成文件, 还有内核配置文件, 再加上各种备份文件
make distclean  mrproper删除的文件, 加上编辑备份文件和一些补丁文件。
 
其 实, 对于一个刚刚从kernel.org上下载的内核源码包, 可以不用执行make clean/make mrproper/make distclean, 因为源码包的状态本身就是clean的。
 
另外, 就算编译过内核之后, 需不需要clean一下,  个人觉得应该具体问题具体对待, 且看linuxsir上也有兄弟对这个问题有疑问:
Q: 很多内核编译的教程都说在make之前要先make mrproper,清除以前编译的产物。但编译器/链接器本身就会检查文件的日期,并确定是否需要重新编译/链接。如果清除了,很多以前已经编译过的代码 又得重新编译。如果说这样能节省硬盘空间的话,那只有那些先前编译过而现在不再需要的模块的空间被节省了,而代价则是编译时间延长了。个人觉得得不偿失, 至少不需要每次编译都来一次make mrproper。
 
A:  我没有make mrproper,每次修改内核配置后很快就能编译完成,很方便,也没发现什么问题
如果make不能确定那些文件要重新编译,那还要make做什 么
个人观点,尽信书则不如无书,实践出真知,呵呵
 
A:  不执行make mrproper是否出错,取决于Makefile的智能化程度。如果Makefile没能完成你所要求的全部改动,很可能编译出来的内核不如你所愿,甚 至可能导致panic。建议重新编译的时候注意看看改动是否都落实了。



android: use make menuconfig, issue the following command in root dir

# make -C kernel/ O=../out/target/product/scx35_sp8830ec/obj/KERNEL/ menuconfig


kuconfig  相当与make menuconfig; cp .config kernel/arch/arm/configs/xxxxx_defconfig


kdconfig 相当与用xxxxx_defconfig来生成.config文件


kmconfig 相当与make menuconfig


uclean/kclean clean uboot/kernel

uconfig 重新配置uboot

umk/kmk 只编译u-boot/kernel

2 Add new feature

2.1 Add the dir to Makefile in driver/video

obj-$(CONFIG_FB_SCX35L)           += sprdfb/

2.2 Add the Kconfig and Makefile in dir: sprdfb

cd sprdfb
such as(Makefile):

obj-$(CONFIG_FB_SCX35L) := sprdfb_main.o sprdfb_panel.o sprdfb_dispc.o \                sprdfb_mcu.o sprdfb_rgb.o sprdfb_mipi.o sprdfb_i2c.o \                sprdfb_spi.o sprdfb_dsi.o  sprdfb_chip_common.o sprdfb_chip_8830.o
(Kconfig):

config FB_SCX35L        boolean "FPGA SharkL frame buffer support "        depends on FB && ARCH_SCX35L        select FB_CFB_FILLRECT        select FB_CFB_COPYAREA        select FB_CFB_IMAGEBLIT        help          Frame buffer driver for SharkL based boards.

config FB_LCD_NT35516_MIPI        boolean "support NT35516 mipi panel"        depends on FB_SC8825 || FB_SCX35 || FB_SCX30G || FB_SCX35L        default y

and so on.
2.3 Use kuconfig to generate default configuration to dir: arch/arm/configs/...

2.4 make bootimage