分析1:built.in.o的生成过程
step1:“根Makefile“中 "u-boot-dirs目标" 执行scripts/Makefile.build 且obj=cmd
PHONY += $(u-boot-dirs)
$(u-boot-dirs): prepare scripts
$(Q)$(MAKE) $(build)=$@
解释:
1. u-boot-dirs为一系列的目录
2.对应展开后的其中一条命令为:@make -f $(srctree)/scripts/Makefile.build obj=cmd
################################################
libs-y += cmd/
libs-y += common/
libs-y += env/
libs-y := $(sort $(libs-y))
#匹配/目录,然后替换中去掉/
u-boot-dirs := $(patsubst %/,%,$(filter %/, $(libs-y))) tools examples
step2:“根Makefile“中 "u-boot-dirs目标" 执行scripts/Makefile.build 且obj=cmd
$(LD) $(ld_flags) -r -o built.in.o $(filter $(obj-y), $^)
############################# scripts/Makefile.build ##################
########## 代码块1 src =obj(src=cmd) #######################
# Modified for U-Boot
prefix := tpl
src := $(patsubst $(prefix)/%,%,$(obj))
ifeq ($(obj),$(src))
prefix := spl
src := $(patsubst $(prefix)/%,%,$(obj))
ifeq ($(obj),$(src))
prefix := .
endif
endif
########## 代码块2 auto.conf 和autoconf.mk组合配置 ##############
# Read auto.conf if it exists, otherwise ignore
# Modified for U-Boot
-include include/config/auto.conf
-include $(prefix)/include/autoconf.mk
include scripts/Makefile.uncmd_spl
include scripts/Kbuild.include
########## 代码块3 inclue cmd/Makefile(包含obj-y obj-m obj-) #################
# The filename Kbuild has precedence over Makefile
kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src))
kbuild-file := $(if $(wildcard $(kbuild-dir)/Kbuild),$(kbuild-dir)/Kbuild,$(kbuild-dir)/Makefile)
include $(kbuild-file)
########## 代码块4 builtin-target=cmd/built-in.o #################
ifneq ($(strip $(obj-y) $(obj-m) $(obj-) $(subdir-m) $(lib-target)),)
builtin-target := $(obj)/built-in.o
endif
########## 代码块4 builtin-target=cmd/built-in.o #################
#
# Rule to compile a set of .o files into one .o file
#
ifdef builtin-target
quiet_cmd_link_o_target = LD $@
# If the list of objects to link is empty, just create an empty built-in.o
cmd_link_o_target = $(if $(strip $(obj-y)),\
$(LD) $(ld_flags) -r -o $@ $(filter $(obj-y), $^) \
$(cmd_secanalysis),\
rm -f $@; $(AR) rcs$(KBUILD_ARFLAGS) $@)
$(builtin-target): $(obj-y) FORCE
$(call if_changed,link_o_target)
targets += $(builtin-target)
endif # builtin-target