Minor Makefile tweak.
[gitmagic/gitmagic.git] / Makefile
blobbd81e1b10d4deaca01858460ec79307015deb82c
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 # If a file has not yet been translated for the target language,
18 # then substitute the English version.
19 ( for FILE in $^ ; do if [ -f $$FILE ]; then cat $$FILE; else \
20 cat en/$$(basename $$FILE); fi; echo ; done ) | \
21 asciidoc -a lang=$(LANG) -d book -b docbook -f conf - > $@
23 # This rule allows unfinished translations to build.
24 # Report an error if the English version of the text file is missing.
25 $(addprefix $(LANG)/,$(TXTFILES)) :
26 ifeq ($(LANG),en)
27 @if [ ! -f $@ ]; then echo English file missing: $@; exit 123; fi
28 else
29 @if [ ! -f $@ ]; then echo $@ missing: using English version; fi
30 endif
32 # Ignore tidy's exit code because Asciidoc generates section IDs beginning with
33 # "_", which xmlto converts to "id" attributes of <a> tags. The standard
34 # insists that "id" attributes begin with a letter, which causes tidy to
35 # print a warning and return a nonzero code.
37 # When Asciidoc 8.3.0+ is widespread, I'll use its idprefix attribute instead
38 # of ignoring return codes.
40 book: book.xml
41 xmlto -m custom-html.xsl -o book html book.xml
42 sed -i 's/xmlns:fo[^ ]*//g' book/*.html
43 -ls book/*.html | xargs -n 1 tidy -utf8 -m -i -q
44 ./makeover
46 book/default.css: book.css
47 -mkdir book
48 rsync book.css book/default.css
50 book.html: book.xml
51 xmlto -m custom-nochunks.xsl html-nochunks $^
52 -tidy -utf8 -imq $@
54 # Set SP_ENCODING to avoid "non SGML character" errors.
55 # Can also do SP_ENCODING="UTF-8".
56 book.pdf: book.xml
57 SP_ENCODING="XML" docbook2pdf book.xml
59 clean:
60 -rm -rf book.xml book.html book
62 sync: target
63 rsync -r book.html book.pdf book/* blynn@tl1.stanford.edu:www/gitmagic/intl/$(LANG)/
65 public:
66 git push blynn@git.or.cz:srv/git/gitmagic.git
67 git push git@github.com:blynn/gitmagic.git