-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
145 lines (108 loc) · 4.77 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
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
# Minimal makefile for Sphinx documentation
# heavily customized for internationalization.
#
# You can set these variables from the command line.
LOCALES := en
LOCALEDIR := _locales
LOCALEFILES := $(LOCALES:%=$(LOCALEDIR)/%/LC_MESSAGES/package.po) $(LOCALES:%=$(LOCALEDIR)/%/LC_MESSAGES/sphinx.po)
UPDATEPO := $(filter update-po,$(MAKECMDGOALS))
DATE := $(shell date +%F)
REVISION := $(shell git describe --always --dirty --abbrev=4)
COPYRIGHT := Membres de CLUB1
export AUTHORS := $(shell awk '{printf t $$0; t=", "}' AUTHORS)
export PACKAGE := CLUB1
export VERSION := main
export RELEASE := $(DATE)-g$(REVISION)
export EMAIL := [email protected]
export LOCALE := fr
export LANGUAGES := $(LOCALE) $(LOCALES)
export LATEXMKOPTS := -file-line-error $(if $(CI),,-quiet)
SPHINXOPTS += $(if $(CI),,-q)
SPHINXBUILD ?= sphinx-build
SPHINXBUILDERS := html dirhtml singlehtml epub latex text man texinfo linkcheck
SPHINXLBUILDERS := $(foreach b,$(SPHINXBUILDERS),$(LANGUAGES:%=$b/%))
SPHINXCMDS := gettext changes xml pseudoxml
SOURCEDIR := .
BUILDDIR := _build
DIRS := $(SPHINXBUILDERS:%=$(BUILDDIR)/%) $(SPHINXLBUILDERS:%=$(BUILDDIR)/%)
ALL := $(LANGUAGES:%=all/%)
XGETTEXT := xgettext -x $(LOCALEDIR)/exclude.po -w 79 --add-comments \
--copyright-holder='$(COPYRIGHT)' --package-name='$(PACKAGE)' \
--package-version='$(VERSION)' --msgid-bugs-address='$(EMAIL)'
DIFF := diff -u --color
RTDVERSION := 2.0.0
PUBHOST ?= club1.fr
PUBDIR ?= /var/www/docs
# Put it first so that "make" without argument is like "make help".
help:
$(SPHINXBUILD) -M help $(SOURCEDIR) $(BUILDDIR) $(SPHINXOPTS) $O
.PHONY: help deps clean update-po latexpdf info publish $(ALL) $(SPHINXBUILDERS) $(SPHINXLBUILDERS) $(SPHINXCMDS)
.SECONDEXPANSION:
$(DIRS):
mkdir -p $@
update-po: $(LOCALEFILES);
check-po: $(LOCALEFILES:%=check-po/%)
msgfmt --check-domain _locales/exclude.po
msgcat $(LOCALEDIR)/exclude.po --sort-output | $(DIFF) - $(LOCALEDIR)/exclude.po
$(LOCALEFILES:%=check-po/%): check-po/%:
msgfmt --check $*
%.mo: %.po
msgfmt -o $@ $<
ifdef UPDATEPO
$(LOCALEFILES): $(LOCALEDIR)/%.po: $(LOCALEDIR)/$$(*F).pot
msgmerge -q --previous --update $@ $< --backup=none -w 79
@touch $@
endif
$(LOCALEDIR)/package.pot: conf.py
$(LOCALEDIR)/%.pot: $(BUILDDIR)/gettext/%.pot
$(XGETTEXT) $^ -o $@
$(BUILDDIR)/gettext/%.pot: gettext;
# Special Sphinx builders that need two steps
latexpdf info: %: $(LANGUAGES:%=\%/%)
$(LANGUAGES:%=latexpdf/%): latexpdf/%: latex/%
cat _templates/style.xdy >> $(BUILDDIR)/$</sphinx.xdy
mogrify -strip -resize '800x600>' -define png:compression-level=9 $(BUILDDIR)/$</*.png
max_print_line=110 $(MAKE) -C $(BUILDDIR)/$<
$(LANGUAGES:%=info/%): info/%: texinfo/%
$(MAKE) -C $(BUILDDIR)/$<
# Add some dependencies to the html builders
html: $(BUILDDIR)/html/index.html $(BUILDDIR)/html/.htaccess $(BUILDDIR)/html/metadata.yaml
$(LANGUAGES:%=html/%): _static/js/theme.js
$(BUILDDIR)/html/index.html: _templates/index.html | $(BUILDDIR)/html
cp $< $@
$(BUILDDIR)/html/.htaccess: _templates/.htaccess .FORCE | $(BUILDDIR)/html
sed -e 's/{{release}}/$(RELEASE)/' $< > $@
$(BUILDDIR)/html/metadata.yaml: .FORCE | $(BUILDDIR)/html
echo 'release: $(RELEASE)' > $@
publish:
rsync -av --checksum --fuzzy --delete-delay --include='.htaccess' --exclude='.*' _build/html/ $(USER)@$(PUBHOST):$(PUBDIR)
# Build the full docs ready to be published for a language
all: $(ALL) html latexpdf epub
$(ALL): export DOWNLOADS = club1-$(@F)-latest.pdf club1-$(@F)-latest.epub
$(ALL): all/%: html/% latexpdf/% epub/% | $(BUILDDIR)/html/%
cp $(BUILDDIR)/latex/$*/club1.pdf $(BUILDDIR)/html/$*/club1-$*-$(RELEASE).pdf
cp $(BUILDDIR)/epub/$*/CLUB1.epub $(BUILDDIR)/html/$*/club1-$*-$(RELEASE).epub
# Shinx builders that builds localized versions.
$(SPHINXBUILDERS): %: $(LANGUAGES:%=\%/%)
# Localized Sphinx builders
$(SPHINXLBUILDERS): $$(if $$(filter fr,$$(@F)),,$(LOCALEDIR)/$$(@F)/LC_MESSAGES/package.mo $(LOCALEDIR)/$$(@F)/LC_MESSAGES/sphinx.mo)
LOCALE=$(@F) $(SPHINXBUILD) -b $(@D) -d $(BUILDDIR)/doctrees/$(@F) $(SOURCEDIR) $(BUILDDIR)/$(@D)/$(@F) $(SPHINXOPTS) $O
# Other Sphinx commands for autocompletion
$(SPHINXCMDS):
$(SPHINXBUILD) -M $@ $(SOURCEDIR) $(BUILDDIR) $(SPHINXOPTS) $O
deps: _static/js/theme.js;
_static/js/theme.js: _static/js/theme.js.orig
patch $< _patches/theme-js-nav-no-reset.diff -o $@
rm $<
.INTERMEDIATE: _static/js/theme.js.orig;
_static/js/theme.js.orig:
wget -q https://raw.githubusercontent.com/readthedocs/sphinx_rtd_theme/$(RTDVERSION)/src/theme.js -O $@
mostlyclean:
rm -f $(LOCALEDIR)/*/LC_MESSAGES/*.mo
rm -f *.log
rm -rf $(BUILDDIR)/*
rm -rf _ext/__pycache__
clean: mostlyclean
rm -f _static/js/theme.js*
.PHONY: .FORCE
.FORCE: