14f0e3a57SRob Herring# SPDX-License-Identifier: GPL-2.0 24f0e3a57SRob HerringDT_DOC_CHECKER ?= dt-doc-validate 34f0e3a57SRob HerringDT_EXTRACT_EX ?= dt-extract-example 44f0e3a57SRob HerringDT_MK_SCHEMA ?= dt-mk-schema 54f0e3a57SRob Herring 66b49f340SNathan ChancellorDT_SCHEMA_LINT = $(shell which yamllint || \ 7b3e664a7SRob Herring echo "warning: python package 'yamllint' not installed, skipping" >&2) 844ec8b20SRob Herring 92783a7f5SRob HerringDT_SCHEMA_MIN_VERSION = 2022.3 10ea5b8b5eSRob Herring 11ea5b8b5eSRob HerringPHONY += check_dtschema_version 12ea5b8b5eSRob Herringcheck_dtschema_version: 1328ead0a4SRob Herring @which $(DT_DOC_CHECKER) >/dev/null || \ 1428ead0a4SRob Herring { echo "Error: '$(DT_DOC_CHECKER)' not found!" >&2; \ 1528ead0a4SRob Herring echo "Ensure dtschema python package is installed and in your PATH." >&2; \ 1628ead0a4SRob Herring echo "Current PATH is:" >&2; \ 1728ead0a4SRob Herring echo "$$PATH" >&2; false; } 18ea5b8b5eSRob Herring @{ echo $(DT_SCHEMA_MIN_VERSION); \ 19a21ca2daSIskren Chernev $(DT_DOC_CHECKER) --version 2>/dev/null || echo 0; } | sort -Vc >/dev/null || \ 20ea5b8b5eSRob Herring { echo "ERROR: dtschema minimum version is v$(DT_SCHEMA_MIN_VERSION)" >&2; false; } 21ea5b8b5eSRob Herring 227ba58fffSRob Herringquiet_cmd_extract_ex = DTEX $@ 237ba58fffSRob Herring cmd_extract_ex = $(DT_EXTRACT_EX) $< > $@ 244f0e3a57SRob Herring 25ea5b8b5eSRob Herring$(obj)/%.example.dts: $(src)/%.yaml check_dtschema_version FORCE 267ba58fffSRob Herring $(call if_changed,extract_ex) 274f0e3a57SRob Herring 28378be0ccSGeert Uytterhoevenfind_all_cmd = find $(srctree)/$(src) \( -name '*.yaml' ! \ 29ef8795f3SRob Herring -name 'processed-schema*' \) 308b6b8021SRob Herring 31*25eba159SCristian Ciocalteafind_cmd = $(find_all_cmd) | grep -F -e "$(subst :," -e ",$(DT_SCHEMA_FILES))" 32309d9559SRob HerringCHK_DT_DOCS := $(shell $(find_cmd)) 33378be0ccSGeert Uytterhoeven 3444ec8b20SRob Herringquiet_cmd_yamllint = LINT $(src) 353e95dfb3SRob Herring cmd_yamllint = ($(find_cmd) | \ 36378be0ccSGeert Uytterhoeven xargs -n200 -P$$(nproc) \ 37378be0ccSGeert Uytterhoeven $(DT_SCHEMA_LINT) -f parsable -c $(srctree)/$(src)/.yamllint >&2) || true 3844ec8b20SRob Herring 397ba58fffSRob Herringquiet_cmd_chk_bindings = CHKDT $@ 403e95dfb3SRob Herring cmd_chk_bindings = ($(find_cmd) | \ 413e95dfb3SRob Herring xargs -n200 -P$$(nproc) $(DT_DOC_CHECKER) -u $(srctree)/$(src)) || true 427ba58fffSRob Herring 438b6b8021SRob Herringquiet_cmd_mk_schema = SCHEMA $@ 44b8a49399SAndrei Ziureaev cmd_mk_schema = f=$$(mktemp) ; \ 45dcc2ed39SRob Herring $(find_all_cmd) > $$f ; \ 46b8a49399SAndrei Ziureaev $(DT_MK_SCHEMA) -j $(DT_MK_SCHEMA_FLAGS) @$$f > $@ ; \ 47b8a49399SAndrei Ziureaev rm -f $$f 488b6b8021SRob Herring 497ba58fffSRob Herringdefine rule_chkdt 5044ec8b20SRob Herring $(if $(DT_SCHEMA_LINT),$(call cmd,yamllint),) 517ba58fffSRob Herring $(call cmd,chk_bindings) 527ba58fffSRob Herring $(call cmd,mk_schema) 537ba58fffSRob Herringendef 547ba58fffSRob Herring 55378be0ccSGeert UytterhoevenDT_DOCS = $(patsubst $(srctree)/%,%,$(shell $(find_all_cmd))) 565fa98c2eSRob Herring 5765220630SRob Herringoverride DTC_FLAGS := \ 5865220630SRob Herring -Wno-avoid_unnecessary_addr_size \ 593eb619b2SRob Herring -Wno-graph_child_address \ 604b7c49f7SSam Protsenko -Wno-interrupt_provider \ 614b7c49f7SSam Protsenko -Wno-unique_unit_address \ 624b7c49f7SSam Protsenko -Wunique_unit_address_if_enabled 6365220630SRob Herring 64c59773d2SRob Herring# Disable undocumented compatible checks until warning free 65c59773d2SRob Herringoverride DT_CHECKER_FLAGS ?= 66c59773d2SRob Herring 672783a7f5SRob Herring$(obj)/processed-schema.json: $(DT_DOCS) $(src)/.yamllint check_dtschema_version FORCE 687ba58fffSRob Herring $(call if_changed_rule,chkdt) 694f0e3a57SRob Herring 702783a7f5SRob Herringalways-y += processed-schema.json 71309d9559SRob Herringalways-$(CHECK_DT_BINDING) += $(patsubst $(srctree)/$(src)/%.yaml,%.example.dts, $(CHK_DT_DOCS)) 72ef8795f3SRob Herringalways-$(CHECK_DT_BINDING) += $(patsubst $(srctree)/$(src)/%.yaml,%.example.dtb, $(CHK_DT_DOCS)) 73fa714cf5SMasahiro Yamada 74fa714cf5SMasahiro Yamada# Hack: avoid 'Argument list too long' error for 'make clean'. Remove most of 75fa714cf5SMasahiro Yamada# build artifacts here before they are processed by scripts/Makefile.clean 76fa714cf5SMasahiro Yamadaclean-files = $(shell find $(obj) \( -name '*.example.dts' -o \ 77ef8795f3SRob Herring -name '*.example.dtb' \) -delete 2>/dev/null) 78b6acf807SRob Herring 79b6acf807SRob Herringdt_compatible_check: $(obj)/processed-schema.json 80b6acf807SRob Herring $(Q)$(srctree)/scripts/dtc/dt-extract-compatibles $(srctree) | xargs dt-check-compatible -v -s $< 81