/[ddp]/manuals/trunk/quick-reference/Makefile
ViewVC logotype

Contents of /manuals/trunk/quick-reference/Makefile

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6709 - (show annotations) (download)
Tue Jun 2 22:40:34 2009 UTC (3 years, 11 months ago) by osamu
File size: 14562 byte(s)
clean old junks in wrong directories
1 #######################################################################
2 # Build debian-reference (v2)
3 # vim: set ts=8:
4 #######################################################################
5 ### basic parameters (build condition dependent) ALL
6 #######################################################################
7 # parent dir name of the SVN source checkout location
8 # make[1]: Entering directory `/org/www.debian.org/ddp-svn/trunk/quick-reference'
9 PDIR := $(notdir $(realpath $(CURDIR)/../..))
10 # if $(PDIR) is ddp-svn -> DDP build
11 # if $(PDIR) is ddp-svn -> normal build -> scp to ~osamu
12
13 ifeq ($(PDIR),ddp-svn)
14 # $(PUBLISHDIR) is set to be: /org/www.debian.org/www/doc/manuals
15 XPUBLISHDIR := $(PUBLISHDIR)
16 PUBLISHDIR := $(PUBLISHDIR)/reference
17 else
18 PUBLISHDIR := $(CURDIR)/html
19 endif
20 # Please note package build script overides $(PUBLISHDIR)
21
22 #######################################################################
23 ### basic parameters (build condition independent) ALL
24 #######################################################################
25 # base file name excluding file extension
26 DOCNAME := debian-reference
27 # Directories (no trailing slash)
28 PXSLT := xslt
29 PBIN := bin
30 ADOC := asciidoc
31 PODOC := po4a
32 IMAGES := /usr/share/xml/docbook/stylesheet/nwalsh/images
33 # Program name and option
34 XP := xsltproc --nonet --novalid --xinclude
35 #XL := xmllint --nonet --noout --postvalid --xinclude
36 # The threshold should be 80 if translation is completed.
37 THRESHOLD:= 0
38 TRANSLATE:= po4a-translate -M utf-8 --format docbook --keep $(THRESHOLD)
39 GETTEXT := po4a-gettextize -M utf-8 -L utf-8 --format docbook
40 UPDATEPO:= po4a-updatepo -M utf-8 --format docbook
41 # # note: the URL is used as identifier, no HTTP is used!
42 # DOCBOOK_XSL=http://docbook.sourceforge.net/release/xsl/current
43 VERBOSE :=
44 # Debian packge archive URL
45 #DEBM := http://ftp.us.debian.org/debian/dists
46 DEBM := http://ftp.jp.debian.org/debian/dists
47 # Debian popcon data source URL
48 UPOPC := http://popcon.debian.org/all-popcon-results.txt.gz
49 # Debian release name and arch used
50 CODE := sid
51 ARCH := amd64
52 UDEBA := $(DEBM)/$(CODE)
53 # AsciiDoc source files in $(ADOC) directories
54 ASCSRC := 00_preface.txt 01_tutorial.txt 02_package.txt \
55 03_sysinit.txt 04_auth.txt 05_network.txt 06_netapp.txt \
56 07_xwindow.txt 08_i18nl10ntxt 09_systips.txt 10_datamngt.txt \
57 11_dataconv.txt 12_program.txt 99_appendix.txt
58 # source files
59 ASCSRCS := $(ADOC)/$(DOCNAME).txt $(addprefix $(ADOC)/, $(ASCSRC))
60 ENTSRCS := urls.ent datadatepop.ent datadatesize.ent popcon.ent pkgsize.ent common.ent
61 XMLSRCS := $(DOCNAME).en.xml $(ENTSRCS)
62 LANGALL := en ja fr it es de pt-br pl zh-tw zh-cn
63 LANGPO := ja
64 LANGNEW :=
65 LANGSGML:= $(filter-out en $(LANGPO), $(LANGALL))
66
67 #########################################################################
68 # Local raw XML files and base data LOCAL
69 #########################################################################
70 ifneq ($(PDIR),ddp-svn)
71
72 # -----------------------------------------------------------------------
73 # This is cleaned after "make clean"
74 # create a raw XML source from asciidoc source
75 $(DOCNAME).raw.xml: $(ASCSRCS)
76 asciidoc -a 'newline=\n' -b docbook -d book -o - $(ADOC)/$(DOCNAME).txt |\
77 sed -e "/<\/authorinitials>/r $(ADOC)/copyright.txt" |\
78 xmllint --format - > $@
79
80 # -----------------------------------------------------------------------
81 # Remotely fetched files prior to the build after "make distclean"
82 # These are cleaned after "make clean"
83 # These will not be a part of source except datadate{pop|size}.ent
84 # datadate{pop|size}.ent are generated as secondary side effects
85
86 all-popcon-results.txt:
87 wget -O - $(UPOPC) | zcat - > all-popcon-results.txt
88 echo "<!ENTITY pop-date \"$(shell date -u +'%F %T %Z')\">" > datadatepop.ent
89
90 packages.txt:
91 wget -O - $(UDEBA)/main/binary-$(ARCH)/Packages.bz2 | bzcat - > packages.main.tmp
92 grep-dctrl -e -sPackage,Installed-Size -P "." packages.main.tmp > packages.main
93 rm packages.main.tmp
94 wget -O - $(UDEBA)/contrib/binary-$(ARCH)/Packages.bz2 | bzcat - > packages.contrib.tmp
95 grep-dctrl -e -sPackage,Installed-Size -P "." packages.contrib.tmp > packages.contrib
96 rm packages.contrib.tmp
97 wget -O - $(UDEBA)/non-free/binary-$(ARCH)/Packages.bz2 | bzcat - > packages.non-free.tmp
98 grep-dctrl -e -sPackage,Installed-Size -P "." packages.non-free.tmp > packages.non-free
99 rm packages.non-free.tmp
100 #sync
101 #sleep 1
102 cat packages.main packages.contrib packages.non-free >$@
103 #
104 echo "<!ENTITY all-packages \"$$(grep -e '^Package:' packages.txt | wc -l)\">" > datadatesize.ent
105 echo "<!ENTITY main-packages \"$$( grep -e '^Package:' packages.main | wc -l)\">" >> datadatesize.ent
106 echo "<!ENTITY contrib-packages \"$$(grep -e '^Package:' packages.contrib | wc -l)\">" >> datadatesize.ent
107 echo "<!ENTITY non-free-packages \"$$(grep -e '^Package:' packages.non-free | wc -l)\">" >> datadatesize.ent
108 echo "<!ENTITY pkgsize-date \"$(shell date -u +'%F %T %Z')\">" >> datadatesize.ent
109 rm packages.main packages.contrib packages.non-free
110
111 # package name list for popcon and size ent file generation
112 # This file is not part of source
113 pkg.lst: $(DOCNAME).raw.xml
114 xsltproc --novalid $(VERBOSE) $(PXSLT)/pkg.xsl $< > $@
115
116 # -----------------------------------------------------------------------
117 # Create final XML sources
118 # This is not cleaned after "make clean" but cleaned by "make distclean"
119
120 # replace table contents with @@@popcon*@@@ and @@@psize*@@@ and
121 # fix URL referencees and table ID.
122 $(DOCNAME).en.xml: $(DOCNAME).raw.xml $(ADOC)/header.txt
123
124 # use asciidoc generated xml file as main contents
125 xsltproc --novalid $(VERBOSE) $(PXSLT)/table.xsl $(DOCNAME).raw.xml |\
126 $(PBIN)/colspec.py |\
127 sed -e '/<!DOCTYPE /d' -e "1r $(ADOC)/header.txt" |\
128 sed -f bin/replace > $@
129
130 # trick to allow building source w/o regenerating urls.ent unneededly
131 urls.ent: $(ASCSRCS)
132 if ! [ -f $(DOCNAME).raw.xml ]; then $(MAKE) $(DOCNAME).raw.xml ; fi
133 xsltproc --novalid $(VERBOSE) $(PXSLT)/urls.xsl $(DOCNAME).raw.xml | sort | uniq | sed -f bin/replace > $@
134
135 # trick to allow building source w/o all-popcon-results.txt
136 datadatepop.ent:
137 $(MAKE) all-popcon-results.txt
138
139 # trick to allow building source w/o packages.txt
140 datadatesize.ent:
141 $(MAKE) packages.txt
142
143 # trick to allow building source w/o all-popcon-results.txt and pkg.lst
144 popcon.ent:
145 if ! [ -f all-popcon-results.txt ]; then $(MAKE) all-popcon-results.txt ; fi
146 if ! [ -f pkg.lst ]; then $(MAKE) pkg.lst ; fi
147 echo "<!ENTITY pop-submissions \"$(shell sed -n -e 's/^Submissions: *\([^ ]*\) *$$/\1/p' < all-popcon-results.txt)\">" > $@
148 echo "<!ENTITY pop-architectures \"$(shell grep -e '^Architecture:' all-popcon-results.txt | wc -l)\">" >> $@
149 echo "<!ENTITY pop-packages \"$(shell grep -e '^Package:' all-popcon-results.txt | wc -l)\">" >> $@
150 TOTAL=$(shell sed -n -e 's/^Submissions: *\([^ ]*\) *$$/\1/p' < all-popcon-results.txt) ;\
151 grep -e '^Package:' all-popcon-results.txt | grep -f pkg.lst | $(PBIN)/popconent $$TOTAL >> $@
152
153 # trick to allow building source w/o packages.txt and pkg.lst
154 pkgsize.ent:
155 if ! [ -f packages.txt ]; then $(MAKE) packages.txt ; fi
156 if ! [ -f pkg.lst ]; then $(MAKE) pkg.lst ; fi
157 $(PBIN)/sizeent packages.txt < pkg.lst > $@
158
159 # change if there have been some change in source
160 common.ent: $(filter-out common.ent, $(XMLSRCS))
161 echo "<!ENTITY build-date \"$(shell date -u +'%F %T %Z')\">" > $@
162 echo "<!ENTITY arch \"$(ARCH)\">" >> $@
163 echo "<!ENTITY codename-stable \"lenny\">" >> $@
164 echo "<!ENTITY codename-testing \"squeeze\">" >> $@
165 echo "<!ENTITY codename-nexttesting \"squeeze+1\">" >> $@
166 echo "<!ENTITY codename-unstable \"sid\">" >> $@
167
168 # -----------------------------------------------------------------------
169 # Create new PO file in $(PODOC)
170 # Use with "make LANGNEW=<language> newpo" while <language>= ja, fr, ...
171 .PHONY: xml
172 xml: $(XMLSRCS) $(addsufix, .xml, $(addprefix $(DOCNAME)., $(LANGPO)))
173 .PHONY: newpo
174 newpo: $(DOCNAME).en.xml
175 if [ -z "$(LANGNEW)" ] || [ -f "$(PODOC)/$(DOCNAME).$(LANGNEW).po" ] ; then exit 1; fi
176 $(GETTEXT) -m $(DOCNAME).en.xml -p $(PODOC)/$(DOCNAME).$(LANGNEW).po
177
178 # -----------------------------------------------------------------------
179 # Update PO files and translate English XML file
180 .PHONY: updatepo
181 updatepo: $(DOCNAME).en.xml
182 $(UPDATEPO) -m $(DOCNAME).en.xml -p $(PODOC)/$(DOCNAME).ja.po
183
184 # create translated XML file while updating PO file
185 $(DOCNAME).%.xml: $(PODOC)/$(DOCNAME).%.po $(DOCNAME).en.xml
186 $(UPDATEPO) -m $(DOCNAME).en.xml -p $(PODOC)/$(DOCNAME).$*.po
187 $(TRANSLATE) -m $(DOCNAME).en.xml -p $(PODOC)/$(DOCNAME).$*.po -l $(DOCNAME).$*.xml
188
189 endif
190 #########################################################################
191 # Create HTML files ALL
192 #########################################################################
193 .PHONY: css
194 css:
195 -rm -rf $(PUBLISHDIR)/images
196 mkdir -p $(PUBLISHDIR)/images
197 cp -f $(PXSLT)/$(DOCNAME).css $(PUBLISHDIR)/$(DOCNAME).css
198 cd $(IMAGES) ; cp caution.png home.gif important.png next.gif note.png prev.gif tip.png up.gif warning.png $(PUBLISHDIR)/images
199
200 .PHONY: html
201 html: $(foreach lang, en $(LANGPO), $(PUBLISHDIR)/$(DOCNAME).$(lang).html) $(foreach lang, en $(LANGPO), $(PUBLISHDIR)/index.$(lang).html)
202
203 $(PUBLISHDIR)/$(DOCNAME).%.html: $(DOCNAME).%.xml $(ENTSRCS)
204 $(XP) --stringparam root.filename $(DOCNAME) \
205 --stringparam base.dir $(PUBLISHDIR)/ \
206 --stringparam html.ext .$*.html \
207 --stringparam html.stylesheet $(DOCNAME).css \
208 xslt/style-onehtml.xsl $<
209
210 $(PUBLISHDIR)/index.%.html: $(DOCNAME).%.xml $(ENTSRCS)
211 $(XP) --stringparam root.filename index \
212 --stringparam base.dir $(PUBLISHDIR)/ \
213 --stringparam html.ext .$*.html \
214 --stringparam html.stylesheet $(DOCNAME).css \
215 xslt/style-html.xsl $<
216
217 .PHONY: txt
218 txt: $(foreach lang, en $(LANGPO), $(PUBLISHDIR)/$(DOCNAME).$(lang).txt)
219 # Build rule for TXT (non-English)
220 # # (UTF-8 compatibility of debiandoc2text is limitted)
221 $(PUBLISHDIR)/$(DOCNAME).%.txt: $(PUBLISHDIR)/$(DOCNAME).%.html
222 LC_ALL=en_US.UTF-8 w3m -dump -cols 65 -T text/html $(PUBLISHDIR)/$(DOCNAME).$*.html >$@
223
224
225 #########################################################################
226 # Utility targets ALL
227 #########################################################################
228 # Replicate
229 REMOTE := people.debian.org:public_html/pub/po4a/
230
231 .PHONY: rsync
232 rsync:
233 rsync --exclude=all-popcon-results.txt --exclude=packages.txt --exclude=pkg.lst --exclude="debian-reference.*.xml" \
234 -rpt --delete-after . $(REMOTE)
235 # somehow rsync does 700, fixit
236 ssh people.debian.org "chmod ugo+rX public_html/pub/po4a"
237
238 .PHONY: url-check
239 # sanity check for url
240 url-check: urls.lst
241 @echo "----- Duplicate URL references (start) -----"
242 -sed -ne "s/<\!ENTITY \([^ ]*\) .*$$/\" \1 \"/p" < $< | uniq -d | xargs -n 1 grep $< -e
243 @echo "----- Duplicate URL references (end) -----"
244 @echo "----- URL check (start) -----"
245 @sed -ne "s/<\!ENTITY [^ ]* \"\(.*\)\">$$/\"\1\"/p" < $< | uniq | xargs -n 1 wget -O /dev/null -nv
246 @echo "----- URL check (end) -----"
247
248 .PHONY: test
249 test: guide-line.en.html
250 guide-line.xml: guide-line.txt
251 asciidoc -a 'newline=\n' -b docbook -d book -o - $< > $@
252
253 guide-line.en.html: guide-line.xml
254 $(XP) --stringparam root.filename guide-line \
255 --stringparam base.dir $(PUBLISHDIR)/ \
256 --stringparam html.ext .en.html \
257 --stringparam html.stylesheet xslt/$(DOCNAME).css \
258 xslt/style-onehtml.xsl $<
259
260 #######################################################################
261 # Update source using remotely fetched data ALL
262 #######################################################################
263 .PHONY: update
264 update:
265 $(MAKE) distclean
266 $(MAKE) $(ENTSRCS)
267 endif$(MAKE) clean
268
269 #######################################################################
270 # Build html for web (DDP or alioth) ALL
271 #######################################################################
272 .PHONY: publish
273
274 publish:
275 $(MAKE) html txt css
276 $(MAKE) -C sgml all PUBLISHDIR=$(PUBLISHDIR) "LANG_ALL=$(LANGSGML)"
277
278 .PHONY: all
279
280 all:
281 $(MAKE) html txt css
282 $(MAKE) -C sgml all PUBLISHDIR=$(PUBLISHDIR) "LANG_ALL=$(LANGSGML)"
283 # skip if DDP
284 export HTMLROOT=$(PUBLISHDIR) ; bin/mkindexhtml
285 $(MAKE) rsync
286
287 #######################################################################
288 # Clean targets ALL
289 #######################################################################
290 .PHONY: clean distclean
291
292 clean:
293 -rm -f *.swp *~ *.tmp
294 -rm -rf $(PUBLISHDIR)
295 # correct error
296 -rm -rf $(XPUBLISHDIR)/images
297 -rm -f $(XPUBLISHDIR)/apa.*.html
298 -rm -f $(XPUBLISHDIR)/ap-appendix.*.html
299 -rm -f $(XPUBLISHDIR)/ch01.*.html
300 -rm -f $(XPUBLISHDIR)/ch02.*.html
301 -rm -f $(XPUBLISHDIR)/ch03.*.html
302 -rm -f $(XPUBLISHDIR)/ch04.*.html
303 -rm -f $(XPUBLISHDIR)/ch05.*.html
304 -rm -f $(XPUBLISHDIR)/ch06.*.html
305 -rm -f $(XPUBLISHDIR)/ch07.*.html
306 -rm -f $(XPUBLISHDIR)/ch08.*.html
307 -rm -f $(XPUBLISHDIR)/ch09.*.html
308 -rm -f $(XPUBLISHDIR)/ch10.*.html
309 -rm -f $(XPUBLISHDIR)/ch11.*.html
310 -rm -f $(XPUBLISHDIR)/ch12.*.html
311 -rm -f $(XPUBLISHDIR)/ch-edit.*.html
312 -rm -f $(XPUBLISHDIR)/ch-gateway.*.html
313 -rm -f $(XPUBLISHDIR)/ch-gnupg.*.html
314 -rm -f $(XPUBLISHDIR)/ch-install.*.html
315 -rm -f $(XPUBLISHDIR)/ch-kernel.*.html
316 -rm -f $(XPUBLISHDIR)/ch-package.*.html
317 -rm -f $(XPUBLISHDIR)/ch-preface.*.html
318 -rm -f $(XPUBLISHDIR)/ch-program.*.html
319 -rm -f $(XPUBLISHDIR)/ch-support.*.html
320 -rm -f $(XPUBLISHDIR)/ch-system.*.html
321 -rm -f $(XPUBLISHDIR)/ch-tips.*.html
322 -rm -f $(XPUBLISHDIR)/ch-tune.*.html
323 -rm -f $(XPUBLISHDIR)/ch-tutorial.*.html
324 -rm -f $(XPUBLISHDIR)/ch-vcs.*.html
325 -rm -f $(XPUBLISHDIR)/ch-woody.*.html
326 -rm -f $(XPUBLISHDIR)/debian-reference.css
327 -rm -f $(XPUBLISHDIR)/debian-reference.*.html
328 -rm -f $(XPUBLISHDIR)/debian-reference.*.txt
329 -rm -f $(XPUBLISHDIR)/footnotes.*.html
330 -rm -f $(XPUBLISHDIR)/index.*.html
331 -rm -f $(XPUBLISHDIR)/pr01.*.html
332 # just this time
333
334 ifneq ($(PDIR),ddp-svn)
335 -rm -f all-popcon-results.txt packages.txt pkg.lst
336 -rm -f $(DOCNAME).ja.xml
337 -rm -f $(DOCNAME).raw.xml
338 $(MAKE) -C sgml clean "LANG_ALL=$(LANGSGML)"
339 endif
340
341 distclean: clean
342 -rm -f *.html
343 -rm -f $(ENTSRCS)
344 ifeq ($PDIR,ddp-svn)
345 -rm -f all-popcon-results.txt packages.txt pkg.lst
346 -rm -f $(DOCNAME).*.xml
347 $(MAKE) -C sgml clean "LANG_ALL=$(LANGSGML)"
348 endif
349

  ViewVC Help
Powered by ViewVC 1.1.5