Makefile: Tidy up SPL dtb production

Use the SPL_NAME variable to simplify the rules. Drop the SPL targets
clean-files since the SPL and TPL dts/ directories are removed by
existing rules. Move the SPL rules into a new spl_dtbs to avoid the
complicated $(if) construct.

Also drop unused pieces from the 'targets' variable.

With this, SPL and TPL have separate dtbs which respect the various
u-boot,dm-spl / u-boot,dm-tpl tags.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass 2020-12-22 19:30:15 -07:00
parent de3e372abd
commit c7674fcb07
2 changed files with 13 additions and 12 deletions

View file

@ -16,13 +16,10 @@ else
DTB := arch/$(ARCH)/dts/$(DEVICE_TREE).dtb DTB := arch/$(ARCH)/dts/$(DEVICE_TREE).dtb
endif endif
spl/$(obj)/dt-spl.dtb: $(DTB) $(objtree)/tools/fdtgrep FORCE $(obj)/dt-$(SPL_NAME).dtb: dts/dt.dtb $(objtree)/tools/fdtgrep FORCE
mkdir -p $(dir $@) mkdir -p $(dir $@)
$(call if_changed,fdtgrep) $(call if_changed,fdtgrep)
tpl/$(obj)/dt-tpl.dtb: $(DTB) $(objtree)/tools/fdtgrep FORCE
$(call if_changed,fdtgrep)
ifeq ($(CONFIG_OF_DTB_PROPS_REMOVE),y) ifeq ($(CONFIG_OF_DTB_PROPS_REMOVE),y)
$(obj)/dt.dtb: $(DTB) $(objtree)/tools/fdtgrep FORCE $(obj)/dt.dtb: $(DTB) $(objtree)/tools/fdtgrep FORCE
$(call if_changed,fdt_rm_props) $(call if_changed,fdt_rm_props)
@ -31,7 +28,7 @@ $(obj)/dt.dtb: $(DTB) FORCE
$(call if_changed,shipped) $(call if_changed,shipped)
endif endif
targets += dt.dtb dt-spl.dtb dt-tpl.dtb targets += dt.dtb
$(DTB): arch-dtbs $(DTB): arch-dtbs
$(Q)test -e $@ || ( \ $(Q)test -e $@ || ( \
@ -55,12 +52,15 @@ else
obj-$(CONFIG_OF_EMBED) := dt.dtb.o obj-$(CONFIG_OF_EMBED) := dt.dtb.o
endif endif
dtbs: $(obj)/dt.dtb \ # Target for U-Boot proper
$(if $(CONFIG_SPL),spl/$(obj)/dt-spl.dtb) \ dtbs: $(obj)/dt.dtb
$(if $(CONFIG_TPL),tpl/$(obj)/dt-tpl.dtb)
@: @:
clean-files := dt.dtb.S dt-spl.dtb.S dt-tpl.dtb.S # Target for SPL/TPL
spl_dtbs: $(obj)/dt-$(SPL_NAME).dtb
@:
clean-files := dt.dtb.S
# Let clean descend into dts directories # Let clean descend into dts directories
subdir- += ../arch/arm/dts ../arch/microblaze/dts ../arch/mips/dts ../arch/sandbox/dts ../arch/x86/dts ../arch/powerpc/dts ../arch/riscv/dts subdir- += ../arch/arm/dts ../arch/microblaze/dts ../arch/mips/dts ../arch/sandbox/dts ../arch/x86/dts ../arch/powerpc/dts ../arch/riscv/dts

View file

@ -37,6 +37,8 @@ SPL_BIN := u-boot-spl
SPL_NAME := spl SPL_NAME := spl
endif endif
export SPL_NAME
ifdef CONFIG_SPL_BUILD ifdef CONFIG_SPL_BUILD
SPL_ := SPL_ SPL_ := SPL_
ifeq ($(CONFIG_TPL_BUILD),y) ifeq ($(CONFIG_TPL_BUILD),y)
@ -459,9 +461,8 @@ endif
PHONY += FORCE PHONY += FORCE
FORCE: FORCE:
PHONY += dtbs $(obj)/dts/dt-$(SPL_NAME).dtb: dts/dt.dtb
dtbs: $(Q)$(MAKE) $(build)=$(obj)/dts spl_dtbs
$(Q)$(MAKE) $(build)=dts dtbs
# Declare the contents of the .PHONY variable as phony. We keep that # Declare the contents of the .PHONY variable as phony. We keep that
# information in a variable so we can use it in if_changed and friends. # information in a variable so we can use it in if_changed and friends.