forked from taobao/nginx-docs-cn
-
Notifications
You must be signed in to change notification settings - Fork 1
/
GNUmakefile
256 lines (198 loc) · 5.81 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
OUT = libxslt
TEXT = text
ZIP = gzip
NGINX_ORG = /data/www/nginx.org
SHELL = ./umasked.sh
CP = /data/sites/java/xsls/\*:$(HOME)/java/xsls/\*
RSYNC = rsync -v -rpc --exclude=.svn
CHMOD = /bin/chmod -R g=u
define XSLScript
java -cp $(CP) \
com.pault.StyleSheet \
-x com.pault.XX -y com.pault.XX \
$(1) xsls/dump.xsls \
| sed 's/ *$$//;/^ *$$/N;/\n *$$/D' > $(2)
if [ ! -s $(2) ]; then rm $(2); fi; test -s $(2)
endef
define XSLT
xmllint --noout --valid $2
xsltproc -o $3 \
$(shell f=`echo $2 | sed 's,^xml/,,;s,[^/]*/,en/,'`; \
[ -f xml/$$f ] && echo --stringparam ORIGIN "$$f") \
$(shell p="$4"; [ -n "$$p" ] && \
echo --stringparam $${p%%=*} $${p#*=}) \
$1 $2
endef
define JPEGNORM
jpegtopnm $1 \
| pamscale -width=150 \
| pnmtojpeg -quality=95 -optimize -dct=float \
> $2
endef
COMMON_DEPS = \
xml/menu.xml \
xml/versions.xml \
xml/i18n.xml \
dtd/content.dtd \
xslt/dirname.xslt \
xslt/link.xslt \
xslt/style.xslt \
xslt/body.xslt \
xslt/menu.xslt \
xslt/ga.xslt \
xslt/content.xslt \
ARTICLE_DEPS = \
$(COMMON_DEPS) \
dtd/article.dtd \
dtd/module.dtd \
xslt/article.xslt \
xslt/donate.xslt \
xslt/directive.xslt \
xslt/versions.xslt \
NEWS_DEPS = \
$(COMMON_DEPS) \
dtd/news.dtd \
xslt/news.xslt \
DOWNLOAD_DEPS = \
$(COMMON_DEPS) \
dtd/article.dtd \
xslt/download.xslt \
SECURITY_DEPS = \
$(COMMON_DEPS) \
dtd/article.dtd \
xslt/security.xslt \
BOOK_DEPS = \
$(COMMON_DEPS) \
dtd/article.dtd \
xslt/books.xslt \
LANGS = en ru cn he ja tr
all: news arx 404 $(LANGS)
news: $(OUT)/index.html $(OUT)/index.rss
arx: $(OUT)/2011.html $(OUT)/2010.html $(OUT)/2009.html
404: $(OUT)/404.html
include $(foreach lang, $(LANGS), xml/$(lang)/GNUmakefile)
$(OUT)/index.html: \
xml/index.xml \
$(NEWS_DEPS)
$(call XSLT, xslt/news.xslt, $<, $@)
$(OUT)/index.rss: \
xml/index.xml \
$(NEWS_DEPS) \
xslt/rss.xslt
$(call XSLT, xslt/rss.xslt, $<, $@)
$(OUT)/2011.html \
$(OUT)/2010.html \
$(OUT)/2009.html: \
xml/index.xml \
$(NEWS_DEPS)
$(call XSLT, xslt/news.xslt, $<, $@, YEAR=$(basename $(notdir $@)))
$(OUT)/404.html: \
xml/404.xml \
xml/menu.xml \
dtd/article.dtd \
dtd/content.dtd \
xslt/ga.xslt \
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 \
xsls/dump.xsls
mkdir -p $(dir $@)
$(call XSLScript, $<, $@)
images: \
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/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, $<, $@)
.PHONY: gzip
gzip: rsync_gzip
$(MAKE) do_gzip
rsync_gzip:
$(CHMOD) $(OUT) $(TEXT)
$(RSYNC) --delete --exclude='*.gz' $(OUT)/ $(TEXT)/ $(ZIP)/
do_gzip: $(addsuffix .gz, $(wildcard $(ZIP)/*.html)) \
$(addsuffix .gz, \
$(foreach lang, $(LANGS), \
$(foreach dir, . docs docs/faq docs/http, \
$(wildcard $(ZIP)/$(lang)/$(dir)/*.html)))) \
$(ZIP)/index.rss.gz \
$(ZIP)/LICENSE.gz \
$(ZIP)/en/CHANGES.gz \
$(addsuffix .gz, $(wildcard $(ZIP)/en/CHANGES-?.?)) \
$(ZIP)/ru/CHANGES.ru.gz \
$(addsuffix .gz, $(wildcard $(ZIP)/ru/CHANGES.ru-?.?)) \
$(addsuffix .gz, $(wildcard $(ZIP)/keys/*.key)) \
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_stable \
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
TEMP = temp
SITE = nginx.org
tarball:
rm -rf $(TEMP)
mkdir -p $(TEMP)/$(SITE)
cp -Rp BSDmakefile GNUmakefile umasked.sh \
xml xsls xslt dtd binary sources text \
$(TEMP)/$(SITE)
rm -f $(SITE).tar.bz2
tar -c -y -f $(SITE).tar.bz2 \
--directory $(TEMP) \
--exclude .svn \
$(SITE)
dir.map: xslt/dirmap.xslt xml/en/docs/dirindex.xml
@xsltproc -o - xslt/dirmap.xslt xml/en/docs/dirindex.xml | \
sort -u -k1,1 | sed 's/^include /\\&/' > $@
ifeq ($(patsubst %.nginx.org,YES,$(shell hostname)), YES)
all: dir.map
copy: copy_dirmap
.PHONY: copy_dirmap
copy_dirmap:
/usr/local/bin/copy_dirmap.sh dir.map
endif
.DELETE_ON_ERROR: