]> pere.pagekite.me Git - text-madewithcc.git/blob - Makefile
Playing with the document generation - Focusing in Spanish right now
[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 PANDOC_OPTS = --top-level-division=part -t docbook -f markdown+inline_notes --variable 'author:Paul Stacey' --variable 'author:Sarah Hinchliff Pearson' --variable 'title:Hecho con Creative Commons'
14 # --top-level-diversion is not available in pandoc in Jessie
15 # PANDOC_OPTS = -t docbook -f markdown+inline_notes
16
17 LANGS = es nl nb
18
19 all: pdf
20
21 clean:
22 rm -f $(SOURCE).pdf $(SOURCE).xml $(SOURCE).md
23 for LANG in $(LANGS); do \
24 rm -f $(SOURCE).$$LANG.pdf $(SOURCE).$$LANG.xml $(SOURCE).$$LANG.md ;\
25 done
26
27 $(SOURCE).md: $(SOURCE).odt fixup.rb
28 TEMP=`tempfile -p mwcc` && \
29 pandoc -f odt $(SOURCE).odt -t markdown > $$TEMP && \
30 ruby fixup.rb $$TEMP $(SOURCE).md && \
31 rm $$TEMP
32
33 pot: po/mwcc.pot po/*/mwcc.po
34 po/mwcc.pot: $(SOURCE).md
35 TEMP=`tempfile -p mwcc` && \
36 po4a-gettextize -f text -m $(SOURCE).md -p $$TEMP -M utf-8 --package-name 'Made with Creative Commons' --package-version $(VERSION) && \
37 echo '# MADE WITH CREATIVE COMMONS' > $@ && \
38 echo '# Copyright (C) 2017 by Creative Commons.' >> $@ && \
39 echo '# This file is published under a Creative Commons Attribution-ShareAlike license (CC BY-SA), version 4.0' >> $@ && \
40 echo '# Authors: Paul Stacey and Sarah Hinchliff Pearson' >> $@ && \
41 tail --lines=+5 $$TEMP >> $@ && \
42 rm $$TEMP
43 set -e; for LANG in po/*/mwcc.po; do \
44 echo -n $$LANG\ ; \
45 msgmerge $$LANG po/mwcc.pot -U ; \
46 done
47
48 $(SOURCE).es.md: $(SOURCE).md po/es/mwcc.po
49 po4a-translate -f text -m $(SOURCE).md -p po/es/mwcc.po -l $@ -l $@ -L utf8 -M utf8 -k 20
50
51 %.xml: %.md
52 pandoc -s -o $@ $(PANDOC_OPTS) $^
53 perl -p -i -e 's/!DOCTYPE article/!DOCTYPE book/' $@
54 perl -p -i -e 's!<(/?)article(info|)?>!<$$1book$$2>!' $@
55
56 pdf: $(SOURCE).pdf
57 %.pdf: %.tex
58 pdflatex $^
59 pdflatex $^
60
61 %.tex: %.xml
62 dblatex -t tex -b xetex $^
63 perl -p -i -e 's/\[latin1\]\{inputenc\}/[utf8]{inputenc}\n\\usepackage[spanish]{babel}/' $@
64 perl -p -i -e 's/\\caption\\end/\\caption{} \\end/' $@
65 perl -p -i -e 's/\\author\{and\}/\\author{Paul Stacey \\and Sarah Hinchliff Pearson}/' $@
66
67 XMLLINTOPTS = --nonet --noout --xinclude --postvalid
68 lint: $(SOURCE).xml
69 xmllint $(XMLLINTOPTS) $^
70
71 .SUFFIXES: .xml .md