Skip to content
Browse files

Makefile: separate targets for each language, book-??.*

Use 'make en', 'make ru', etc. for a single language, and 'make' or 'make all' for all languages at once.
  • Loading branch information...
1 parent 3bee926 commit 163c3e976d223e06c7e48e0ba9c3f0534ac036c1 @t-t committed Mar 1, 2011
Showing with 33 additions and 33 deletions.
  1. +5 −6 .gitignore
  2. +26 −25 Makefile
  3. +2 −2 makeover
View
11 .gitignore
@@ -1,6 +1,5 @@
-
-book.html
-book.pdf
-book.xml
-book/
-conf
+/book-??.html
+/book-??.pdf
+/book-??.xml
+/book-??/
+/conf
View
51 Makefile
@@ -1,39 +1,40 @@
-# The language we are building.
-# For example, Run "make LANG=es" to build the Spanish edition.
-LANG := en
+# The availaible translation languages.
+# When starting a new translation, add a language code here.
+TRANSLATIONS = de es fr ru
+LANGS = en $(TRANSLATIONS)
SHELL := /bin/bash
-.PHONY: target clean sync push
+.PHONY: all clean sync public $(LANGS)
-target: book book/default.css book.html book.pdf
+all: $(LANGS)
+
+$(LANGS): %: 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 \
multiplayer.txt grandmaster.txt secrets.txt drawbacks.txt translate.txt
-book.xml: $(addprefix $(LANG)/,$(TXTFILES))
+$(foreach l,$(LANGS),book-$(l).xml): book-%.xml: $(addprefix %/,$(TXTFILES))
# Concatenate the text files and feed to AsciiDoc.
# If a file has not yet been translated for the target language,
# then substitute the English version.
# Kludge to support any translation of "Preface".
echo '[specialsections]' > conf ; \
- if [ $(LANG) != ru ]; then \
- sed -n '/^== .* ==$$/p' $(LANG)/preface.txt | sed 's/^== \(.*\) ==$$/^\1$$=preface/' >> conf ; \
+ if [ $* != ru ]; then \
+ sed -n '/^== .* ==$$/p' $*/preface.txt | sed 's/^== \(.*\) ==$$/^\1$$=preface/' >> conf ; \
else \
cp lang-ru.conf conf ; fi ; \
( for FILE in $^ ; do if [ -f $$FILE ]; then cat $$FILE; else \
cat en/$$(basename $$FILE); fi; echo ; done ) | \
- asciidoc -a lang=$(LANG) -d book -b docbook -f conf - > $@
+ asciidoc -a lang=$* -d book -b docbook -f conf - > $@
# This rule allows unfinished translations to build.
# Report an error if the English version of the text file is missing.
-$(addprefix $(LANG)/,$(TXTFILES)) :
-ifeq ($(LANG),en)
+$(addprefix en/,$(TXTFILES)):
@if [ ! -f $@ ]; then echo English file missing: $@; exit 123; fi
-else
+$(foreach l,$(TRANSLATIONS),$(addprefix $(l)/,$(TXTFILES))):
@if [ ! -f $@ ]; then echo $@ missing: using English version; fi
-endif
# Ignore tidy's exit code because Asciidoc generates section IDs beginning with
# "_", which xmlto converts to "id" attributes of <a> tags. The standard
@@ -43,27 +44,27 @@ endif
# 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
+$(foreach l,$(LANGS),book-$(l)): 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
+$(foreach l,$(LANGS),book-$(l)/default.css): book-%/default.css: book.css
+ -mkdir book-$*
+ rsync book.css book-$*/default.css
-book.html: book.xml
+$(foreach l,$(LANGS),book-$(l).html): 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
+$(foreach l,$(LANGS),book-$(l).pdf): book-%.pdf: book-%.xml
+ SP_ENCODING="XML" docbook2pdf book-$*.xml
clean:
- -rm -rf book.xml book.html book
+ -rm -rf $(foreach l,$(LANGS),book-$(l).pdf book-$(l).xml book-$(l).html book-$(l))
sync: target
rsync -r book.html book.pdf book/* blynn@xenon.stanford.edu:www/gitmagic/intl/$(LANG)/
View
4 makeover
@@ -1,9 +1,9 @@
#!/bin/bash
# Extract table of contents from index.html and delete preface link.
-BOOKDIR=book
+BOOKDIR=book-$1
TITLE="Git Magic"
-case $LANG in
+case $1 in
ru)
TITLE="Магия Git"
;;

0 comments on commit 163c3e9

Please sign in to comment.
Something went wrong with that request. Please try again.