Skip to content

Commit 90b335f

Browse files
nvswarrenRob Herring
authored andcommitted
kbuild: centralize .dts->.dtb rule
All architectures that use cmd_dtc do so in almost the same way. Create a central build rule to avoid duplication. The one difference is that most current uses of dtc build $(obj)/%.dtb from $(src)/dts/%.dts rather than building the .dtb in the same directory as the .dts file. This difference will be eliminated arch-by-arch in future patches. MIPS is the exception here; it already uses the exact same rule as the new common rule, so the duplicate is removed in this patch to avoid any conflict. arch/mips changes courtesy of Ralf Baechle. Update Documentation/kbuild to remove the explicit call to cmd_dtc from the example, now that the rule exists in a centralized location. Cc: Arnd Bergmann <[email protected]> Cc: [email protected] Cc: Olof Johansson <[email protected]> Cc: Russell King <[email protected]> Acked-by: Catalin Marinas <[email protected]> Cc: Jonas Bonn <[email protected]> Cc: [email protected] Cc: Aurelien Jacquiot <[email protected]> Cc: [email protected] Cc: Mark Salter <[email protected]> Cc: Michal Simek <[email protected]> Cc: [email protected] Cc: Chris Zankel <[email protected]> Cc: [email protected] Cc: Max Filippov <[email protected]> Signed-off-by: Ralf Baechle <[email protected]> Signed-off-by: Stephen Warren <[email protected]> Signed-off-by: Rob Herring <[email protected]>
1 parent 4a92a38 commit 90b335f

5 files changed

Lines changed: 11 additions & 16 deletions

File tree

Documentation/kbuild/makefiles.txt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,15 +1175,16 @@ When kbuild executes, the following steps are followed (roughly):
11751175
in an init section in the image. Platform code *must* copy the
11761176
blob to non-init memory prior to calling unflatten_device_tree().
11771177

1178-
Example:
1179-
#arch/x86/platform/ce4100/Makefile
1180-
clean-files := *dtb.S
1178+
To use this command, simply add *.dtb into obj-y or targets, or make
1179+
some other target depend on %.dtb
11811180

1182-
DTC_FLAGS := -p 1024
1183-
obj-y += foo.dtb.o
1181+
A central rule exists to create $(obj)/%.dtb from $(src)/%.dts;
1182+
architecture Makefiles do no need to explicitly write out that rule.
11841183

1185-
$(obj)/%.dtb: $(src)/%.dts
1186-
$(call cmd,dtc)
1184+
Example:
1185+
targets += $(dtb-y)
1186+
clean-files += *.dtb
1187+
DTC_FLAGS ?= -p 1024
11871188

11881189
--- 6.8 Custom kbuild commands
11891190

arch/mips/cavium-octeon/Makefile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ DTB_FILES = $(patsubst %.dts, %.dtb, $(DTS_FILES))
2424

2525
obj-y += $(patsubst %.dts, %.dtb.o, $(DTS_FILES))
2626

27-
$(obj)/%.dtb: $(src)/%.dts FORCE
28-
$(call if_changed_dep,dtc)
29-
3027
# Let's keep the .dtb files around in case we want to look at them.
3128
.SECONDARY: $(addprefix $(obj)/, $(DTB_FILES))
3229

arch/mips/lantiq/dts/Makefile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
11
obj-$(CONFIG_DT_EASY50712) := easy50712.dtb.o
2-
3-
$(obj)/%.dtb: $(obj)/%.dts
4-
$(call if_changed,dtc)

arch/mips/netlogic/dts/Makefile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
11
obj-$(CONFIG_DT_XLP_EVP) := xlp_evp.dtb.o
2-
3-
$(obj)/%.dtb: $(obj)/%.dts
4-
$(call if_changed,dtc)

scripts/Makefile.lib

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,9 @@ $(obj)/%.dtb.S: $(obj)/%.dtb
266266
quiet_cmd_dtc = DTC $@
267267
cmd_dtc = $(objtree)/scripts/dtc/dtc -O dtb -o $@ -b 0 $(DTC_FLAGS) -d $(depfile) $<
268268

269+
$(obj)/%.dtb: $(src)/%.dts FORCE
270+
$(call if_changed_dep,dtc)
271+
269272
# Bzip2
270273
# ---------------------------------------------------------------------------
271274

0 commit comments

Comments
 (0)