chiark / gitweb /
Fixed all examples, fixed many (not all, yet) entities.
[developers-reference.git] / Makefile
1 # Makefile, used for the developers-reference in DocBook XML
2
3 SOURCES         := $(wildcard *.dbk *.ent)
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:
16 # - dblatex (0.2.6 has a minor problem with programlisting inside of
17 #   footnote, and a major one with lang="ja");
18 # - docbook2pdf (seems to die on UTF-8, #431085); and
19 # - xmllint (not mature enough, waits in NEW, #182445)
20 FOP=fop
21 # The "-k 0" should be removed as soon as the translations are ready
22 TRANSLATE=po4a-translate -f docbook -k 0
23
24 # XSL files and parameters
25 # note: the URL is used as identifier, no HTTP is used!
26 DOCBOOK_XSL=http://docbook.sourceforge.net/release/xsl/current
27 # one file per chapter
28 DBK2HTML=--stringparam chunk.section.depth 0 \
29     --stringparam section.autolabel 1 \
30     --stringparam use.id.as.filename 1 \
31     $(DOCBOOK_XSL)/xhtml/chunk.xsl
32 # all in one file
33 DBK2HTML1=--stringparam section.autolabel 1 \
34     $(DOCBOOK_XSL)/xhtml/docbook.xsl
35 DBK2FO=$$TOP/fop.xsl
36 #    $(DOCBOOK_XSL)/fo/docbook.xsl
37
38 .PHONY: all
39 all:    $(TARGETS)
40
41 .PHONY: validate
42 validate:                       $(SOURCES)
43         $(XL) index.dbk
44
45 %/validate:                     $(addprefix %/,$(SOURCES))
46         cd $(@D) && $(XL) index.dbk
47
48 .PHONY: developers-reference.html %/developers-reference.html
49 developers-reference.html:      $(PWD)/index.html
50 %/developers-reference.html:    $(addprefix %/,index.html)
51         @true
52
53 .PRECIOUS:                      %/index.html
54 index.html:                     $(PWD)/developers-reference.html
55 %/index.html:                   $(addprefix %/,$(SOURCES))
56         cd $(@D) && $(XP) $(DBK2HTML) index.dbk
57
58 # There must be an easier way than recursive make!
59 .PRECIOUS:              %.dbk %.ent
60 ifndef LINGUA
61 %.dbk %.ent: FORCE
62         [ "$$LINGUA" = . ] || $(MAKE) $@ LINGUA=$(@D)
63 FORCE:
64 else
65 $(LINGUA)/%.dbk:        %.dbk $(patsubst %.dbk,po4a/$(LINGUA)/%.po,%.dbk)
66         $(TRANSLATE) -m $< -p po4a/$(@:.dbk=.po) -l $@
67
68 $(LINGUA)/%.ent:        %.ent
69         cd $(@D) && ln -sf ../$(@F) .
70 endif
71
72 developers-reference.txt:       $(PWD)/developers-reference.txt
73 %/developers-reference.txt:     $(addprefix %/,$(SOURCES))
74         $(XP) $(DBK2HTML1) $(@D)/index.dbk \
75             | w3m -cols 65 -dump -T text/html > $@
76
77 developers-reference.fo:        $(PWD)/developers-reference.fo
78         @true
79
80 %/developers-reference.fo:      $(addprefix %/,$(SOURCES)) fop.xsl
81         TOP=`pwd` && cd $(@D) && $(XP) $(DBK2FO) index.dbk > $(@F)
82
83 developers-reference.pdf:       $(PWD)/developers-reference.pdf
84 %/developers-reference.pdf:     %/developers-reference.fo
85         $(FOP) -fo $< -pdf $@
86
87 version.ent:    debian/changelog
88         ./debian/rules $@
89
90 .PHONY: clean
91 clean:
92         rm -f *.fo *.html *.pdf *.txt
93         rm -rf $(LANGS)
94         rm -f version.ent
95         rm -f `find . -name "*~" -o -name "*.bak"`
96         rm -f *~ *.bak .#* core
97
98 .PHONY: distclean
99 distclean: clean
100         rm -f *.rej *.orig
101
102 # if rule bomb out, delete the target
103 .DELETE_ON_ERROR: