chiark / gitweb /
collab maintenance: global part => first paragraph. Closes: #483231.
[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 # list of targets, that currently cannot build
14 BLACKLIST       := ja/developers-reference.pdf
15
16 # hopefully overwritten by caller, e.g. debian/rules
17 VERSION=unknown
18 PUBDATE=unknown
19
20 # programs for creating output
21 XP=xsltproc --nonet --novalid --xinclude
22 XL=xmllint --nonet --noout --postvalid --xinclude
23 # dblatex 0.2.8 has some problems (e.g. #465221 and Japanese does
24 # not build)
25 # Alternatives:
26 # - docbook2pdf (seems to die on UTF-8, #431085); and
27 # - fop is currently in contrib, but can go to main, see #366783
28 # - xmlroff (not mature enough, #182445)
29 DBLATEX=dblatex --style=db2latex
30 # The "--keep 0" should be removed as soon as the translations are ready
31 TRANSLATE=po4a-translate --format docbook --keep 0
32
33 # XSL files and parameters
34 # note: the URL is used as identifier, no HTTP is used!
35 DOCBOOK_XSL=http://docbook.sourceforge.net/release/xsl/current
36 # for HTML output
37 DBK2HTML=$(CURDIR)/html.xsl
38 # all in one file for text output
39 DBK2HTML1=$(CURDIR)/txt.xsl
40
41 .PHONY: all
42 all:    $(filter-out $(BLACKLIST), $(TARGETS))
43
44 .PHONY: validate
45 validate:                       $(SOURCES)
46         $(XL) index.dbk
47
48 %/validate:                     $(addprefix %/,$(SOURCES))
49         cd $(@D) && $(XL) index.dbk
50
51 .PHONY: developers-reference.html %/developers-reference.html
52 developers-reference.html:      $(CURDIR)/index.html
53 %/developers-reference.html:    $(addprefix %/,index.html)
54         @true
55
56 .PRECIOUS:                      %/index.html
57 index.html:                     $(CURDIR)/developers-reference.html
58 %/index.html:                   $(addprefix %/,$(SOURCES))
59         cd $(@D) && $(XP) $(DBK2HTML) index.dbk
60
61 # There must be an easier way than recursive make!
62 .PRECIOUS:              %.dbk %.ent
63 ifndef LINGUA
64 %.dbk %.ent: FORCE
65         $(MAKE) $@ LINGUA=`basename $(@D)`
66
67 FORCE:
68 else
69 $(LINGUA)/%.dbk:        %.dbk $(patsubst %.dbk,po4a/$(LINGUA)/%.po,%.dbk)
70         $(TRANSLATE) -m $< -p po4a/$(@:.dbk=.po) -l $@
71
72 $(LINGUA)/common.ent:   common.ent
73         cd $(@D) && ln -sf ../$(@F) .
74 endif
75
76 developers-reference.txt:       $(CURDIR)/developers-reference.txt
77 %/developers-reference.txt:     $(addprefix %/,$(SOURCES))
78         $(XP) $(DBK2HTML1) $(@D)/index.dbk \
79             | w3m -cols 65 -dump -T text/html > $@
80
81 developers-reference.pdf:       $(CURDIR)/developers-reference.pdf
82 %/developers-reference.pdf:     $(addprefix %/,$(SOURCES))
83         TOP=`pwd` && cd $(@D) && $(DBLATEX) index.dbk \
84             && mv index.dbk.pdf $(@F)
85
86 .PHONY: pot
87 pot:                            $(patsubst %.dbk,po4a/po/%.pot,$(SOURCES))
88 po4a/po/%.pot:                  %.dbk
89         po4a-gettextize --format docbook --master $< --po $@
90
91 ifdef LINGUA
92 .PHONY: updatepo
93 updatepo:                       $(patsubst %.dbk,po4a/$(LINGUA)/%.po,$(SOURCES))
94 po4a/$(LINGUA)/%.po:            %.dbk
95         po4a-updatepo --format docbook --master $< --po $@
96 endif
97
98 %/version.ent:
99         echo '<!ENTITY version "$(VERSION)">' >  $@
100         echo '<!ENTITY pubdate "$(PUBDATE)">' >> $@
101
102 .PHONY: clean
103 clean:
104         rm -f *.fo *.html *.pdf *.txt
105         for L in $(LANGS); do rm -rf `basename ./"$$L"/`; done
106         rm -f version.ent
107         rm -f `find . -name "*~" -o -name "*.bak"`
108         rm -f *~ *.bak .#* core
109
110 .PHONY: distclean
111 distclean: clean
112         rm -f *.rej *.orig
113
114 # if rule bomb out, delete the target
115 .DELETE_ON_ERROR: