| 1 |
##############################################################################
|
| 2 |
# Makefile for the Debian New Maintainers' Guide
|
| 3 |
##############################################################################
|
| 4 |
|
| 5 |
# Note: This Makefile should work perfectly without the debian/ directory.
|
| 6 |
|
| 7 |
# Required packages for building documentation source
|
| 8 |
# basic: xsltproc, docbook-xsl (These are dependency of dblatex)
|
| 9 |
# i18n: po4a
|
| 10 |
# plain text conv.: w3m
|
| 11 |
# pdf via pdflatex: dblatex, ghostscript, lmodern, texlive-lang-*
|
| 12 |
# pdf via xelatex: texlive-xelatex, (ttf-font-packages)
|
| 13 |
|
| 14 |
##############################################################################
|
| 15 |
# Package specific customization
|
| 16 |
##############################################################################
|
| 17 |
# package name
|
| 18 |
MANUAL := maint-guide
|
| 19 |
# common inclusion entity files (excluding version)
|
| 20 |
COMMON_ENT := common.ent
|
| 21 |
# format to be built
|
| 22 |
FORMATS := html txt pdf
|
| 23 |
##############################################################################
|
| 24 |
# PDF build tool customization for each lunguage
|
| 25 |
##############################################################################
|
| 26 |
# languages supported by direct DocBook files (always: en)
|
| 27 |
LANGS_EN := en
|
| 28 |
# languages supported by translation PO files
|
| 29 |
LANGS_PO := ca de es fr it ja ru de zh-cn zh-tw
|
| 30 |
# ca: 99%
|
| 31 |
# de: 24%
|
| 32 |
# es: 97%
|
| 33 |
# fr: 100%
|
| 34 |
# it: 100%
|
| 35 |
# ja: 100%
|
| 36 |
# ru: 100%
|
| 37 |
# zh-cn: 33%
|
| 38 |
# zh-tw:28%
|
| 39 |
#
|
| 40 |
# dblatex is used as the default PDF build tool
|
| 41 |
# No PDF build for these lunguages (in case of error, use this as work around)
|
| 42 |
LANGS_NOPDF :=
|
| 43 |
# all languages to build
|
| 44 |
LANGS := $(LANGS_EN) $(LANGS_PO)
|
| 45 |
# local script file directory
|
| 46 |
SCRIPT := script
|
| 47 |
# translation contents directory such as PO file
|
| 48 |
PO4A := po4a
|
| 49 |
# The translation threshold percent should be 80, if translation is completed.
|
| 50 |
THRESHOLD := 0
|
| 51 |
# XSLT (Extensible Stylesheet Language Transformations) file directory
|
| 52 |
XSLT := xslt
|
| 53 |
# manual publish directory
|
| 54 |
ifeq ($(PUBLISHDIR),)
|
| 55 |
# local test build
|
| 56 |
MANUALDIR := $(CURDIR)/html
|
| 57 |
else
|
| 58 |
# www-master.debian.org build script.
|
| 59 |
MANUALDIR := $(abspath $(PUBLISHDIR)/$(MANUAL))
|
| 60 |
endif
|
| 61 |
XTMPDIR := $(CURDIR)/tmp
|
| 62 |
# CSS (Cascading Style Sheets) file
|
| 63 |
CSS := $(MANUAL).css
|
| 64 |
# Image files
|
| 65 |
IMAGES := caution.png home.gif important.png next.gif note.png prev.gif tip.png up.gif warning.png draft.png
|
| 66 |
IMAGESSRC := /usr/share/xml/docbook/stylesheet/nwalsh/images
|
| 67 |
IMAGESDIR := $(MANUALDIR)/images
|
| 68 |
|
| 69 |
# install
|
| 70 |
install_file := install -p -m 664
|
| 71 |
install_dir := install -d -m 2775
|
| 72 |
|
| 73 |
# Change $(DRAFTMODE) from "yes" to "maybe" when this $(MANUAL) should go into
|
| 74 |
# production mode
|
| 75 |
#DRAFTMODE := yes
|
| 76 |
DRAFTMODE := maybe
|
| 77 |
export DRAFTMODE
|
| 78 |
##############################################################################
|
| 79 |
# PO update
|
| 80 |
##############################################################################
|
| 81 |
# Usually, POMODE = update|static
|
| 82 |
POMODE := static
|
| 83 |
|
| 84 |
##############################################################################
|
| 85 |
# build tool customization for debug etc.
|
| 86 |
##############################################################################
|
| 87 |
XP := xsltproc --nonet --novalid --xinclude
|
| 88 |
XL := xmllint --nonet --noout --postvalid --xinclude
|
| 89 |
# Set $(DEBUG) to activate debug mode
|
| 90 |
ifeq ($(DEBUG),)
|
| 91 |
DBLATEX := dblatex
|
| 92 |
else
|
| 93 |
DBLATEX := dblatex --verbose --dump --debug
|
| 94 |
endif
|
| 95 |
##############################################################################
|
| 96 |
# Basic phony targets
|
| 97 |
##############################################################################
|
| 98 |
.PHONY: all build build-indep
|
| 99 |
all: build
|
| 100 |
|
| 101 |
build: build-indep
|
| 102 |
|
| 103 |
build-indep: $(foreach lng,$(LANGS), $(foreach fmt, $(filter-out html, $(FORMATS)), $(MANUAL).$(lng).$(fmt))) \
|
| 104 |
$(foreach lng,$(LANGS), $(foreach fmt, $(filter html, $(FORMATS)), index.$(lng).html))
|
| 105 |
|
| 106 |
##############################################################################
|
| 107 |
# Utility phony targets
|
| 108 |
##############################################################################
|
| 109 |
.PHONY: dbk dbk-orig txt html pdf po pot
|
| 110 |
txt: $(foreach lng,$(LANGS), $(MANUAL).$(lng).txt)
|
| 111 |
html: $(foreach lng,$(LANGS), index.$(lng).html)
|
| 112 |
pdf: $(foreach lng,$(LANGS), $(MANUAL).$(lng).pdf)
|
| 113 |
po:
|
| 114 |
touch $(MANUAL).en.dbk
|
| 115 |
$(MAKE) $(foreach lng, $(LANGS_PO), $(PO4A)/$(MANUAL).$(lng).po) POMODE=update
|
| 116 |
pot: $(PO4A)/$(MANUAL).pot
|
| 117 |
dbk: $(foreach lng,$(LANGS_PO), $(MANUAL).$(lng).dbk)
|
| 118 |
|
| 119 |
##############################################################################
|
| 120 |
# Conditional branching variable
|
| 121 |
##############################################################################
|
| 122 |
# Conditional branching of build process is implimented by recursively calling
|
| 123 |
# this Makefile. The first level executon of this Makefile calls $(MAKE) with
|
| 124 |
# the controlling variable $(LINGUA). The second level executon of this
|
| 125 |
# Makefile uses $(LINGUA) as conditional branching. Initial value of $(LINGUA)
|
| 126 |
# is "".
|
| 127 |
LINGUA :=
|
| 128 |
|
| 129 |
##############################################################################
|
| 130 |
# Version file preparations
|
| 131 |
##############################################################################
|
| 132 |
# version from debian/changelog
|
| 133 |
ifeq ($(PUBLISHDIR),)
|
| 134 |
# if not for www-master (e.g., package building)
|
| 135 |
version.ent:
|
| 136 |
echo "<!ENTITY docisodate \"$(shell LC_ALL=C date -u +'%F %T %Z')\">" > version.ent
|
| 137 |
[ -r debian/changelog ] && \
|
| 138 |
echo "<!ENTITY docversion \"$(shell LC_ALL=C dpkg-parsechangelog | grep '^Version: ' | sed 's/^Version: *//')\">" >> version.ent ||\
|
| 139 |
echo "<!ENTITY docversion \"unknown version\">" >> version.ent
|
| 140 |
else
|
| 141 |
# if for www-master directly building from subversion source
|
| 142 |
version.ent:
|
| 143 |
echo "<!ENTITY docisodate \"$(shell LC_ALL=C date -u +'%F %T %Z')\">" > version.ent
|
| 144 |
[ -r debian/changelog ] && \
|
| 145 |
echo "<!ENTITY docversion \"$(shell LC_ALL=C dpkg-parsechangelog | grep '^Version: ' | sed 's/^Version: *//')-svn\">" >> version.ent ||\
|
| 146 |
echo "<!ENTITY docversion \"unknown version\">" >> version.ent
|
| 147 |
endif
|
| 148 |
##############################################################################
|
| 149 |
# DocBook XML source file preparations
|
| 150 |
##############################################################################
|
| 151 |
$(MANUAL).en.dbk:
|
| 152 |
# This is source
|
| 153 |
@true
|
| 154 |
|
| 155 |
# Generate base localized DocBook XML files for all non-"en"
|
| 156 |
# This does not depend on $(PO4A)/$(MANUAL).%.po intentionally
|
| 157 |
# to aviod automatic update of $(PO4A)/$(MANUAL).%.po.
|
| 158 |
$(MANUAL).%.dbk: $(MANUAL).en.dbk $(PO4A)/$(MANUAL).%.ent $(PO4A)/$(MANUAL).%.po
|
| 159 |
po4a-translate --format docbook --keep $(THRESHOLD) --master-charset UTF-8 \
|
| 160 |
--master $< --po $(PO4A)/$(MANUAL).$*.po --localized $@ ;\
|
| 161 |
sed -i -e 's/$(PO4A)\/$(MANUAL)\.en\.ent/$(PO4A)\/$(MANUAL).$*.ent/' $@ ;\
|
| 162 |
|
| 163 |
##############################################################################
|
| 164 |
# DocBook PO source file preparations
|
| 165 |
##############################################################################
|
| 166 |
ifeq ($(POMODE),update)
|
| 167 |
# Always update localized PO files while making PO template(pot) as needed
|
| 168 |
# .PHONY as follows does not work nicely with %, thus FORCE is used here.
|
| 169 |
#.PHONY: $(foreach lng, $(LANGS_PO), $(PO4A)/$(MANUAL).$(lng).po)
|
| 170 |
$(PO4A)/$(MANUAL).%.po: FORCE
|
| 171 |
$(MAKE) $(PO4A)/$(MANUAL).pot
|
| 172 |
msgmerge --update --previous $@ $(PO4A)/$(MANUAL).pot
|
| 173 |
else
|
| 174 |
|
| 175 |
$(PO4A)/$(MANUAL).%.po: FORCE
|
| 176 |
: # do nothing
|
| 177 |
endif
|
| 178 |
|
| 179 |
# Generate PO template(pot) file from English DocBook XML file
|
| 180 |
# make sure no location line for easier merge.
|
| 181 |
$(PO4A)/$(MANUAL).pot: $(MANUAL).en.dbk
|
| 182 |
po4a-gettextize --format docbook --master-charset UTF-8 --master $< |\
|
| 183 |
msgcat --no-location - > $@
|
| 184 |
|
| 185 |
##############################################################################
|
| 186 |
# Plain text building
|
| 187 |
##############################################################################
|
| 188 |
# Generate formatted output in single page plain text
|
| 189 |
# txt.xsl provide work around for hidden URL links by appending them explicitly.
|
| 190 |
$(MANUAL).%.txt: $(MANUAL).%.dbk $(COMMON_ENT)
|
| 191 |
[ -e version.ent ] || $(MAKE) version.ent
|
| 192 |
@test -n "`which w3m`" || { echo "E: w3m not found. Please install the w3m package." ; false ; }
|
| 193 |
$(XP) $(XSLT)/txt.xsl $< |\
|
| 194 |
LC_ALL=C.UTF-8 w3m -o display_charset=UTF-8 -cols 70 -dump -no-graph -T text/html > $@
|
| 195 |
|
| 196 |
##############################################################################
|
| 197 |
# HTML text building
|
| 198 |
##############################################################################
|
| 199 |
# Generate formatted output in multi-page html text
|
| 200 |
index.%.html: $(MANUAL).%.dbk $(COMMON_ENT)
|
| 201 |
[ -e version.ent ] || $(MAKE) version.ent
|
| 202 |
$(XP) --stringparam draft.mode $(DRAFTMODE) \
|
| 203 |
--stringparam root.filename index \
|
| 204 |
--stringparam html.ext .$*.html \
|
| 205 |
--stringparam html.stylesheet $(MANUAL).css \
|
| 206 |
$(XSLT)/html.xsl $<
|
| 207 |
|
| 208 |
##############################################################################
|
| 209 |
# PDF building (conditional)
|
| 210 |
##############################################################################
|
| 211 |
|
| 212 |
ifeq ($(LINGUA),)
|
| 213 |
# if $(LINGUA) is "" (unset == inital call)
|
| 214 |
|
| 215 |
$(MANUAL).%.pdf: $(MANUAL).%.dbk $(COMMON_ENT)
|
| 216 |
[ -e version.ent ] || $(MAKE) version.ent
|
| 217 |
# This calls itself while setting LINGUA (conditional trick) for $@
|
| 218 |
make "LINGUA=$*" $@
|
| 219 |
|
| 220 |
$(MANUAL).%.tex: $(MANUAL).%.dbk $(COMMON_ENT)
|
| 221 |
[ -e version.ent ] || $(MAKE) version.ent
|
| 222 |
# This calls itself while setting LINGUA (conditional trick) for $@
|
| 223 |
make "LINGUA=$*" $@
|
| 224 |
|
| 225 |
else ifeq ($(filter-out $(LANGS_NOPDF),$(LINGUA)),)
|
| 226 |
# if $(LINGUA) belongs to $(LANGS_NOPDF)
|
| 227 |
|
| 228 |
$(MANUAL).$(LINGUA).pdf: $(MANUAL).$(LINGUA).dbk $(COMMON_ENT)
|
| 229 |
echo "PDF building for $(LINGUA) currently disabled." > $@
|
| 230 |
|
| 231 |
else
|
| 232 |
# build with xelatex backend
|
| 233 |
|
| 234 |
$(MANUAL).$(LINGUA).pdf: $(MANUAL).$(LINGUA).dbk $(COMMON_ENT)
|
| 235 |
@test -n "`which $(DBLATEX)`" || { echo "E: dblatex not found. Please install the dblatex package." ; false ; }
|
| 236 |
@mkdir -p $(XTMPDIR)
|
| 237 |
export TMPDIR=$(XTMPDIR) ; \
|
| 238 |
export TEXINPUTS=".:" ; \
|
| 239 |
$(XP) $(XSLT)/dblatex.xsl $< | \
|
| 240 |
$(DBLATEX) --style=db2latex \
|
| 241 |
--backend=xetex \
|
| 242 |
--xsl-user=$(XSLT)/user_param.xsl \
|
| 243 |
--xsl-user=$(XSLT)/xetex_param.xsl \
|
| 244 |
--param=draft.mode=$(DRAFTMODE) \
|
| 245 |
--param=lingua=$(LINGUA) \
|
| 246 |
--output=$@ -
|
| 247 |
|
| 248 |
$(MANUAL).$(LINGUA).tex: $(MANUAL).$(LINGUA).dbk $(COMMON_ENT)
|
| 249 |
@test -n "`which $(DBLATEX)`" || { echo "E: dblatex not found. Please install the dblatex package." ; false ; }
|
| 250 |
@mkdir -p $(XTMPDIR)
|
| 251 |
export TMPDIR=$(XTMPDIR) ; \
|
| 252 |
export TEXINPUTS=".:"; \
|
| 253 |
$(XP) $(XSLT)/dblatex.xsl $< | \
|
| 254 |
$(DBLATEX) --style=db2latex \
|
| 255 |
--type=tex \
|
| 256 |
--backend=xetex \
|
| 257 |
--xsl-user=$(XSLT)/user_param.xsl \
|
| 258 |
--xsl-user=$(XSLT)/xetex_param.xsl \
|
| 259 |
--param=draft.mode=$(DRAFTMODE) \
|
| 260 |
--param=lingua=$(LINGUA) \
|
| 261 |
--output=$@ -
|
| 262 |
|
| 263 |
endif
|
| 264 |
|
| 265 |
##############################################################################
|
| 266 |
# This rule controls the build and installation on the website
|
| 267 |
# Logs are here: http://www-master.debian.org/build-logs/ddp/
|
| 268 |
# For web page building (publish)
|
| 269 |
# this can and will be overriden by a higher level makefile
|
| 270 |
##############################################################################
|
| 271 |
.PHONY: publish
|
| 272 |
publish:
|
| 273 |
# next lines are for transition
|
| 274 |
-$(MAKE) clean
|
| 275 |
# real publish target
|
| 276 |
-rm -f version.ent
|
| 277 |
$(MAKE) version.ent
|
| 278 |
$(MAKE) html txt pdf
|
| 279 |
[ -d $(IMAGESDIR) ] || $(install_dir) $(IMAGESDIR)
|
| 280 |
$(install_file) *.html $(MANUALDIR)
|
| 281 |
$(install_file) $(MANUAL).*.txt $(MANUALDIR)
|
| 282 |
$(install_file) $(MANUAL).*.pdf $(MANUALDIR)
|
| 283 |
$(install_file) $(CSS) $(MANUALDIR)
|
| 284 |
echo "AddCharset UTF-8 .txt" > $(MANUALDIR)/.htaccess
|
| 285 |
$(install_file) $(addprefix $(IMAGESSRC)/, $(IMAGES)) $(IMAGESDIR)
|
| 286 |
|
| 287 |
##############################################################################
|
| 288 |
# Special utility targets used only by the maintainer
|
| 289 |
##############################################################################
|
| 290 |
.PHONY: tw
|
| 291 |
# Translate from zh-cn to zh-tw (semi-automatic)
|
| 292 |
tw:
|
| 293 |
msgcat --no-wrap $(PO4A)/$(MANUAL).zh-cn.po | opencc | sed -f $(BIN)/cn2tw.sed | msgcat - > $(PO4A)/$(MANUAL).zh-tw.po
|
| 294 |
|
| 295 |
# phony targets for PO maintainances
|
| 296 |
.PHONY: tidypo
|
| 297 |
tidypo:
|
| 298 |
for f in $(LANGS_PO); do msgcat --no-location $(PO4A)/$(MANUAL).$$f.po | sponge $(PO4A)/$(MANUAL).$$f.po ; done
|
| 299 |
msgcat --no-location $(PO4A)/$(MANUAL).pot | sponge $(PO4A)/$(MANUAL).pot
|
| 300 |
|
| 301 |
##############################################################################
|
| 302 |
# Special utility targets used by the maintainer and translators
|
| 303 |
##############################################################################
|
| 304 |
.PHONY: checkpo
|
| 305 |
checkpo:
|
| 306 |
for f in $(LANGS_PO); do msgfmt --check --verbose $(PO4A)/$(MANUAL).$$f.po | sponge $(PO4A)/$(MANUAL).$$f.po; done
|
| 307 |
msgfmt --check --verbose $(PO4A)/$(MANUAL).pot | sponge $(PO4A)/$(MANUAL).pot
|
| 308 |
|
| 309 |
.PHONY: validate
|
| 310 |
validate: $(foreach lng,$(LANGS_PO),$(MANUAL).$(lng).dbk) $(COMMON_ENT)
|
| 311 |
for f in $(LANGS_PO); do $(XL) $(MANUAL).$$f.dbk; done
|
| 312 |
|
| 313 |
##############################################################################
|
| 314 |
# Basic utility targets for clean
|
| 315 |
##############################################################################
|
| 316 |
.PHONY: clean distclean prep
|
| 317 |
clean:
|
| 318 |
rm -f version.ent
|
| 319 |
rm -rf $(MANUALDIR)
|
| 320 |
rm -rf $(XTMPDIR)
|
| 321 |
rm -f $(foreach lng, $(LANGS_PO), $(MANUAL).$(lng).dbk)
|
| 322 |
-rm -rf *.fo *.pdf *.txt *.html *.rej
|
| 323 |
rm -f *~ *.bak .#*
|
| 324 |
rm -f $(PO4A)/*.mo $(PO4A)/*~ $(PO4A)/*.bak
|
| 325 |
rm -f *.cb *.cb2 *.glo *.idx *.log *.out *.tex *.toc *.aux
|
| 326 |
|
| 327 |
distclean: clean
|
| 328 |
|
| 329 |
prep:
|
| 330 |
debian/rules prep
|
| 331 |
|
| 332 |
# if rule bomb out, delete the target
|
| 333 |
#.DELETE_ON_ERROR:
|
| 334 |
|
| 335 |
FORCE:
|
| 336 |
|