-
Notifications
You must be signed in to change notification settings - Fork 21
/
UG-build.mk
175 lines (151 loc) · 7.91 KB
/
UG-build.mk
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
#
# UG-build.mk
#
# Makefile should include this file and UG-build-adoc.mk if English document,
# or UG-build-po.mk if localized document.
#
# If adding new UGs in the future, maintain the naming convention:
# xxxxxx-users-guide.adoc for the UG's IN- variable below.
IN_UG=drbd-users-guide.adoc
IN_LS=linstor-users-guide.adoc
IN_VSAN=vsan-users-guide.adoc
IN_UNDERSTANDING_GW=linstorgw-users-guide.adoc
OUTDIR=output
OUTDIRPDF=$(OUTDIR)-pdf
OUTDIRHTML=$(OUTDIR)-html
OUTDIRHTMLIMAGES=$(OUTDIRHTML)/images
OUTDIRPDFFINAL=$(OUTDIRPDF)-finalize
OUTDIRHTMLFINAL=$(OUTDIRHTML)-finalize
IMGDIR=../../images
# Set the FONTDIR variable, only if not already set, e.g. within a $lang/Makefile
FONTDIR ?= ../../linbit-fonts
THEMESDIR=../../themes
STYLESDIR=../../styles
OUTHTML_UG=$(addsuffix .html,$(basename $(IN_UG)))
OUTHTML_LS=$(addsuffix .html,$(basename $(IN_LS)))
OUTHTML_VSAN=$(addsuffix .html,$(basename $(IN_VSAN)))
OUTHTML_UNDERSTANDING_GW=$(addsuffix .html,$(basename $(IN_UNDERSTANDING_GW)))
# The -WEBDEVS variables below should result in file names in the form:
# xxxxxxx-users-guide-without-css.html, e.g.,
# vsan-users-guide-without-css.html. This is the HTML file that will be
# included in each UG's ZIP file after running the UGx-html-finalize `make`
# target. The PHP script that is part of the GitLab "preview" phase of the UG
# building process relies on this naming convention.
OUTHTML_UG_WEBDEVS=$(addsuffix -without-css.html,$(basename $(IN_UG)))
OUTHTML_LS_WEBDEVS=$(addsuffix -without-css.html,$(basename $(IN_LS)))
OUTHTML_VSAN_WEBDEVS=$(addsuffix -without-css.html,$(basename $(IN_VSAN)))
OUTHTML_UNDERSTANDING_GW_WEBDEVS=$(addsuffix -without-css.html,$(basename $(IN_UNDERSTANDING_GW)))
OUTPDF_UG=$(addsuffix .pdf,$(basename $(IN_UG)))
OUTPDF_LS=$(addsuffix .pdf,$(basename $(IN_LS)))
OUTPDF_VSAN=$(addsuffix .pdf,$(basename $(IN_VSAN)))
OUTPDF_UNDERSTANDING_GW=$(addsuffix .pdf,$(basename $(IN_UNDERSTANDING_GW)))
# for HTML
SVGS=$(addprefix ../../, $(SVGSUSED))
# output svgs from svgs
OUTSVGSSVGS=$(patsubst $(IMGDIR)/%.svg,$(OUTDIRHTMLIMAGES)/%.svg, $(SVGS))
PNGS=$(addprefix ../../, $(PNGSUSED))
# output pngs from pngs
OUTPNGSPNGS=$(patsubst $(IMGDIR)/%.png,$(OUTDIRHTMLIMAGES)/%.png, $(PNGS))
OUTADOCS=$(addprefix $(OUTDIRHTML)/, $(SRC))
# HTML
$(OUTDIRHTMLIMAGES): $(IMGDIR)
mkdir $@ || true
$(OUTDIRHTMLIMAGES)/%.svg: $(IMGDIR)/%.svg
cp $< $@
$(OUTDIRHTMLIMAGES)/%.png: $(IMGDIR)/%.png
cp $< $@
$(OUTDIRHTML)/%.adoc: %.adoc
# sed 's/\(^image::.*\)\.svg\(.*\)/\1.png\2/g' $< > $@
echo mkdir -p $@/$(shell dirname $<)
cp $< $@
$(OUTDIRHTML)/$(OUTHTML_UG): $(OUTDIRHTMLIMAGES) $(SRC) $(OUTSVGSSVGS) $(OUTPNGSPNGS) $(OUTADOCS)
asciidoctor $(ASCIIDOCTOR_ADD_OPTIONS) -n -d book -a toc=left -a linkcss -a sectanchors=yes $(OPTS) -o ./$(OUTDIRHTML)/$(OUTHTML_UG) $(OUTDIRHTML)/$(IN_UG)
$(OUTDIRHTML)/$(OUTHTML_LS): $(OUTDIRHTMLIMAGES) $(SRC) $(OUTSVGSSVGS) $(OUTPNGSPNGS) $(OUTADOCS)
if test -f $(OUTDIRHTML)/$(IN_LS); then \
asciidoctor $(ASCIIDOCTOR_ADD_OPTIONS) -n -d book -a toc=left -a linkcss -a sectanchors=yes $(OPTS) -o ./$(OUTDIRHTML)/$(OUTHTML_LS) $(OUTDIRHTML)/$(IN_LS); \
else \
echo "LINSTOR guide not found"; \
fi
$(OUTDIRHTML)/$(OUTHTML_VSAN): $(OUTDIRHTMLIMAGES) $(SRC) $(OUTSVGSSVGS) $(OUTPNGSPNGS) $(OUTADOCS)
if test -f $(OUTDIRHTML)/$(IN_VSAN); then \
asciidoctor $(ASCIIDOCTOR_ADD_OPTIONS) -n -d book -a toc=left -a linkcss -a sectanchors=yes $(OPTS) -o ./$(OUTDIRHTML)/$(OUTHTML_VSAN) $(OUTDIRHTML)/$(IN_VSAN); \
else \
echo "VSAN guide not found"; \
fi
$(OUTDIRHTML)/$(OUTHTML_UNDERSTANDING_GW): $(OUTDIRHTMLIMAGES) $(SRC) $(OUTSVGSSVGS) $(OUTPNGSPNGS) $(OUTADOCS)
if test -f $(OUTDIRHTML)/$(IN_UNDERSTANDING_GW); then \
asciidoctor $(ASCIIDOCTOR_ADD_OPTIONS) -n -d book -a toc=left -a linkcss -a sectanchors=yes $(OPTS) -o ./$(OUTDIRHTML)/$(OUTHTML_UNDERSTANDING_GW) $(OUTDIRHTML)/$(IN_UNDERSTANDING_GW); \
else \
echo "Understanding LINSTOR Gateway guide not found"; \
fi
html: $(OUTDIRHTML)/$(OUTHTML_UG) $(OUTDIRHTML)/$(OUTHTML_LS) $(OUTDIRHTML)/$(OUTHTML_VSAN) $(OUTDIRHTML)/$(OUTHTML_UNDERSTANDING_GW)
@echo "Generated web pages in $$(pwd)/$(OUTDIRHTML)"
@echo "Execute 'make html-finalize' to prepare upload"
html-finalize: html
rm -rf $(OUTDIRHTMLFINAL) && mkdir $(OUTDIRHTMLFINAL)
mv $(OUTDIRHTML)/$(OUTHTML_UG) $(OUTDIRHTML)/$(OUTHTML_UG_WEBDEVS)
td=$$(mktemp -d) && \
cp -r $(OUTDIRHTML)/$(OUTHTML_UG_WEBDEVS) $(OUTDIRHTMLIMAGES) $$td && \
(cd $$td && zip drbd.zip $(OUTHTML_UG_WEBDEVS) images/*.*) && mv $$td/drbd.zip $(OUTDIRHTMLFINAL) && rm -rf "$$td"
if test -f $(OUTDIRHTML)/$(OUTHTML_LS); then \
mv $(OUTDIRHTML)/$(OUTHTML_LS) $(OUTDIRHTML)/$(OUTHTML_LS_WEBDEVS) && \
td=$$(mktemp -d) && \
cp $(OUTDIRHTML)/$(OUTHTML_LS_WEBDEVS) "$$td"/$(OUTHTML_LS_WEBDEVS) && cp -r $(OUTDIRHTMLIMAGES) $$td && \
(cd $$td && zip linstor.zip $(OUTHTML_LS_WEBDEVS) images/*.*) && mv $$td/linstor.zip $(OUTDIRHTMLFINAL) && rm -rf "$$td"; \
fi
if test -f $(OUTDIRHTML)/$(OUTHTML_VSAN); then \
mv $(OUTDIRHTML)/$(OUTHTML_VSAN) $(OUTDIRHTML)/$(OUTHTML_VSAN_WEBDEVS) && \
td=$$(mktemp -d) && \
cp $(OUTDIRHTML)/$(OUTHTML_VSAN_WEBDEVS) "$$td"/$(OUTHTML_VSAN_WEBDEVS) && cp -r $(OUTDIRHTMLIMAGES) $$td && \
(cd $$td && zip vsan.zip $(OUTHTML_VSAN_WEBDEVS) images/*.*) && mv $$td/vsan.zip $(OUTDIRHTMLFINAL) && rm -rf "$$td"; \
fi
if test -f $(OUTDIRHTML)/$(OUTHTML_UNDERSTANDING_GW); then \
mv $(OUTDIRHTML)/$(OUTHTML_UNDERSTANDING_GW) $(OUTDIRHTML)/$(OUTHTML_UNDERSTANDING_GW_WEBDEVS) && \
td=$$(mktemp -d) && \
cp $(OUTDIRHTML)/$(OUTHTML_UNDERSTANDING_GW_WEBDEVS) "$$td"/$(OUTHTML_UNDERSTANDING_GW_WEBDEVS) && cp -r $(OUTDIRHTMLIMAGES) $$td && \
(cd $$td && zip linstorgateway.zip $(OUTHTML_UNDERSTANDING_GW_WEBDEVS) images/*.*) && mv $$td/linstorgateway.zip $(OUTDIRHTMLFINAL) && rm -rf "$$td"; \
fi
# PDF
./images: $(IMAGEDIR)
ln -s $(IMGDIR)
$(OUTDIRPDF)/$(OUTPDF_UG): $(SRC) $(SVGSUSED)
if [ -d $(FONTDIR) ] && \
! echo "$(OPTS)" | grep -qFw 'de-brand'; then \
INTERN="--theme $(THEMESDIR)/pdf-$(lang)-theme.yml -a pdf-fontsdir=$(FONTDIR)"; else \
INTERN=""; fi && \
asciidoctor-pdf $(ASCIIDOCTOR_ADD_OPTIONS) -d book $$INTERN $(OPTS) -o $@ $(IN_UG)
$(OUTDIRPDF)/$(OUTPDF_LS): $(SRC) $(SVGSUSED)
if [ -d $(FONTDIR) ] && \
! echo "$(OPTS)" | grep -qFw 'de-brand'; then \
INTERN="--theme $(THEMESDIR)/pdf-$(lang)-theme.yml -a pdf-fontsdir=$(FONTDIR)"; else \
INTERN=""; fi && \
if test -f $(IN_LS); then asciidoctor-pdf $(ASCIIDOCTOR_ADD_OPTIONS) -d book $$INTERN $(OPTS) -o $@ $(IN_LS); fi
$(OUTDIRPDF)/$(OUTPDF_VSAN): $(SRC) $(SVGSUSED)
if [ -d $(FONTDIR) ] && \
! echo "$(OPTS)" | grep -qFw 'de-brand'; then \
INTERN="--theme $(THEMESDIR)/pdf-$(lang)-theme.yml -a pdf-fontsdir=$(FONTDIR)"; else \
INTERN=""; fi && \
if test -f $(IN_VSAN); then asciidoctor-pdf $(ASCIIDOCTOR_ADD_OPTIONS) -d book $$INTERN $(OPTS) -o $@ $(IN_VSAN); fi
$(OUTDIRPDF)/$(OUTPDF_UNDERSTANDING_GW): $(SRC) $(SVGSUSED)
if [ -d $(FONTDIR) ] && [ "$(lang)" != "cn" ] && \
! echo "$(OPTS)" | grep -qFw 'de-brand'; then \
INTERN="--theme $(THEMESDIR)/pdf-$(lang)-theme.yml -a pdf-fontsdir=$(FONTDIR)"; else \
INTERN=""; fi && \
if test -f $(IN_UNDERSTANDING_GW); then asciidoctor-pdf $(ASCIIDOCTOR_ADD_OPTIONS) -d book $$INTERN $(OPTS) -o $@ $(IN_UNDERSTANDING_GW); fi
pdf: ./images $(OUTDIRPDF)/$(OUTPDF_UG) $(OUTDIRPDF)/$(OUTPDF_LS) $(OUTDIRPDF)/$(OUTPDF_VSAN) $(OUTDIRPDF)/$(OUTPDF_UNDERSTANDING_GW)
@echo "Generated $$(pwd)/$(OUTDIRPDF)/{$(OUTPDF_UG),$(OUTPDF_LS),$(OUTPDF_VSAN),$(OUTPDF_UNDERSTANDING_GW)}"
pdf-finalize: pdf
rm -rf $(OUTDIRPDFFINAL) && mkdir $(OUTDIRPDFFINAL)
cp $(OUTDIRPDF)/*.pdf $(OUTDIRPDFFINAL) && \
D=$$(basename $$PWD)-$$(date +%F) && \
for f in $(OUTDIRPDFFINAL)/*.pdf; do \
mv $$f $(OUTDIRPDFFINAL)/$$(basename $$f .pdf)-$$D.pdf; \
done
CLEAN_FILES += \
$(OUTDIRHTML)/*.adoc $(OUTDIRHTML)/*.css $(OUTDIRHTML)/*.html \
$(OUTDIRHTMLIMAGES)/* $(OUTDIRPDF)/* $(OUTDIREPUB) \
$(OUTDIRHTMLFINAL) $(OUTDIRPDFFINAL) $(OUTDIREPUBFINAL)
clean:
rm -rf $(CLEAN_FILES) \
unlink ../../UG8.4/*/images \
unlink ../../UG9/*/images