forked from nginx/unit-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
85 lines (67 loc) · 2.2 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
SPHINX ?= sphinx-build
SERVER ?= python3 -mhttp.server
SITEMAP ?= python3 sitemaps.py
URL ?= https://unit.nginx.org
GOOGLE ?= https://www.google.com/webmasters/tools/ping?sitemap=
BING ?= http://www.bing.com/ping?sitemap=
# https://github.com/tdewolff/minify/tree/master/cmd/minify
MINIFY ?= minify
BUILDDIR ?= build
DEPLOYDIR ?= deploy
EXCLUDE = \
--exclude='.*' \
--exclude='*.inv' \
--exclude='*/pygments.css' \
--exclude='/contents' \
--exclude='searchindex.js' \
--exclude='/search'
COMPRESS = -size +1000c \
\( -name '*.html' \
-o -name '*.css' \
-o -name '*.js' \
-o -name '*.svg' \
-o -name '*.txt' \
-o -name '*.xml' \)
.PHONY: site serve check clean deploy do_gzip
site: $(BUILDDIR)
@$(SPHINX) -E -b nxt_html source "$(BUILDDIR)"
$(BUILDDIR):
mkdir "$(BUILDDIR)"
mkdir "$(BUILDDIR)/keys/"
serve: site
@cd "$(BUILDDIR)" && $(SERVER)
check:
@$(SPHINX) -b linkcheck -d "$(BUILDDIR)/.doctrees" source .
clean:
rm -rf $(BUILDDIR)
ping:
curl "$(GOOGLE)$(URL)/sitemap.xml"
curl "$(BING)$(URL)/sitemap.xml"
deploy: site
$(eval TMP := $(shell mktemp -d))
curl https://nginx.org/keys/nginx_signing.key | gpg --dearmor \
| tee "$(BUILDDIR)/keys/nginx-keyring.gpg" > /dev/null
gpg --dry-run --quiet --import --import-options import-show \
"$(BUILDDIR)/keys/nginx-keyring.gpg"
rsync -rv $(EXCLUDE) "$(BUILDDIR)/" "$(TMP)"
$(MINIFY) -vr "$(TMP)" -o "$(TMP)"
$(MINIFY) -v --type html "$(TMP)/go" -o "$(TMP)/go"
rsync -rcv --delete --exclude='*.gz' --exclude='tmp.*' \
--exclude='/sitemap.xml' "$(TMP)/" "$(DEPLOYDIR)"
$(SITEMAP) "$(URL)" index.html "$(DEPLOYDIR)" -e sitemapexclude.txt \
> "$(TMP)/sitemap.xml"
$(MINIFY) -v "$(TMP)/sitemap.xml" -o "$(TMP)/sitemap.xml"
rsync -rcv "$(TMP)/sitemap.xml" "$(DEPLOYDIR)"
-rm -rf "$(TMP)"
rsync -rcv security.txt "$(DEPLOYDIR)/.well-known/"
$(MAKE) do_gzip
chmod -R g=u "$(DEPLOYDIR)"
do_gzip: $(addsuffix .gz, $(shell find "$(DEPLOYDIR)" $(COMPRESS) 2>/dev/null))
find "$(DEPLOYDIR)" -type f ! -name '*.gz' \
-exec test \! -e {}.gz \; -print
find "$(DEPLOYDIR)" -type f -name '*.gz' | \
while read f ; do test -e "$${f%.gz}" || rm -fv "$$f" ; done
$(DEPLOYDIR)/%.gz: $(DEPLOYDIR)/%
rm -f $<.gz
zopfli -c $< > $<.gz
touch -r $< $<.gz