History

kbuild: simplify dtbs_install by reading the list of compiled DTBs

Retrieve the list of *.dtb(o) files from arch/*/boot/dts/dtbs-list instead of traversing the directory tree again. Please note that 'make dtbs_install' installs *.dtb(o) files directly added to dtb-y because scripts/Makefile.dtbinst installs $(dtb-y) without expanding the -dtbs suffix. This commit preserves this behavior.

Masahiro Yamada committed 2 years ago

Commit 8f668641 parent 24507873 files · +19 −21Browse files

Unified · Split

3 files
  1. Makefile +1 −1
  2. scripts/Kbuild.include +0 −6
  3. scripts/Makefile.dtbinst +18 −14
Makefile+1−1
@@ -1411,7 +1411,7 @@ endif · 1410 unmodified lines
14111411 dtbs_check: dtbs
14121412
14131413 dtbs_install:
1414− $(Q)$(MAKE) $(dtbinst)=$(dtstree) dst=$(INSTALL_DTBS_PATH)
1414+ $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.dtbinst obj=$(dtstree)
14151415
14161416 ifdef CONFIG_OF_EARLY_FLATTREE
14171417 all: dtbs
scripts/Kbuild.include+0−6
@@ -113,12 +113,6 @@ endef · 112 unmodified lines
113113 # $(Q)$(MAKE) $(build)=dir
114114 build := -f $(srctree)/scripts/Makefile.build obj
115115
116−###
117−# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.dtbinst obj=
118−# Usage:
119−# $(Q)$(MAKE) $(dtbinst)=dir
120−dtbinst := -f $(srctree)/scripts/Makefile.dtbinst obj
121−
122116 ###
123117 # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.clean obj=
124118 # Usage:
scripts/Makefile.dtbinst+18−14
@@ -8,32 +8,36 @@ · 7 unmodified lines
88 # $INSTALL_PATH/dtbs/$KERNELRELEASE
99 # ==========================================================================
1010
11−src := $(obj)
12−
1311 PHONY := __dtbs_install
1412 __dtbs_install:
1513
1614 include include/config/auto.conf
1715 include $(srctree)/scripts/Kbuild.include
18−include $(kbuild-file)
19−
20−dtbs := $(addprefix $(dst)/, $(dtb-y) $(if $(CONFIG_OF_ALL_DTBS),$(dtb-)))
21−subdirs := $(addprefix $(obj)/, $(subdir-y) $(subdir-m))
2216
23−__dtbs_install: $(dtbs) $(subdirs)
24− @:
17+dst := $(INSTALL_DTBS_PATH)
2518
2619 quiet_cmd_dtb_install = INSTALL $@
2720 cmd_dtb_install = install -D $< $@
2821
29−$(dst)/%.dtb: $(obj)/%.dtb
22+$(dst)/%: $(obj)/%
3023 $(call cmd,dtb_install)
3124
32−$(dst)/%.dtbo: $(obj)/%.dtbo
33− $(call cmd,dtb_install)
25+dtbs := $(patsubst $(obj)/%,%,$(call read-file, $(obj)/dtbs-list))
26+
27+ifdef CONFIG_ARCH_WANT_FLAT_DTB_INSTALL
3428
35−PHONY += $(subdirs)
36−$(subdirs):
37− $(Q)$(MAKE) $(dtbinst)=$@ dst=$(if $(CONFIG_ARCH_WANT_FLAT_DTB_INSTALL),$(dst),$(patsubst $(obj)/%,$(dst)/%,$@))
29+define gen_install_rules
30+$(dst)/%: $(obj)/$(1)%
31+ $$(call cmd,dtb_install)
32+endef
33+
34+$(foreach d, $(sort $(dir $(dtbs))), $(eval $(call gen_install_rules,$(d))))
35+
36+dtbs := $(notdir $(dtbs))
37+
38+endif # CONFIG_ARCH_WANT_FLAT_DTB_INSTALL
39+
40+__dtbs_install: $(addprefix $(dst)/, $(dtbs))
41+ @:
3842
3943 .PHONY: $(PHONY)