Adjust `makeover` to handle newer AsciiDoc output.
[gitmagic.git] / Makefile
blob0bcd168779f478d94e6b6959b6b215fb53ae775a
1 # The availaible translation languages.
2 # When starting a new translation, add a language code here.
4 TRANSLATIONS = de es fr ko pt_br ru uk vi zh_cn zh_tw it pl
5 LANGS = en $(TRANSLATIONS)
7 .PHONY: all clean $(LANGS)
9 all: $(LANGS)
11 $(LANGS): %: book-% book-%/default.css book-%.html book-%.pdf book-%.epub
13 # The book consists of these text files in the following order:
15 TXTFILES := preface.txt intro.txt basic.txt clone.txt branch.txt history.txt \
16 multiplayer.txt grandmaster.txt secrets.txt drawbacks.txt translate.txt
18 $(foreach l,$(LANGS),book-$(l).xml): book-%.xml: $(addprefix %/,$(TXTFILES))
19 # Concatenate the text files and feed to AsciiDoc.
20 # If a file has not yet been translated for the target language,
21 # then substitute the English version.
22 # Kludge to support any translation of "Preface".
23 echo '[specialsections]' > conf ; \
24 if [ $* != ru ]; then \
25 sed -n '/^== .* ==$$/p' $*/preface.txt | sed 's/^== \(.*\) ==$$/^\1$$=preface/' >> conf ; \
26 else \
27 cp lang-ru.conf conf ; fi ; \
28 ( for FILE in $^ ; do if [ -f $$FILE ]; then cat $$FILE; else \
29 cat en/$$(basename $$FILE); fi; echo ; done ) | \
30 asciidoc -a lang=$* -d book -b docbook -f conf - > $@
32 # This rule allows unfinished translations to build.
33 # Report an error if the English version of the text file is missing.
34 $(addprefix en/,$(TXTFILES)):
35 @if [ ! -f $@ ]; then echo English file missing: $@; exit 123; fi
36 $(foreach l,$(TRANSLATIONS),$(addprefix $(l)/,$(TXTFILES))):
37 @if [ ! -f $@ ]; then echo $@ missing: using English version; fi
39 # Ignore tidy's exit code because Asciidoc generates section IDs beginning with
40 # "_", which xmlto converts to "id" attributes of <a> tags. The standard
41 # insists that "id" attributes begin with a letter, which causes tidy to
42 # print a warning and return a nonzero code.
44 # When Asciidoc 8.3.0+ is widespread, I'll use its idprefix attribute instead
45 # of ignoring return codes.
47 $(foreach l,$(LANGS),book-$(l)): book-%: book-%.xml
48 xmlto -m custom-html.xsl -o book-$* html book-$*.xml
49 sed -i'' -e 's/xmlns:fo[^ ]*//g' book-$*/*.html
50 -ls book-$*/*.html | xargs -n 1 tidy -utf8 -m -i -q
51 ./makeover $*
53 $(foreach l,$(LANGS),book-$(l)/default.css): book-%/default.css: book.css
54 -mkdir -p book-$*
55 rsync book.css book-$*/default.css
57 $(foreach l,$(LANGS),book-$(l).html): book-%.html: book-%.xml
58 pandoc -s -f docbook -t html5 -o $@ $^
60 $(foreach l,$(LANGS),book-$(l).pdf): book-%.pdf: book-%.xml
61 pandoc -s -f docbook -o $@ --pdf-engine=xelatex $^
63 book-ru.pdf: book-ru.xml
64 pandoc -s -f docbook -o $@ --pdf-engine xelatex -V mainfont='DejaVuSansMono' $^
66 book-uk.pdf: book-uk.xml
67 pandoc -s -f docbook -o $@ --pdf-engine xelatex -V mainfont='DejaVuSansMono' $^
69 book-ko.pdf: book-ko.xml
70 pandoc -s -f docbook -o $@ --pdf-engine xelatex -V CJKmainfont='NanumGothic' $^
72 book-zh_cn.pdf: book-zh_cn.xml
73 pandoc -s -f docbook -o $@ --pdf-engine xelatex -V CJKmainfont='WenQuanYi Micro Hei Mono' $^
75 book-zh_tw.pdf: book-zh_tw.xml
76 pandoc -s -f docbook -o $@ --pdf-engine xelatex -V CJKmainfont='WenQuanYi Micro Hei Mono' $^
78 $(foreach l,$(LANGS),book-$(l).epub): book-%.epub: book-%.xml
79 pandoc -s -f docbook -o $@ $^
81 clean:
82 -rm -rf $(foreach l,$(LANGS),book-$(l).pdf book-$(l).xml book-$(l).html book-$(l)) \
83 *.fo *.log *.out *.aux conf