chiark / gitweb /
Updated changelog.
[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 epub
8 LANGS           := de 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 TRANSLATE=po4a po4a/po4a.cfg
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=$(CURDIR)/html.xsl
37 # all in one file for text output
38 DBK2HTML1=$(CURDIR)/txt.xsl
39
40 .PHONY: all
41 all:    $(filter-out $(BLACKLIST), $(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 # This rule controls the build and installation on the website
51 # Logs are here: http://www-master.debian.org/build-logs/ddp/
52 .PHONY: publish
53 publish:        all
54         [ -d $(PUBLISHDIR) ] || exit 1
55         install -d -m 755 $(PUBLISHDIR)/developers-reference
56         rm -f $(PUBLISHDIR)/developers-reference/*.html
57         rm -f en && ln -sf . en
58         $(foreach format,$(FORMATS),$(foreach lang,en $(LANGS),for file in $(lang)/*.$(format); do if [ -e "$$file" ]; then cp --preserve=timestamps $$file $(PUBLISHDIR)/developers-reference/$$(basename $$file .$(format)).$(lang).$(format); fi; done;))
59         ln -sf index.en.html $(PUBLISHDIR)/developers-reference/index.html
60         ln -sf developers-reference.en.pdf $(PUBLISHDIR)/developers-reference/developers-reference.pdf
61         ln -sf developers-reference.en.txt $(PUBLISHDIR)/developers-reference/developers-reference.txt
62         ln -sf developers-reference.en.epub $(PUBLISHDIR)/developers-reference/developers-reference.epub
63
64 .PHONY: developers-reference.html %/developers-reference.html
65 developers-reference.html:      $(CURDIR)/index.html
66 %/developers-reference.html:    $(addprefix %/,index.html)
67         @true
68
69 .PRECIOUS:                      %/index.html
70 index.html:                     $(CURDIR)/developers-reference.html
71 %/index.html:                   $(addprefix %/,$(SOURCES))
72         cd $(@D) && $(XP) $(DBK2HTML) index.dbk
73
74 # There must be an easier way than recursive make!
75 .PRECIOUS:              %.dbk %.ent
76 ifndef LINGUA
77 %.dbk %.ent: FORCE
78         $(TRANSLATE)
79         $(MAKE) $@ LINGUA=`basename $(@D)`
80
81 FORCE:
82 else
83 $(LINGUA)/%.dbk:        %.dbk po4a/$(LINGUA).po
84         $(TRANSLATE)
85
86 $(LINGUA)/common.ent:   common.ent
87         cd $(@D) && ln -sf ../$(@F) .
88 endif
89
90 developers-reference.txt:       $(CURDIR)/developers-reference.txt
91 %/developers-reference.txt:     $(addprefix %/,$(SOURCES))
92         $(XP) $(DBK2HTML1) $(@D)/index.dbk \
93             | LC_ALL=C.UTF-8 w3m -o display_charset=UTF-8 -cols 70 -dump -no-graph -T text/html > $@
94
95 XSLT            := xslt
96
97 developers-reference.pdf:       $(CURDIR)/developers-reference.pdf
98 %/developers-reference.pdf:     $(addprefix %/,$(SOURCES))
99         $(DBLATEX) $(@D)/index.dbk \
100             --backend=xetex \
101             --xsl-user=$(XSLT)/user_param.xsl \
102             --xsl-user=$(XSLT)/xetex_param.xsl \
103             --param=lingua=$(@D) \
104             && mv $(@D)/index.dbk.pdf $@
105
106 developers-reference.epub:      $(CURDIR)/developers-reference.epub
107 %/developers-reference.epub:     $(addprefix %/,$(SOURCES))
108         TOP=`pwd` && cd $(@D) && xmlto epub index.dbk && mv index.epub $(@F)
109
110 .PHONY: pot
111 pot:                                    po4a/po/developers-reference.pot
112 po4a/po/developers-reference.pot:       %.dbk
113         $(TRANSLATE)
114
115 ifdef LINGUA
116 .PHONY: updatepo
117 updatepo:                       po4a/po/$(LINGUA).po
118 po4a/po/$(LINGUA).po:           %.dbk
119         $(TRANSLATE)
120 endif
121
122 tidypo:
123         for po in po4a/po/*.po; do \
124             msgcat -o $$po $$po; \
125         done
126
127 checkpo:
128         @for po in po4a/po/*.po; do \
129             msgfmt -vv $$po; \
130         done
131
132 %/version.ent:
133         echo '<!ENTITY version "$(VERSION)">' >  $@
134         echo '<!ENTITY pubdate "$(PUBDATE)">' >> $@
135
136 .PHONY: clean
137 clean:
138         rm -f *.fo *.html *.pdf *.txt *.epub
139         for L in $(LANGS); do rm -rf `basename ./"$$L"/`; done
140         rm -f version.ent
141         rm -f `find . -name "*~" -o -name "*.bak"`
142         rm -f *~ *.bak .#* core
143
144 .PHONY: distclean
145 distclean: clean
146         rm -f *.rej *.orig
147
148 # if rule bomb out, delete the target
149 .DELETE_ON_ERROR: