forked from webb/niem-json-guidance-auxiliary
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.in
243 lines (193 loc) · 8.03 KB
/
Makefile.in
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
#############################################################################
# Don't touch these...
#############################################################################
this_makefile := ${lastword ${MAKEFILE_LIST}}
SHELL = @bash@ -o pipefail -o errexit -o nounset
.SECONDARY:
#############################################################################
# things to set / override
#############################################################################
# PROGRAMS
# autoconf
MKDIR_P = @MKDIR_P@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
SED = @SED@
# local configure
bash = @bash@
chmod = @chmod@
m4 = @m4@
touch = @touch@
# regular commands
dot = dot
xs_validate = xs-validate
ajv = ajv
# convert is an image converter from ImageMagick
convert = convert
# site stuff
site_dir = @site_dir@
temp_dir = tmp
build_dir = ${temp_dir}/build
tokens_dir = ${temp_dir}/tokens
#############################################################################
# all files: build
# build target files in the source directory.
all_files = \
${build_dir}/examples/object-model/object-model.png \
${build_dir}/examples/object-model/object-model.side-by-side.txt \
${build_dir}/examples/crash/model.png \
#############################################################################
# validation targets
# object model iepd files
object_model_iepd_xml_catalog = examples/object-model/object-model-iepd/niem/xml-catalog.xml
example_schema_json = examples/request/schema.json
validate_files = \
${tokens_dir}/xsd-valid/${object_model_iepd_xml_catalog}/examples/object-model/object-model.xml \
${tokens_dir}/js-valid/${example_schema_json}/examples/request/instance.json \
${tokens_dir}/xsd-valid/${example_crash_xml_catalog}/examples/crash/instance-xsi-type.xml \
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# example/crash
example_crash_xml_catalog = examples/crash/niem/xml-catalog.xml
example_crash_json_schema = examples/crash/schema.json
validate_files += \
${tokens_dir}/xsd-valid/${example_crash_xml_catalog}/examples/crash/instance-xsi-type.xml \
${tokens_dir}/js-valid/always-valid/examples/crash/instance.json \
${tokens_dir}/js-valid/always-valid/examples/crash/schema.json \
${tokens_dir}/js-valid/${example_crash_json_schema}/examples/crash/instance.json \
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# graphics
graphics_domains_png_source = graphics/domains/niem-4.0-release-domains.png
build_graphics_domains_png_medium = ${graphics_domains_png_source:%.png=${build_dir}/%-medium.png}
all_files += ${build_graphics_domains_png_medium}
install_files_relative += json/whatis/niem-4.0-release-domains-medium.png
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# sample iepd files
sample_iepd_xml_catalog = sample-iepd/base-xsd/xml-catalog.xml
sample_iepd_files = \
sample-iepd/iep-samples/iep3.xml \
sample-iepd/iep-samples/iep2.xml \
sample-iepd/iep-samples/iep1.xml
validate_files += ${sample_iepd_files:%=${tokens_dir}/xsd-valid/${sample_iepd_xml_catalog}/%}
# json files
always_valid_json_files = \
examples/array.json \
examples/false.json \
examples/null.json \
examples/number.json \
examples/object-empty.json \
examples/object-model.json \
examples/object-model/object-model.json \
examples/object-model/object-model.no-context.json \
examples/string.json \
examples/true.json \
validate_files += ${always_valid_json_files:%=${tokens_dir}/js-valid/always-valid/%}
install_files_relative += \
json/guidance/object-model.png \
json/guidance/object-model.merged.txt \
json/json-schema/instance.json \
json/json-schema/schema.json \
json/tutorial/model.png \
json/tutorial/wantlist.xml \
json/tutorial/instance.json \
json/tutorial/schema.json \
install_files = ${install_files_relative:%=${site_dir}/%}
#############################################################################
#HELP:Default target is "all". Targets include:
.DEFAULT_GOAL = all
.PHONY: all # Build everything
all: ${all_files}
.PHONY: validate # Validate conformance of files
validate: ${validate_files}
.PHONY: install # Install files in site directory
install: ${install_files}
.PHONY: uninstall # Remove all installed files from site directory
uninstall:
${RM} ${install_files}
.PHONY: clean # clean build products
clean:
${RM} -r ${temp_dir}
find . -type f -name '.DS_Store' -delete
find . -type f -name '*~' -delete
find . -type f -name 'tmp.*' -delete
.PHONY: distclean # Clean all products
distclean: clean
#############################################################################
# all: build
# copy in
${build_dir}/%: %
${MKDIR_P} ${dir $@}
${INSTALL_DATA} $< $@
# PNG file from graphviz DOT file
${build_dir}/%.png: ${build_dir}/%.dot
${dot} -Tpng -o$@ $<
# Run M4 on DOT files
${build_dir}/%.dot: ${build_dir}/%.dot.m4 dot_macros.m4
${m4} -P dot_macros.m4 $< > $@ || ( ${RM} $@ && false )
# Build single text file with side-by-side render of XML and JSON files
${build_dir}/examples/object-model/object-model.side-by-side.txt: examples/object-model/object-model.xml examples/object-model/object-model.json
${MKDIR_P} ${dir $@}
L=$$(( 2 + $$(awk -f examples/object-model/get-length-of-longest-line.awk examples/object-model/object-model.xml) )) \
&& lam -f -$$L.$$L $^ > $@ || ( ${RM} $@ && false )
#############################################################################
# validate
# xsd
${tokens_dir}/xsd-valid/${object_model_iepd_xml_catalog}/%.xml: %.xml ${object_model_iepd_xml_catalog}
${xs_validate} --catalog=${object_model_iepd_xml_catalog} $<
${MKDIR_P} ${dir $@}
${touch} $@
${tokens_dir}/xsd-valid/${sample_iepd_xml_catalog}/%.xml: %.xml ${sample_iepd_xml_catalog}
${xs_validate} --catalog=${sample_iepd_xml_catalog} $<
${MKDIR_P} ${dir $@}
${touch} $@
${tokens_dir}/xsd-valid/${example_crash_xml_catalog}/%.xml: %.xml ${example_crash_xml_catalog}
${xs_validate} --catalog=${example_crash_xml_catalog} $<
${MKDIR_P} ${dir $@}
${touch} $@
is_json_schema = json-schemas/always-valid.schema.json
${tokens_dir}/js-valid/always-valid/%: % ${is_json_schema}
${ajv} -s ${is_json_schema} -d $<
${MKDIR_P} ${dir $@}
${touch} $@
${tokens_dir}/js-valid/${example_schema_json}/examples/request/instance.json: examples/request/instance.json ${example_schema_json}
${ajv} -s ${example_schema_json} -d $<
${MKDIR_P} ${dir $@}
${touch} $@
${tokens_dir}/js-valid/${example_crash_json_schema}/%.json: %.json ${example_crash_json_schema}
${ajv} -s ${example_crash_json_schema} -d $<
${MKDIR_P} ${dir $@}
${touch} $@
#############################################################################
# install
${site_dir}/json/guidance/object-model.png: ${build_dir}/examples/object-model/object-model.png
${MKDIR_P} ${dir $@}
${INSTALL_DATA} $< $@
${site_dir}/json/guidance/object-model.merged.txt: ${build_dir}/examples/object-model/object-model.side-by-side.txt
${MKDIR_P} ${dir $@}
${INSTALL_DATA} $< $@
${site_dir}/json/json-schema/%.json: examples/request/%.json
${MKDIR_P} ${dir $@}
${INSTALL_DATA} $< $@
${site_dir}/json/tutorial/%: ${build_dir}/examples/crash/%
${MKDIR_P} ${dir $@}
${INSTALL_DATA} $< $@
${site_dir}/json/tutorial/%: /examples/crash/%
${MKDIR_P} ${dir $@}
${INSTALL_DATA} $< $@
${site_dir}/json/tutorial/wantlist.xml: ${build_dir}/examples/crash/niem/wantlist.xml
${MKDIR_P} ${dir $@}
${INSTALL_DATA} $< $@
#############################################################################
# graphics: build & install
${build_graphics_domains_png_medium}: ${graphics_domains_png_source}
${MKDIR_P} ${dir $@}
${convert} $< -resize 400 $@
${site_dir}/json/whatis/niem-4.0-release-domains-medium.png: ${build_graphics_domains_png_medium}
${MKDIR_P} ${dir $@}
${INSTALL_DATA} $< $@
#############################################################################
# make help: this must be the last target
.PHONY: help # Print this help
help:
@ ${SED} -e '/^\.PHONY:/s/^\.PHONY: *\([^ #]*\) *\#\( *\)\([^ ].*\)/\2\1: \3/p;/^[^#]*#HELP:/s/[^#]*#HELP:\(.*\)/\1/p;d' ${this_makefile}
# don't put anything after this