]> pere.pagekite.me Git - text-madewithcc.git/blob - Makefile
Makefile cleanup to parametrize language builds
[text-madewithcc.git] / Makefile
1 #
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 :)
4 # -GW
5 #
6 SOURCE=MadewithCreativeCommonsmostup-to-dateversion
7
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.
11 VERSION=20170609-2
12
13 TITLE="Hecho con Creative Commons"
14 TEXLANG=spanish
15 TEXLANGCODE=es
16
17 #TITLE="Laget med Creative Commons"
18 #TEXLANG=norsk
19 #TEXLANGCODE=nb
20
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
26
27 LANGS = de es nb nl pl
28
29 all: pdf
30
31 distclean: clean
32 rm -f $(SOURCE).md
33 for LANG in $(LANGS); do \
34 rm -f $(SOURCE).$$LANG.md ;\
35 done
36 clean:
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 ;\
41 done; \
42 done
43
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 && \
48 rm $$TEMP
49
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 >> $@ && \
59 rm $$TEMP
60 set -e; for LANG in po/*/mwcc.po; do \
61 echo -n $$LANG\ ; \
62 msgmerge $$LANG po/mwcc.pot -U ; \
63 done
64
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
67
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
70
71 %.xml: %.md
72 pandoc -s -o $@ $(PANDOC_OPTS) $^
73 perl -p -i -e 's/!DOCTYPE article/!DOCTYPE book/ ; \
74 s!<(/?)article(info|)?>!<$$1book$$2>!' $@
75
76 pdf: $(SOURCE).pdf
77 %.pdf: %.tex
78 pdflatex $^
79 pdflatex $^
80
81 %.tex: %.xml
82 dblatex -t tex -b xetex $^
83 perl -p -i -e 's/\[latin1\]\{inputenc\}/[utf8]{inputenc}\n\\usepackage[$(TEXLANG)]{babel}/; \
84 s/\\setcounter\{tocdepth\}.*/\\setcounter{tocdepth}{1}/; \
85 s/\\setcounter\{secnumdepth\}.*/\\setcounter{secnumdepth}{-1}/; \
86 s/\\caption\\end/\\caption{} \\end/; \
87 s!\\maketitle!\\input{extra/$(TEXLANGCODE)/cover.tex}!; \
88 s/\\author\{and\}/\\author{Paul Stacey \\and Sarah Hinchliff Pearson}/; \
89 s/\\DBKinditem\{\\writtenby\}\{and\}/\\DBKinditem{\writtenby}{Paul Stacey and Sarah Hinchliff Pearson}/; \
90 s/\\listoffigures//; \
91 s/\\part\{(Foreword|Prefacio|Introduction|Introducción)\}/\\chapter*{$$1} \\addcontentsline{toc}{chapter}{$$1}/; \
92 s/\\section\{(Notes|Notas)\}/\\section*{$$1}/; \
93 s/(Web links?|Vínculos Web)/\\section*{$$1}/; \
94 s/^\s*(Revenue model|Interview date|Interviewees?|(Modelo de ingresos|Fecha de la entrevista|Entrevistad(?:o|a|os|as)))/\\textbf{$$1}/;' $@
95 perl -p -i -e '$$work=1 if /chapter.Arduino/; $$work=0 if /chapter.(Bibliography|Bibliografía)/; \
96 next unless $$work; \
97 s/(\\label\{[-\.\wáéíóúñ]+\}\\hyperlabel\{[-\.\wáéíóúñ]+\}%)/$$1\n\\begin{quote}/i; \
98 s/(Profile written by.+|Perfil escrito por.+)/$$1\n\\end{quote}/' $@
99
100 XMLLINTOPTS = --nonet --noout --xinclude --postvalid
101 lint: $(SOURCE).xml
102 xmllint $(XMLLINTOPTS) $^
103
104 .SUFFIXES: .xml .md