# # As of October 2017, I'm doing some Spanish-specific adjustments to # this Makefile; they should be generalized... But I'm taking a step at a time :) # -GW # SOURCE=MadewithCreativeCommonsmostup-to-dateversion # Versioning: I'm using the date on which I got the source document # (2017-06-09), plus an incrementing local part, that *should* # increase every time the generated Markdown is modified. VERSION=20170609-2 TEXLANGCODE=es #TEXLANGCODE=nb # pandoc version 1.17.2~dfsg-3 do not understand # --top-level-diversion, while version 1.19.2.4~dfsg-1+b3 do. PANDOC_OPTS = \ --standalone \ --top-level-division=part \ -t docbook \ -f markdown+inline_notes+ascii_identifiers LANGS := $(shell ls po/*/mwcc.po|cut -d/ -f2) all: pdf epub distclean: clean rm -f $(SOURCE).md for LANG in $(LANGS); do \ rm -f $(SOURCE).$$LANG.md ;\ done clean: for EXT in aux cb cb2 glo idx lof log tex toc xml pdf epub; do \ rm -f $(SOURCE).$$EXT ;\ for LANG in $(LANGS); do \ rm -f $(SOURCE).$$LANG.$$EXT ;\ done; \ done $(RM) *~ $(SOURCE).md: $(SOURCE).odt fixup.rb TEMP=`tempfile -p mwcc` && \ pandoc -f odt $(SOURCE).odt -t markdown > $$TEMP && \ ruby fixup.rb $$TEMP $(SOURCE).md && \ rm $$TEMP pot: po/mwcc.pot po/*/mwcc.po po/mwcc.pot: $(SOURCE).xml TEMP=`tempfile -p mwcc` && \ po4a-gettextize -f docbook -m $(SOURCE).xml -p $$TEMP -M utf-8 --package-name 'Made with Creative Commons' --package-version $(VERSION) && \ echo '# MADE WITH CREATIVE COMMONS' > $@ && \ echo '# Copyright (C) 2017 by Creative Commons.' >> $@ && \ echo '# This file is published under a Creative Commons Attribution-ShareAlike license (CC BY-SA), version 4.0' >> $@ && \ echo '# Authors: Paul Stacey and Sarah Hinchliff Pearson' >> $@ && \ tail --lines=+5 $$TEMP >> $@ && \ rm $$TEMP po/*/mwcc.po: po/mwcc.pot msgmerge --previous $@ po/mwcc.pot -U touch $@ $(SOURCE).es.xml: $(SOURCE).xml po/es/mwcc.po po4a-translate -f docbook -m $(SOURCE).xml -p po/es/mwcc.po -l $@ -l $@ -L utf-8 -M utf-8 -k 0 $(SOURCE).nb.xml: $(SOURCE).xml po/nb/mwcc.po po4a-translate -f docbook -m $(SOURCE).xml -p po/nb/mwcc.po -l $@ -l $@ -L utf-8 -M utf-8 -k 0 $(SOURCE).xml: $(SOURCE).md fixup-docbook.rb TEMP=`tempfile -p mwcc` && \ pandoc -s -o $$TEMP $(PANDOC_OPTS) $(SOURCE).md && \ ruby fixup-docbook.rb $$TEMP $@ && \ rm $$TEMP pdf: $(SOURCE).pdf %.pdf: %.tex pdflatex $^ pdflatex $^ epub: $(SOURCE).epub %.epub: %.xml dbtoepub $^ # Replace Unicode Hair Space (U+200A) with space, as   is not # handled by LaTeX/dblatex, see . %.tex: %.xml dblatex -t tex -b xetex $^ perl -p -i -e 's/\\caption\\end/\\caption{} \\end/; \ s/ / /g; \ s!\\maketitle!\\input{extra/$(TEXLANGCODE)/cover.tex}!; \ s/\\author\{and\}/\\author{Paul Stacey \\and Sarah Hinchliff Pearson}/; \ s/\\DBKinditem\{\\writtenby\}\{and\}/\\DBKinditem{\writtenby}{Paul Stacey and Sarah Hinchliff Pearson}/; \ s/\\listoffigures//; \ s/\\chapter\{(Colophon|Dedication)\}/\\chapter*{}/; \ s/\\chapter\{(Foreword|Prefacio|Forord|Introduction|Introducción|Introduksjon)\}/\\chapter*{$$1} \\addcontentsline{toc}{chapter}{$$1}/; \ s/\\section\{(Notes|Notas)\}/\\section*{$$1}/; \ s/(Web links?|Vínculos Web)/\\section*{$$1}/; \ s/^\s*(Revenue model|Interview date|Interviewees?|(Modelo de ingresos|Fecha de la entrevista|Entrevistad(?:o|a|os|as)))/\\textbf{$$1}/;' $@ XMLLINTOPTS = --nonet --noout --xinclude --postvalid lint: $(SOURCE).xml xmllint $(XMLLINTOPTS) $^ lint-es: $(SOURCE).nb.xml xmllint $(XMLLINTOPTS) $^ lint-nb: $(SOURCE).nb.xml xmllint $(XMLLINTOPTS) $^ check-urls: retval=0; for u in $$(perl -n -e'// && print "$$1\n"' MadewithCreativeCommonsmostup-to-dateversion.xml | sort -u); do \ HEAD -H "User-Agent: Docbook XML URL checker" "$$u" > /dev/null || echo "error fetching $$u"; retval=1; \ done; exit $$retval # Experimental build rule to test Docbook XSL + FOP processor xsl-fo-%.pdf: %.xml xsltproc --output $(subst .pdf,.fo,$@) \ extra/stylesheet-fo.xsl $^; \ fop -fo $(subst .pdf,.fo,$@) -pdf $@ status: for LANG in $(LANGS); do \ printf "$$LANG "; msgfmt -o /dev/null --statistics po/$$LANG/mwcc.po; \ done .SUFFIXES: .xml .md