ROM Android: Compile Kernel untuk MediaTek
MTK Kernel Builder
2012-09-24 16:44:41| 分类: Android | 标签:kernel android makefile |举报 |字号 订阅 KConfig 流程 关心点1: kernel builder: @makeMtk
make -f mediatek/build/makemtk.mk kernel
@mediatek/build/makemtk.mk
kernel/build.sh
@kernel/build.sh
make mediatek-configs nice make ${makeflags} ${makedefs} silentoldconfig make ${makeflags} ${makejobs} ${makedefs}
mediatek-configs 目标是怎么回事? 原来:
@kernel/Makefile
include $(srctree)/arch/$(SRCARCH)/Makefile
@kernel/arch/arm/Makefile
include ../mediatek/build/kernel/Makefile
@mediatek/build/kernel/Makefile
.config mediatek-configs: $(MTK_ROOT_GEN_CONFIG)/kconfig $(MTK_ROOT_GEN_CONFIG)
@echo "[COPY] $< --> $@" @cp $< $@ @echo "[COPY] $< --> .config" @cp $< .config
@kernel/Kconfig
source "arch/$SRCARCH/Kconfig"
@alps/kernel/arch/arm/Kconfig source "../mediatek/source/kernel/Kconfig" @alps/mediatek/source/kernel/Kconfig
31 if ARCH_MT6573 32 source "../mediatek/platform/mt6573/kernel/Kconfig/Kernel" 33 source "../mediatek/platform/mt6573/kernel/Kconfig/Board" 34 source "../mediatek/platform/mt6573/kernel/Kconfig/Drivers" 35 endif
@mediatek/platform/mt6573/kernel/Kconfig/Drivers
34 # Frame Buffer Related 35 menuconfig MTK_FB # FB_MT6516 FB_MT6573 36 bool "MediaTek Framebuffer Driver" 37 depends on FB 38 select FB_CFB_FILLRECT 39 select FB_CFB_COPYAREA 40 select FB_CFB_IMAGEBLIT 41 select FB_SOFT_CURSOR 42 ---help--- 43 This selects the MediaTek(R) frame buffer driver. 44 If you want to use MediaTek(R) frame buffer diver, say Y here. 45 If unsure, say N.
关心点2:
menuconfig是从哪里来?这样解释:
@alps/kernel/Makefile %config: scripts_basic outputmakefile FORCE
$(Q)mkdir -p include/linux include/config $(Q)$(MAKE) $(build)=scripts/kconfig $@
关于最后的一条命令: 我打印出来是这样的效果: make -f scripts/Makefile.build obj=scripts/kconfig menuconfig
不知道$(build)变量是怎么计算出来的,后来发现是这样的: @kernel/Makefile 329 include $(srctree)/scripts/Kbuild.include
@kernel/scripts/Kbuild.include 156 ### 157 # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.build obj= 158 # Usage: 159 # $(Q)$(MAKE) $(build)=dir 160 build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj
这样,就解析出来了上面的东西,
@kernel/scripts/Makefile.build
41 # The filename Kbuild has precedence over Makefile 42 kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src)) 43 kbuild-file := $(if $(wildcard $(kbuild-dir)/Kbuild),$(kbuild-dir)/Kbuild,$(kbuild-dir)/Makefile) 44 include $(kbuild-file)
这样就将 kernel/scripts/kconfig/Makefile 包含进去了。 查看文件 kernel/scripts/kconfig/Makefile 也就不用我多说了: @scripts/kconfig/Makefile xconfig: $(obj)/qconf
$< $(Kconfig)
gconfig: $(obj)/gconf
$< $(Kconfig)
menuconfig: $(obj)/mconf
$< $(Kconfig)
config: $(obj)/conf
$< --oldaskconfig $(Kconfig)
nconfig: $(obj)/nconf
$< $(Kconfig)
oldconfig: $(obj)/conf
$< --$@ $(Kconfig)
silentoldconfig: $(obj)/conf
$(Q)mkdir -p include/generated $< --$@ $(Kconfig) cp -f include/generated/autoconf.h include/linux/autoconf.h
关心点3:
.config 文件最终还会被更新一次:查看kernel log
[COPY] ../mediatek/config/out/s816_bef/autoconfig/kconfig --> mediatek-configs
[COPY] ../mediatek/config/out/s816_bef/autoconfig/kconfig --> .config
HOSTCC scripts/kconfig/conf.o SHIPPED scripts/kconfig/zconf.tab.c SHIPPED scripts/kconfig/lex.zconf.c SHIPPED scripts/kconfig/zconf.hash.c HOSTCC scripts/kconfig/zconf.tab.o HOSTLD scripts/kconfig/conf
scripts/kconfig/conf --silentoldconfig Kconfig
- configuration written to .config
cp -f include/generated/autoconf.h include/linux/autoconf.h
看kernel config 的程序 scripts/kconfig/conf 里面的代码有: scripts/kconfig/confdata.c:66: char *name = getenv("KCONFIG_CONFIG"); 而@Makefile 240:KCONFIG_CONFIG ?= .config export KCONFIG_CONFIG 可以获知这样的信息。
mediatek/config/out/s816_bef/autoconfig/kconfig: mediatek/config/mt6575/autoconfig/kconfig/platform
mediatek/config/common/autoconfig/kconfig/AEE mediatek/config/s816_bef/autoconfig/kconfig/project
mediatek/config/out/s816_bef/autoconfig @echo "[CONFIG] generate mediatek/config/out/s816_bef/autoconfig/kconfig" @cat mediatek/config/mt6575/autoconfig/kconfig/platform mediatek/config/common/autoconfig/kconfig/AEE
mediatek/config/s816_bef/autoconfig/kconfig/project | python mediatek/build/tools/config/merge-kconfig.py >
mediatek/config/out/s816_bef/autoconfig/kconfig
查了一下应该是: define .mtk.config.generate-auto-merge-rules .PHONY: mediatek-configs.$(1) mediatek-configs: mediatek-configs.$(1) mediatek-configs.$(1): $(2) $(2): PRIVATE_FILE_LIST := $(3) $(2): $(3) $(4)
@echo "[CONFIG] generate $(2)" @cat $(3) | $(5) > $(2)
endef
应该是这样类似的$(call .mtk.config.generate-auto-merge-rules,kconfig,xx.xx.xx) 更有可能是这样的:$(call .mtk.config.generate-auto-rules,xx,xx,xx) 这个就要自己去验证了。