chiark / gitweb /
update Japanese translation
[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           := 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 # 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 # This rule controls the build and installation on the website
52 # Logs are here: http://www-master.debian.org/build-logs/ddp/
53 .PHONY: publish
54 publish:        all
55         [ -d $(PUBLISHDIR) ] || exit 1
56         install -d -m 755 $(PUBLISHDIR)/developers-reference
57         rm -f $(PUBLISHDIR)/developers-reference/*.html
58         rm -f en && ln -sf . en
59         $(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;))
60         ln -sf index.en.html $(PUBLISHDIR)/developers-reference/index.html
61         ln -sf developers-reference.en.pdf $(PUBLISHDIR)/developers-reference/developers-reference.pdf
62         ln -sf developers-reference.en.txt $(PUBLISHDIR)/developers-reference/developers-reference.txt
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         $(MAKE) $@ LINGUA=`basename $(@D)`
79
80 FORCE:
81 else
82 $(LINGUA)/%.dbk:        %.dbk $(patsubst %.dbk,po4a/$(LINGUA)/%.po,%.dbk)
83 #       $(TRANSLATE) -m $< -p po4a/$(@:.dbk=.po) -l $@ -a ?po4a/$(@:.dbk=.add)
84 # workaround to "-a ?" only possible with po4a version in Squeeze, otherwise build is broken in Lenny
85         if [ -f po4a/$(@:.dbk=.add) ]; then \
86                 $(TRANSLATE) -m $< -p po4a/$(@:.dbk=.po) -l $@ -a po4a/$(@:.dbk=.add); else \
87                 $(TRANSLATE) -m $< -p po4a/$(@:.dbk=.po) -l $@; fi
88
89 $(LINGUA)/common.ent:   common.ent
90         cd $(@D) && ln -sf ../$(@F) .
91 endif
92
93 developers-reference.txt:       $(CURDIR)/developers-reference.txt
94 %/developers-reference.txt:     $(addprefix %/,$(SOURCES))
95         $(XP) $(DBK2HTML1) $(@D)/index.dbk \
96             | w3m -o display_charset=UTF-8 -cols 70 -dump -no-graph -T text/html > $@
97
98 developers-reference.pdf:       $(CURDIR)/developers-reference.pdf
99 %/developers-reference.pdf:     $(addprefix %/,$(SOURCES))
100         TOP=`pwd` && cd $(@D) && $(DBLATEX) index.dbk \
101             && mv index.dbk.pdf $(@F)
102
103 .PHONY: pot
104 pot:                            $(patsubst %.dbk,po4a/po/%.pot,$(SOURCES))
105 po4a/po/%.pot:                  %.dbk
106         po4a-gettextize --format docbook --master $< --po $@
107
108 ifdef LINGUA
109 .PHONY: updatepo
110 updatepo:                       $(patsubst %.dbk,po4a/$(LINGUA)/%.po,$(SOURCES))
111 po4a/$(LINGUA)/%.po:            %.dbk
112         po4a-updatepo --previous --format docbook --master $< --po $@
113 endif
114
115 tidypo:
116         for po in $(wildcard po4a/*/*.po po4a/*/*.pot); do \
117             msgcat $$po > $$po.tmp && mv $$po.tmp $$po; \
118         done
119
120 checkpo:
121         @for po in $(wildcard po4a/*/*.po po4a/*/*.pot); do \
122             echo $$po; \
123             msgfmt --check --verbose $$po; \
124         done
125
126 %/version.ent:
127         echo '<!ENTITY version "$(VERSION)">' >  $@
128         echo '<!ENTITY pubdate "$(PUBDATE)">' >> $@
129
130 .PHONY: clean
131 clean:
132         rm -f *.fo *.html *.pdf *.txt
133         for L in $(LANGS); do rm -rf `basename ./"$$L"/`; done
134         rm -f version.ent
135         rm -f `find . -name "*~" -o -name "*.bak"`
136         rm -f *~ *.bak .#* core
137
138 .PHONY: distclean
139 distclean: clean
140         rm -f *.rej *.orig
141
142 # if rule bomb out, delete the target
143 .DELETE_ON_ERROR: