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 # pandoc version 1.17.2~dfsg-3 do not understand
14 # --top-level-diversion, while version 1.19.2.4~dfsg-1+b3 do.
17 --top-level-division=part \
19 -f markdown+inline_notes+ascii_identifiers
21 LANGS := $(shell ls po/*/mwcc.po|cut -d/ -f2)
27 for LANG in $(LANGS); do \
28 rm -f $(SOURCE).$$LANG.md ;\
31 for EXT in aux cb cb2 glo idx lof log tex toc xml pdf epub; do \
32 rm -f $(SOURCE).$$EXT ;\
33 for LANG in $(LANGS); do \
34 rm -f $(SOURCE).$$LANG.$$EXT ;\
39 $(SOURCE).md: $(SOURCE).odt fixup.rb
40 TEMP=`tempfile -p mwcc` && \
41 pandoc -f odt $(SOURCE).odt -t markdown > $$TEMP && \
42 ruby fixup.rb $$TEMP $(SOURCE).md && \
45 pot: po/mwcc.pot po/*/mwcc.po
46 po/mwcc.pot: $(SOURCE).xml
47 TEMP=`tempfile -p mwcc` && \
48 po4a-gettextize -f docbook -m $(SOURCE).xml -p $$TEMP -M utf-8 --package-name 'Made with Creative Commons' --package-version $(VERSION) && \
49 echo '# MADE WITH CREATIVE COMMONS' > $@ && \
50 echo '# Copyright (C) 2017 by Creative Commons.' >> $@ && \
51 echo '# This file is published under a Creative Commons Attribution-ShareAlike license (CC BY-SA), version 4.0' >> $@ && \
52 echo '# Authors: Paul Stacey and Sarah Hinchliff Pearson' >> $@ && \
53 tail --lines=+5 $$TEMP >> $@ && \
56 po/*/mwcc.po: po/mwcc.pot
57 msgmerge --previous $@ po/mwcc.pot -U
60 $(SOURCE).es.xml: $(SOURCE).xml po/es/mwcc.po
61 po4a-translate -f docbook -m $(SOURCE).xml -p po/es/mwcc.po -l $@ -l $@ -L utf-8 -M utf-8 -k 0
63 $(SOURCE).nb.xml: $(SOURCE).xml po/nb/mwcc.po
64 po4a-translate -f docbook -m $(SOURCE).xml -p po/nb/mwcc.po -l $@ -l $@ -L utf-8 -M utf-8 -k 0
66 $(SOURCE).xml: $(SOURCE).md fixup-docbook.rb
67 TEMP=`tempfile -p mwcc` && \
68 pandoc -s -o $$TEMP $(PANDOC_OPTS) $(SOURCE).md && \
69 ruby fixup-docbook.rb $$TEMP $@ && \
81 # Replace Unicode Hair Space (U+200A) with space, as   is not
82 # handled by LaTeX/dblatex, see <URL: https://bugs.debian.org/889603 >.
84 dblatex -T simple -t tex -b xetex -p extra/pdf.xsl $^
85 perl -p -i -e 's/\[latin1\]\{inputenc\}/[utf8]{inputenc}/; \
86 s/\\caption\\end/\\caption{} \\end/; \
88 s/\\chapter\{(Colophon|Dedication)\}/\\chapter*{}/; \
89 s/\\chapter\{(Foreword|Prefacio|Forord|Introduction|Introducción|Introduksjon)\}/\\chapter*{$$1} \\addcontentsline{toc}{chapter}{$$1}/; \
90 s/\\section\{(Notes|Notas)\}/\\section*{$$1}/; \
91 s/(Web links?|Vínculos Web)/\\section*{$$1}/;' $@
93 XMLLINTOPTS = --nonet --noout --xinclude --postvalid
95 xmllint $(XMLLINTOPTS) $^
96 lint-es: $(SOURCE).nb.xml
97 xmllint $(XMLLINTOPTS) $^
98 lint-nb: $(SOURCE).nb.xml
99 xmllint $(XMLLINTOPTS) $^
102 retval=0; for u in $$(perl -n -e'/<ulink url="(.+)"\/>/ && print "$$1\n"' MadewithCreativeCommonsmostup-to-dateversion.xml | sort -u); do \
103 HEAD -H "User-Agent: Docbook XML URL checker" "$$u" > /dev/null || echo "error fetching $$u"; retval=1; \
106 # Experimental build rule to test Docbook XSL + FOP processor
108 xsltproc --output $(subst .pdf,.fo,$@) \
109 extra/stylesheet-fo.xsl $^; \
110 fop -fo $(subst .pdf,.fo,$@) -pdf $@
113 for LANG in $(LANGS); do \
114 printf "$$LANG "; msgfmt -o /dev/null --statistics po/$$LANG/mwcc.po; \