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 HerringDT_MK_SCHEMA_FLAGS := $(if $(DT_SCHEMA_FILES), -u)
64f0e3a57SRob Herring
74f0e3a57SRob Herringquiet_cmd_chk_binding = CHKDT   $(patsubst $(srctree)/%,%,$<)
805aeca7cSRob Herring      cmd_chk_binding = $(DT_DOC_CHECKER) -u $(srctree)/$(src) $< ; \
94f0e3a57SRob Herring                        $(DT_EXTRACT_EX) $< > $@
104f0e3a57SRob Herring
114f0e3a57SRob Herring$(obj)/%.example.dts: $(src)/%.yaml FORCE
124f0e3a57SRob Herring	$(call if_changed,chk_binding)
134f0e3a57SRob Herring
144f0e3a57SRob HerringDT_TMP_SCHEMA := processed-schema.yaml
154f0e3a57SRob Herringextra-y += $(DT_TMP_SCHEMA)
164f0e3a57SRob Herring
174f0e3a57SRob Herringquiet_cmd_mk_schema = SCHEMA  $@
18afa974b7SMasahiro Yamada      cmd_mk_schema = $(DT_MK_SCHEMA) $(DT_MK_SCHEMA_FLAGS) -o $@ $(real-prereqs)
194f0e3a57SRob Herring
205fa98c2eSRob HerringDT_DOCS = $(shell \
215fa98c2eSRob Herring	cd $(srctree)/$(src) && \
225fa98c2eSRob Herring	find * \( -name '*.yaml' ! -name $(DT_TMP_SCHEMA) \) \
235fa98c2eSRob Herring	)
245fa98c2eSRob Herring
254f0e3a57SRob HerringDT_SCHEMA_FILES ?= $(addprefix $(src)/,$(DT_DOCS))
264f0e3a57SRob Herring
274f0e3a57SRob Herringextra-y += $(patsubst $(src)/%.yaml,%.example.dts, $(DT_SCHEMA_FILES))
284f0e3a57SRob Herringextra-y += $(patsubst $(src)/%.yaml,%.example.dtb, $(DT_SCHEMA_FILES))
294f0e3a57SRob Herring
304f0e3a57SRob Herring$(obj)/$(DT_TMP_SCHEMA): $(DT_SCHEMA_FILES) FORCE
314f0e3a57SRob Herring	$(call if_changed,mk_schema)
32