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; do \
42 rm -f $(SOURCE).$$EXT ;\
43 for LANG in $(LANGS); do \
44 rm -f $(SOURCE).$$LANG.$$EXT ;\
48 $(SOURCE).md: $(SOURCE).odt fixup.rb
49 TEMP=`tempfile -p mwcc` && \
50 pandoc -f odt $(SOURCE).odt -t markdown > $$TEMP && \
51 ruby fixup.rb $$TEMP $(SOURCE).md && \
54 pot: po/mwcc.pot po/*/mwcc.po
55 po/mwcc.pot: $(SOURCE).md
56 TEMP=`tempfile -p mwcc` && \
57 po4a-gettextize -f text -m $(SOURCE).md -p $$TEMP -M utf-8 --package-name 'Made with Creative Commons' --package-version $(VERSION) && \
58 echo '# MADE WITH CREATIVE COMMONS' > $@ && \
59 echo '# Copyright (C) 2017 by Creative Commons.' >> $@ && \
60 echo '# This file is published under a Creative Commons Attribution-ShareAlike license (CC BY-SA), version 4.0' >> $@ && \
61 echo '# Authors: Paul Stacey and Sarah Hinchliff Pearson' >> $@ && \
62 tail --lines=+5 $$TEMP >> $@ && \
64 set -e; for LANG in po/*/mwcc.po; do \
66 msgmerge $$LANG po/mwcc.pot -U ; \
69 $(SOURCE).es.md: $(SOURCE).md po/es/mwcc.po
70 po4a-translate -f text -m $(SOURCE).md -p po/es/mwcc.po -l $@ -l $@ -L utf8 -M utf8 -k 0
72 $(SOURCE).nb.md: $(SOURCE).md po/nb/mwcc.po
73 po4a-translate -f text -m $(SOURCE).md -p po/nb/mwcc.po -l $@ -l $@ -L utf8 -M utf8 -k 0
76 pandoc -s -o $@ $(PANDOC_OPTS) $^
77 perl -p -i -e 's/!DOCTYPE article/!DOCTYPE book/ ; \
78 s!<(/?)article(info|)?>!<$$1book$$2>!' $@
90 dblatex -t tex -b xetex $^
91 perl -p -i -e 's/\[latin1\]\{inputenc\}/[utf8]{inputenc}\n\\usepackage[$(TEXLANG)]{babel}/; \
92 s/\\setcounter\{tocdepth\}.*/\\setcounter{tocdepth}{1}/; \
93 s/\\setcounter\{secnumdepth\}.*/\\setcounter{secnumdepth}{-1}/; \
94 s/\\caption\\end/\\caption{} \\end/; \
95 s!\\maketitle!\\input{extra/$(TEXLANGCODE)/cover.tex}!; \
96 s/\\author\{and\}/\\author{Paul Stacey \\and Sarah Hinchliff Pearson}/; \
97 s/\\DBKinditem\{\\writtenby\}\{and\}/\\DBKinditem{\writtenby}{Paul Stacey and Sarah Hinchliff Pearson}/; \
98 s/\\listoffigures//; \
99 s/\\part\{(Foreword|Prefacio|Introduction|Introducción)\}/\\chapter*{$$1} \\addcontentsline{toc}{chapter}{$$1}/; \
100 s/\\section\{(Notes|Notas)\}/\\section*{$$1}/; \
101 s/(Web links?|Vínculos Web)/\\section*{$$1}/; \
102 s/^\s*(Revenue model|Interview date|Interviewees?|(Modelo de ingresos|Fecha de la entrevista|Entrevistad(?:o|a|os|as)))/\\textbf{$$1}/;' $@
103 perl -p -i -e '$$work=1 if /chapter.Arduino/; $$work=0 if /chapter.(Bibliography|Bibliografía)/; \
104 next unless $$work; \
105 s/(\\label\{[-\.\wáéíóúñ]+\}\\hyperlabel\{[-\.\wáéíóúñ]+\}%)/$$1\n\\begin{quote}/i; \
106 s/(Profile written by.+|Perfil escrito por.+|Profilen skrevet av.+)/$$1\n\\end{quote}/' $@
108 XMLLINTOPTS = --nonet --noout --xinclude --postvalid
110 xmllint $(XMLLINTOPTS) $^
111 lint-es: $(SOURCE).nb.xml
112 xmllint $(XMLLINTOPTS) $^
113 lint-nb: $(SOURCE).nb.xml
114 xmllint $(XMLLINTOPTS) $^
117 for LANG in $(LANGS); do \
118 printf "$$LANG "; msgfmt -o /dev/null --statistics po/$$LANG/mwcc.po; \