-
-
Notifications
You must be signed in to change notification settings - Fork 67
/
Copy pathMakefile
111 lines (91 loc) · 3.9 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
-include ../config.mk
include ../default.mk
docs: texi info html html-dir pdf
texi: $(PKG).texi
info: $(PKG).info dir
html: $(PKG).html
html-dir: $(PKG)/index.html
pdf: $(PKG).pdf
ORG_ARGS = --batch -Q $(ORG_LOAD_PATH)
ORG_EVAL += --eval "(setq indent-tabs-mode nil)"
ORG_EVAL += --eval "(setq org-src-preserve-indentation nil)"
ORG_EVAL += --funcall org-texinfo-export-to-texinfo
redo-docs:
@touch $(PKG).org
@make docs
.revdesc: ;
_ := $(shell test "$(REVDESC)" = "$$(cat .revdesc 2> /dev/null)" ||\
echo "$(REVDESC)" > .revdesc)
%.texi: %.org .orgconfig .revdesc
@printf "Generating $@\n"
@$(EMACS) $(ORG_ARGS) $< $(ORG_EVAL)
@sed -i -e 's/“/``/g' -e "s/”/''/g" -e '$$a\' $(PKG).texi #'
%.info: %.texi
@printf "Generating $@\n"
@$(MAKEINFO) --no-split $< -o $@
dir: $(PKG).info
@printf "Generating $@\n"
@printf "%s" $^ | xargs -n 1 $(INSTALL_INFO) --dir=$@
HTML_FIXUP_CSS = '/<link rel="stylesheet" type="text\/css" href="\/assets\/page.css">/a\
<link rel="icon" href="/assets/magit_alt1.ico">\
\n<link class="s-css-s--style" rel="stylesheet" title="Default" href="/assets/themes/default.css">\
\n<link class="s-css-s--style" rel="stylesheet alternate" title="Default high contrast" href="/assets/themes/default-high-contrast.css">\
\n<link class="s-css-s--style" rel="stylesheet alternate" title="Solarized dark xterm" href="/assets/themes/solarized-dark-xterm.css">\
\n<link class="s-css-s--style" rel="stylesheet alternate" title="Black on white" href="/assets/themes/black-on-white.css">\
\n<script src="/assets/js/simple-css-switch.js"></script>'
HTML_FIXUP_ONLOAD = 's/<body lang="en">/<body lang="en" onload="simpleCssSwitch()">/'
HTML_FIXUP_MENU = '/<\/body>/i<div id="s-css-s--menu"><\/div>'
%.html: %.texi
@printf "Generating $@\n"
@$(MAKEINFO) --html --no-split $(MANUAL_HTML_ARGS) $<
@sed -i -e $(HTML_FIXUP_CSS) -e $(HTML_FIXUP_ONLOAD) -e $(HTML_FIXUP_MENU) $@
%/index.html: %.texi
@printf "Generating $(PKG)/*.html\n"
@rm -rf $(PKG)
@$(MAKEINFO) --html -o $(PKG)/ $(MANUAL_HTML_ARGS) $<
@for f in $$(find $(PKG) -name '*.html') ; do \
sed -i -e $(HTML_FIXUP_CSS) -e $(HTML_FIXUP_ONLOAD) -e $(HTML_FIXUP_MENU) $$f ; \
done
%.pdf: %.texi
@printf "Generating $@\n"
@texi2pdf --clean $< > /dev/null
PUBLISH_PATH ?= /manual/
RELEASE_PATH ?= /manual/$(VERSION)/
S3_BUCKET ?= s3://$(DOMAIN)
PUBLISH_TARGET = $(S3_BUCKET)$(PUBLISH_PATH)
RELEASE_TARGET = $(S3_BUCKET)$(RELEASE_PATH)
CFRONT_PATHS = $(PKG).html $(PKG).pdf $(PKG)/*
comma := ,
empty :=
space := $(empty) $(empty)
publish: redo-docs
@aws s3 cp $(PKG).html $(PUBLISH_TARGET)
@aws s3 cp $(PKG).pdf $(PUBLISH_TARGET)
@aws s3 sync $(PKG) $(PUBLISH_TARGET)$(PKG)/
@printf "Generating CDN invalidation\n"
@aws cloudfront create-invalidation --distribution-id $(CFRONT_DIST) --paths \
"$(subst $(space),$(comma),$(addprefix $(PUBLISH_PATH),$(CFRONT_PATHS)))" > /dev/null
release: redo-docs
@aws s3 cp $(PKG).html $(RELEASE_TARGET)
@aws s3 cp $(PKG).pdf $(RELEASE_TARGET)
@aws s3 sync $(PKG) $(RELEASE_TARGET)$(PKG)/
@aws s3 cp $(PUBLISH_TARGET)dir.html $(RELEASE_TARGET)dir.html
@aws s3 cp $(PUBLISH_TARGET)dir/index.html $(RELEASE_TARGET)dir/index.html
@printf "Generating CDN invalidation\n"
@aws cloudfront create-invalidation --distribution-id $(CFRONT_DIST) --paths \
"$(subst $(space),$(comma),$(addprefix $(RELEASE_PATH),$(CFRONT_PATHS)))" > /dev/null
.PHONY: stats
stats:
@printf "Generating statistics\n"
@$(GITSTATS) $(GITSTATS_ARGS) $(TOP) $(GITSTATS_DIR)
stats-upload:
@printf "Uploading statistics...\n"
@aws s3 sync $(GITSTATS_DIR) $(S3_BUCKET)/stats/$(PKG)
@printf "Uploaded to $(S3_BUCKET)/stats/$(PKG)\n"
@printf "Generating CDN invalidation\n"
@aws cloudfront create-invalidation \
--distribution-id $(CFRONT_DIST) --paths "/stats/*" > /dev/null
CLEAN = $(PKG).info dir $(PKG) $(PKG).html $(PKG).pdf
clean:
@printf " Cleaning docs/*...\n"
@rm -rf $(CLEAN)