Rewrote "Uninterrupted Workflow".
[gitmagic.git] / Makefile
blob561791502eb6484de18d28af1e2dc83fa9c402d1
1 # The language we are building.
2 # For example, Run "make LANG=es" to build the Spanish edition.
3 LANG := en
5 .PHONY: target clean sync push
7 target: book book/default.css book.html book.pdf
9 # The book consists of these text files in the following order:
11 TXTFILES := preface.txt intro.txt basic.txt clone.txt branch.txt history.txt \
12 multiplayer.txt grandmaster.txt secrets.txt drawbacks.txt translate.txt
14 book.xml: $(addprefix $(LANG)/,$(TXTFILES))
15 # Kludge to make preface sections work for languages besides English.
16 echo '[specialsections]' > conf
17 sed -n '/^== .* ==$$/p' $(LANG)/preface.txt | sed 's/^== \(.*\) ==$$/^\1$$=sect-preface/' >> conf
18 # Concatenate the text files and feed to AsciiDoc.
19 # If a file has not yet been translated for the target language,
20 # then substitute the English version.
21 ( for FILE in $^ ; do if [ -f $$FILE ]; then cat $$FILE; else \
22 cat en/$$(basename $$FILE); fi; echo ; done ) | \
23 asciidoc -a lang=$(LANG) -d book -b docbook -f conf - > $@
25 # This rule allows unfinished translations to build.
26 # Report an error if the English version of the text file is missing.
27 $(addprefix $(LANG)/,$(TXTFILES)) :
28 ifeq ($(LANG),en)
29 @if [ ! -f $@ ]; then echo English file missing: $@; exit 123; fi
30 else
31 @if [ ! -f $@ ]; then echo $@ missing: using English version; fi
32 endif
34 # Ignore tidy's exit code because Asciidoc generates section IDs beginning with
35 # "_", which xmlto converts to "id" attributes of <a> tags. The standard
36 # insists that "id" attributes begin with a letter, which causes tidy to
37 # print a warning and return a nonzero code.
39 # When Asciidoc 8.3.0+ is widespread, I'll use its idprefix attribute instead
40 # of ignoring return codes.
42 book: book.xml
43 xmlto -m custom-html.xsl -o book html book.xml
44 sed -i 's/xmlns:fo[^ ]*//g' book/*.html
45 -ls book/*.html | xargs -n 1 tidy -utf8 -m -i -q
46 ./makeover
48 book/default.css: book.css
49 -mkdir book
50 rsync book.css book/default.css
52 book.html: book.xml
53 xmlto -m custom-nochunks.xsl html-nochunks $^
54 -tidy -utf8 -imq $@
56 # Set SP_ENCODING to avoid "non SGML character" errors.
57 # Can also do SP_ENCODING="UTF-8".
58 book.pdf: book.xml
59 SP_ENCODING="XML" docbook2pdf book.xml
61 clean:
62 -rm -rf book.xml book.html book
64 sync: target
65 rsync -r book.html book.pdf book/* blynn@tl1.stanford.edu:www/gitmagic/intl/$(LANG)/
67 public:
68 git push blynn@git.or.cz:srv/git/gitmagic.git
69 git push git@github.com:blynn/gitmagic.git
70 git push git@gitorious.org:gitmagic/mainline.git