]> pere.pagekite.me Git - text-madewithcc.git/blobdiff - Makefile
Reflow XMl with xmllint after generating it, to make sure it get predictable indentation.
[text-madewithcc.git] / Makefile
index 035b25752d7dc7d556ed659924277217d987eb14..286d9349fec92beb2128d31a6b36657488aed16a 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -10,12 +10,6 @@ SOURCE=MadewithCreativeCommonsmostup-to-dateversion
 # increase every time the generated Markdown is modified.
 VERSION=20170609-2
 
-TEXLANG=spanish
-TEXLANGCODE=es
-
-#TEXLANG=norsk
-#TEXLANGCODE=nb
-
 # pandoc version 1.17.2~dfsg-3 do not understand
 # --top-level-diversion, while version 1.19.2.4~dfsg-1+b3 do.
 PANDOC_OPTS = \
@@ -30,10 +24,10 @@ all: pdf epub
 
 distclean: clean
        rm -f $(SOURCE).md
+clean:
        for LANG in $(LANGS); do \
            rm -f $(SOURCE).$$LANG.md ;\
        done
-clean:
        for EXT in aux cb cb2 glo idx lof log tex toc xml pdf epub; do \
            rm -f $(SOURCE).$$EXT ;\
            for LANG in $(LANGS); do \
@@ -63,45 +57,52 @@ po/*/mwcc.po: po/mwcc.pot
        msgmerge --previous $@ po/mwcc.pot -U
        touch $@
 
+$(SOURCE).de.xml: $(SOURCE).xml po/de/mwcc.po
+       po4a-translate -f docbook -m $(SOURCE).xml -p po/de/mwcc.po -l $@ -l $@ -L utf-8 -M utf-8 -k 0
+
 $(SOURCE).es.xml: $(SOURCE).xml po/es/mwcc.po
        po4a-translate -f docbook -m $(SOURCE).xml -p po/es/mwcc.po -l $@ -l $@ -L utf-8 -M utf-8 -k 0
 
 $(SOURCE).nb.xml: $(SOURCE).xml po/nb/mwcc.po
        po4a-translate -f docbook -m $(SOURCE).xml -p po/nb/mwcc.po -l $@ -l $@ -L utf-8 -M utf-8 -k 0
 
+$(SOURCE).nl.xml: $(SOURCE).xml po/nl/mwcc.po
+       po4a-translate -f docbook -m $(SOURCE).xml -p po/nl/mwcc.po -l $@ -l $@ -L utf-8 -M utf-8 -k 0
+
+$(SOURCE).pl.xml: $(SOURCE).xml po/pl/mwcc.po
+       po4a-translate -f docbook -m $(SOURCE).xml -p po/pl/mwcc.po -l $@ -l $@ -L utf-8 -M utf-8 -k 0
+
+$(SOURCE).uk.xml: $(SOURCE).xml po/uk/mwcc.po
+       po4a-translate -f docbook -m $(SOURCE).xml -p po/uk/mwcc.po -l $@ -l $@ -L utf-8 -M utf-8 -k 0
+
 $(SOURCE).xml: $(SOURCE).md fixup-docbook.rb
        TEMP=`tempfile -p mwcc` && \
          pandoc -s -o $$TEMP $(PANDOC_OPTS) $(SOURCE).md && \
          ruby fixup-docbook.rb $$TEMP $@ && \
          rm $$TEMP
+       xmllint --format $@ > $@.new && mv $@.new $@
 
 pdf: $(SOURCE).pdf
+       for LANG in $(LANGS); do \
+           $(MAKE) $(SOURCE).$$LANG.pdf ; \
+       done
 %.pdf: %.tex
        pdflatex $^
        pdflatex $^
 
 epub: $(SOURCE).epub
+       for LANG in $(LANGS); do \
+           $(MAKE) $(SOURCE).$$LANG.epub ; \
+       done
 %.epub: %.xml
        dbtoepub $^
 
+DBLATEX_OPTS = -T simple -t tex -b xetex -p extra/pdf.xsl
 # Replace Unicode Hair Space (U+200A) with space, as   is not
 # handled by LaTeX/dblatex, see <URL: https://bugs.debian.org/889603 >.
 %.tex: %.xml
-       dblatex -t tex -b xetex $^
-       perl -p -i -e 's/\[latin1\]\{inputenc\}/[utf8]{inputenc}\n\\usepackage[$(TEXLANG)]{babel}/; \
-               s/ / /g; \
-               s/\\setcounter\{tocdepth\}.*/\\setcounter{tocdepth}{1}/; \
-               s/\\setcounter\{secnumdepth\}.*/\\setcounter{secnumdepth}{-1}/; \
-               s/\\caption\\end/\\caption{} \\end/; \
-               s!\\maketitle!\\input{extra/$(TEXLANGCODE)/cover.tex}!; \
-               s/\\author\{and\}/\\author{Paul Stacey \\and Sarah Hinchliff Pearson}/; \
-               s/\\DBKinditem\{\\writtenby\}\{and\}/\\DBKinditem{\writtenby}{Paul Stacey and Sarah Hinchliff Pearson}/; \
-               s/\\listoffigures//; \
-               s/\\chapter\{(Colophon|Dedication)\}/\\chapter*{}/; \
-               s/\\chapter\{(Foreword|Prefacio|Introduction|Introducción)\}/\\chapter*{$$1} \\addcontentsline{toc}{chapter}{$$1}/; \
-               s/\\section\{(Notes|Notas)\}/\\section*{$$1}/; \
-               s/(Web links?|Vínculos Web)/\\section*{$$1}/; \
-               s/^\s*(Revenue model|Interview date|Interviewees?|(Modelo de ingresos|Fecha de la entrevista|Entrevistad(?:o|a|os|as)))/\\textbf{$$1}/;' $@
+       dblatex $(DBLATEX_OPTS) $^
+       perl -p -i -e 's/ / /g' $@
 
 XMLLINTOPTS = --nonet --noout  --xinclude --postvalid
 lint: $(SOURCE).xml