1 # SPDX-License-Identifier: GPL-2.0
2 DT_DOC_CHECKER ?
= dt-doc-validate
3 DT_EXTRACT_EX ?
= dt-extract-example
4 DT_MK_SCHEMA ?
= dt-mk-schema
6 DT_SCHEMA_MIN_VERSION
= 2020.5
8 PHONY
+= check_dtschema_version
9 check_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
; }
14 quiet_cmd_chk_binding
= CHKDT
$(patsubst $(srctree
)/%,%,$<)
15 cmd_chk_binding
= $(DT_DOC_CHECKER
) -u
$(srctree
)/$(src
) $< ; \
16 $(DT_EXTRACT_EX
) $< > $@
18 $(obj
)/%.example.dts
: $(src
)/%.yaml check_dtschema_version FORCE
19 $(call if_changed
,chk_binding
)
21 # Use full schemas when checking %.example.dts
22 DT_TMP_SCHEMA
:= $(obj
)/processed-schema-examples.yaml
24 find_cmd
= find
$(srctree
)/$(src
) \
( -name
'*.yaml' ! \
25 -name
'processed-schema*' ! \
26 -name
'*.example.dt.yaml' \
)
28 quiet_cmd_mk_schema
= SCHEMA
$@
29 cmd_mk_schema
= rm -f
$@
; \
30 $(if
$(DT_MK_SCHEMA_FLAGS
), \
31 echo
$(real-prereqs
), \
33 xargs
$(DT_MK_SCHEMA
) $(DT_MK_SCHEMA_FLAGS
) >> $@
35 DT_DOCS
= $(shell $(find_cmd
) | sed
-e
's|^$(srctree)/||')
37 override DTC_FLAGS
:= \
38 -Wno-avoid_unnecessary_addr_size \
39 -Wno-graph_child_address \
40 -Wno-interrupt_provider
42 $(obj
)/processed-schema-examples.yaml
: $(DT_DOCS
) check_dtschema_version FORCE
43 $(call if_changed
,mk_schema
)
45 ifeq ($(DT_SCHEMA_FILES
),)
47 # Unless DT_SCHEMA_FILES is specified, use the full schema for dtbs_check too.
48 # Just copy processed-schema-examples.yaml
50 $(obj
)/processed-schema.yaml
: $(obj
)/processed-schema-examples.yaml FORCE
51 $(call if_changed
,copy
)
53 DT_SCHEMA_FILES
= $(DT_DOCS
)
57 # If DT_SCHEMA_FILES is specified, use it for processed-schema.yaml
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
)
65 extra-
$(CHECK_DT_BINDING
) += $(patsubst $(src
)/%.yaml
,%.example.dts
, $(DT_SCHEMA_FILES
))
66 extra-
$(CHECK_DT_BINDING
) += $(patsubst $(src
)/%.yaml
,%.example.dt.yaml
, $(DT_SCHEMA_FILES
))
67 extra-
$(CHECK_DT_BINDING
) += processed-schema-examples.yaml
68 extra-
$(CHECK_DTBS
) += processed-schema.yaml
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
72 clean-files
= $(shell find
$(obj
) \
( -name
'*.example.dts' -o \
73 -name
'*.example.dt.yaml' \
) -delete
2>/dev
/null
)