Skip to content

Commit 2450787

Browse files
committed
kbuild: create a list of all built DTB files
It is useful to have a list of all *.dtb and *.dtbo files generated from the current build. With this commit, 'make dtbs' creates arch/*/boot/dts/dtbs-list, which lists the dtb(o) files created in the current build. It maintains the order of the dtb-y additions in Makefiles although the order is not important for DTBs. It is a (good) side effect through the reuse of the modules.order rule. Please note this list only includes the files directly added to dtb-y. For example, consider this case: foo-dtbs := foo_base.dtb foo_overlay.dtbo dtb-y := foo.dtb In this example, the list will include foo.dtb, but not foo_base.dtb or foo_overlay.dtbo. Signed-off-by: Masahiro Yamada <[email protected]>
1 parent f6314b7 commit 2450787

File tree

4 files changed

+21
-10
lines changed

4 files changed

+21
-10
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
*.xz
5353
*.zst
5454
Module.symvers
55+
dtbs-list
5556
modules.order
5657

5758
#

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1393,7 +1393,7 @@ ifneq ($(dtstree),)
13931393

13941394
PHONY += dtbs dtbs_prepare dtbs_install dtbs_check
13951395
dtbs: dtbs_prepare
1396-
$(Q)$(MAKE) $(build)=$(dtstree)
1396+
$(Q)$(MAKE) $(build)=$(dtstree) need-dtbslist=1
13971397

13981398
# include/config/kernel.release is actually needed when installing DTBs because
13991399
# INSTALL_DTBS_PATH contains $(KERNELRELEASE). However, we do not want to make
@@ -1932,7 +1932,7 @@ clean: $(clean-dirs)
19321932
-o -name '*.ko.*' \
19331933
-o -name '*.dtb' -o -name '*.dtbo' \
19341934
-o -name '*.dtb.S' -o -name '*.dtbo.S' \
1935-
-o -name '*.dt.yaml' \
1935+
-o -name '*.dt.yaml' -o -name 'dtbs-list' \
19361936
-o -name '*.dwo' -o -name '*.lst' \
19371937
-o -name '*.su' -o -name '*.mod' \
19381938
-o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \

scripts/Makefile.build

+12-8
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ endif
7171
# subdir-builtin and subdir-modorder may contain duplications. Use $(sort ...)
7272
subdir-builtin := $(sort $(filter %/built-in.a, $(real-obj-y)))
7373
subdir-modorder := $(sort $(filter %/modules.order, $(obj-m)))
74+
subdir-dtbslist := $(sort $(filter %/dtbs-list, $(dtb-y)))
7475

7576
targets-for-builtin := $(extra-y)
7677

@@ -388,6 +389,7 @@ $(obj)/%.asn1.c $(obj)/%.asn1.h: $(src)/%.asn1 $(objtree)/scripts/asn1_compiler
388389
# To build objects in subdirs, we need to descend into the directories
389390
$(subdir-builtin): $(obj)/%/built-in.a: $(obj)/% ;
390391
$(subdir-modorder): $(obj)/%/modules.order: $(obj)/% ;
392+
$(subdir-dtbslist): $(obj)/%/dtbs-list: $(obj)/% ;
391393

392394
#
393395
# Rule to compile a set of .o files into one .a file (without symbol table)
@@ -404,19 +406,21 @@ $(obj)/built-in.a: $(real-obj-y) FORCE
404406
$(call if_changed,ar_builtin)
405407

406408
#
407-
# Rule to create modules.order file
409+
# Rule to create modules.order and dtbs-list
408410
#
409-
# Create commands to either record .ko file or cat modules.order from
410-
# a subdirectory
411-
# Add $(obj-m) as the prerequisite to avoid updating the timestamp of
412-
# modules.order unless contained modules are updated.
411+
# This is a list of build artifacts (module or dtb) from the current Makefile
412+
# and its sub-directories. The timestamp should be updated when any of the
413+
# member files.
413414

414-
cmd_modules_order = { $(foreach m, $(real-prereqs), \
415-
$(if $(filter %/modules.order, $m), cat $m, echo $m);) :; } \
415+
cmd_gen_order = { $(foreach m, $(real-prereqs), \
416+
$(if $(filter %/$(notdir $@), $m), cat $m, echo $m);) :; } \
416417
> $@
417418

418419
$(obj)/modules.order: $(obj-m) FORCE
419-
$(call if_changed,modules_order)
420+
$(call if_changed,gen_order)
421+
422+
$(obj)/dtbs-list: $(dtb-y) FORCE
423+
$(call if_changed,gen_order)
420424

421425
#
422426
# Rule to compile a set of .o files into one .a file (with symbol table)

scripts/Makefile.lib

+6
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ else
4545
obj-y := $(filter-out %/, $(obj-y))
4646
endif
4747

48+
ifdef need-dtbslist
49+
dtb-y += $(addsuffix /dtbs-list, $(subdir-ym))
50+
always-y += dtbs-list
51+
endif
52+
4853
# Expand $(foo-objs) $(foo-y) etc. by replacing their individuals
4954
suffix-search = $(strip $(foreach s, $3, $($(1:%$(strip $2)=%$s))))
5055
# List composite targets that are constructed by combining other targets
@@ -99,6 +104,7 @@ lib-y := $(addprefix $(obj)/,$(lib-y))
99104
real-obj-y := $(addprefix $(obj)/,$(real-obj-y))
100105
real-obj-m := $(addprefix $(obj)/,$(real-obj-m))
101106
multi-obj-m := $(addprefix $(obj)/, $(multi-obj-m))
107+
dtb-y := $(addprefix $(obj)/, $(dtb-y))
102108
multi-dtb-y := $(addprefix $(obj)/, $(multi-dtb-y))
103109
real-dtb-y := $(addprefix $(obj)/, $(real-dtb-y))
104110
subdir-ym := $(addprefix $(obj)/,$(subdir-ym))

0 commit comments

Comments
 (0)