forked from blynn/gitmagic
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
62 lines (48 loc) · 1.99 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
LANG := en
.PHONY: target clean sync push
target: book book/default.css book.html book.pdf
# The book consists of these text files in the following order:
TXTFILES := preface.txt intro.txt basic.txt clone.txt branch.txt history.txt \
grandmaster.txt secrets.txt drawbacks.txt
book.xml: $(addprefix $(LANG)/,$(TXTFILES))
# Kludge to make preface sections work for languages besides English.
echo '[specialsections]' > conf
sed -n '/^== .* ==$$/p' $(LANG)/preface.txt | sed 's/^== \(.*\) ==$$/^\1$$=sect-preface/' >> conf
# Concatenate the text files and feed to AsciiDoc.
( for FILE in $^ ; do cat $$FILE ; echo ; done ) | \
asciidoc -a lang=$(LANG) -d book -b docbook -f conf - > $@
# Allow unfinished translations to build with this dummy rule.
# Report an error if we reach this rule for the English version.
$(addprefix $(LANG)/,$(TXTFILES)) :
ifeq ($(LANG),en)
echo English file missing: $@; exit 123
endif
# Ignore tidy's exit code because Asciidoc generates section IDs beginning with
# "_", which xmlto converts to "id" attributes of <a> tags. The standard
# insists that "id" attributes begin with a letter, which causes tidy to
# print a warning and return a nonzero code.
#
# When Asciidoc 8.3.0+ is widespread, I'll use its idprefix attribute instead
# of ignoring return codes.
book: book.xml
xmlto -m custom-html.xsl -o book html book.xml
sed -i 's/xmlns:fo[^ ]*//g' book/*.html
-ls book/*.html | xargs -n 1 tidy -utf8 -m -i -q
./makeover
book/default.css: book.css
-mkdir book
rsync book.css book/default.css
book.html: book.xml
xmlto -m custom-nochunks.xsl html-nochunks $^
-tidy -utf8 -imq $@
# Set SP_ENCODING to avoid "non SGML character" errors.
# Can also do SP_ENCODING="UTF-8".
book.pdf: book.xml
SP_ENCODING="XML" docbook2pdf book.xml
clean:
-rm -rf book.xml book.html book
sync: target
rsync -r book.html book.pdf book/* blynn@tl1.stanford.edu:www/gitmagic/intl/$(LANG)/
public:
git push blynn@git.or.cz:srv/git/gitmagic.git
git push git@github.com:blynn/gitmagic.git