chiark / gitweb /
Use dblatex instead of fop, as long fop is in contrib.
[developers-reference.git] / Makefile
1 # Makefile, used for the developers-reference in DocBook XML
2
3 # Note: This Makefile should work perfectly without the debian/ directory.
4
5 SOURCES         := $(wildcard *.dbk) common.ent version.ent
6
7 FORMATS         := html txt pdf
8 LANGS           := fr ja
9 TARGETS         := $(foreach fmt,$(FORMATS),developers-reference.$(fmt)) \
10                    $(foreach lng,$(LANGS), \
11                        $(foreach fmt,$(FORMATS), \
12                            $(lng)/developers-reference.$(fmt)))
13
14 # hopefully overwritten by caller, e.g. debian/rules
15 VERSION=unknown
16 PUBDATE=unknown
17
18 # programs for creating output
19 XP=xsltproc --nonet --novalid --xinclude
20 XL=xmllint --nonet --noout --postvalid --xinclude
21 # dblatex 0.2.8 has some problems (e.g. #465221), but we can
22 # live with that for now (but: Japanese PDF seems to need
23 # non-free cyberbit font.)
24 # Alternatives:
25 # - docbook2pdf (seems to die on UTF-8, #431085); and
26 # - fop is currently in contrib, but can go to main, see #366783
27 # - xmlroff (not mature enough, #182445)
28 DBLATEX=dblatex --style=db2latex
29 # The "--keep 0" should be removed as soon as the translations are ready
30 TRANSLATE=po4a-translate --format docbook --keep 0
31
32 # XSL files and parameters
33 # note: the URL is used as identifier, no HTTP is used!
34 DOCBOOK_XSL=http://docbook.sourceforge.net/release/xsl/current
35 # one file per chapter
36 DBK2HTML=--stringparam chunk.section.depth 0 \
37     --stringparam section.autolabel 1 \
38     --stringparam use.id.as.filename 1 \
39     $(DOCBOOK_XSL)/xhtml/chunk.xsl
40 # all in one file
41 DBK2HTML1=--stringparam section.autolabel 1 \
42     $(DOCBOOK_XSL)/xhtml/docbook.xsl
43
44 .PHONY: all
45 all:    $(TARGETS)
46
47 .PHONY: validate
48 validate:                       $(SOURCES)
49         $(XL) index.dbk
50
51 %/validate:                     $(addprefix %/,$(SOURCES))
52         cd $(@D) && $(XL) index.dbk
53
54 .PHONY: developers-reference.html %/developers-reference.html
55 developers-reference.html:      $(PWD)/index.html
56 %/developers-reference.html:    $(addprefix %/,index.html)
57         @true
58
59 .PRECIOUS:                      %/index.html
60 index.html:                     $(PWD)/developers-reference.html
61 %/index.html:                   $(addprefix %/,$(SOURCES))
62         cd $(@D) && $(XP) $(DBK2HTML) index.dbk
63
64 # There must be an easier way than recursive make!
65 .PRECIOUS:              %.dbk %.ent
66 ifndef LINGUA
67 %.dbk %.ent: FORCE
68         $(MAKE) $@ LINGUA=$(@D)
69
70 FORCE:
71 else
72 $(LINGUA)/%.dbk:        %.dbk $(patsubst %.dbk,po4a/$(LINGUA)/%.po,%.dbk)
73         $(TRANSLATE) -m $< -p po4a/$(@:.dbk=.po) -l $@
74
75 $(LINGUA)/common.ent:   common.ent
76         cd $(@D) && ln -sf ../$(@F) .
77 endif
78
79 developers-reference.txt:       $(PWD)/developers-reference.txt
80 %/developers-reference.txt:     $(addprefix %/,$(SOURCES))
81         $(XP) $(DBK2HTML1) $(@D)/index.dbk \
82             | w3m -cols 65 -dump -T text/html > $@
83
84 developers-reference.pdf:       $(PWD)/developers-reference.pdf
85 %/developers-reference.pdf:     $(addprefix %/,$(SOURCES))
86         TOP=`pwd` && cd $(@D) && $(DBLATEX) index.dbk \
87             && mv index.dbk.pdf $(@F)
88
89 .PHONY: pot
90 pot:                            $(patsubst %.dbk,po4a/po/%.pot,$(SOURCES))
91 po4a/po/%.pot:                  %.dbk
92         po4a-gettextize --format docbook --master $< --po $@
93
94 ifdef LINGUA
95 .PHONY: updatepo
96 updatepo:                       $(patsubst %.dbk,po4a/$(LINGUA)/%.po,$(SOURCES))
97 po4a/$(LINGUA)/%.po:            %.dbk
98         po4a-updatepo --format docbook --master $< --po $@
99 endif
100
101 %/version.ent:
102         echo '<!ENTITY version "$(VERSION)">' >  $@
103         echo '<!ENTITY pubdate "$(PUBDATE)">' >> $@
104
105 .PHONY: clean
106 clean:
107         rm -f *.fo *.html *.pdf *.txt
108         rm -rf $(LANGS)
109         rm -f version.ent
110         rm -f `find . -name "*~" -o -name "*.bak"`
111         rm -f *~ *.bak .#* core
112
113 .PHONY: distclean
114 distclean: clean
115         rm -f *.rej *.orig
116
117 # if rule bomb out, delete the target
118 .DELETE_ON_ERROR: