-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
131 lines (105 loc) · 3.78 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# xml-cv v0.1.0
# Copyright © 2018–2019, 2021 Boian Berberov
#
# Licensed under the EUPL-1.2 only.
# License text: https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
# SPDX-License-Identifier: EUPL-1.2
.PHONY: step-localize step-flatten step-adapt step-render
.PHONY: fodt md html linkedin terms all clean
LANG:=en-US
YEARS:=10
INPUT_DIR:=in
OUTPUT_DIR:=out
XSLT_PARAMS:=--stringparam lang $(LANG) --stringparam years $(YEARS)
SOURCES=$(notdir $(wildcard $(INPUT_DIR)/*.xml))
#
# 1. Localization Step
#
L10N_DIR=$(OUTPUT_DIR)/localized
L10N_FILES=$(addprefix $(L10N_DIR)/, $(SOURCES))
$(L10N_DIR):
mkdir -p $@
# XSLT_PARAMS: lang
$(L10N_DIR)/%.xml: $(INPUT_DIR)/%.xml transform/localize_xml-lang.xsl | $(L10N_DIR)
# Do not xmllint; breaks whitespace
xsltproc $(XSLT_PARAMS) transform/localize_xml-lang.xsl $< \
> $@
step-localize: $(L10N_FILES)
#
# 2. Flattening
#
FLAT_DIR=$(OUTPUT_DIR)/flattened
FLAT_FILES=$(addprefix $(FLAT_DIR)/, $(SOURCES))
$(FLAT_DIR):
mkdir -p $@
# Resolving all xlink:href attributes and replicating content
$(FLAT_DIR)/%.xml: $(L10N_DIR)/%.xml transform/flatten_xlink-href.xsl | $(FLAT_DIR)
# Do not xmllint; breaks whitespace
xsltproc transform/flatten_xlink-href.xsl $< \
> $@
step-flatten: $(FLAT_FILES)
#
# 3. Content adaptation
#
ADAPT_DIR=$(OUTPUT_DIR)/adapted
ADAPTED_SUFFIX=.adapted
GENERIC_SUFFIX=.generic
ADAPTED_NAMES=$(addsuffix $(ADAPTED_SUFFIX).xml, $(basename $(SOURCES)))
GENERIC_NAMES=$(addsuffix $(GENERIC_SUFFIX).xml, $(basename $(SOURCES)))
ADAPT_NAMES=$(ADAPTED_NAMES) $(GENERIC_NAMES)
ADAPTED_FILES=$(addprefix $(ADAPT_DIR)/, $(ADAPTED_NAMES))
GENERIC_FILES=$(addprefix $(ADAPT_DIR)/, $(GENERIC_NAMES))
ADAPT_FILES=$(ADAPTED_FILES) $(GENERIC_FILES)
$(ADAPT_DIR):
mkdir -p $@
# XSLT_PARAMS: years
$(ADAPT_DIR)/%$(ADAPTED_SUFFIX).xml: $(FLAT_DIR)/%.xml transform/adapt_adapted.xsl | $(ADAPT_DIR)
# Do not xmllint; breaks whitespace
xsltproc $(XSLT_PARAMS) transform/adapt_adapted.xsl $< \
> $@
$(ADAPT_DIR)/%$(GENERIC_SUFFIX).xml: $(FLAT_DIR)/%.xml transform/adapt_generic.xsl | $(ADAPT_DIR)
# Do not xmllint; breaks whitespace
xsltproc transform/adapt_generic.xsl $< \
> $@
step-adapt: $(ADAPT_FILES)
#
# 4. Rendering
#
RENDER_DIR=$(OUTPUT_DIR)/final
FODT_FILES=$(addprefix $(RENDER_DIR)/, $(addsuffix .fodt, $(basename $(ADAPT_NAMES))))
HTML_FILES=$(addprefix $(RENDER_DIR)/, $(addsuffix .html, $(basename $(ADAPT_NAMES))))
MD_FILES=$(addprefix $(RENDER_DIR)/, $(addsuffix .md, $(basename $(ADAPT_NAMES))))
LINKEDIN_FILES=$(addprefix $(RENDER_DIR)/, $(addsuffix .linkedin.html, $(basename $(ADAPT_NAMES))))
TERMS_FILES=$(addprefix $(RENDER_DIR)/, $(addsuffix .terms.txt, $(basename $(ADAPT_NAMES))))
$(RENDER_DIR):
mkdir -p $@
# XSLT_PARAMS: lang
$(RENDER_DIR)/%.fodt: $(ADAPT_DIR)/%.xml transform/render_fodt.xsl style/fodt_document-styles.xml | $(RENDER_DIR)
xsltproc $(XSLT_PARAMS) transform/render_fodt.xsl $< \
| XMLLINT_INDENT=$$'\t' xmllint --format - \
> $@
# XSLT_PARAMS: lang
$(RENDER_DIR)/%.html: $(ADAPT_DIR)/%.xml transform/render_html.xsl style/html_style.xml | $(RENDER_DIR)
xsltproc $(XSLT_PARAMS) transform/render_html.xsl $< \
> $@
# XSLT_PARAMS: lang
$(RENDER_DIR)/%.md: $(ADAPT_DIR)/%.xml transform/render_md.xsl | $(RENDER_DIR)
xsltproc $(XSLT_PARAMS) transform/render_md.xsl $< \
> $@
$(RENDER_DIR)/%.linkedin.html: $(ADAPT_DIR)/%.xml transform/render_linkedin.xsl style/linkedin_style.xml | $(RENDER_DIR)
xsltproc transform/render_linkedin.xsl $< \
> $@
$(RENDER_DIR)/%.terms.txt: $(ADAPT_DIR)/%.xml transform/render_term-extract.xsl | $(RENDER_DIR)
xsltproc transform/render_term-extract.xsl $< \
| sort \
| uniq -c \
| sort -k 1nr,2f \
> $@
fodt: $(FODT_FILES)
html: $(HTML_FILES)
md: $(MD_FILES)
linkedin: $(LINKEDIN_FILES)
terms: $(TERMS_FILES)
all step-render: fodt html md linkedin terms
clean:
rm -rf $(OUTPUT_DIR)