b.bin,u-boot.nodtb.bin的依赖也是u-boot(在分析u-boot.bin时,已经分析过)。
4.1.4 spl/u-boot-spl.bin
spl/u-boot-spl.bin: spl/u-boot-spl
@:
spl/u-boot-spl: tools prepare \
$(if $(CONFIG_OF_SEPARATE)$(CONFIG_OF_EMBED)$(CONFIG_SPL_OF_PLATDATA),dts/dt.dtb) \
$(if $(CONFIG_OF_SEPARATE)$(CONFIG_OF_EMBED)$(CONFIG_TPL_OF_PLATDATA),dts/dt.dtb)
$(Q)$(MAKE) obj=spl -f $(srctree)/scripts/Makefile.spl all
4.1.5 u-boot.img、u-boot-dtb.img
u-boot-dtb.img u-boot.img u-boot.kwb u-boot.pbl u-boot-ivt.img: \ //CONFIG_SPL_LOAD_FIT=y
$(if $(CONFIG_SPL_LOAD_FIT),u-boot-nodtb.bin dts/dt.dtb,u-boot.bin) FORCE
$(call if_changed,mkimage)
CONFIG_SPL_LOAD_FIT在include/config/auto.conf中有定义,因此u-boot-dtb.img和u-boot.img的依赖是u-boot-nodtb.bin 和dts/dt.dtb。
4.1.6 u-boot.dtb
u-boot.dtb: dts/dt.dtb
$(call cmd,copy)
u-boot.dtb的依赖是dts/dt.dtb。
4.1.7 u-boot.elf
u-boot.elf: u-boot.bin
$(Q)$(OBJCOPY) -I binary $(PLATFORM_ELFFLAGS) $< u-boot-elf.o
$(call if_changed,u-boot-elf)
u-boot.elf的依赖是u-boot.bin。
4.2 目标cfg
# 顶层Makefile
u-boot.cfg spl/u-boot.cfg tpl/u-boot.cfg: include/config.h FORCE
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.autoconf $(@)
......
cfg: u-boot.cfg
依赖include/config.h是一个头文件,该头文件是在配置编译过程中自动生成的,详解参见UBOOT编译--- include/config.h、 include/autoconf.mk、include/autoconf.mk.dep、u-boot.cfg(三)。
5. 目标u-boot的依赖分析
u-boot-dirs := $(patsubst %/,%,$(filter %/, $(libs-y))) tools examples //重点关注(前半部分是提取$(libs-y)尾最后一个‘/’之前的内容,即编译所在目录)
libs-y := $(patsubst %/, %/built-in.o, $(libs-y))
u-boot-init := $(head-y)
u-boot-main := $(libs-y)
......
u-boot: $(u-boot-init) $(u-boot-main) u-boot.lds FORCE
+$(call if_changed,u-boot__)
ifeq ($(CONFIG_KALLSYMS),y) //未定义
$(call cmd,smap)
$(call cmd,u-boot__) common/system_map.o
endif
......
# The actual objects are generated when descending,
# make sure no implicit rule kicks in
$(sort $(u-boot-init) $(u-boot-main)): $(u-boot-dirs) ;
......
# Handle descending into subdirectories listed in $(vmlinux-dirs)
# Preset locale variables to speed up the build process. Limit locale
# tweaks to this spot to avoid wrong language settings when running
# make menuconfig etc.
# Error messages still appears in the original language
PHONY += $(u-boot-dirs)
$(u-boot-dirs): prepare scripts
$(Q)$(MAKE) $(build)=$@
目标u-boot的依赖有三个:$ (u-boot-init)、$ (u-boot-main)、u-boot.lds、FORCE。其中$ (u-boot-init)、$(u-boot-main)和u-boot.lds分别被定义为:
u-boot-init := $(head-y)
u-boot-main := $(libs-y)
u-boot.lds: $(LDSCRIPT) prepare FORCE
$(call if_changed_dep,cpp_lds)
其中 $ (u-boot-init) 和 $ (u-boot-main)又依赖于$ (u-boot-dirs),$ (u-boot-dirs)是$(libs-y)最后一个‘/’之前的内容,即编译所在目录 ‘/’(比如:arch/arm/cpu)。
5.1 $(head-y)
head-y 定义在 arch/arm/Makefile中,其中CPU在我使用的开发板被定义为armv8(include/config/auto.conf中有定义CONFIG_SYS_CPU="armv8",顶层config.mk定义 CPU := $(CONFIG_SYS_CPU:"%"=%))。
# arch/arm/Makefile
head-y := arch/arm/cpu/$(CPU)/start.o
因此:
head-y := arch/arm/cpu/armv8/start.o
5.2 依赖$(libs-y)
libs-y定义在顶层的Makefile和arch/arm/Makefile(include arch/$ (ARCH)/Makefile)中。可以发现$(libs-y)被定义为各层驱动目录下build-in.o的集合:
# 顶层Makefile
#########################################################################
# U-Boot objects....order is important (i.e. start must be first)
HAVE_VENDOR