]> pere.pagekite.me Git - text-free-culture-lessig.git/blob - Makefile
Make it easier to use replacement dblatex version.
[text-free-culture-lessig.git] / Makefile
1 #
2 # configuration here:
3 #
4
5 url = http://www.sslug.dk/~chlor/lessig/freeculture.sgml.2004-04-01.gz
6
7 # PDF rule
8 # Valid book options are a4paper, a5paper, b5paper, letterpaper,
9 # legalpaper, landscape, 11pt, 12pt, oneside, twocolumn, notitlepage,
10 # titlepage, openany, draft, fleqn, leqno
11 # -P latex.class.options=a5paper
12 DBLATEX = dblatex
13 DBLATEX_OPTS = \
14 -T simple \
15 -b xetex \
16 -r data/dblatex-postprocess \
17 --indexstyle=myindexstyle.ist \
18 --xsl-user=data/dblatex-endnotes.xsl \
19 --xsl-user=data/user_param.xsl \
20 --xsl-user=data/xetex_param.xsl \
21 -V \
22 -P latex.index.tool=xindy \
23 -p data/pdf.xsl
24
25
26 DBTOEPUB = dbtoepub
27
28 IMAGES = images/cc.png images/pattern-modern-media-ownership.png images/tom-the-dancing-bug.png
29
30 XSLT = \
31 data/user_param.xsl
32
33 DB_XSLT = \
34 data/dblatex-endnotes.xsl \
35 data/xetex_param.xsl
36
37 HTML_XSLT = \
38 $(XSLT) \
39 data/html.xsl \
40 data/stylesheet-html.xsl
41
42 PDF_XSLT = \
43 $(DB_XSLT) \
44 $(XSLT) \
45 data/lulu.xsl \
46 data/licentia.xsl \
47 data/pdf.xsl \
48 data/stylesheet-fo.xsl
49
50
51 all: lint lint.nb html epub pdf mobi
52
53 freeculture.nb.po: freeculture.pot
54 po4a --no-translations --msgmerge-opt --no-location po4a.cfg
55
56 freeculture.nb.xml: freeculture.nb.po freeculture.xml
57 po4a --translate-only freeculture.nb.xml po4a.cfg
58
59 freeculture.es_419.po: freeculture.pot
60 po4a --no-translations --msgmerge-opt --no-location po4a.cfg
61 freeculture.es_419.xml: freeculture.es_419.po freeculture.xml
62 po4a --translate-only freeculture.es_419.xml po4a.cfg
63
64 pdf: freeculture.nb.pdf freeculture.pdf
65 epub: freeculture.nb.epub freeculture.epub
66 mobi: freeculture.nb.mobi freeculture.mobi
67 html: freeculture.nb.html freeculture.html
68
69 %.pdf: %.xml $(IMAGES) $(PDF_XSLT) Makefile myclass.cls data/dblatex-postprocess
70 # Possible pipelines:
71 #
72 # dblatex:
73 # This converts the docbook content to latex and leave it to latex
74 # to format it. Index ranges are broken in oldstable, fixed in jessie.
75 #
76 # xmlto:
77 # Alternative processing path to dblatex is to use xmlto using fop
78 # to create PDF like this. The PDF output (visual design) is
79 # better, but the footnote handling is worse and images are missing.
80 #
81 # docbook-xsl:
82 # Third alternative is to use xsltproc and fop directly, as
83 # recommended by <URL: http://www.sagehill.net/docbookxsl/index.html >.
84 # This include images, but the index refs and footnote/endnote handling
85 # is broken.
86
87 pipeline=dblatex; \
88 echo "Using $$pipeline pipeline" ; \
89 case "$$pipeline" in \
90 dblatex) \
91 PATH=$(PWD)/bin:$$PATH $(DBLATEX) $(DBLATEX_OPTS) $< ; \
92 ;; \
93 xmlto) \
94 xmlto --noautosize \
95 -x data/stylesheet-fo.xsl \
96 --with-fop pdf $< ; \
97 ;; \
98 docbook-xsl) \
99 xsltproc \
100 --output $(subst .pdf,.fo,$@) \
101 data/stylesheet-fo.xsl \
102 $< ; \
103 fop -c data/fop-params.xconf -fo $(subst .pdf,.fo,$@) -pdf $@ ; \
104 ;; \
105 esac
106
107 pdf-compare: freeculture.xml $(IMAGES)
108 $(DBLATEX) -o freeculture-dblatex.pdf freeculture.xml
109 $(DBLATEX) -T db2latex \-o freeculture-dblatex-db2latex.pdf freeculture.xml
110
111 # plain xmlto fail
112 #xmlto pdf freeculture.xml && mv freeculture.pdf freeculture-xmlto.pdf
113 xmlto --with-fop pdf freeculture.xml && mv freeculture.pdf freeculture-xmlto-fop.pdf
114
115 xsltproc --output freeculture-docbook-xsl.fo \
116 /usr/share/xml/docbook/stylesheet/docbook-xsl/fo/docbook.xsl \
117 freeculture.xml
118 fop -fo freeculture-docbook-xsl.fo -pdf freeculture-docbook-xsl.pdf
119
120 %.html: %.xml $(IMAGES) $(HTML_XSLT)
121 xmlto \
122 -x data/stylesheet-html.xsl \
123 html-nochunks \
124 $<
125
126 %.txt: %.xml $(IMAGES)
127 xmlto txt $<
128
129 %.epub: %.xml $(IMAGES)
130 $(DBTOEPUB) $<
131
132 %.mobi: %.epub
133 ebook-convert $< $@
134
135 freeculture.xml:
136 GET $(url) | gunzip > freeculture.xml
137
138 # <beginpage> workaround can be removed when BTS #684137 is fixed in
139 # po4a.
140 freeculture.pot: freeculture.xml
141 po4a-gettextize -o nodefault='<beginpage>' -o inline='<beginpage>' \
142 -f docbook -m $^ > $@.new && mv $@.new $@
143
144 stats: update-stats progress.png
145 update-stats: freeculture.nb.po lint.nb
146 ( \
147 printf "%s " $$(date +"%Y-%m-%dT%H%M") ; \
148 msgfmt -o /dev/null --statistics freeculture.nb.po 2>&1 \
149 ) \
150 | sed -e 's/translated messages/oversatte meldinger/' -e 's/fuzzy translations/antatte oversettelser/' -e 's/untranslated messages/oversatte meldinger/' \
151 | tee -a stats.txt
152 progress.png: stats.txt progress.gnuplot
153 awk '{print $$1, $$2, $$5, $$8}' < stats.txt > stats.csv
154 gnuplot progress.gnuplot
155 rm stats.csv
156
157 # Have to disable --postvalid, when using xref with xrefstyle.
158 # See <URL: http://bugs.debian.org/682944 > for the bug report.
159 XMLLINTOPTS = --nonet --noout --xinclude --postvalid
160 lint: freeculture.xml
161 xmllint $(XMLLINTOPTS) freeculture.xml
162
163 lint.nb: freeculture.nb.xml
164 xmllint $(XMLLINTOPTS) freeculture.nb.xml
165
166 images/cc.svg:
167 wget -O $@ http://upload.wikimedia.org/wikipedia/commons/9/97/CC_some_rights_reserved_new_2.svg
168
169 images/cc.png: images/cc.svg
170 inkscape -z -D --export-height=200 -D --export-png=$(shell pwd)/$@ $^
171
172 .xcf.png:
173 convert $^ $@
174
175 clean:
176 $(RM) *~
177
178 distclean: clean
179 $(RM) freeculture-docbook-xsl.pdf \
180 freeculture-docbook-xsl.fo \
181 freeculture-dblatex-db2latex.pdf \
182 freeculture-dblatex.pdf \
183 freeculture-xmlto-fop.pdf
184
185 .SUFFIXES: .png .xcf .svg .xml