]> pere.pagekite.me Git - text-madewithcc.git/blob - Makefile
Move code to emphesize keywords from LaTeX to markdown.
[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 TEXLANGCODE=es
14
15 #TEXLANGCODE=nb
16
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.
19 PANDOC_OPTS = \
20 --standalone \
21 --top-level-division=part \
22 -t docbook \
23 -f markdown+inline_notes+ascii_identifiers
24
25 LANGS := $(shell ls po/*/mwcc.po|cut -d/ -f2)
26
27 all: pdf epub
28
29 distclean: clean
30 rm -f $(SOURCE).md
31 for LANG in $(LANGS); do \
32 rm -f $(SOURCE).$$LANG.md ;\
33 done
34 clean:
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 ;\
39 done; \
40 done
41 $(RM) *~
42
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 && \
47 rm $$TEMP
48
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 >> $@ && \
58 rm $$TEMP
59
60 po/*/mwcc.po: po/mwcc.pot
61 msgmerge --previous $@ po/mwcc.pot -U
62 touch $@
63
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
66
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
69
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 $@ && \
74 rm $$TEMP
75
76 pdf: $(SOURCE).pdf
77 %.pdf: %.tex
78 pdflatex $^
79 pdflatex $^
80
81 epub: $(SOURCE).epub
82 %.epub: %.xml
83 dbtoepub $^
84
85 # Replace Unicode Hair Space (U+200A) with space, as   is not
86 # handled by LaTeX/dblatex, see <URL: https://bugs.debian.org/889603 >.
87 %.tex: %.xml
88 dblatex -t tex -b xetex $^
89 perl -p -i -e 's/\\caption\\end/\\caption{} \\end/; \
90 s/ / /g; \
91 s!\\maketitle!\\input{extra/$(TEXLANGCODE)/cover.tex}!; \
92 s/\\author\{and\}/\\author{Paul Stacey \\and Sarah Hinchliff Pearson}/; \
93 s/\\DBKinditem\{\\writtenby\}\{and\}/\\DBKinditem{\writtenby}{Paul Stacey and Sarah Hinchliff Pearson}/; \
94 s/\\listoffigures//; \
95 s/\\chapter\{(Colophon|Dedication)\}/\\chapter*{}/; \
96 s/\\chapter\{(Foreword|Prefacio|Forord|Introduction|Introducción|Introduksjon)\}/\\chapter*{$$1} \\addcontentsline{toc}{chapter}{$$1}/; \
97 s/\\section\{(Notes|Notas)\}/\\section*{$$1}/; \
98 s/(Web links?|Vínculos Web)/\\section*{$$1}/;' $@
99
100 XMLLINTOPTS = --nonet --noout --xinclude --postvalid
101 lint: $(SOURCE).xml
102 xmllint $(XMLLINTOPTS) $^
103 lint-es: $(SOURCE).nb.xml
104 xmllint $(XMLLINTOPTS) $^
105 lint-nb: $(SOURCE).nb.xml
106 xmllint $(XMLLINTOPTS) $^
107
108 check-urls:
109 retval=0; for u in $$(perl -n -e'/<ulink url="(.+)"\/>/ && print "$$1\n"' MadewithCreativeCommonsmostup-to-dateversion.xml | sort -u); do \
110 HEAD -H "User-Agent: Docbook XML URL checker" "$$u" > /dev/null || echo "error fetching $$u"; retval=1; \
111 done; exit $$retval
112
113 # Experimental build rule to test Docbook XSL + FOP processor
114 xsl-fo-%.pdf: %.xml
115 xsltproc --output $(subst .pdf,.fo,$@) \
116 extra/stylesheet-fo.xsl $^; \
117 fop -fo $(subst .pdf,.fo,$@) -pdf $@
118
119 status:
120 for LANG in $(LANGS); do \
121 printf "$$LANG "; msgfmt -o /dev/null --statistics po/$$LANG/mwcc.po; \
122 done
123
124 .SUFFIXES: .xml .md