Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

kbuild: split device tree build rules into scripts/Makefile.dtbs

scripts/Makefile.lib is included not only from scripts/Makefile.build
but also from scripts/Makefile.{modfinal,package,vmlinux,vmlinux_o},
where DT build rules are not required.

Split the DT build rules out to scripts/Makefile.dtbs, and include it
only when necessary.

While I was here, I added $(DT_TMP_SCHEMA) as a prerequisite of
$(multi-dtb-y).

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Rob Herring (Arm) <robh@kernel.org>

+153 -135
+1 -1
drivers/of/fdt.c
··· 34 34 35 35 /* 36 36 * __dtb_empty_root_begin[] and __dtb_empty_root_end[] magically created by 37 - * cmd_dt_S_dtb in scripts/Makefile.lib 37 + * cmd_wrap_S_dtb in scripts/Makefile.dtbs 38 38 */ 39 39 extern uint8_t __dtb_empty_root_begin[]; 40 40 extern uint8_t __dtb_empty_root_end[];
+2 -2
drivers/of/unittest.c
··· 1861 1861 struct device_node *unittest_data_node = NULL, *np; 1862 1862 /* 1863 1863 * __dtbo_testcases_begin[] and __dtbo_testcases_end[] are magically 1864 - * created by cmd_dt_S_dtbo in scripts/Makefile.lib 1864 + * created by cmd_wrap_S_dtbo in scripts/Makefile.dtbs 1865 1865 */ 1866 1866 extern uint8_t __dtbo_testcases_begin[]; 1867 1867 extern uint8_t __dtbo_testcases_end[]; ··· 3525 3525 3526 3526 /* 3527 3527 * __dtbo_##overlay_name##_begin[] and __dtbo_##overlay_name##_end[] are 3528 - * created by cmd_dt_S_dtbo in scripts/Makefile.lib 3528 + * created by cmd_wrap_S_dtbo in scripts/Makefile.dtbs 3529 3529 */ 3530 3530 3531 3531 #define OVERLAY_INFO_EXTERN(overlay_name) \
+8 -17
scripts/Makefile.build
··· 57 57 # subdir-builtin and subdir-modorder may contain duplications. Use $(sort ...) 58 58 subdir-builtin := $(sort $(filter %/built-in.a, $(real-obj-y))) 59 59 subdir-modorder := $(sort $(filter %/modules.order, $(obj-m))) 60 - subdir-dtbslist := $(sort $(filter %/dtbs-list, $(dtb-y))) 61 60 62 61 targets-for-builtin := $(extra-y) 63 62 ··· 348 349 349 350 targets += $(filter-out $(subdir-builtin), $(real-obj-y)) 350 351 targets += $(filter-out $(subdir-modorder), $(real-obj-m)) 351 - targets += $(real-dtb-y) $(lib-y) $(always-y) 352 + targets += $(lib-y) $(always-y) 352 353 353 354 # Linker scripts preprocessor (.lds.S -> .lds) 354 355 # --------------------------------------------------------------------------- ··· 374 375 # To build objects in subdirs, we need to descend into the directories 375 376 $(subdir-builtin): $(obj)/%/built-in.a: $(obj)/% ; 376 377 $(subdir-modorder): $(obj)/%/modules.order: $(obj)/% ; 377 - $(subdir-dtbslist): $(obj)/%/dtbs-list: $(obj)/% ; 378 378 379 379 # 380 380 # Rule to compile a set of .o files into one .a file (without symbol table) ··· 389 391 $(obj)/built-in.a: $(real-obj-y) FORCE 390 392 $(call if_changed,ar_builtin) 391 393 392 - # 393 - # Rule to create modules.order and dtbs-list 394 - # 395 - # This is a list of build artifacts (module or dtb) from the current Makefile 396 - # and its sub-directories. The timestamp should be updated when any of the 397 - # member files. 394 + # This is a list of build artifacts from the current Makefile and its 395 + # sub-directories. The timestamp should be updated when any of the member files. 398 396 399 397 cmd_gen_order = { $(foreach m, $(real-prereqs), \ 400 398 $(if $(filter %/$(notdir $@), $m), cat $m, echo $m);) :; } \ 401 399 > $@ 402 400 403 401 $(obj)/modules.order: $(obj-m) FORCE 404 - $(call if_changed,gen_order) 405 - 406 - $(obj)/dtbs-list: $(dtb-y) FORCE 407 402 $(call if_changed,gen_order) 408 403 409 404 # ··· 427 436 $(patsubst %$(strip $(1)),%$(sfx), \ 428 437 $(filter %$(strip $(1)), $(targets)))) 429 438 # %.asn1.o <- %.asn1.[ch] <- %.asn1 430 - # %.dtb.o <- %.dtb.S <- %.dtb <- %.dts 431 - # %.dtbo.o <- %.dtbo.S <- %.dtbo <- %.dtso 432 - targets += $(call intermediate_targets, .asn1.o, .asn1.c .asn1.h) \ 433 - $(call intermediate_targets, .dtb.o, .dtb.S .dtb) \ 434 - $(call intermediate_targets, .dtbo.o, .dtbo.S .dtbo) 439 + targets += $(call intermediate_targets, .asn1.o, .asn1.c .asn1.h) 435 440 436 441 # Include additional build rules when necessary 437 442 # --------------------------------------------------------------------------- ··· 442 455 userprogs := $(sort $(userprogs)) 443 456 ifneq ($(userprogs),) 444 457 include $(srctree)/scripts/Makefile.userprogs 458 + endif 459 + 460 + ifneq ($(need-dtbslist)$(dtb-y)$(dtb-)$(filter %.dtb %.dtb.o %.dtbo.o,$(targets)),) 461 + include $(srctree)/scripts/Makefile.dtbs 445 462 endif 446 463 447 464 # Build
+142
scripts/Makefile.dtbs
··· 1 + # SPDX-License-Identifier: GPL-2.0-only 2 + 3 + # If CONFIG_OF_ALL_DTBS is enabled, all DT blobs are built 4 + dtb-$(CONFIG_OF_ALL_DTBS) += $(dtb-) 5 + 6 + # Composite DTB (i.e. DTB constructed by overlay) 7 + multi-dtb-y := $(call multi-search, $(dtb-y), .dtb, -dtbs) 8 + # Primitive DTB compiled from *.dts 9 + real-dtb-y := $(call real-search, $(dtb-y), .dtb, -dtbs) 10 + # Base DTB that overlay is applied onto 11 + base-dtb-y := $(filter %.dtb, $(call real-search, $(multi-dtb-y), .dtb, -dtbs)) 12 + 13 + dtb-y := $(addprefix $(obj)/, $(dtb-y)) 14 + multi-dtb-y := $(addprefix $(obj)/, $(multi-dtb-y)) 15 + real-dtb-y := $(addprefix $(obj)/, $(real-dtb-y)) 16 + 17 + always-y += $(dtb-y) 18 + targets += $(real-dtb-y) 19 + 20 + # dtbs-list 21 + # --------------------------------------------------------------------------- 22 + 23 + ifdef need-dtbslist 24 + subdir-dtbslist := $(addsuffix /dtbs-list, $(subdir-ym)) 25 + dtb-y += $(subdir-dtbslist) 26 + always-y += $(obj)/dtbs-list 27 + endif 28 + 29 + $(subdir-dtbslist): $(obj)/%/dtbs-list: $(obj)/% ; 30 + 31 + $(obj)/dtbs-list: $(dtb-y) FORCE 32 + $(call if_changed,gen_order) 33 + 34 + # Assembly file to wrap dtb(o) 35 + # --------------------------------------------------------------------------- 36 + 37 + # Generate an assembly file to wrap the output of the device tree compiler 38 + quiet_cmd_wrap_S_dtb = WRAP $@ 39 + cmd_wrap_S_dtb = { \ 40 + symbase=__$(patsubst .%,%,$(suffix $<))_$(subst -,_,$(notdir $*)); \ 41 + echo '\#include <asm-generic/vmlinux.lds.h>'; \ 42 + echo '.section .dtb.init.rodata,"a"'; \ 43 + echo '.balign STRUCT_ALIGNMENT'; \ 44 + echo ".global $${symbase}_begin"; \ 45 + echo "$${symbase}_begin:"; \ 46 + echo '.incbin "$<" '; \ 47 + echo ".global $${symbase}_end"; \ 48 + echo "$${symbase}_end:"; \ 49 + echo '.balign STRUCT_ALIGNMENT'; \ 50 + } > $@ 51 + 52 + $(obj)/%.dtb.S: $(obj)/%.dtb FORCE 53 + $(call if_changed,wrap_S_dtb) 54 + 55 + $(obj)/%.dtbo.S: $(obj)/%.dtbo FORCE 56 + $(call if_changed,wrap_S_dtb) 57 + 58 + # Schema check 59 + # --------------------------------------------------------------------------- 60 + 61 + ifneq ($(CHECK_DTBS),) 62 + DT_CHECKER ?= dt-validate 63 + DT_CHECKER_FLAGS ?= $(if $(DT_SCHEMA_FILES),-l $(DT_SCHEMA_FILES),-m) 64 + DT_BINDING_DIR := Documentation/devicetree/bindings 65 + DT_TMP_SCHEMA := $(objtree)/$(DT_BINDING_DIR)/processed-schema.json 66 + dtb-check-enabled = $(if $(filter %.dtb, $@),y) 67 + endif 68 + 69 + quiet_dtb_check_tag = $(if $(dtb-check-enabled),[C], ) 70 + cmd_dtb_check = $(if $(dtb-check-enabled),; $(DT_CHECKER) $(DT_CHECKER_FLAGS) -u $(srctree)/$(DT_BINDING_DIR) -p $(DT_TMP_SCHEMA) $@ || true) 71 + 72 + # Overlay 73 + # --------------------------------------------------------------------------- 74 + 75 + # NOTE: 76 + # Do not replace $(filter %.dtb %.dtbo, $^) with $(real-prereqs). When a single 77 + # DTB is turned into a multi-blob DTB, $^ will contain header file dependencies 78 + # recorded in the .*.cmd file. 79 + quiet_cmd_fdtoverlay = OVL $(quiet_dtb_check_tag) $@ 80 + cmd_fdtoverlay = $(objtree)/scripts/dtc/fdtoverlay -o $@ -i $(filter %.dtb %.dtbo, $^) $(cmd_dtb_check) 81 + 82 + $(multi-dtb-y): $(DT_TMP_SCHEMA) FORCE 83 + $(call if_changed,fdtoverlay) 84 + $(call multi_depend, $(multi-dtb-y), .dtb, -dtbs) 85 + 86 + # DTC 87 + # --------------------------------------------------------------------------- 88 + 89 + DTC ?= $(objtree)/scripts/dtc/dtc 90 + DTC_FLAGS += -Wno-unique_unit_address 91 + 92 + # Disable noisy checks by default 93 + ifeq ($(findstring 1,$(KBUILD_EXTRA_WARN)),) 94 + DTC_FLAGS += -Wno-unit_address_vs_reg \ 95 + -Wno-avoid_unnecessary_addr_size \ 96 + -Wno-alias_paths \ 97 + -Wno-graph_child_address \ 98 + -Wno-simple_bus_reg 99 + else 100 + DTC_FLAGS += -Wunique_unit_address_if_enabled 101 + endif 102 + 103 + ifneq ($(findstring 2,$(KBUILD_EXTRA_WARN)),) 104 + DTC_FLAGS += -Wnode_name_chars_strict \ 105 + -Wproperty_name_chars_strict \ 106 + -Wunique_unit_address 107 + endif 108 + 109 + DTC_FLAGS += $(DTC_FLAGS_$(target-stem)) 110 + 111 + # Set -@ if the target is a base DTB that overlay is applied onto 112 + DTC_FLAGS += $(if $(filter $(patsubst $(obj)/%,%,$@), $(base-dtb-y)), -@) 113 + 114 + DTC_INCLUDE := $(srctree)/scripts/dtc/include-prefixes 115 + 116 + dtc_cpp_flags = -Wp,-MMD,$(depfile).pre.tmp -nostdinc -I $(DTC_INCLUDE) -undef -D__DTS__ 117 + 118 + dtc-tmp = $(subst $(comma),_,$(dot-target).dts.tmp) 119 + 120 + quiet_cmd_dtc = DTC $(quiet_dtb_check_tag) $@ 121 + cmd_dtc = \ 122 + $(HOSTCC) -E $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \ 123 + $(DTC) -o $@ -b 0 $(addprefix -i,$(dir $<) $(DTC_INCLUDE)) \ 124 + $(DTC_FLAGS) -d $(depfile).dtc.tmp $(dtc-tmp) ; \ 125 + cat $(depfile).pre.tmp $(depfile).dtc.tmp > $(depfile) \ 126 + $(cmd_dtb_check) 127 + 128 + $(obj)/%.dtb: $(obj)/%.dts $(DTC) $(DT_TMP_SCHEMA) FORCE 129 + $(call if_changed_dep,dtc) 130 + 131 + $(obj)/%.dtbo: $(src)/%.dtso $(DTC) FORCE 132 + $(call if_changed_dep,dtc) 133 + 134 + # targets 135 + # --------------------------------------------------------------------------- 136 + 137 + targets += $(always-y) 138 + 139 + # %.dtb.o <- %.dtb.S <- %.dtb <- %.dts 140 + # %.dtbo.o <- %.dtbo.S <- %.dtbo <- %.dtso 141 + targets += $(call intermediate_targets, .dtb.o, .dtb.S .dtb) \ 142 + $(call intermediate_targets, .dtbo.o, .dtbo.S .dtbo)
-115
scripts/Makefile.lib
··· 45 45 obj-y := $(filter-out %/, $(obj-y)) 46 46 endif 47 47 48 - ifdef need-dtbslist 49 - dtb-y += $(addsuffix /dtbs-list, $(subdir-ym)) 50 - always-y += dtbs-list 51 - endif 52 - 53 48 # Expand $(foo-objs) $(foo-y) etc. by replacing their individuals 54 49 suffix-search = $(strip $(foreach s, $3, $($(1:%$(strip $2)=%$s)))) 55 50 # List composite targets that are constructed by combining other targets ··· 75 80 userprogs += $(userprogs-always-y) $(userprogs-always-m) 76 81 always-y += $(userprogs-always-y) $(userprogs-always-m) 77 82 78 - # DTB 79 - # If CONFIG_OF_ALL_DTBS is enabled, all DT blobs are built 80 - dtb-$(CONFIG_OF_ALL_DTBS) += $(dtb-) 81 - 82 - # Composite DTB (i.e. DTB constructed by overlay) 83 - multi-dtb-y := $(call multi-search, $(dtb-y), .dtb, -dtbs) 84 - # Primitive DTB compiled from *.dts 85 - real-dtb-y := $(call real-search, $(dtb-y), .dtb, -dtbs) 86 - # Base DTB that overlay is applied onto 87 - base-dtb-y := $(filter %.dtb, $(call real-search, $(multi-dtb-y), .dtb, -dtbs)) 88 - 89 - always-y += $(dtb-y) 90 - 91 83 # Add subdir path 92 84 93 85 ifneq ($(obj),.) ··· 86 104 real-obj-y := $(addprefix $(obj)/,$(real-obj-y)) 87 105 real-obj-m := $(addprefix $(obj)/,$(real-obj-m)) 88 106 multi-obj-m := $(addprefix $(obj)/, $(multi-obj-m)) 89 - dtb-y := $(addprefix $(obj)/, $(dtb-y)) 90 - multi-dtb-y := $(addprefix $(obj)/, $(multi-dtb-y)) 91 - real-dtb-y := $(addprefix $(obj)/, $(real-dtb-y)) 92 107 subdir-ym := $(addprefix $(obj)/,$(subdir-ym)) 93 108 endif 94 109 ··· 234 255 235 256 ld_flags = $(KBUILD_LDFLAGS) $(ldflags-y) $(LDFLAGS_$(@F)) 236 257 237 - DTC_INCLUDE := $(srctree)/scripts/dtc/include-prefixes 238 - 239 - dtc_cpp_flags = -Wp,-MMD,$(depfile).pre.tmp -nostdinc \ 240 - $(addprefix -I,$(DTC_INCLUDE)) \ 241 - -undef -D__DTS__ 242 - 243 258 ifdef CONFIG_OBJTOOL 244 259 245 260 objtool := $(objtree)/tools/objtool/objtool ··· 322 349 323 350 quiet_cmd_gzip = GZIP $@ 324 351 cmd_gzip = cat $(real-prereqs) | $(KGZIP) -n -f -9 > $@ 325 - 326 - # DTC 327 - # --------------------------------------------------------------------------- 328 - DTC ?= $(objtree)/scripts/dtc/dtc 329 - DTC_FLAGS += \ 330 - -Wno-unique_unit_address 331 - 332 - # Disable noisy checks by default 333 - ifeq ($(findstring 1,$(KBUILD_EXTRA_WARN)),) 334 - DTC_FLAGS += -Wno-unit_address_vs_reg \ 335 - -Wno-avoid_unnecessary_addr_size \ 336 - -Wno-alias_paths \ 337 - -Wno-graph_child_address \ 338 - -Wno-simple_bus_reg 339 - else 340 - DTC_FLAGS += \ 341 - -Wunique_unit_address_if_enabled 342 - endif 343 - 344 - ifneq ($(findstring 2,$(KBUILD_EXTRA_WARN)),) 345 - DTC_FLAGS += -Wnode_name_chars_strict \ 346 - -Wproperty_name_chars_strict \ 347 - -Wunique_unit_address 348 - endif 349 - 350 - DTC_FLAGS += $(DTC_FLAGS_$(target-stem)) 351 - 352 - # Set -@ if the target is a base DTB that overlay is applied onto 353 - DTC_FLAGS += $(if $(filter $(patsubst $(obj)/%,%,$@), $(base-dtb-y)), -@) 354 - 355 - # Generate an assembly file to wrap the output of the device tree compiler 356 - quiet_cmd_wrap_S_dtb = WRAP $@ 357 - cmd_wrap_S_dtb = { \ 358 - symbase=__$(patsubst .%,%,$(suffix $<))_$(subst -,_,$(notdir $*)); \ 359 - echo '\#include <asm-generic/vmlinux.lds.h>'; \ 360 - echo '.section .dtb.init.rodata,"a"'; \ 361 - echo '.balign STRUCT_ALIGNMENT'; \ 362 - echo ".global $${symbase}_begin"; \ 363 - echo "$${symbase}_begin:"; \ 364 - echo '.incbin "$<" '; \ 365 - echo ".global $${symbase}_end"; \ 366 - echo "$${symbase}_end:"; \ 367 - echo '.balign STRUCT_ALIGNMENT'; \ 368 - } > $@ 369 - 370 - $(obj)/%.dtb.S: $(obj)/%.dtb FORCE 371 - $(call if_changed,wrap_S_dtb) 372 - 373 - $(obj)/%.dtbo.S: $(obj)/%.dtbo FORCE 374 - $(call if_changed,wrap_S_dtb) 375 - 376 - quiet_dtb_check_tag = $(if $(dtb-check-enabled),[C], ) 377 - cmd_dtb_check = $(if $(dtb-check-enabled),; $(DT_CHECKER) $(DT_CHECKER_FLAGS) -u $(srctree)/$(DT_BINDING_DIR) -p $(DT_TMP_SCHEMA) $@ || true) 378 - 379 - quiet_cmd_dtc = DTC $(quiet_dtb_check_tag) $@ 380 - cmd_dtc = $(HOSTCC) -E $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \ 381 - $(DTC) -o $@ -b 0 \ 382 - $(addprefix -i,$(dir $<) $(DTC_INCLUDE)) $(DTC_FLAGS) \ 383 - -d $(depfile).dtc.tmp $(dtc-tmp) ; \ 384 - cat $(depfile).pre.tmp $(depfile).dtc.tmp > $(depfile) \ 385 - $(cmd_dtb_check) 386 - 387 - # NOTE: 388 - # Do not replace $(filter %.dtb %.dtbo, $^) with $(real-prereqs). When a single 389 - # DTB is turned into a multi-blob DTB, $^ will contain header file dependencies 390 - # recorded in the .*.cmd file. 391 - quiet_cmd_fdtoverlay = OVL $(quiet_dtb_check_tag) $@ 392 - cmd_fdtoverlay = $(objtree)/scripts/dtc/fdtoverlay -o $@ -i $(filter %.dtb %.dtbo, $^) $(cmd_dtb_check) 393 - 394 - $(multi-dtb-y): FORCE 395 - $(call if_changed,fdtoverlay) 396 - $(call multi_depend, $(multi-dtb-y), .dtb, -dtbs) 397 - 398 - ifneq ($(CHECK_DTBS),) 399 - DT_CHECKER ?= dt-validate 400 - DT_CHECKER_FLAGS ?= $(if $(DT_SCHEMA_FILES),-l $(DT_SCHEMA_FILES),-m) 401 - DT_BINDING_DIR := Documentation/devicetree/bindings 402 - DT_TMP_SCHEMA := $(objtree)/$(DT_BINDING_DIR)/processed-schema.json 403 - dtb-check-enabled = $(if $(filter %.dtb, $@),y) 404 - endif 405 - 406 - $(obj)/%.dtb: $(obj)/%.dts $(DTC) $(DT_TMP_SCHEMA) FORCE 407 - $(call if_changed_dep,dtc) 408 - 409 - $(obj)/%.dtbo: $(src)/%.dtso $(DTC) FORCE 410 - $(call if_changed_dep,dtc) 411 - 412 - dtc-tmp = $(subst $(comma),_,$(dot-target).dts.tmp) 413 352 414 353 # Bzip2 415 354 # ---------------------------------------------------------------------------