Makefile 2.0 KB
Newer Older
1 2 3 4
# SPDX-License-Identifier: GPL-2.0
DT_DOC_CHECKER ?= dt-doc-validate
DT_EXTRACT_EX ?= dt-extract-example
DT_MK_SCHEMA ?= dt-mk-schema
5
DT_MK_SCHEMA_USERONLY_FLAG := $(if $(DT_SCHEMA_FILES), -u)
6

7 8 9 10 11 12 13 14
DT_SCHEMA_MIN_VERSION = 2020.5

PHONY += check_dtschema_version
check_dtschema_version:
	@{ echo $(DT_SCHEMA_MIN_VERSION); \
	$(DT_DOC_CHECKER) --version 2>/dev/null || echo 0; } | sort -VC || \
	{ echo "ERROR: dtschema minimum version is v$(DT_SCHEMA_MIN_VERSION)" >&2; false; }

15
quiet_cmd_chk_binding = CHKDT   $(patsubst $(srctree)/%,%,$<)
16
      cmd_chk_binding = $(DT_DOC_CHECKER) -u $(srctree)/$(src) $< ; \
17 18
                        $(DT_EXTRACT_EX) $< > $@

19
$(obj)/%.example.dts: $(src)/%.yaml check_dtschema_version FORCE
20 21
	$(call if_changed,chk_binding)

22 23
# Use full schemas when checking %.example.dts
DT_TMP_SCHEMA := $(obj)/processed-schema-examples.yaml
24

25 26 27 28
find_cmd = find $(srctree)/$(src) \( -name '*.yaml' ! \
		-name 'processed-schema*' ! \
		-name '*.example.dt.yaml' \)

29
quiet_cmd_mk_schema = SCHEMA  $@
30 31 32 33 34
      cmd_mk_schema = rm -f $@ ; \
                      $(if $(DT_MK_SCHEMA_FLAGS), \
                           echo $(real-prereqs), \
                           $(find_cmd)) | \
                      xargs $(DT_MK_SCHEMA) $(DT_MK_SCHEMA_FLAGS) >> $@
35

36
DT_DOCS = $(shell $(find_cmd) | sed -e 's|^$(srctree)/||')
37

38
DT_SCHEMA_FILES ?= $(DT_DOCS)
39

40 41 42
extra-$(CHECK_DT_BINDING) += $(patsubst $(src)/%.yaml,%.example.dts, $(DT_SCHEMA_FILES))
extra-$(CHECK_DT_BINDING) += $(patsubst $(src)/%.yaml,%.example.dt.yaml, $(DT_SCHEMA_FILES))
extra-$(CHECK_DT_BINDING) += processed-schema-examples.yaml
43

44 45
override DTC_FLAGS := \
	-Wno-avoid_unnecessary_addr_size \
46 47
	-Wno-graph_child_address \
	-Wno-interrupt_provider
48

49
$(obj)/processed-schema-examples.yaml: $(DT_DOCS) check_dtschema_version FORCE
50
	$(call if_changed,mk_schema)
51

52
$(obj)/processed-schema.yaml: DT_MK_SCHEMA_FLAGS := $(DT_MK_SCHEMA_USERONLY_FLAG)
53
$(obj)/processed-schema.yaml: $(DT_SCHEMA_FILES) check_dtschema_version FORCE
54
	$(call if_changed,mk_schema)
55

56
extra-y += processed-schema.yaml