Remove duplicate files. Allow partial translations.
[gitmagic.git] / Makefile
blob4408b0c426d22f394c79d0b7afb4c8e49d1530c6
1 LANG := en
3 .PHONY: target clean sync push
5 target: book book/default.css book.html book.pdf
7 # The book consists of these text files in the following order:
9 TXTFILES := preface.txt intro.txt basic.txt clone.txt branch.txt history.txt \
10 grandmaster.txt secrets.txt drawbacks.txt
12 book.xml: $(addprefix $(LANG)/,$(TXTFILES))
13 # Kludge to make preface sections work for languages besides English.
14 echo '[specialsections]' > conf
15 sed -n '/^== .* ==$$/p' $(LANG)/preface.txt | sed 's/^== \(.*\) ==$$/^\1$$=sect-preface/' >> conf
16 # Concatenate the text files and feed to AsciiDoc.
17 ( for FILE in $^ ; do cat $$FILE ; echo ; done ) | \
18 asciidoc -a lang=$(LANG) -d book -b docbook -f conf - > $@
20 # Allow unfinished translations to build with this dummy rule.
21 # Report an error if we reach this rule for the English version.
22 $(addprefix $(LANG)/,$(TXTFILES)) :
23 ifeq ($(LANG),en)
24 echo English file missing: $@; exit 123
25 endif
27 # Ignore tidy's exit code because Asciidoc generates section IDs beginning with
28 # "_", which xmlto converts to "id" attributes of <a> tags. The standard
29 # insists that "id" attributes begin with a letter, which causes tidy to
30 # print a warning and return a nonzero code.
32 # When Asciidoc 8.3.0+ is widespread, I'll use its idprefix attribute instead
33 # of ignoring return codes.
35 book: book.xml
36 xmlto -m custom-html.xsl -o book html book.xml
37 sed -i 's/xmlns:fo[^ ]*//g' book/*.html
38 -ls book/*.html | xargs -n 1 tidy -utf8 -m -i -q
39 ./makeover
41 book/default.css: book.css
42 -mkdir book
43 rsync book.css book/default.css
45 book.html: book.xml
46 xmlto -m custom-nochunks.xsl html-nochunks $^
47 -tidy -utf8 -imq $@
49 # Set SP_ENCODING to avoid "non SGML character" errors.
50 # Can also do SP_ENCODING="UTF-8".
51 book.pdf: book.xml
52 SP_ENCODING="XML" docbook2pdf book.xml
54 clean:
55 -rm -rf book.xml book.html book
57 sync: target
58 rsync -r book.html book.pdf book/* blynn@tl1.stanford.edu:www/gitmagic/intl/$(LANG)/
60 public:
61 git push blynn@git.or.cz:srv/git/gitmagic.git
62 git push git@github.com:blynn/gitmagic.git