chiark / gitweb /
git-svn-id: svn://anonscm.debian.org/ddp/developers-reference/trunk@4908 313b444b...
[developers-reference.git] / Makefile
1 # Makefile, used for the developers-reference in DocBook XML
2
3 SOURCES         := $(wildcard *.dbk)
4
5 FORMATS         := html txt pdf
6 LANGS           := fr ja
7 TARGETS         := $(foreach fmt,$(FORMATS),developers-reference.$(fmt)) \
8                    $(foreach lng,$(LANGS), \
9                        $(foreach fmt,$(FORMATS), \
10                            $(lng)/developers-reference.$(fmt)))
11 # programs for creating output
12 XP=xsltproc --nonet --novalid --xinclude
13 XL=xmllint --nonet --noout --postvalid --xinclude
14 # fop is currently in contrib, but can go to main, see #366783
15 # alternatives: docbook2pdf (seems to die on UTF-8), dblatex (0.2.4
16 # just hangs here) and xmllint (not mature enough, waits in NEW)
17 FOP=fop
18 # The "-k 0" should be removed as soon as the translations are ready
19 TRANSLATE=po4a-translate -f docbook -k 0
20
21 # XSL files and parameters
22 # note: the URL is used as identifier, no HTTP is used!
23 DOCBOOK_XSL=http://docbook.sourceforge.net/release/xsl/current
24 # one file per chapter
25 DBK2HTML=--stringparam chunk.section.depth 0 \
26     --stringparam section.autolabel 1 \
27     --stringparam use.id.as.filename 1 \
28     $(DOCBOOK_XSL)/xhtml/chunk.xsl
29 # all in one file
30 DBK2HTML1=--stringparam section.autolabel 1 \
31     $(DOCBOOK_XSL)/xhtml/docbook.xsl
32 DBK2FO=$$TOP/fop.xsl
33 #    $(DOCBOOK_XSL)/fo/docbook.xsl
34
35 .PHONY: all
36 all:    $(TARGETS)
37
38 .PHONY: validate
39 validate:
40         $(XL) index.dbk
41
42 .PHONY: developers-reference.html %/developers-reference.html
43 developers-reference.html:      $(PWD)/index.html
44 %/developers-reference.html:    $(addprefix %/,index.html)
45         @true
46
47 .PRECIOUS:                      %/index.html
48 index.html:                     $(PWD)/developers-reference.html
49 %/index.html:                   $(addprefix %/,$(SOURCES))
50         mkdir -p $(@D) || true
51         cd $(@D) && $(XP) $(DBK2HTML) index.dbk
52
53 # There must be an easier way than recursive make!
54 .PRECIOUS:              %.dbk
55 ifndef LINGUA
56 %.dbk: FORCE
57         [ "$$LINGUA" = . ] || make $@ LINGUA=$(@D)
58 FORCE:
59 else
60 $(LINGUA)/%.dbk:        %.dbk $(patsubst %.dbk,po4a/$(LINGUA)/%.po,%.dbk)
61         $(TRANSLATE) -m $< -p po4a/$(@:.dbk=.po) -l $@
62 endif
63
64 developers-reference.txt:       $(PWD)/developers-reference.txt
65 %/developers-reference.txt:     $(addprefix %/,$(SOURCES))
66         $(XP) $(DBK2HTML1) $(@D)/index.dbk \
67             | w3m -cols 65 -dump -T text/html > $@
68
69 developers-reference.fo:        $(PWD)/developers-reference.fo
70         @true
71
72 %/developers-reference.fo:      $(addprefix %/,$(SOURCES)) fop.xsl
73         TOP=`pwd` && cd $(@D) && $(XP) $(DBK2FO) index.dbk > $(@F)
74
75 developers-reference.pdf:       $(PWD)/developers-reference.pdf
76 %/developers-reference.pdf:     %/developers-reference.fo
77         $(FOP) -fo $< -pdf $@
78
79 version.ent:    debian/changelog
80         ./debian/rules $@
81
82 .PHONY: clean
83 clean:
84         rm -f *.fo *.html *.pdf *.txt
85         rm -rf $(LANGS)
86         rm -f version.ent
87         rm -f `find . -name "*~" -o -name "*.bak"`
88         rm -f *~ *.bak .#* core
89
90 .PHONY: distclean
91 distclean: clean
92         rm -f *.rej *.orig
93
94 # if rule bomb out, delete the target
95 .DELETE_ON_ERROR: