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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.5