]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
kbuild: create a list of all built DTB files
authorMasahiro Yamada <masahiroy@kernel.org>
Tue, 9 Jan 2024 12:07:34 +0000 (21:07 +0900)
committerMasahiro Yamada <masahiroy@kernel.org>
Mon, 19 Feb 2024 09:20:39 +0000 (18:20 +0900)
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 <masahiroy@kernel.org>
.gitignore
Makefile
scripts/Makefile.build
scripts/Makefile.lib

index 689a4fa3f5477aa0fd46997eca5ee7a29cd78f8a..c59dc60ba62ef082cd027bb0a2f0d74cfebb7d71 100644 (file)
@@ -52,6 +52,7 @@
 *.xz
 *.zst
 Module.symvers
+dtbs-list
 modules.order
 
 #
index 41fa8a2565f54e4773321a193d3d7c5abb5f07f9..f5755b81591b2639e3fe74e321dafe7d031ec4c8 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1393,7 +1393,7 @@ ifneq ($(dtstree),)
 
 PHONY += dtbs dtbs_prepare dtbs_install dtbs_check
 dtbs: dtbs_prepare
-       $(Q)$(MAKE) $(build)=$(dtstree)
+       $(Q)$(MAKE) $(build)=$(dtstree) need-dtbslist=1
 
 # include/config/kernel.release is actually needed when installing DTBs because
 # INSTALL_DTBS_PATH contains $(KERNELRELEASE). However, we do not want to make
@@ -1932,7 +1932,7 @@ clean: $(clean-dirs)
                -o -name '*.ko.*' \
                -o -name '*.dtb' -o -name '*.dtbo' \
                -o -name '*.dtb.S' -o -name '*.dtbo.S' \
-               -o -name '*.dt.yaml' \
+               -o -name '*.dt.yaml' -o -name 'dtbs-list' \
                -o -name '*.dwo' -o -name '*.lst' \
                -o -name '*.su' -o -name '*.mod' \
                -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
index dae447a1ad30c4a30d48f4741e7a5dfd81622ced..4971f54c855e9d385d05b2653ec3aec974ee73fe 100644 (file)
@@ -71,6 +71,7 @@ endif
 # subdir-builtin and subdir-modorder may contain duplications. Use $(sort ...)
 subdir-builtin := $(sort $(filter %/built-in.a, $(real-obj-y)))
 subdir-modorder := $(sort $(filter %/modules.order, $(obj-m)))
+subdir-dtbslist := $(sort $(filter %/dtbs-list, $(dtb-y)))
 
 targets-for-builtin := $(extra-y)
 
@@ -388,6 +389,7 @@ $(obj)/%.asn1.c $(obj)/%.asn1.h: $(src)/%.asn1 $(objtree)/scripts/asn1_compiler
 # To build objects in subdirs, we need to descend into the directories
 $(subdir-builtin): $(obj)/%/built-in.a: $(obj)/% ;
 $(subdir-modorder): $(obj)/%/modules.order: $(obj)/% ;
+$(subdir-dtbslist): $(obj)/%/dtbs-list: $(obj)/% ;
 
 #
 # 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
        $(call if_changed,ar_builtin)
 
 #
-# Rule to create modules.order file
+# Rule to create modules.order and dtbs-list
 #
-# Create commands to either record .ko file or cat modules.order from
-# a subdirectory
-# Add $(obj-m) as the prerequisite to avoid updating the timestamp of
-# modules.order unless contained modules are updated.
+# This is a list of build artifacts (module or dtb) from the current Makefile
+# and its sub-directories. The timestamp should be updated when any of the
+# member files.
 
-cmd_modules_order = { $(foreach m, $(real-prereqs), \
-       $(if $(filter %/modules.order, $m), cat $m, echo $m);) :; } \
+cmd_gen_order = { $(foreach m, $(real-prereqs), \
+       $(if $(filter %/$(notdir $@), $m), cat $m, echo $m);) :; } \
        > $@
 
 $(obj)/modules.order: $(obj-m) FORCE
-       $(call if_changed,modules_order)
+       $(call if_changed,gen_order)
+
+$(obj)/dtbs-list: $(dtb-y) FORCE
+       $(call if_changed,gen_order)
 
 #
 # Rule to compile a set of .o files into one .a file (with symbol table)
index cd5b181060f151f2c28186feb5b96db37ee04da9..b35d39022a30a23c9f181fc8098b78f9ccdd6fe8 100644 (file)
@@ -45,6 +45,11 @@ else
 obj-y          := $(filter-out %/, $(obj-y))
 endif
 
+ifdef need-dtbslist
+dtb-y          += $(addsuffix /dtbs-list, $(subdir-ym))
+always-y       += dtbs-list
+endif
+
 # Expand $(foo-objs) $(foo-y) etc. by replacing their individuals
 suffix-search = $(strip $(foreach s, $3, $($(1:%$(strip $2)=%$s))))
 # List composite targets that are constructed by combining other targets
@@ -99,6 +104,7 @@ lib-y                := $(addprefix $(obj)/,$(lib-y))
 real-obj-y     := $(addprefix $(obj)/,$(real-obj-y))
 real-obj-m     := $(addprefix $(obj)/,$(real-obj-m))
 multi-obj-m    := $(addprefix $(obj)/, $(multi-obj-m))
+dtb-y          := $(addprefix $(obj)/, $(dtb-y))
 multi-dtb-y    := $(addprefix $(obj)/, $(multi-dtb-y))
 real-dtb-y     := $(addprefix $(obj)/, $(real-dtb-y))
 subdir-ym      := $(addprefix $(obj)/,$(subdir-ym))