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_OPTS = --top-level-division=part -t docbook -f markdown+inline_notes+ascii_identifiers \
22 --variable 'author:Paul Stacey' --variable 'author:Sarah Hinchliff Pearson' \
23 --variable 'title:$(TITLE)'
24 # --top-level-diversion is not available in pandoc in Jessie
25 # PANDOC_OPTS = -t docbook -f markdown+inline_notes
27 LANGS = de es nb nl pl
33 for LANG in $(LANGS); do \
34 rm -f $(SOURCE).$$LANG.md ;\
37 for EXT in aux cb cb2 glo idx lof log tex toc xml pdf; do \
38 rm -f $(SOURCE).$$EXT ;\
39 for LANG in $(LANGS); do \
40 rm -f $(SOURCE).$$LANG.$$EXT ;\
44 $(SOURCE).md: $(SOURCE).odt fixup.rb
45 TEMP=`tempfile -p mwcc` && \
46 pandoc -f odt $(SOURCE).odt -t markdown > $$TEMP && \
47 ruby fixup.rb $$TEMP $(SOURCE).md && \
50 pot: po/mwcc.pot po/*/mwcc.po
51 po/mwcc.pot: $(SOURCE).md
52 TEMP=`tempfile -p mwcc` && \
53 po4a-gettextize -f text -m $(SOURCE).md -p $$TEMP -M utf-8 --package-name 'Made with Creative Commons' --package-version $(VERSION) && \
54 echo '# MADE WITH CREATIVE COMMONS' > $@ && \
55 echo '# Copyright (C) 2017 by Creative Commons.' >> $@ && \
56 echo '# This file is published under a Creative Commons Attribution-ShareAlike license (CC BY-SA), version 4.0' >> $@ && \
57 echo '# Authors: Paul Stacey and Sarah Hinchliff Pearson' >> $@ && \
58 tail --lines=+5 $$TEMP >> $@ && \
60 set -e; for LANG in po/*/mwcc.po; do \
62 msgmerge $$LANG po/mwcc.pot -U ; \
65 $(SOURCE).es.md: $(SOURCE).md po/es/mwcc.po
66 po4a-translate -f text -m $(SOURCE).md -p po/es/mwcc.po -l $@ -l $@ -L utf8 -M utf8 -k 0
68 $(SOURCE).nb.md: $(SOURCE).md po/nb/mwcc.po
69 po4a-translate -f text -m $(SOURCE).md -p po/nb/mwcc.po -l $@ -l $@ -L utf8 -M utf8 -k 0
72 pandoc -s -o $@ $(PANDOC_OPTS) $^
73 perl -p -i -e 's/!DOCTYPE article/!DOCTYPE book/ ; \
74 s!<(/?)article(info|)?>!<$$1book$$2>!' $@
86 dblatex -t tex -b xetex $^
87 perl -p -i -e 's/\[latin1\]\{inputenc\}/[utf8]{inputenc}\n\\usepackage[$(TEXLANG)]{babel}/; \
88 s/\\setcounter\{tocdepth\}.*/\\setcounter{tocdepth}{1}/; \
89 s/\\setcounter\{secnumdepth\}.*/\\setcounter{secnumdepth}{-1}/; \
90 s/\\caption\\end/\\caption{} \\end/; \
91 s!\\maketitle!\\input{extra/$(TEXLANGCODE)/cover.tex}!; \
92 s/\\author\{and\}/\\author{Paul Stacey \\and Sarah Hinchliff Pearson}/; \
93 s/\\DBKinditem\{\\writtenby\}\{and\}/\\DBKinditem{\writtenby}{Paul Stacey and Sarah Hinchliff Pearson}/; \
94 s/\\listoffigures//; \
95 s/\\part\{(Foreword|Prefacio|Introduction|Introducción)\}/\\chapter*{$$1} \\addcontentsline{toc}{chapter}{$$1}/; \
96 s/\\section\{(Notes|Notas)\}/\\section*{$$1}/; \
97 s/(Web links?|Vínculos Web)/\\section*{$$1}/; \
98 s/^\s*(Revenue model|Interview date|Interviewees?|(Modelo de ingresos|Fecha de la entrevista|Entrevistad(?:o|a|os|as)))/\\textbf{$$1}/;' $@
99 perl -p -i -e '$$work=1 if /chapter.Arduino/; $$work=0 if /chapter.(Bibliography|Bibliografía)/; \
100 next unless $$work; \
101 s/(\\label\{[-\.\wáéíóúñ]+\}\\hyperlabel\{[-\.\wáéíóúñ]+\}%)/$$1\n\\begin{quote}/i; \
102 s/(Profile written by.+|Perfil escrito por.+)/$$1\n\\end{quote}/' $@
104 XMLLINTOPTS = --nonet --noout --xinclude --postvalid
106 xmllint $(XMLLINTOPTS) $^