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