-
Notifications
You must be signed in to change notification settings - Fork 29
/
GNUmakefile
391 lines (309 loc) · 9.96 KB
/
GNUmakefile
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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
OUT = libxslt
TEXT = text
CSS = css
IMG = img
ZIP = gzip
NGINX_ORG = /data/www/nginx.org
SHELL = tools/umasked.sh
XSLS ?= tools/xslscript.pl
RSYNC = rsync -v -rpc
CHMOD = /bin/chmod -R g=u
define XSLScript
$(XSLS) -o $(2) $(1)
endef
define XSLT
xmllint --noout --valid $2
xsltproc -o $3 \
$(shell ff="$(strip $2)"; f=$${ff#xml/*/}; \
if [ "$$f" != "$$ff" ]; then \
[ -f xml/en/$$f ] && echo --stringparam ORIGIN "en/$$f";\
t=; for l in $(LANGS); do \
[ -f "xml/$$l/$$f" ] && t="$$t$$l "; done; \
echo --stringparam TRANS "\"$$t\""; \
fi) \
$(if $4,--stringparam $4 $5) \
$1 $2
endef
define JPEGNORM
jpegtopnm $1 \
| pamscale -width=150 \
| pnmtojpeg -quality=95 -optimize -dct=float \
> $2
endef
COMMON_DEPS = \
xml/banner.xml \
xml/menu.xml \
xml/i18n.xml \
dtd/content.dtd \
xslt/dirname.xslt \
xslt/link.xslt \
xslt/style.xslt \
xslt/body.xslt \
xslt/menu.xslt \
xslt/content.xslt \
ARTICLE_DEPS = \
$(COMMON_DEPS) \
xml/versions.xml \
dtd/article.dtd \
dtd/module.dtd \
xslt/article.xslt \
xslt/books.xslt \
xslt/directive.xslt \
xslt/donate.xslt \
xslt/download.xslt \
xslt/security.xslt \
xslt/versions.xslt \
xslt/projects.xslt \
NEWS_DEPS = \
$(COMMON_DEPS) \
dtd/news.dtd \
xslt/news.xslt \
LANGS = en ru
YEARS = \
2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 \
2020 2021 2022 2023 2024
all: homepage news arx 404 css $(LANGS)
homepage: $(OUT)/index.html
news: $(OUT)/news.html $(OUT)/index.rss
arx: $(foreach year,$(YEARS),$(OUT)/$(year).html)
404: $(OUT)/404.html
css: $(foreach f,$(wildcard css/*.css),$(OUT)/$(f))
DIRIND_DEPS =
VARIND_DEPS =
define lang-specific
TOP=
DOCS=
REFS=
FAQ=
include xml/$(lang)/GNUmakefile
$(lang): \
$$(foreach f,index $$(TOP),$(OUT)/$(lang)/$$(f).html) \
$$(foreach f,index $$(DOCS) $$(REFS) $$(FAQ), \
$(OUT)/$(lang)/docs/$$(f).html)
$(OUT)/$(lang)/docs/index.html: \
$$(foreach f,$$(DOCS) $$(REFS), \
$(OUT)/$(lang)/docs/$$(f).html)
$(OUT)/$(lang)/docs/faq.html: \
$$(foreach f,$$(FAQ),$(OUT)/$(lang)/docs/$$(f).html)
ifneq (,$$(filter dirindex,$$(DOCS)))
DIRIND_DEPS += xml/$(lang)/docs/dirindex.xml
xml/$(lang)/docs/dirindex.xml: \
$$(foreach f,$$(REFS),xml/$(lang)/docs/$$(f).xml) \
xslt/dirindex.xslt
echo "<modules>$$(patsubst %, \
<module name=\"%\"/>, $$(filter %.xml,$$^))</modules>" | \
xsltproc -o - --stringparam LANG $(lang) \
xslt/dirindex.xslt - | \
sed 's;xml/[^/]*/docs/;;g' > $$@
endif
ifneq (,$$(filter varindex,$$(DOCS)))
VARIND_DEPS += xml/$(lang)/docs/varindex.xml
xml/$(lang)/docs/varindex.xml: \
$$(foreach f,$$(REFS),xml/$(lang)/docs/$$(f).xml) \
xslt/varindex.xslt
echo "<modules>$$(patsubst %, \
<module name=\"%\"/>, $$(filter %.xml,$$^))</modules>" | \
xsltproc -o - --stringparam LANG $(lang) \
xslt/varindex.xslt - | \
sed 's;xml/[^/]*/docs/;;g' > $$@
endif
endef
$(foreach lang, $(LANGS), $(eval $(call lang-specific)))
$(foreach lang, $(LANGS), $(OUT)/$(lang)/docs/dirindex.html): $(DIRIND_DEPS)
$(foreach lang, $(LANGS), $(OUT)/$(lang)/docs/varindex.html): $(VARIND_DEPS)
$(OUT)/index.html: \
xml/homepage.xml \
$(ARTICLE_DEPS)
$(call XSLT, xslt/article.xslt, $<, $@)
$(OUT)/index.rss: \
xml/index.xml \
$(NEWS_DEPS) \
xslt/rss.xslt
$(call XSLT, xslt/rss.xslt, $<, $@)
$(OUT)/news.html: \
xml/index.xml \
$(NEWS_DEPS)
$(call XSLT, xslt/news.xslt, $<, $@)
$(foreach year,$(YEARS),$(OUT)/$(year).html): \
xml/index.xml \
$(NEWS_DEPS)
$(call XSLT, xslt/news.xslt, $<, $@, YEAR, $(basename $(notdir $@)))
$(OUT)/404.html: \
xml/404.xml \
$(COMMON_DEPS) \
dtd/error.dtd \
xslt/error.xslt
$(call XSLT, xslt/error.xslt, $<, $@)
$(OUT)/%.html: xml/%.xml \
$(ARTICLE_DEPS)
$(call XSLT, xslt/article.xslt, $<, $@)
# Prevent intermediate .xslt files from being removed.
$(patsubst xsls/%.xsls,xslt/%.xslt,$(wildcard xsls/*.xsls)):
xslt/%.xslt: xsls/%.xsls
mkdir -p $(dir $@)
$(call XSLScript, $<, $@)
$(OUT)/css/%.css: css/%.css
mkdir -p $(dir $@)
cp $< $@
genapi:
$(MAKE) -C yaml
images: \
binary/books/complete_nginx_cookbook_2019.jpg \
binary/books/deploying_nginx_as_api_gateway.jpg \
binary/books/nginx_cookbook.jpg \
binary/books/nginx_http_server_3rd_ed.jpg \
binary/books/nginx_troubleshooting.jpg \
binary/books/nginx_richtig_konfigurieren.jpg \
binary/books/practical_nginx_guide_jp.jpg \
binary/books/nginx_pocket_reference_jp.jpg \
binary/books/nginx_http_server_jp.jpg \
binary/books/nginx_1_web_server.jpg \
binary/books/nginx_http_server.jpg \
binary/books/nginx_in_practice.jpg \
binary/books/mastering_nginx.jpg \
binary/books/nginx_http_server_2nd_ed.jpg \
binary/books/instant_nginx_starter.jpg \
binary/books/nginx_module_extension.jpg \
binary/books/nginx_high_performance.jpg \
binary/books/nginx_essentials.jpg \
binary/books/nginx_http_server_4th_ed.jpg
binary/books/complete_nginx_cookbook_2019.jpg: \
sources/ebk-ORM-NGINX-Cookbook-mega-2019-150x185.jpg
mkdir -p $(dir $@)
$(call JPEGNORM, $<, $@)
binary/books/deploying_nginx_as_api_gateway.jpg: \
sources/ebk-Deploying-NGINX-Plus-as-API-Gateway-150x185.jpg
mkdir -p $(dir $@)
$(call JPEGNORM, $<, $@)
binary/books/nginx_cookbook.jpg: sources/B05431_0.jpg
mkdir -p $(dir $@)
$(call JPEGNORM, $<, $@)
binary/books/nginx_http_server_3rd_ed.jpg: \
sources/0337OS_4846_Nginx.jpg
mkdir -p $(dir $@)
$(call JPEGNORM, $<, $@)
binary/books/nginx_troubleshooting.jpg: \
sources/51T7ds6JdBL._SX404_BO1,204,203,200_.jpg
mkdir -p $(dir $@)
$(call JPEGNORM, $<, $@)
binary/books/nginx_richtig_konfigurieren.jpg: sources/5106%2B0b2pbL.jpg
mkdir -p $(dir $@)
$(call JPEGNORM, $<, $@)
binary/books/practical_nginx_guide_jp.jpg: sources/9784774178660.jpg
mkdir -p $(dir $@)
$(call JPEGNORM, $<, $@)
binary/books/nginx_pocket_reference_jp.jpg: \
sources/51JYTdy8jrL._SX335_BO1,204,203,200_.jpg
mkdir -p $(dir $@)
$(call JPEGNORM, $<, $@)
binary/books/nginx_http_server_jp.jpg: sources/1106030720.jpg
mkdir -p $(dir $@)
$(call JPEGNORM, $<, $@)
binary/books/nginx_1_web_server.jpg: \
sources/Nginx\ 1\ Web\ Server\ Implementation\ Cookbook.jpg
mkdir -p $(dir $@)
$(call JPEGNORM, "$<", $@)
binary/books/nginx_http_server.jpg: sources/0868OS_MockupCover.jpg
mkdir -p $(dir $@)
$(call JPEGNORM, $<, $@)
binary/books/nginx_in_practice.jpg: sources/20807089-1_o.jpg
mkdir -p $(dir $@)
$(call JPEGNORM, $<, $@)
binary/books/mastering_nginx.jpg: sources/3311OS_4851_Mastering\ NGINX_0.jpg
mkdir -p $(dir $@)
$(call JPEGNORM, "$<", $@)
binary/books/nginx_http_server_2nd_ed.jpg: sources/2322OS_cov.jpg
mkdir -p $(dir $@)
$(call JPEGNORM, $<, $@)
binary/books/instant_nginx_starter.jpg: sources/5125OS_cov.jpg
mkdir -p $(dir $@)
$(call JPEGNORM, $<, $@)
binary/books/nginx_module_extension.jpg: sources/3046OS_cover.jpg
mkdir -p $(dir $@)
$(call JPEGNORM, $<, $@)
binary/books/nginx_high_performance.jpg: sources/1839OS.jpg
mkdir -p $(dir $@)
$(call JPEGNORM, $<, $@)
binary/books/nginx_essentials.jpg: sources/B04282_MockupCover_Normal.jpg
mkdir -p $(dir $@)
$(call JPEGNORM, $<, $@)
binary/books/nginx_http_server_4th_ed.jpg: sources/9781788623551.jpg
mkdir -p $(dir $@)
$(call JPEGNORM, $<, $@)
.PHONY: gzip
gzip: rsync_gzip
$(MAKE) do_gzip
rsync_gzip:
$(CHMOD) $(OUT) $(TEXT)
$(RSYNC) --delete --exclude='*.gz' $(OUT)/ $(TEXT)/ $(IMG) $(ZIP)/
do_gzip: $(addsuffix .gz, $(wildcard $(ZIP)/*.html)) \
$(addsuffix .gz, \
$(foreach lang, $(LANGS), \
$(foreach dir, . docs docs/dev docs/faq docs/http docs/mail docs/njs docs/stream, \
$(wildcard $(ZIP)/$(lang)/$(dir)/*.html)))) \
$(ZIP)/index.rss.gz \
$(ZIP)/LICENSE.gz \
$(ZIP)/en/CHANGES.gz \
$(addsuffix .gz, $(wildcard $(ZIP)/en/CHANGES-?.?)) \
$(addsuffix .gz, $(wildcard $(ZIP)/en/CHANGES-?.??)) \
$(ZIP)/ru/CHANGES.ru.gz \
$(addsuffix .gz, $(wildcard $(ZIP)/ru/CHANGES.ru-?.?)) \
$(addsuffix .gz, $(wildcard $(ZIP)/ru/CHANGES.ru-?.??)) \
$(addsuffix .gz, $(wildcard $(ZIP)/keys/*.key)) \
$(addsuffix .gz, $(wildcard $(ZIP)/css/*.css)) \
$(addsuffix .gz, $(wildcard $(ZIP)/img/*.svg)) \
find $(ZIP) -type f ! -name '*.gz' -exec test \! -e {}.gz \; -print
find $(ZIP) -type f -name '*.gz' | \
while read f ; do test -e "$${f%.gz}" || rm -fv "$$f" ; done
$(ZIP)/%.gz: $(ZIP)/%
rm -f $<.gz
gzip -9cn $< > $<.gz
touch -r $< $<.gz
draft: all
$(CHMOD) $(OUT)
$(RSYNC) --delete $(OUT)/ $(NGINX_ORG)/$(OUT)/
.PHONY: binary
binary:
$(CHMOD) binary
$(RSYNC) binary/ $(NGINX_ORG)/
copy:
$(CHMOD) $(ZIP) binary
$(RSYNC) $(ZIP)/ binary/ $(NGINX_ORG)/
$(RSYNC) --delete $(foreach lang, $(LANGS), $(ZIP)/$(lang)) \
$(NGINX_ORG)/
dev: xslt/version.xslt sign
dev: NGINX:=$(shell xsltproc xslt/version.xslt xml/versions.xml)
stable: xslt/version.xslt sign
stable: NGINX:=$(shell xsltproc --stringparam VERSION stable \
xslt/version.xslt xml/versions.xml)
legacy: xslt/version.xslt sign
legacy: NGINX:=$(shell xsltproc --stringparam VERSION legacy \
xslt/version.xslt xml/versions.xml)
any: sign
any: NGINX=0.7.69
sign:
@echo sign nginx-$(NGINX)
gpg -sab binary/download/nginx-$(NGINX).tar.gz
gpg -sab binary/download/nginx-$(NGINX).zip
dir.map: xslt/dirmap.xslt xml/en/docs/dirindex.xml \
xml/en/docs/varindex.xml
@xsltproc -o - xslt/dirmap.xslt xml/en/docs/dirindex.xml \
xml/en/docs/varindex.xml > $@
ifeq ($(patsubst %.nginx.com,YES,$(shell hostname)), YES)
all: images
ifeq ($(NGINX_ORG), /data/www/nginx.org)
all: dir.map
copy: copy_dirmap
.PHONY: copy_dirmap
copy_dirmap:
/usr/local/bin/copy_dirmap.sh dir.map $(NGINX_ORG)
endif
draft: copy_draft
.PHONY: copy_draft
copy_draft:
/usr/local/bin/copy_draft.sh $(NGINX_ORG)
endif
clean:
rm -rf $(ZIP) $(OUT) xml/*/docs/dirindex.xml dir.map \
xml/*/docs/varindex.xml
.DELETE_ON_ERROR: