blob: bf7d64632e20afb1ac98baf8563481d4e4481e96 [file] [log] [blame]
Tom Rini53633a82024-02-29 12:33:36 -05001# 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_LINT = $(shell which yamllint || \
7 echo "warning: python package 'yamllint' not installed, skipping" >&2)
8
9DT_SCHEMA_MIN_VERSION = 2023.9
10
11PHONY += check_dtschema_version
12check_dtschema_version:
13 @which $(DT_DOC_CHECKER) >/dev/null || \
14 { echo "Error: '$(DT_DOC_CHECKER)' not found!" >&2; \
15 echo "Ensure dtschema python package is installed and in your PATH." >&2; \
16 echo "Current PATH is:" >&2; \
17 echo "$$PATH" >&2; false; }
18 @{ echo $(DT_SCHEMA_MIN_VERSION); \
19 $(DT_DOC_CHECKER) --version 2>/dev/null || echo 0; } | sort -Vc >/dev/null || \
20 { echo "ERROR: dtschema minimum version is v$(DT_SCHEMA_MIN_VERSION)" >&2; false; }
21
22quiet_cmd_extract_ex = DTEX $@
23 cmd_extract_ex = $(DT_EXTRACT_EX) $< > $@
24
25$(obj)/%.example.dts: $(src)/%.yaml check_dtschema_version FORCE
26 $(call if_changed,extract_ex)
27
Tom Rini762f85b2024-07-20 11:15:10 -060028find_all_cmd = find $(src) \( -name '*.yaml' ! \
Tom Rini53633a82024-02-29 12:33:36 -050029 -name 'processed-schema*' \)
30
Tom Rini93743d22024-04-01 09:08:13 -040031find_cmd = $(find_all_cmd) | \
32 sed 's|^$(srctree)/||' | \
33 grep -F -e "$(subst :," -e ",$(DT_SCHEMA_FILES))" | \
34 sed 's|^|$(srctree)/|'
Tom Rini762f85b2024-07-20 11:15:10 -060035CHK_DT_EXAMPLES := $(patsubst $(srctree)/%.yaml,%.example.dtb, $(shell $(find_cmd)))
Tom Rini53633a82024-02-29 12:33:36 -050036
37quiet_cmd_yamllint = LINT $(src)
38 cmd_yamllint = ($(find_cmd) | \
39 xargs -n200 -P$$(nproc) \
Tom Rini762f85b2024-07-20 11:15:10 -060040 $(DT_SCHEMA_LINT) -f parsable -c $(src)/.yamllint >&2) \
41 && touch $@ || true
Tom Rini53633a82024-02-29 12:33:36 -050042
Tom Rini762f85b2024-07-20 11:15:10 -060043quiet_cmd_chk_bindings = CHKDT $(src)
Tom Rini53633a82024-02-29 12:33:36 -050044 cmd_chk_bindings = ($(find_cmd) | \
Tom Rini762f85b2024-07-20 11:15:10 -060045 xargs -n200 -P$$(nproc) $(DT_DOC_CHECKER) -u $(src)) \
46 && touch $@ || true
Tom Rini53633a82024-02-29 12:33:36 -050047
48quiet_cmd_mk_schema = SCHEMA $@
49 cmd_mk_schema = f=$$(mktemp) ; \
50 $(find_all_cmd) > $$f ; \
51 $(DT_MK_SCHEMA) -j $(DT_MK_SCHEMA_FLAGS) @$$f > $@ ; \
52 rm -f $$f
53
Tom Rini53633a82024-02-29 12:33:36 -050054DT_DOCS = $(patsubst $(srctree)/%,%,$(shell $(find_all_cmd)))
55
56override DTC_FLAGS := \
57 -Wno-avoid_unnecessary_addr_size \
58 -Wno-graph_child_address \
59 -Wno-interrupt_provider \
60 -Wno-unique_unit_address \
61 -Wunique_unit_address_if_enabled
62
Tom Rini762f85b2024-07-20 11:15:10 -060063$(obj)/processed-schema.json: $(DT_DOCS) check_dtschema_version FORCE
64 $(call if_changed,mk_schema)
65
66targets += .dt-binding.checked .yamllint.checked
67$(obj)/.yamllint.checked: $(DT_DOCS) $(src)/.yamllint FORCE
68 $(if $(DT_SCHEMA_LINT),$(call if_changed,yamllint),)
69
70$(obj)/.dt-binding.checked: $(DT_DOCS) FORCE
71 $(call if_changed,chk_bindings)
Tom Rini53633a82024-02-29 12:33:36 -050072
73always-y += processed-schema.json
Tom Rini762f85b2024-07-20 11:15:10 -060074targets += $(patsubst $(obj)/%,%, $(CHK_DT_EXAMPLES))
75targets += $(patsubst $(obj)/%.dtb,%.dts, $(CHK_DT_EXAMPLES))
Tom Rini53633a82024-02-29 12:33:36 -050076
77# Hack: avoid 'Argument list too long' error for 'make clean'. Remove most of
78# build artifacts here before they are processed by scripts/Makefile.clean
79clean-files = $(shell find $(obj) \( -name '*.example.dts' -o \
80 -name '*.example.dtb' \) -delete 2>/dev/null)
81
82dt_compatible_check: $(obj)/processed-schema.json
83 $(Q)$(srctree)/scripts/dtc/dt-extract-compatibles $(srctree) | xargs dt-check-compatible -v -s $<
Tom Rini762f85b2024-07-20 11:15:10 -060084
85PHONY += dt_binding_check
86dt_binding_check: $(obj)/.dt-binding.checked $(obj)/.yamllint.checked $(CHK_DT_EXAMPLES)