1 # SPDX-License-Identifier: GPL-2.0 1 # SPDX-License-Identifier: GPL-2.0 2 DT_DOC_CHECKER ?= dt-doc-validate 2 DT_DOC_CHECKER ?= dt-doc-validate 3 DT_EXTRACT_EX ?= dt-extract-example 3 DT_EXTRACT_EX ?= dt-extract-example 4 DT_MK_SCHEMA ?= dt-mk-schema 4 DT_MK_SCHEMA ?= dt-mk-schema 5 5 6 DT_SCHEMA_LINT = $(shell which yamllint || \ !! 6 DT_SCHEMA_LINT = $(shell which yamllint) 7 echo "warning: python package 'yamllint' not << 8 7 9 DT_SCHEMA_MIN_VERSION = 2023.9 !! 8 DT_SCHEMA_MIN_VERSION = 2021.2.1 10 9 11 PHONY += check_dtschema_version 10 PHONY += check_dtschema_version 12 check_dtschema_version: 11 check_dtschema_version: 13 @which $(DT_DOC_CHECKER) >/dev/null || 12 @which $(DT_DOC_CHECKER) >/dev/null || \ 14 { echo "Error: '$(DT_DOC_CHECK 13 { echo "Error: '$(DT_DOC_CHECKER)' not found!" >&2; \ 15 echo "Ensure dtschema python 14 echo "Ensure dtschema python package is installed and in your PATH." >&2; \ 16 echo "Current PATH is:" >&2; 15 echo "Current PATH is:" >&2; \ 17 echo "$$PATH" >&2; false; } 16 echo "$$PATH" >&2; false; } 18 @{ echo $(DT_SCHEMA_MIN_VERSION); \ 17 @{ echo $(DT_SCHEMA_MIN_VERSION); \ 19 $(DT_DOC_CHECKER) --version 2>/dev/nul 18 $(DT_DOC_CHECKER) --version 2>/dev/null || echo 0; } | sort -Vc >/dev/null || \ 20 { echo "ERROR: dtschema minimum versio 19 { echo "ERROR: dtschema minimum version is v$(DT_SCHEMA_MIN_VERSION)" >&2; false; } 21 20 22 quiet_cmd_extract_ex = DTEX $@ 21 quiet_cmd_extract_ex = DTEX $@ 23 cmd_extract_ex = $(DT_EXTRACT_EX) $< > $ 22 cmd_extract_ex = $(DT_EXTRACT_EX) $< > $@ 24 23 25 $(obj)/%.example.dts: $(src)/%.yaml check_dtsc 24 $(obj)/%.example.dts: $(src)/%.yaml check_dtschema_version FORCE 26 $(call if_changed,extract_ex) 25 $(call if_changed,extract_ex) 27 26 28 find_all_cmd = find $(src) \( -name '*.yaml' ! !! 27 # Use full schemas when checking %.example.dts 29 -name 'processed-schema*' \) !! 28 DT_TMP_SCHEMA := $(obj)/processed-schema-examples.json 30 29 31 find_cmd = $(find_all_cmd) | \ !! 30 find_all_cmd = find $(srctree)/$(src) \( -name '*.yaml' ! \ 32 sed 's|^$(srctree)/||' | \ !! 31 -name 'processed-schema*' ! \ 33 grep -F -e "$(subst :," -e ",$ !! 32 -name '*.example.dt.yaml' \) 34 sed 's|^|$(srctree)/|' !! 33 35 CHK_DT_EXAMPLES := $(patsubst $(srctree)/%.yam !! 34 ifeq ($(DT_SCHEMA_FILES),) >> 35 find_cmd = $(find_all_cmd) >> 36 else >> 37 find_cmd = echo $(addprefix $(srctree)/, $(DT_SCHEMA_FILES)) >> 38 endif 36 39 37 quiet_cmd_yamllint = LINT $(src) 40 quiet_cmd_yamllint = LINT $(src) 38 cmd_yamllint = ($(find_cmd) | \ 41 cmd_yamllint = ($(find_cmd) | \ 39 xargs -n200 -P$$(nproc) \ 42 xargs -n200 -P$$(nproc) \ 40 $(DT_SCHEMA_LINT) -f pars !! 43 $(DT_SCHEMA_LINT) -f parsable -c $(srctree)/$(src)/.yamllint >&2) || true 41 && touch $@ || true << 42 44 43 quiet_cmd_chk_bindings = CHKDT $(src) !! 45 quiet_cmd_chk_bindings = CHKDT $@ 44 cmd_chk_bindings = ($(find_cmd) | \ 46 cmd_chk_bindings = ($(find_cmd) | \ 45 xargs -n200 -P$$(npr !! 47 xargs -n200 -P$$(nproc) $(DT_DOC_CHECKER) -u $(srctree)/$(src)) || true 46 && touch $@ || true << 47 48 48 quiet_cmd_mk_schema = SCHEMA $@ 49 quiet_cmd_mk_schema = SCHEMA $@ 49 cmd_mk_schema = f=$$(mktemp) ; \ 50 cmd_mk_schema = f=$$(mktemp) ; \ 50 $(find_all_cmd) > $$f ; !! 51 $(if $(DT_MK_SCHEMA_FLAGS), \ >> 52 printf '%s\n' $(real-prereqs), \ >> 53 $(find_all_cmd)) > $$f ; \ 51 $(DT_MK_SCHEMA) -j $(DT_ 54 $(DT_MK_SCHEMA) -j $(DT_MK_SCHEMA_FLAGS) @$$f > $@ ; \ 52 rm -f $$f 55 rm -f $$f 53 56 >> 57 define rule_chkdt >> 58 $(if $(DT_SCHEMA_LINT),$(call cmd,yamllint),) >> 59 $(call cmd,chk_bindings) >> 60 $(call cmd,mk_schema) >> 61 endef >> 62 54 DT_DOCS = $(patsubst $(srctree)/%,%,$(shell $( 63 DT_DOCS = $(patsubst $(srctree)/%,%,$(shell $(find_all_cmd))) 55 64 56 override DTC_FLAGS := \ 65 override DTC_FLAGS := \ 57 -Wno-avoid_unnecessary_addr_size \ 66 -Wno-avoid_unnecessary_addr_size \ 58 -Wno-graph_child_address \ 67 -Wno-graph_child_address \ 59 -Wno-interrupt_provider \ !! 68 -Wno-interrupt_provider 60 -Wno-unique_unit_address \ !! 69 61 -Wunique_unit_address_if_enabled !! 70 # Disable undocumented compatible checks until warning free >> 71 override DT_CHECKER_FLAGS ?= >> 72 >> 73 $(obj)/processed-schema-examples.json: $(DT_DOCS) $(src)/.yamllint check_dtschema_version FORCE >> 74 $(call if_changed_rule,chkdt) >> 75 >> 76 ifeq ($(DT_SCHEMA_FILES),) >> 77 >> 78 # Unless DT_SCHEMA_FILES is specified, use the full schema for dtbs_check too. >> 79 # Just copy processed-schema-examples.json >> 80 >> 81 $(obj)/processed-schema.json: $(obj)/processed-schema-examples.json FORCE >> 82 $(call if_changed,copy) 62 83 63 $(obj)/processed-schema.json: $(DT_DOCS) check !! 84 DT_SCHEMA_FILES = $(DT_DOCS) >> 85 >> 86 else >> 87 >> 88 # If DT_SCHEMA_FILES is specified, use it for processed-schema.json >> 89 >> 90 $(obj)/processed-schema.json: DT_MK_SCHEMA_FLAGS := -u >> 91 $(obj)/processed-schema.json: $(DT_SCHEMA_FILES) check_dtschema_version FORCE 64 $(call if_changed,mk_schema) 92 $(call if_changed,mk_schema) 65 93 66 targets += .dt-binding.checked .yamllint.check !! 94 endif 67 $(obj)/.yamllint.checked: $(DT_DOCS) $(src)/.y !! 95 68 $(if $(DT_SCHEMA_LINT),$(call if_chang !! 96 always-$(CHECK_DT_BINDING) += processed-schema-examples.json 69 !! 97 always-$(CHECK_DTBS) += processed-schema.json 70 $(obj)/.dt-binding.checked: $(DT_DOCS) FORCE !! 98 always-$(CHECK_DT_BINDING) += $(patsubst $(src)/%.yaml,%.example.dts, $(DT_SCHEMA_FILES)) 71 $(call if_changed,chk_bindings) !! 99 always-$(CHECK_DT_BINDING) += $(patsubst $(src)/%.yaml,%.example.dt.yaml, $(DT_SCHEMA_FILES)) 72 << 73 always-y += processed-schema.json << 74 targets += $(patsubst $(obj)/%,%, $(CHK_DT_EXA << 75 targets += $(patsubst $(obj)/%.dtb,%.dts, $(CH << 76 100 77 # Hack: avoid 'Argument list too long' error f 101 # Hack: avoid 'Argument list too long' error for 'make clean'. Remove most of 78 # build artifacts here before they are process 102 # build artifacts here before they are processed by scripts/Makefile.clean 79 clean-files = $(shell find $(obj) \( -name '*. 103 clean-files = $(shell find $(obj) \( -name '*.example.dts' -o \ 80 -name '*.example.dtb' !! 104 -name '*.example.dt.yaml' \) -delete 2>/dev/null) 81 << 82 dt_compatible_check: $(obj)/processed-schema.j << 83 $(Q)$(srctree)/scripts/dtc/dt-extract- << 84 << 85 PHONY += dt_binding_check << 86 dt_binding_check: $(obj)/.dt-binding.checked $ <<
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.