url = http://www.sslug.dk/~chlor/lessig/freeculture.sgml.2004-04-01.gz
-path1=Dokumentasjon/BokenOmLinux
-path2='\/Dokumentasjon\/BokenOmLinux\/'
+# PDF rule
+# Valid book options are a4paper, a5paper, b5paper, letterpaper,
+# legalpaper, landscape, 11pt, 12pt, oneside, twocolumn, notitlepage,
+# titlepage, openany, draft, fleqn, leqno
+DBLATEX = dblatex \
+ -P latex.class.options=a5paper \
+ -T db2latex \
+ --backend=xetex \
+ --param lingua=nb \
+ --xsl-user=data/user_param.xsl \
+ --xsl-user=data/xetex_param.xsl \
+ -p data/pdf.xsl
-ORIGLANG = en
+DBTOEPUB = dbtoepub
-name = freeculture
-DEBIAN_EDU_DOC_TITLE=Free Culture
-export
+IMAGES = images/cc.png
-DBLATEX = dblatex -T db2latex --backend=xetex --xsl-user=data/user_param.xsl --xsl-user=data/xetex_param.xsl -p data/pdf.xsl --param=lingua=nb
+XSLTS = \
+ data/user_param.xsl \
+ data/xetex_param.xsl \
+ data/pdf.xsl
-all: pdf
+all: lint lint.nb html epub pdf
freeculture.nb.po: freeculture.pot
po4a --no-translations --msgmerge-opt --no-location po4a.cfg
freeculture.nb.xml: freeculture.nb.po freeculture.xml
po4a --translate-only freeculture.nb.xml po4a.cfg
-pdf: freeculture.nb.pdf
+pdf: freeculture.nb.pdf freeculture.pdf
+epub: freeculture.nb.epub
+html: freeculture.html freeculture.nb.html
-freeculture.pdf: freeculture.xml
- $(DBLATEX) $(name).xml --param=lingua=en
+%.pdf: %.xml $(IMAGES) $(XSLTS)
+ $(DBLATEX) $<
-freeculture.nb.pdf: freeculture.nb.xml
- $(DBLATEX) freeculture.nb.xml --param=lingua=nb
+# Alternative processing path to dblatex is to use xmlto using fop to
+# create PDF like this. The PDF output (visual design) is better, but
+# the PDF index and footnote handling is worse and images are missing.
+# xmlto --noautosize --stringparam paper.type=A5 \
+# --with-fop pdf $<
+
+# Third alternative is to use xsltproc and fop directly, as
+# recommended by <URL: http://www.sagehill.net/docbookxsl/index.html > .
+# This include images, but the index and footnote handling is
+# broken.
+# xsltproc \
+# --output myfile.fo \
+# --stringparam paper.type A5 \
+# /usr/share/xml/docbook/stylesheet/docbook-xsl/fo/docbook.xsl \
+# $<
+# fop -fo myfile.fo -pdf $@
+
+%.html: %.xml $(IMAGES)
+ xmlto html-nochunks $<
+
+%.txt: %.xml $(IMAGES)
+ xmlto txt $<
+
+%.epub: %.xml $(IMAGES)
+ $(DBTOEPUB) $<
freeculture.xml:
GET $(url) | gunzip > freeculture.xml
freeculture.pot: freeculture.xml
- po4a-gettextize -f docbook -m $^ > $@
+ po4a-gettextize -f docbook -m $^ > $@.new && mv $@.new $@
+
+stats: update-stats progress.png
+update-stats:
+ ( \
+ printf "%s " $$(date +"%Y-%m-%dT%H%M") ; \
+ msgfmt -o /dev/null --statistics freeculture.nb.po 2>&1 \
+ ) | tee -a stats.txt
+progress.png: stats.txt progress.gnuplot
+ awk '{print $$1, $$2, $$5, $$8}' < stats.txt > stats.csv
+ gnuplot progress.gnuplot
+ rm stats.csv
+
+# Have to disable --postvalid, when using xref with xrefstyle.
+# See <URL: http://bugs.debian.org/682944 > for the bug report.
+XMLLINTOPTS = --nonet --noout --xinclude --postvalid
+lint: freeculture.xml
+ xmllint $(XMLLINTOPTS) freeculture.xml
+
+lint.nb: freeculture.nb.xml
+ xmllint $(XMLLINTOPTS) freeculture.nb.xml
+
+images/cc.svg:
+ wget -O $@ http://upload.wikimedia.org/wikipedia/commons/9/97/CC_some_rights_reserved_new_2.svg
+
+images/cc.png: images/cc.svg
+ inkscape -z -D --export-height=200 -D --export-png=$(shell pwd)/$@ $^