1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311
|
#######################################################################
# Build maint-guide
# vim: set ts=8:
#######################################################################
### key adjustable parameters
#######################################################################
# base file name excluding file extension
MANUAL := maint-guide
# languages translated with PO files
LANGPO := ca de es fr it ja ru vi zh-cn zh-tw
# languages to skip generation of PDF files
NOPDF :=
# languages to build document
LANGALL = en $(LANGPO)
VERSION := "GIT: $(shell LC_ALL=C date -u +'%F %T %Z')"
# set SOURCE_DATE_EPOCH if unset (when not called from debhelper)
SOURCE_DATE_EPOCH ?= $(shell dpkg-parsechangelog -STimestamp)
# date in changelog
SOURCE_DATE := $(shell date -u +'%F %T %Z' --date=@$(SOURCE_DATE_EPOCH))
ifndef TMPDIR
TMPDIR := $(CURDIR)/tmp
endif
# Change $(DRAFTMODE) from "yes" to "maybe" when this document
# should go into production mode
#DRAFTMODE := yes
DRAFTMODE := maybe
export DRAFTMODE
#######################################################################
### basic constant parameters
#######################################################################
# Directories (no trailing slash)
DXSL := xslt
DBIN := bin
DDOC := doc
DPO := po
DIMG := /usr/share/xml/docbook/stylesheet/nwalsh/images
# Program name and option
XLINT := xmllint --format
XPNO := xsltproc --novalid --nonet
XPINC := xsltproc --novalid --nonet --xinclude
# The threshold should be 80 if translation is completed.
THRESHOLD:= 0
PO4A := po4a -v
UPDATEPO:= msgmerge --update --previous
MSGATTR := msgattrib
MSGCAT := msgcat
DBLATEX := dblatex
# English source files
DOCS := $(shell ls $(DDOC)/*)
# source XML inclusion files (excluding version.ent)
ENT_STAT:= common.ent $(addsuffix .ent, $(addprefix $(DPO)/, $(LANGPO)))
ENT_ALL := $(ENT_STAT) version.ent
# source PO files for all languages (build prcess requires these)
SRC_PO := $(addsuffix .po, $(addprefix $(DPO)/, $(LANGPO)))
# source XML files for all languages (build prcess requires these)
SRC_XML := $(addsuffix .xml, $(addprefix $(MANUAL)., $(LANGPO)))
#######################################################################
# Used as $(call check-command, <command>, <package>)
define check-command
set -e; if ! which $(1) >/dev/null; then \
echo "Missing command: $(1), install package: $(2)"; \
false; \
fi
endef
#######################################################################
# $ make all # build all
#######################################################################
.PHONY: all
# set LANGPO to limit language to speed up build
all: css html txt pdf
#######################################################################
# $ make test # build html for testing (for Translator)
#######################################################################
.PHONY: test
test: html css
#######################################################################
# $ make publish # build html text from EN.XML/PO for DDP
#######################################################################
.PHONY: package
# $(PUBLISHDIR) is set to be: /org/www.debian.org/www/doc/manuals for master-www
publish:
-mkdir -p $(PUBLISHDIR)/$(MANUAL)
$(MAKE) css html txt "TMPDIR=$(PUBLISHDIR)/$(MANUAL)"
#######################################################################
# $ make clean # clean files ready for tar
#######################################################################
.PHONY: clean
clean:
-rm -f $(addsuffix .xml, $(addprefix $(MANUAL)., *))
-rm -f *.swp *~ *.tmp
-rm -f $(DPO)/*~ $(DPO)/*.mo $(DPO)/*.po.*
-rm -rf $(TMPDIR)
-rm -f version.ent
#######################################################################
# $ make distclean # clean files to reset EN.XML/ENT/POT
#######################################################################
.PHONY: distclean
distclean: clean
-rm -f $(DDOC)/*~
-rm -f fuzzy.log
##############################################################################
# Version file preparations
##############################################################################
# version from debian/changelog
# if for www-master directly building from subversion source
version.ent: $(DOCS)
echo "<!ENTITY docisodate \"$(SOURCE_DATE)\">" > version.ent
echo "<!ENTITY docversion \"$(VERSION)\">" >> version.ent
#######################################################################
# $ make po # update all PO from EN.XML
#######################################################################
# Always update POs and XMLs with po4a, then create fuzzy.log
fuzzy.log:
@$(call check-command, msgmerge, gettext)
touch -t 200001010000 $(DPO)/templates.pot
$(PO4A) po4a.cfg
: > fuzzy.log
for f in $(LANGPO); do \
sed -i -e "s/$(DPO)\/en\.ent/$(DPO)\/$$f.ent/" $(MANUAL).$$f.xml ; \
MESS1="no-obsolete $$f `$(MSGATTR) --no-obsolete $(DPO)/$$f.po |grep ^msgid |sed 1d|wc -l`";\
MESS2="untranslated $$f `$(MSGATTR) --untranslated $(DPO)/$$f.po |grep ^msgid |sed 1d|wc -l`";\
MESS3="fuzzy $$f `$(MSGATTR) --fuzzy $(DPO)/$$f.po |grep ^msgid |sed 1d|wc -l`";\
echo "$$MESS1" >>fuzzy.log ; \
echo "$$MESS2" >>fuzzy.log ; \
echo "$$MESS3" >>fuzzy.log ; \
echo "" >>fuzzy.log ;\
done
.PHONY: po
po: fuzzy.log
$(SRC_PO): fuzzy.log
.PHONY: xml
xml: fuzzy.log
$(SRC_XML): fuzzy.log
#######################################################################
# $ make wrap # wrap all PO
#######################################################################
.PHONY: wrap nowrap wip
wrap:
@$(call check-command, msgcat, gettext)
for XX in $(foreach LX, $(LANGPO), $(DPO)/$(LX).po); do \
$(MSGCAT) -o $$XX $$XX ;\
done
nowrap:
@$(call check-command, msgcat, gettext)
for XX in $(foreach LX, $(LANGPO), $(DPO)/$(LX).po); do \
$(MSGCAT) -o $$XX --no-wrap $$XX ;\
done
wip:
@$(call check-command, msgattrib, gettext)
for XX in $(foreach LX, $(LANGPO), $(DPO)/$(LX).po); do \
$(MSGATTR) -o $$XX.fuzz --fuzzy $$XX ;\
$(MSGATTR) -o $$XX.untr --untranslated $$XX ;\
done
#######################################################################
# $ make xml # update all *.xml (EN.XML ...) from DOCS /ENT/PO/ADD
#######################################################################
$(MANUAL).en.xml: $(DOCS)
: > $@
for i in $(DOCS) ; do cat $$i >> $@ ; done
#######################################################################
# $ make css # update CSS and DIMG in $(TMPDIR)
#######################################################################
.PHONY: css
css:
-rm -rf $(TMPDIR)/images
mkdir -p $(TMPDIR)/images
cp -f $(DXSL)/debian.css $(TMPDIR)/debian.css
echo "AddCharset UTF-8 .txt" > $(TMPDIR)/.htaccess
cd png ; cp caution.png home.png important.png next.png note.png prev.png tip.png warning.png $(TMPDIR)/images
#######################################################################
# $ make html # update all HTML in $(TMPDIR)
#######################################################################
.PHONY: html
html: $(foreach LX, $(LANGALL), $(TMPDIR)/index.$(LX).html)
$(TMPDIR)/index.%.html: $(MANUAL).%.xml $(ENT_ALL)
@$(call check-command, xsltproc, xsltproc)
-mkdir -p $(TMPDIR)
$(XPINC) --stringparam base.dir $(TMPDIR)/ \
--stringparam html.ext .$*.html \
$(DXSL)/style-html.xsl $<
#######################################################################
# $ make txt # update all Plain TEXT in $(TMPDIR)
#######################################################################
.PHONY: txt
txt: $(foreach LX, $(LANGALL), $(TMPDIR)/$(MANUAL).$(LX).txt)
# txt.xsl provides work around for hidden URL links by appending them explicitly.
$(TMPDIR)/$(MANUAL).%.txt: $(MANUAL).%.xml $(ENT_ALL)
@$(call check-command, w3m, w3m)
@$(call check-command, xsltproc, xsltproc)
-mkdir -p $(TMPDIR)
@test -n "`which w3m`" || { echo "ERROR: w3m not found. Please install the w3m package." ; false ; }
$(XPINC) $(DXSL)/style-txt.xsl $< | \
LC_ALL=en_US.UTF-8 w3m -o display_charset=UTF-8 -cols 70 -dump -no-graph -T text/html > $@
#######################################################################
# $ make pdf # update all PDF in $(TMPDIR)
#######################################################################
.PHONY: pdf
pdf: $(foreach LX, $(LANGALL), $(TMPDIR)/$(MANUAL).$(LX).pdf)
$(foreach LX, $(NOPDF), $(TMPDIR)/$(MANUAL).$(LX).pdf):
-mkdir -p $(TMPDIR)
echo "PDF generation skipped." >$@
# dblatex.xsl provide work around for hidden URL links by appending them explicitly.
$(TMPDIR)/$(MANUAL).%.pdf: $(MANUAL).%.xml $(ENT_ALL)
@$(call check-command, dblatex, dblatex)
@$(call check-command, xsltproc, xsltproc)
-mkdir -p $(TMPDIR)/pdf-$*
@test -n "`which $(DBLATEX)`" || { echo "ERROR: dblatex not found. Please install the dblatex package." ; false ; }
export TEXINPUTS=".:"; \
export TMPDIR="$(TMPDIR)/pdf-$*"; \
$(XPINC) $(DXSL)/dblatex.xsl $< | \
$(DBLATEX) --style=native \
--debug \
--backend=xetex \
--xsl-user=$(DXSL)/user_param.xsl \
--xsl-user=$(DXSL)/xetex_param.xsl \
--param=draft.mode=$(DRAFTMODE) \
--param=lingua=$* \
--output=$@ - || { echo "OMG!!!!!! XXX_CHECK_XXX ... Do not worry ..."; true ; }
#######################################################################
# $ make tex # update all TeX source in $(TMPDIR)
#######################################################################
.PHONY: tex
tex: $(foreach LX, $(LANGALL), $(TMPDIR)/$(MANUAL).$(LX).tex)
# dblatex.xsl provide work around for hidden URL links by appending them explicitly.
$(TMPDIR)/$(MANUAL).%.tex: $(MANUAL).%.xml $(ENT_ALL)
-mkdir -p $(TMPDIR)/tex-$*
@test -n "`which $(DBLATEX)`" || { echo "ERROR: dblatex not found. Please install the dblatex package." ; false ; }
export TEXINPUTS=".:"; \
export TMPDIR="$(TMPDIR)/tex-$*"; \
$(XPINC) $(DXSL)/dblatex.xsl $< | \
$(DBLATEX) --style=native \
--debug \
--type=tex \
--backend=xetex \
--xsl-user=$(DXSL)/user_param.xsl \
--xsl-user=$(DXSL)/xetex_param.xsl \
--param=draft.mode=$(DRAFTMODE) \
--param=lingua=$* \
--output=$@ - || { echo "OMG!!!!!! XXX_CHECK_XXX ... Do not worry ..."; true ; }
#######################################################################
# $ make epub # update all epub in $(TMPDIR)
#######################################################################
.PHONY: epub
epub: $(foreach LX, $(LANGALL), $(TMPDIR)/$(MANUAL).$(LX).epub)
$(TMPDIR)/$(MANUAL).%.epub: $(MANUAL).%.xml $(ENT_ALL)
@$(call check-command, xsltproc, xsltproc)
-mkdir -p $(TMPDIR)/epub-$*/
cd $(TMPDIR)/epub-$*/ ; $(XPINC) $(CURDIR)/$(DXSL)/style-epub.xsl $(CURDIR)/$<
cp -f $(DXSL)/mimetype $(TMPDIR)/epub-$*/mimetype
cp -f $(DXSL)/debian.css $(TMPDIR)/epub-$*/OEBPS/debian.css
cp -f $(DXSL)/debian-openlogo.png $(TMPDIR)/epub-$*/OEBPS/debian-openlogo.png
cd $(TMPDIR)/epub-$*/ ; zip -r $@ ./
#######################################################################
### Utility targets
#######################################################################
#######################################################################
# $ make rsync
# export build result to http://people.debian.org/~osamu/$(MANUAL)/
#######################################################################
.PHONY: rsync
rsync: all
-rm -rf $(TMPDIR)/pdf-*
-rm -rf $(TMPDIR)/tex-*
-rm -rf $(TMPDIR)/epub-*
cp -f fuzzy.log $(TMPDIR)/
rsync -avz $(TMPDIR)/ osamu@people.debian.org:public_html/$(MANUAL)/
#######################################################################
# $ make url # check duplicate URL references
#######################################################################
.PHONY: url
url: $(MANUAL).en.xml
@echo "----- Duplicate URL references (start) -----"
-sed -ne "/^<\!ENTITY/s/<\!ENTITY \([^ ]*\) .*$$/\" \1 \"/p" < $< | uniq -d | xargs -n 1 grep $< -e | grep -e "^<\!ENTITY"
@echo "----- Duplicate URL references (end) -----"
|