u-boot版本: v2015.04
branch: imx_v2015.04_3.14.52_1.1.0_ga
#make mx6qecovacsandroid_config
Makefile:
%config: scripts_basic outputmakefile FORCE
$(Q)$(MAKE) $(build)=scripts/kconfig $@
scripts/kconfig/Makefile:
# Added for U-Boot (backward compatibility)
%_config: %_defconfig
@:
%_defconfig: $(obj)/conf
$(Q)$< --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig)
$<为$(obj)/conf,是个可执行程序,$(SRCARCH)是.., $@是mx6qecovacsandroid_defconfig
$(Kconfig)为根目录Kconfig。
所以 $(Q)$< --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig)
就是
$(obj)/conf --defconfig=configs/mx6qecovacsandroid_defconfig Kconfig
这个过程主要是把mx6qecovacsandroid_defconfig和Kconfig的定义导出到.config文件中,
下一步make会用到它,其中Kconfig会递归包含相应目录下的Kconfig,如下列出是我们关注的部分:
source "arch/Kconfig"
arch/Kconfig:
source "arch/arm/Kconfig"
arch/arm/Kconfig:
source "board/freescale/mx6qecovacs/Kconfig"
包含到了我们自己定义的Kconfig了!
board/freescale/mx6qecovacs/Kconfig:
if TARGET_MX6QECOVACS
config SYS_BOARD
default "mx6qecovacs"
config SYS_VENDOR
default "freescale"
config SYS_SOC
default "mx6"
config SYS_CONFIG_NAME
default "mx6qecovacs"
endif
这几个参数和u-boot_v2009.08中的就如出一辙了,所以其实只是编译的方法不一样而已。
新版为了兼容性能更好,使用了和kernel一样的编译方法。先利用conf解析Kconfig生成.config,
之后编译系统会想将以.config生成include/config/auto.conf,然后Makefile和sripts/Makefile.build
会包含进来,这样子目录的Makefile就可以通过这些变量来确定哪些文件要被编译进来了。
接下来调用
#make
默认目标是_all:
PHONY += all
ifeq ($(KBUILD_EXTMOD),)
_all: all
else
_all: modules
endif
all的定义:
#grep 'ALL-y' . -rns
./scripts/Makefile.spl:152:ALL-y += $(obj)/$(SPL_BIN).bin
./scripts/Makefile.spl:155:ALL-y += $(obj)/$(BOARD)-spl.bin
./scripts/Makefile.spl:159:ALL-y += $(obj)/sunxi-spl.bin
./scripts/Makefile.spl:163:ALL-y += boot.bin
./scripts/Makefile.spl:166:all: $(ALL-y)
./Makefile:731:ALL-y += u-boot.srec u-boot.bin System.map binary_size_check
./Makefile:760:ALL-y += u-boot-dtb-tegra.bin
./Makefile:762:ALL-y += u-boot-nodtb-tegra.bin
./Makefile:769:ALL-y += $(CONFIG_BUILD_TARGET:"%"=%)
./Makefile:792:all: $(ALL-y)
./arch/arm/config.mk:104:ALL-y += checkarmreloc
./arch/arm/config.mk:125:ALL-y += SPL
./arch/arm/config.mk:129:ALL-y += u-boot-dtb.imx
./arch/arm/config.mk:131:ALL-y += u-boot.imx
auto.conf会在编译之前会被间接调用到:
Makefile:
include/config/uboot.release: include/config/auto.conf FORCE
$(call filechk,uboot.release)
Makefile:
include/config/%.conf: $(KCONFIG_CONFIG) include/config/auto.conf.cmd
$(Q)$(MAKE) -f $(srctree)/Makefile silentoldconfig
@# If the following part fails, include/config/auto.conf should be
@# deleted so "make silentoldconfig" will be re-run on the next build.
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.autoconf || \
{ rm -f include/config/auto.conf; false; }
@# include/config.h has been updated after "make silentoldconfig".
@# We need to touch include/config/auto.conf so it gets newer
@# than include/config.h.
@# Otherwise, 'make silentoldconfig' would be invoked twice.
$(Q)touch include/config/auto.conf
scripts/kconfig/Makefile:
silentoldconfig: $(obj)/conf
$(Q)mkdir -p include/config include/generated
$< --$@ $(Kconfig)
$< --$@ $(Kconfig)也就是
$(obj)/conf --silentoldconfig Kconfig
使用conf生成auto.conf,autoconf.h这两个重要文件。
后面就是根据auto.conf和autoconf.h的定义生成u-boot.bin, u-boot.imx等这些文件
拿u-boot.imx举例:
./arch/arm/imx-common/Makefile:53:u-boot.imx: u-boot.bin $(IMX_CONFIG) FORCE
./Makefile:848:u-boot.bin: u-boot FORCE
./Makefile:1128:u-boot: $(u-boot-init) $(u-boot-main) u-boot.lds
./Makefile:678:u-boot-init := $(head-y)
./Makefile:679:u-boot-main := $(libs-y)
./arch/arm/Makefile:65:head-y := arch/arm/cpu/$(CPU)/start.o
./Makefile:627:libs-y += lib/
./Makefile:630:libs-y += fs/
./Makefile:631:libs-y += net/
./Makefile:632:libs-y += disk/
./Makefile:633:libs-y += drivers/
./Makefile:634:libs-y += drivers/dma/
./Makefile:635:libs-y += drivers/gpio/
./Makefile:636:libs-y += drivers/i2c/
......
./arch/arm/Makefile:63:libs-y += $(machdirs)
./arch/arm/Makefile:73:libs-y += arch/arm/cpu/$(CPU)/
./arch/arm/Makefile:74:libs-y += arch/arm/cpu/
./arch/arm/Makefile:75:libs-y += arch/arm/lib/
./arch/arm/Makefile:79:libs-y += arch/arm/imx-common/
......