1# SPDX-License-Identifier: GPL-2.0 2DT_DOC_CHECKER ?= dt-doc-validate 3DT_EXTRACT_EX ?= dt-extract-example 4DT_MK_SCHEMA ?= dt-mk-schema 5 6DT_SCHEMA_MIN_VERSION = 2020.5 7 8PHONY += check_dtschema_version 9check_dtschema_version: 10 @{ echo $(DT_SCHEMA_MIN_VERSION); \ 11 $(DT_DOC_CHECKER) --version 2>/dev/null || echo 0; } | sort -VC || \ 12 { echo "ERROR: dtschema minimum version is v$(DT_SCHEMA_MIN_VERSION)" >&2; false; } 13 14quiet_cmd_chk_binding = CHKDT $(patsubst $(srctree)/%,%,$<) 15 cmd_chk_binding = $(DT_DOC_CHECKER) -u $(srctree)/$(src) $< ; \ 16 $(DT_EXTRACT_EX) $< > $@ 17 18$(obj)/%.example.dts: $(src)/%.yaml check_dtschema_version FORCE 19 $(call if_changed,chk_binding) 20 21# Use full schemas when checking %.example.dts 22DT_TMP_SCHEMA := $(obj)/processed-schema-examples.yaml 23 24find_cmd = find $(srctree)/$(src) \( -name '*.yaml' ! \ 25 -name 'processed-schema*' ! \ 26 -name '*.example.dt.yaml' \) 27 28quiet_cmd_mk_schema = SCHEMA $@ 29 cmd_mk_schema = rm -f $@ ; \ 30 $(if $(DT_MK_SCHEMA_FLAGS), \ 31 echo $(real-prereqs), \ 32 $(find_cmd)) | \ 33 xargs $(DT_MK_SCHEMA) $(DT_MK_SCHEMA_FLAGS) >> $@ 34 35DT_DOCS = $(shell $(find_cmd) | sed -e 's|^$(srctree)/||') 36 37override DTC_FLAGS := \ 38 -Wno-avoid_unnecessary_addr_size \ 39 -Wno-graph_child_address \ 40 -Wno-interrupt_provider 41 42$(obj)/processed-schema-examples.yaml: $(DT_DOCS) check_dtschema_version FORCE 43 $(call if_changed,mk_schema) 44 45ifeq ($(DT_SCHEMA_FILES),) 46 47# Unless DT_SCHEMA_FILES is specified, use the full schema for dtbs_check too. 48# Just copy processed-schema-examples.yaml 49 50$(obj)/processed-schema.yaml: $(obj)/processed-schema-examples.yaml FORCE 51 $(call if_changed,copy) 52 53DT_SCHEMA_FILES = $(DT_DOCS) 54 55else 56 57# If DT_SCHEMA_FILES is specified, use it for processed-schema.yaml 58 59$(obj)/processed-schema.yaml: DT_MK_SCHEMA_FLAGS := -u 60$(obj)/processed-schema.yaml: $(DT_SCHEMA_FILES) check_dtschema_version FORCE 61 $(call if_changed,mk_schema) 62 63endif 64 65extra-$(CHECK_DT_BINDING) += $(patsubst $(src)/%.yaml,%.example.dts, $(DT_SCHEMA_FILES)) 66extra-$(CHECK_DT_BINDING) += $(patsubst $(src)/%.yaml,%.example.dt.yaml, $(DT_SCHEMA_FILES)) 67extra-$(CHECK_DT_BINDING) += processed-schema-examples.yaml 68extra-$(CHECK_DTBS) += processed-schema.yaml 69 70# Hack: avoid 'Argument list too long' error for 'make clean'. Remove most of 71# build artifacts here before they are processed by scripts/Makefile.clean 72clean-files = $(shell find $(obj) \( -name '*.example.dts' -o \ 73 -name '*.example.dt.yaml' \) -delete 2>/dev/null) 74