chiark / gitweb /
Move XSL parameters in specific files.
[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 # for HTML output
36 DBK2HTML=$(PWD)/html.xsl
37 # all in one file for text output
38 DBK2HTML1=$(PWD)/txt.xsl
39
40 .PHONY: all
41 all:    $(TARGETS)
42
43 .PHONY: validate
44 validate:                       $(SOURCES)
45         $(XL) index.dbk
46
47 %/validate:                     $(addprefix %/,$(SOURCES))
48         cd $(@D) && $(XL) index.dbk
49
50 .PHONY: developers-reference.html %/developers-reference.html
51 developers-reference.html:      $(PWD)/index.html
52 %/developers-reference.html:    $(addprefix %/,index.html)
53         @true
54
55 .PRECIOUS:                      %/index.html
56 index.html:                     $(PWD)/developers-reference.html
57 %/index.html:                   $(addprefix %/,$(SOURCES))
58         cd $(@D) && $(XP) $(DBK2HTML) index.dbk
59
60 # There must be an easier way than recursive make!
61 .PRECIOUS:              %.dbk %.ent
62 ifndef LINGUA
63 %.dbk %.ent: FORCE
64         $(MAKE) $@ LINGUA=$(@D)
65
66 FORCE:
67 else
68 $(LINGUA)/%.dbk:        %.dbk $(patsubst %.dbk,po4a/$(LINGUA)/%.po,%.dbk)
69         $(TRANSLATE) -m $< -p po4a/$(@:.dbk=.po) -l $@
70
71 $(LINGUA)/common.ent:   common.ent
72         cd $(@D) && ln -sf ../$(@F) .
73 endif
74
75 developers-reference.txt:       $(PWD)/developers-reference.txt
76 %/developers-reference.txt:     $(addprefix %/,$(SOURCES))
77         $(XP) $(DBK2HTML1) $(@D)/index.dbk \
78             | w3m -cols 65 -dump -T text/html > $@
79
80 developers-reference.pdf:       $(PWD)/developers-reference.pdf
81 %/developers-reference.pdf:     $(addprefix %/,$(SOURCES))
82         TOP=`pwd` && cd $(@D) && $(DBLATEX) index.dbk \
83             && mv index.dbk.pdf $(@F)
84
85 .PHONY: pot
86 pot:                            $(patsubst %.dbk,po4a/po/%.pot,$(SOURCES))
87 po4a/po/%.pot:                  %.dbk
88         po4a-gettextize --format docbook --master $< --po $@
89
90 ifdef LINGUA
91 .PHONY: updatepo
92 updatepo:                       $(patsubst %.dbk,po4a/$(LINGUA)/%.po,$(SOURCES))
93 po4a/$(LINGUA)/%.po:            %.dbk
94         po4a-updatepo --format docbook --master $< --po $@
95 endif
96
97 %/version.ent:
98         echo '<!ENTITY version "$(VERSION)">' >  $@
99         echo '<!ENTITY pubdate "$(PUBDATE)">' >> $@
100
101 .PHONY: clean
102 clean:
103         rm -f *.fo *.html *.pdf *.txt
104         rm -rf $(LANGS)
105         rm -f version.ent
106         rm -f `find . -name "*~" -o -name "*.bak"`
107         rm -f *~ *.bak .#* core
108
109 .PHONY: distclean
110 distclean: clean
111         rm -f *.rej *.orig
112
113 # if rule bomb out, delete the target
114 .DELETE_ON_ERROR: