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_LINT
= $(shell which yamllint
)
8 DT_SCHEMA_MIN_VERSION
= 2020.8.1
10 PHONY
+= check_dtschema_version
11 check_dtschema_version
:
12 @
{ echo
$(DT_SCHEMA_MIN_VERSION
); \
13 $(DT_DOC_CHECKER
) --version
2>/dev
/null || echo
0; } |
sort -VC || \
14 { echo
"ERROR: dtschema minimum version is v$(DT_SCHEMA_MIN_VERSION)" >&2; false
; }
16 quiet_cmd_extract_ex
= DTEX
$@
17 cmd_extract_ex
= $(DT_EXTRACT_EX
) $< > $@
19 $(obj
)/%.example.dts
: $(src
)/%.yaml check_dtschema_version FORCE
20 $(call if_changed
,extract_ex
)
22 # Use full schemas when checking %.example.dts
23 DT_TMP_SCHEMA
:= $(obj
)/processed-schema-examples.json
25 find_cmd
= find
$(srctree
)/$(src
) \
( -name
'*.yaml' ! \
26 -name
'processed-schema*' ! \
27 -name
'*.example.dt.yaml' \
)
29 quiet_cmd_yamllint
= LINT
$(src
)
30 cmd_yamllint
= ($(find_cmd
) | \
31 xargs
$(DT_SCHEMA_LINT
) -f parsable
-c
$(srctree
)/$(src
)/.yamllint
) || true
33 quiet_cmd_chk_bindings
= CHKDT
$@
34 cmd_chk_bindings
= ($(find_cmd
) | \
35 xargs
-n200
-P
$$(nproc
) $(DT_DOC_CHECKER
) -u
$(srctree
)/$(src
)) || true
37 quiet_cmd_mk_schema
= SCHEMA
$@
38 cmd_mk_schema
= f
=$$(mktemp
) ; \
39 $(if
$(DT_MK_SCHEMA_FLAGS
), \
40 printf
'%s\n' $(real-prereqs
), \
41 $(find_cmd
)) > $$f ; \
42 $(DT_MK_SCHEMA
) -j
$(DT_MK_SCHEMA_FLAGS
) @
$$f > $@
; \
46 $(if
$(DT_SCHEMA_LINT
),$(call cmd
,yamllint
),)
47 $(call cmd
,chk_bindings
)
51 DT_DOCS
= $(shell $(find_cmd
) | sed
-e
's|^$(srctree)/||')
53 override DTC_FLAGS
:= \
54 -Wno-avoid_unnecessary_addr_size \
55 -Wno-graph_child_address \
56 -Wno-interrupt_provider
58 $(obj
)/processed-schema-examples.json
: $(DT_DOCS
) $(src
)/.yamllint check_dtschema_version FORCE
59 $(call if_changed_rule
,chkdt
)
61 ifeq ($(DT_SCHEMA_FILES
),)
63 # Unless DT_SCHEMA_FILES is specified, use the full schema for dtbs_check too.
64 # Just copy processed-schema-examples.json
66 $(obj
)/processed-schema.json
: $(obj
)/processed-schema-examples.json FORCE
67 $(call if_changed
,copy
)
69 DT_SCHEMA_FILES
= $(DT_DOCS
)
73 # If DT_SCHEMA_FILES is specified, use it for processed-schema.json
75 $(obj
)/processed-schema.json
: DT_MK_SCHEMA_FLAGS
:= -u
76 $(obj
)/processed-schema.json
: $(DT_SCHEMA_FILES
) check_dtschema_version FORCE
77 $(call if_changed
,mk_schema
)
81 extra-
$(CHECK_DT_BINDING
) += processed-schema-examples.json
82 extra-
$(CHECK_DTBS
) += processed-schema.json
83 extra-
$(CHECK_DT_BINDING
) += $(patsubst $(src
)/%.yaml
,%.example.dts
, $(DT_SCHEMA_FILES
))
84 extra-
$(CHECK_DT_BINDING
) += $(patsubst $(src
)/%.yaml
,%.example.dt.yaml
, $(DT_SCHEMA_FILES
))
86 # Hack: avoid 'Argument list too long' error for 'make clean'. Remove most of
87 # build artifacts here before they are processed by scripts/Makefile.clean
88 clean-files
= $(shell find
$(obj
) \
( -name
'*.example.dts' -o \
89 -name
'*.example.dt.yaml' \
) -delete
2>/dev
/null
)