]> pere.pagekite.me Git - text-madewithcc.git/blobdiff - Makefile
Translated using Weblate (Norwegian Bokmål)
[text-madewithcc.git] / Makefile
index aa8a73ba7e64aafb5b1c012fec568481a54b551c..b0a37a408758b14f6b12d7ab6dd7c575f33071da 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,3 +1,8 @@
+#
+# As of October 2017, I'm doing some Spanish-specific adjustments to
+# this Makefile; they should be generalized... But I'm taking a step at a time :)
+# -GW
+#
 SOURCE=MadewithCreativeCommonsmostup-to-dateversion
 
 # Versioning: I'm using the date on which I got the source document
@@ -5,9 +10,41 @@ SOURCE=MadewithCreativeCommonsmostup-to-dateversion
 # increase every time the generated Markdown is modified.
 VERSION=20170609-2
 
-# --top-level-diversion is not available in pandoc in Jessie
-PANDOCOPTS = --top-level-division=part -t docbook -f markdown+inline_notes
-PANDOCOPTS = -t docbook -f markdown+inline_notes
+TITLE="Hecho con Creative Commons"
+TEXLANG=spanish
+TEXLANGCODE=es
+
+#TITLE="Laget med Creative Commons"
+#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 = \
+  --standalone \
+  --top-level-division=part \
+  -t docbook \
+  -f markdown+inline_notes+ascii_identifiers \
+  --variable 'author:Paul Stacey' --variable 'author:Sarah Hinchliff Pearson' \
+  --variable 'title:$(TITLE)'
+
+LANGS := $(shell ls po/*/mwcc.po|cut -d/ -f2)
+
+all: pdf epub
+
+distclean: clean
+       rm -f $(SOURCE).md
+       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 \
+               rm -f $(SOURCE).$$LANG.$$EXT ;\
+           done; \
+        done
+       $(RM) *~
 
 $(SOURCE).md: $(SOURCE).odt fixup.rb
        TEMP=`tempfile -p mwcc` && \
@@ -25,20 +62,76 @@ po/mwcc.pot: $(SOURCE).md
        echo '# Authors: Paul Stacey and Sarah Hinchliff Pearson' >> $@ && \
        tail --lines=+5 $$TEMP >> $@ && \
        rm $$TEMP
-       for LANG in po/*/mwcc.po; do \
-           echo -n $$LANG\  ; \
-           msgmerge $$LANG po/mwcc.pot -U ; \
-       done
 
+po/*/mwcc.po: po/mwcc.pot
+       msgmerge --previous $@ po/mwcc.pot -U
+       touch $@
+
+$(SOURCE).es.md: $(SOURCE).md po/es/mwcc.po
+       po4a-translate -f text -m $(SOURCE).md -p po/es/mwcc.po -l $@ -l $@ -L utf-8 -M utf-8 -k 0
+
+$(SOURCE).nb.md: $(SOURCE).md po/nb/mwcc.po
+       po4a-translate -f text -m $(SOURCE).md -p po/nb/mwcc.po -l $@ -l $@ -L utf-8 -M utf-8 -k 0
 
 %.xml: %.md
-       pandoc -o $@ $(PANDOCOPTS) MadewithCreativeCommonsmostup-to-dateversion.md
+       TEMP=`tempfile -p mwcc` && \
+         pandoc -s -o $$TEMP $(PANDOC_OPTS) $^ && \
+         ruby fixup-docbook.rb $$TEMP $@ && \
+         rm $$TEMP
+
+pdf: $(SOURCE).pdf
+%.pdf: %.tex
+       pdflatex $^
+       pdflatex $^
+
+epub: $(SOURCE).epub
+%.epub: %.xml
+       dbtoepub $^
 
-pdf: MadewithCreativeCommonsmostup-to-dateversion.xml
-       dblatex -b xetex MadewithCreativeCommonsmostup-to-dateversion.xml
+# 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/\\part\{(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}/;' $@
+       perl -p -i -e '$$work=1 if /chapter.Arduino/; $$work=0 if /chapter.(Bibliography|Bibliografía)/; \
+               next unless $$work; \
+               s/(\\label\{[-\.\wáéíóúñ]+\}\\hyperlabel\{[-\.\wáéíóúñ]+\}%)/$$1\n\\begin{quote}/i; \
+               s/(Profile written by.+|Perfil escrito por.+|Profilen skrevet av.+)/$$1\n\\end{quote}/' $@
 
 XMLLINTOPTS = --nonet --noout  --xinclude --postvalid
-lint: MadewithCreativeCommonsmostup-to-dateversion.xml
+lint: $(SOURCE).xml
+       xmllint $(XMLLINTOPTS) $^
+lint-es: $(SOURCE).nb.xml
+       xmllint $(XMLLINTOPTS) $^
+lint-nb: $(SOURCE).nb.xml
        xmllint $(XMLLINTOPTS) $^
 
+check-urls:
+       retval=0; for u in $$(perl -n -e'/<ulink url="(.+)"\/>/ && print "$$1\n"' MadewithCreativeCommonsmostup-to-dateversion.xml | sort -u); do \
+         HEAD -H "User-Agent: Docbook XML URL checker" "$$u" > /dev/null || echo "error fetching $$u"; retval=1; \
+       done; exit $$retval
+
+# Experimental build rule to test Docbook XSL + FOP processor 
+xsl-fo-%.pdf: %.xml
+       xsltproc --output $(subst .pdf,.fo,$@) \
+         extra/stylesheet-fo.xsl $^; \
+       fop -fo $(subst .pdf,.fo,$@) -pdf $@
+
+status:
+       for LANG in $(LANGS); do \
+          printf "$$LANG "; msgfmt -o /dev/null --statistics po/$$LANG/mwcc.po; \
+       done
+
 .SUFFIXES: .xml .md