Makefile: Invoke dtoc only once

Update the Makefile to run dtoc only once, generating all required files.
This saves time since there is a lot of processing in each invocation of
dtoc.

We already have a variable for the object files to build, so use that
instead of repeating the same filenames. Add a C version of this also,
for the same reason.

This makes it easier to add new C files (generated by dtoc) to the build
later, as needed.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass 2020-12-28 20:34:53 -07:00
parent 10cbd3b7da
commit be3bd3bb17

View file

@ -121,6 +121,7 @@ u-boot-spl-init := $(head-y)
u-boot-spl-main := $(libs-y)
ifdef CONFIG_$(SPL_TPL_)OF_PLATDATA
u-boot-spl-platdata := $(obj)/dts/dt-platdata.o
u-boot-spl-platdata_c := $(patsubst %.o,%.c,$(u-boot-spl-platdata))
endif
# Linker Script
@ -310,17 +311,15 @@ pythonpath = PYTHONPATH=scripts/dtc/pylibfdt
DTOC_ARGS := $(pythonpath) $(srctree)/tools/dtoc/dtoc \
-d $(obj)/$(SPL_BIN).dtb
quiet_cmd_dtocc = DTOC C $@
cmd_dtocc = $(DTOC_ARGS) -o $@ platdata
quiet_cmd_dtoch = DTOC H $@
cmd_dtoch = $(DTOC_ARGS) -o $@ struct
quiet_cmd_dtoc = DTOC $@
cmd_dtoc = $(DTOC_ARGS) -c $(obj)/dts -C include/generated all
quiet_cmd_plat = PLAT $@
cmd_plat = $(CC) $(c_flags) -c $< -o $(filter-out $(PHONY),$@)
targets += $(obj)/dts/dt-platdata.o
$(obj)/dts/dt-platdata.o: $(obj)/dts/dt-platdata.c \
targets += $(u-boot-spl-platdata)
$(obj)/dts/dt-%.o: $(obj)/dts/dt-%.c \
include/generated/dt-structs-gen.h prepare FORCE
$(call if_changed,plat)
@ -328,11 +327,9 @@ PHONY += dts_dir
dts_dir:
$(shell [ -d $(obj)/dts ] || mkdir -p $(obj)/dts)
include/generated/dt-structs-gen.h: $(obj)/$(SPL_BIN).dtb dts_dir FORCE
$(call if_changed,dtoch)
$(obj)/dts/dt-platdata.c: $(obj)/$(SPL_BIN).dtb dts_dir FORCE
$(call if_changed,dtocc)
include/generated/dt-structs-gen.h $(u-boot-spl-platdata_c) &: \
$(obj)/$(SPL_BIN).dtb dts_dir FORCE
$(call if_changed,dtoc)
ifdef CONFIG_SAMSUNG
ifdef CONFIG_VAR_SIZE_SPL