-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
114 lines (93 loc) · 3.18 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
I_D = draft-ietf-netmod-yang-metadata
REVNO = 06
DATE ?= $(shell date +%F)
MODULES = ietf-yang-metadata
SUBMODULES =
FIGURES = example-last-modified.yang
EXAMPLE_BASE = example
EXAMPLE_TYPE = get-reply
baty = $(EXAMPLE_BASE)-$(EXAMPLE_TYPE)
EXAMPLE_INST = $(baty).xml
PYANG_OPTS =
# Paths for pyang
export PYANG_RNG_LIBDIR ?= /usr/share/yang/schema
export PYANG_XSLT_DIR ?= /usr/share/yang/xslt
export YANG_MODPATH ?= .:/usr/share/yang/modules/ietf:/usr/share/yang/modules/iana
artworks = $(addsuffix .aw, $(yass) $(yams)) $(addsuffix .aw, $(FIGURES))
# $(EXAMPLE_INST).aw
idrev = $(I_D)-$(REVNO)
yams = $(addsuffix .yang, $(MODULES))
yass = $(addsuffix .yang, $(SUBMODULES))
xsldir = .tools/xslt
xslpars = --stringparam date $(DATE) --stringparam i-d-name $(I_D) \
--stringparam i-d-rev $(REVNO)
schemas = $(baty).rng $(baty).sch $(baty).dsrl
y2dopts = -t $(EXAMPLE_TYPE) -b $(EXAMPLE_BASE)
.PHONY: all clean rnc refs validate yang
all: $(idrev).txt # $(schemas) model.tree
refs: stdrefs.ent
yang: $(yass) $(yams)
$(idrev).xml: $(I_D).xml $(artworks) figures.ent yang.ent
@xsltproc --novalid $(xslpars) $(xsldir)/upd-i-d.xsl $< | \
xmllint --noent -o $@ -
$(idrev).txt: $(idrev).xml
@xml2rfc --dtd=.tools/schema/rfc2629.dtd $<
hello.xml: $(yass) $(yams) hello-external.ent
@echo '<hello xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">' > $@
@echo '<capabilities>' >> $@
@echo '<capability>urn:ietf:params:netconf:base:1.1</capability>' >> $@
@for m in $(yams); do \
capa=$$(pyang $(PYANG_OPTS) -f capability --capability-entity $$m); \
if [ "$$capa" != "" ]; then \
echo "<capability>$$capa</capability>" >> $@; \
fi \
done
@cat hello-external.ent >> $@
@echo '</capabilities>' >> $@
@echo '</hello>' >> $@
stdrefs.ent: $(I_D).xml
xsltproc --novalid --output $@ $(xsldir)/get-refs.xsl $<
yang.ent: $(yass) $(yams)
@echo '<!-- External entities for files with modules -->' > $@
@for f in $^; do \
echo '<!ENTITY '"$$f SYSTEM \"$$f.aw\">" >> $@; \
done
ifneq ($EXAMPLE_INST,)
@echo '<!ENTITY '"$(EXAMPLE_INST) SYSTEM \"$(EXAMPLE_INST).aw\">" >> $@
endif
figures.ent: $(FIGURES)
ifeq ($(FIGURES),)
@touch $@
else
@echo '<!-- External entities for files with figures -->' > $@; \
for f in $^; do \
echo '<!ENTITY '"$$f SYSTEM \"$$f.aw\">" >> $@; \
done
endif
%.yang: %.yinx
@xsltproc --xinclude $(xsldir)/canonicalize.xsl $< | \
xsltproc --output $@ $(xslpars) $(xsldir)/yin2yang.xsl -
ietf-%.yang.aw: ietf-%.yang
@pyang $(PYANG_OPTS) --ietf $<
@echo '<artwork>' > $@
@echo '<![CDATA[<CODE BEGINS> file '"\"ietf-$*@$(DATE).yang\"" >> $@
@echo >> $@
@cat $< >> $@
@echo >> $@
@echo '<CODE ENDS>]]></artwork>' >> $@
%.aw: %
@echo '<artwork><![CDATA[' > $@; \
cat $< >> $@; \
echo ']]></artwork>' >> $@
$(schemas): hello.xml
yang2dsdl $(y2dopts) -L $<
%.rnc: %.rng
trang -I rng -O rnc $< $@
rnc: $(baty).rnc
validate: $(EXAMPLE_INST) $(schemas)
@yang2dsdl -j -s $(y2dopts) -v $<
model.tree: hello.xml
pyang $(PYANG_OPTS) -f tree -o $@ -L $<
clean:
@rm -rf *.rng *.rnc *.sch *.dsrl hello.xml model.tree \
$(yams) $(idrev).* $(artworks) figures.ent yang.ent