u-boot(二) - 配置

一,u-boot的默认配置 xxx_defconfig

在顶层的Makefile中找到如下规则

%config: scripts_basic outputmakefile FORCE

    $(Q)$(MAKE) $(build)=scripts/kconfig $@

target -> %config -> mx6ull_14x14_evk_defconfig

command -> $(Q)$(MAKE) $(build)=scripts/kconfig $@ -> @make -f ./scripts/Makefile.build obj=scripts/kconfig mx6ull_14x14_evk_defconfig

1,依赖条件1:scripts_basic

# Basic helpers built in scripts/

PHONY += scripts_basic

scripts_basic:

    $(Q)$(MAKE) $(build)=scripts/basic

    $(Q)rm -f .tmp_quiet_recordmcount

->

scripts_basic:

    @make -f scripts/Makefile.build obj=scripts/basic

    @rm -f.tmp_quiet_recordmcount

所以依赖条件1变为:

scripts_basic:

    @make -f scripts/Makefile.build obj=scripts/basic

    @rm -f.tmp_quiet_recordmcount

然后将src下的makefile包含进来,最终src= scripts/basic下的makefile内容被编译。

查看scripts\basic目录下的makefile  编译了fixdep.c,用于解决依赖的问题。

2,依赖条件2:outputmakefile

PHONY += outputmakefile

# outputmakefile generates a Makefile in the output directory, if using a

# separate output directory. This allows convenient use of make in the

# output directory.

outputmakefile:

ifneq ($(KBUILD_SRC),)

    $(Q)ln -fsn $(srctree) source

    $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile \

        $(srctree) $(objtree) $(VERSION) $(PATCHLEVEL)

endif

KBUILD_SRC为空,此依赖条件并不执行。

3,依赖条件3:FORCE(不执行什么)

PHONY += FORCE

FORCE:

Makefile 伪目标 FORCE

force则通常是用户自定义的一个目标,它没有命令,也没有依赖,所以它总是被认为是需要更新的。

因此,如果一个目标依赖于force,那么这个目标的命令总是会被执行。

这在你想要强制执行某些命令时非常有用,例如清理操作或者强制重新编译。

4,此时目标变成

mx6ull_14x14_evk_defconfig:scripts_basic

    @make –f ./scripts/Makefile.build obj=scripts/kconfig mx6ull_14x14_evk_defconfig

结果是将scripts/kconfig目录下makefile文件的中目标被编译。即:scripts/kconfig/Makefile中的%_defconfig被匹配:

%_defconfig: scripts/kconfig/conf

    $(Q)$<$(silent) --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig)

展开后:

mx6ull_14x14_evk_defconfig:scripts/kconfig/conf

    $(Q)scripts/kconfig/conf --defconfig=arch/../configs/mx6ull_14x14_evk_defconfig Kconfig