chiark / gitweb /
cb6924cb1ef49cc0b0b95c68658932117c6a444e
[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 # fop is currently in contrib, but can go to main, see #366783
22 # Alternatives:
23 # - dblatex (0.2.6 has some problems, next release will be OK;
24 #   Japanese PDF needs non-free cyberbit font)
25 # - docbook2pdf (seems to die on UTF-8, #431085); and
26 # - xmlroff (not mature enough, #182445)
27 FOP=fop
28 # The "--keep 0" should be removed as soon as the translations are ready
29 TRANSLATE=po4a-translate --format docbook --keep 0
30
31 # XSL files and parameters
32 # note: the URL is used as identifier, no HTTP is used!
33 DOCBOOK_XSL=http://docbook.sourceforge.net/release/xsl/current
34 # one file per chapter
35 DBK2HTML=--stringparam chunk.section.depth 0 \
36     --stringparam section.autolabel 1 \
37     --stringparam use.id.as.filename 1 \
38     $(DOCBOOK_XSL)/xhtml/chunk.xsl
39 # all in one file
40 DBK2HTML1=--stringparam section.autolabel 1 \
41     $(DOCBOOK_XSL)/xhtml/docbook.xsl
42 DBK2FO=$$TOP/fop.xsl
43 #    $(DOCBOOK_XSL)/fo/docbook.xsl
44
45 .PHONY: all
46 all:    $(TARGETS)
47
48 .PHONY: validate
49 validate:                       $(SOURCES)
50         $(XL) index.dbk
51
52 %/validate:                     $(addprefix %/,$(SOURCES))
53         cd $(@D) && $(XL) index.dbk
54
55 .PHONY: developers-reference.html %/developers-reference.html
56 developers-reference.html:      $(PWD)/index.html
57 %/developers-reference.html:    $(addprefix %/,index.html)
58         @true
59
60 .PRECIOUS:                      %/index.html
61 index.html:                     $(PWD)/developers-reference.html
62 %/index.html:                   $(addprefix %/,$(SOURCES))
63         cd $(@D) && $(XP) $(DBK2HTML) index.dbk
64
65 # There must be an easier way than recursive make!
66 .PRECIOUS:              %.dbk %.ent
67 ifndef LINGUA
68 %.dbk %.ent: FORCE
69         $(MAKE) $@ LINGUA=$(@D)
70
71 FORCE:
72 else
73 $(LINGUA)/%.dbk:        %.dbk $(patsubst %.dbk,po4a/$(LINGUA)/%.po,%.dbk)
74         $(TRANSLATE) -m $< -p po4a/$(@:.dbk=.po) -l $@
75
76 $(LINGUA)/%.ent:        %.ent
77         cd $(@D) && ln -sf ../$(@F) .
78 endif
79
80 developers-reference.txt:       $(PWD)/developers-reference.txt
81 %/developers-reference.txt:     $(addprefix %/,$(SOURCES))
82         $(XP) $(DBK2HTML1) $(@D)/index.dbk \
83             | w3m -cols 65 -dump -T text/html > $@
84
85 developers-reference.fo:        $(PWD)/developers-reference.fo
86         @true
87
88 %/developers-reference.fo:      $(addprefix %/,$(SOURCES)) fop.xsl
89         TOP=`pwd` && cd $(@D) && $(XP) $(DBK2FO) index.dbk > $(@F)
90
91 developers-reference.pdf:       $(PWD)/developers-reference.pdf
92 %/developers-reference.pdf:     %/developers-reference.fo
93         $(FOP) -fo $< -pdf $@
94
95 .PHONY: pot
96 pot:                            $(patsubst %.dbk,po4a/po/%.pot,$(SOURCES))
97 po4a/po/%.pot:                  %.dbk
98         po4a-gettextize --format docbook --master $< --po $@
99
100 ifdef LINGUA
101 .PHONY: updatepo
102 updatepo:                       $(patsubst %.dbk,po4a/$(LINGUA)/%.po,$(SOURCES))
103 po4a/$(LINGUA)/%.po:            %.dbk
104         po4a-updatepo --format docbook --master $< --po $@
105 endif
106
107 version.ent:
108         echo '<!ENTITY version "$(VERSION)">' >  $@
109         echo '<!ENTITY pubdate "$(PUBDATE)">' >> $@
110
111 .PHONY: clean
112 clean:
113         rm -f *.fo *.html *.pdf *.txt
114         rm -rf $(LANGS)
115         rm -f version.ent
116         rm -f `find . -name "*~" -o -name "*.bak"`
117         rm -f *~ *.bak .#* core
118
119 .PHONY: distclean
120 distclean: clean
121         rm -f *.rej *.orig
122
123 # if rule bomb out, delete the target
124 .DELETE_ON_ERROR: