2 # As of October 2017, I'm doing some Spanish-specific adjustments to
3 # this Makefile; they should be generalized... But I'm taking a step at a time :)
6 SOURCE=MadewithCreativeCommonsmostup-to-dateversion
8 # Versioning: I'm using the date on which I got the source document
9 # (2017-06-09), plus an incrementing local part, that *should*
10 # increase every time the generated Markdown is modified.
13 TITLE="Hecho con Creative Commons"
17 #TITLE="Laget med Creative Commons"
21 # pandoc version 1.17.2~dfsg-3 do not understand
22 # --top-level-diversion, while version 1.19.2.4~dfsg-1+b3 do.
25 --top-level-division=part \
27 -f markdown+inline_notes+ascii_identifiers \
28 --variable 'author:Paul Stacey' --variable 'author:Sarah Hinchliff Pearson' \
29 --variable 'title:$(TITLE)'
31 LANGS := $(shell ls po/*/mwcc.po|cut -d/ -f2)
37 for LANG in $(LANGS); do \
38 rm -f $(SOURCE).$$LANG.md ;\
41 for EXT in aux cb cb2 glo idx lof log tex toc xml pdf epub; do \
42 rm -f $(SOURCE).$$EXT ;\
43 for LANG in $(LANGS); do \
44 rm -f $(SOURCE).$$LANG.$$EXT ;\
49 $(SOURCE).md: $(SOURCE).odt fixup.rb
50 TEMP=`tempfile -p mwcc` && \
51 pandoc -f odt $(SOURCE).odt -t markdown > $$TEMP && \
52 ruby fixup.rb $$TEMP $(SOURCE).md && \
55 pot: po/mwcc.pot po/*/mwcc.po
56 po/mwcc.pot: $(SOURCE).md
57 TEMP=`tempfile -p mwcc` && \
58 po4a-gettextize -f text -m $(SOURCE).md -p $$TEMP -M utf-8 --package-name 'Made with Creative Commons' --package-version $(VERSION) && \
59 echo '# MADE WITH CREATIVE COMMONS' > $@ && \
60 echo '# Copyright (C) 2017 by Creative Commons.' >> $@ && \
61 echo '# This file is published under a Creative Commons Attribution-ShareAlike license (CC BY-SA), version 4.0' >> $@ && \
62 echo '# Authors: Paul Stacey and Sarah Hinchliff Pearson' >> $@ && \
63 tail --lines=+5 $$TEMP >> $@ && \
66 po/*/mwcc.po: po/mwcc.pot
67 msgmerge --previous $@ po/mwcc.pot -U
70 $(SOURCE).es.md: $(SOURCE).md po/es/mwcc.po
71 po4a-translate -f text -m $(SOURCE).md -p po/es/mwcc.po -l $@ -l $@ -L utf-8 -M utf-8 -k 0
73 $(SOURCE).nb.md: $(SOURCE).md po/nb/mwcc.po
74 po4a-translate -f text -m $(SOURCE).md -p po/nb/mwcc.po -l $@ -l $@ -L utf-8 -M utf-8 -k 0
77 TEMP=`tempfile -p mwcc` && \
78 pandoc -s -o $$TEMP $(PANDOC_OPTS) $^ && \
79 ruby fixup-docbook.rb $$TEMP $@ && \
91 # Replace Unicode Hair Space (U+200A) with space, as   is not
92 # handled by LaTeX/dblatex, see <URL: https://bugs.debian.org/889603 >.
94 dblatex -t tex -b xetex $^
95 perl -p -i -e 's/\[latin1\]\{inputenc\}/[utf8]{inputenc}\n\\usepackage[$(TEXLANG)]{babel}/; \
97 s/\\setcounter\{tocdepth\}.*/\\setcounter{tocdepth}{1}/; \
98 s/\\setcounter\{secnumdepth\}.*/\\setcounter{secnumdepth}{-1}/; \
99 s/\\caption\\end/\\caption{} \\end/; \
100 s!\\maketitle!\\input{extra/$(TEXLANGCODE)/cover.tex}!; \
101 s/\\author\{and\}/\\author{Paul Stacey \\and Sarah Hinchliff Pearson}/; \
102 s/\\DBKinditem\{\\writtenby\}\{and\}/\\DBKinditem{\writtenby}{Paul Stacey and Sarah Hinchliff Pearson}/; \
103 s/\\listoffigures//; \
104 s/\\part\{(Foreword|Prefacio|Introduction|Introducción)\}/\\chapter*{$$1} \\addcontentsline{toc}{chapter}{$$1}/; \
105 s/\\section\{(Notes|Notas)\}/\\section*{$$1}/; \
106 s/(Web links?|Vínculos Web)/\\section*{$$1}/; \
107 s/^\s*(Revenue model|Interview date|Interviewees?|(Modelo de ingresos|Fecha de la entrevista|Entrevistad(?:o|a|os|as)))/\\textbf{$$1}/;' $@
108 perl -p -i -e '$$work=1 if /chapter.Arduino/; $$work=0 if /chapter.(Bibliography|Bibliografía)/; \
109 next unless $$work; \
110 s/(\\label\{[-\.\wáéíóúñ]+\}\\hyperlabel\{[-\.\wáéíóúñ]+\}%)/$$1\n\\begin{quote}/i; \
111 s/(Profile written by.+|Perfil escrito por.+|Profilen skrevet av.+)/$$1\n\\end{quote}/' $@
113 XMLLINTOPTS = --nonet --noout --xinclude --postvalid
115 xmllint $(XMLLINTOPTS) $^
116 lint-es: $(SOURCE).nb.xml
117 xmllint $(XMLLINTOPTS) $^
118 lint-nb: $(SOURCE).nb.xml
119 xmllint $(XMLLINTOPTS) $^
121 # Experimental build rule to test Docbook XSL + FOP processor
123 xsltproc /usr/share/xml/docbook/stylesheet/docbook-xsl/fo/docbook.xsl $^ > $@.fo
127 for LANG in $(LANGS); do \
128 printf "$$LANG "; msgfmt -o /dev/null --statistics po/$$LANG/mwcc.po; \