X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=developers-reference.git;a=blobdiff_plain;f=Makefile;h=8dac6d1d806b32a4f6e30ad22bebab60c3f933af;hp=4056d3518db9c14de8b313b12e2244cfa89d1602;hb=22cf909af0f96e48102f528c16fc5107ccde8287;hpb=03e0eabd83e3c775ffa5e811339be41965291cdf diff --git a/Makefile b/Makefile index 4056d35..8dac6d1 100644 --- a/Makefile +++ b/Makefile @@ -1,107 +1,140 @@ -# Makefile, used for the DDP manuals.sgml area +# Makefile, used for the developers-reference in DocBook XML -MANUAL := $(notdir $(shell pwd)) -PUBLISHDIR := ../../../public_html/manuals.html +# Note: This Makefile should work perfectly without the debian/ directory. -SOURCES := $(wildcard *.sgml) +SOURCES := $(wildcard *.dbk) common.ent version.ent -TARGETS := $(foreach fmt,html txt pdf,developers-reference.$(fmt)) \ - $(filter-out developers-reference.ja.pdf, \ - $(foreach langext,.ja .fr, \ - $(foreach fmt,html txt pdf,developers-reference$(langext).$(fmt)))) +FORMATS := html txt pdf +LANGS := fr ja +TARGETS := $(foreach fmt,$(FORMATS),developers-reference.$(fmt)) \ + $(foreach lng,$(LANGS), \ + $(foreach fmt,$(FORMATS), \ + $(lng)/developers-reference.$(fmt))) +# list of targets, that currently cannot build +BLACKLIST := ja/developers-reference.pdf -# programs for creating output -DEBIANDOC2HTML := debiandoc2html -d debiandoc.decl -c -DEBIANDOC2TEXT := debiandoc2text -d debiandoc.decl -DEBIANDOC2LATEX := debiandoc2latex -d debiandoc.decl - -make_directory := install -d -m 755 -install_file := install -m 644 -p +# hopefully overwritten by caller, e.g. debian/rules +VERSION=unknown +PUBDATE=unknown -MAX_TEX_RECURSION := 5 +# programs for creating output +XP=xsltproc --nonet --novalid --xinclude +XL=xmllint --nonet --noout --postvalid --xinclude +# dblatex 0.2.8 has some problems (e.g. #465221 and Japanese does +# not build) +# Alternatives: +# - docbook2pdf (seems to die on UTF-8, #431085); and +# - fop is currently in contrib, but can go to main, see #366783 +# - xmlroff (not mature enough, #182445) +DBLATEX=dblatex --style=db2latex +# The "--keep 0" should be removed as soon as the translations are ready +TRANSLATE=po4a-translate --format docbook --keep 0 + +# XSL files and parameters +# note: the URL is used as identifier, no HTTP is used! +DOCBOOK_XSL=http://docbook.sourceforge.net/release/xsl/current +# for HTML output +DBK2HTML=$(CURDIR)/html.xsl +# all in one file for text output +DBK2HTML1=$(CURDIR)/txt.xsl .PHONY: all -all: $(TARGETS) +all: $(filter-out $(BLACKLIST), $(TARGETS)) .PHONY: validate -validate: $(addsuffix .validate,$(SOURCES)) +validate: $(SOURCES) + $(XL) index.dbk + +%/validate: $(addprefix %/,$(SOURCES)) + cd $(@D) && $(XL) index.dbk -# hmmm, this rule may need to be revised/tested +# This rule controls the build and installation on the website +# Logs are here: http://www-master.debian.org/build-logs/ddp/ +.PHONY: publish publish: all [ -d $(PUBLISHDIR) ] || exit 1 - rm -f $(PUBLISHDIR)/$(MANUAL)/*.html - $(make_directory) $(PUBLISHDIR)/$(MANUAL) - $(install_file) developers-reference*.html/*.html \ - $(PUBLISHDIR)/$(MANUAL) - -developers-reference.html: developers-reference.sgml - $(DEBIANDOC2HTML) -l C $< - -developers-reference.%.html: developers-reference.%.sgml - $(DEBIANDOC2HTML) -l $* $< - -developers-reference.txt: developers-reference.sgml - $(DEBIANDOC2TEXT) -l C -O $< > $@ - -developers-reference.%.txt: developers-reference.%.sgml - $(DEBIANDOC2TEXT) -l $* -O $< > $@ - -developers-reference.tex: developers-reference.sgml - $(DEBIANDOC2LATEX) -l C -O $< > $@ - -developers-reference.%.tex: developers-reference.%.sgml - $(DEBIANDOC2LATEX) -l $* -O $< > $@ - -%.pdf: %.tex -# note that I have seen bi-stable .aux files, thus we check two levels deep - -cp -pf prior.aux pprior.aux 2>/dev/null - -cp -pf $(basename $<).aux prior.aux 2>/dev/null -# fail if we don't have pdflatex correctly installed - kpsewhich pdflatex.fmt >/dev/null -# due to a bug in debiandoc2latex2e output, this might fail - -pdflatex '\nonstopmode\input{$<}' >/dev/null # see $(@:.pdf=.log) for details - @set -e ;\ - if ! cmp $(basename $<).aux prior.aux 2>/dev/null && \ - ! cmp $(basename $<).aux pprior.aux 2>/dev/null; then \ - if expr $(MAKELEVEL) '<' $(MAX_TEX_RECURSION) >/dev/null;\ - then \ - echo "remaking $@ (take $(MAKELEVEL))" ;\ - rm -f $@ ;\ - $(MAKE) $@ ;\ - else \ - echo "E: $@ needs remaking, but we have reached max. level, $(MAX_TEX_RECURSION)" ;\ - fi \ - fi - rm -f prior.aux pprior.aux - -version.ent: debian/changelog - ./debian/rules $@ - -%.validate : % - nsgmls -wall -gues $< - touch $@ - -USERMAP := ../../ddp/CVSROOT/users -.PHONY: prepare -prepare: - @[ -f CVS/Root -a -f $(USERMAP) ] || \ - ( echo "silly rabbit, prepare is for Adam" 1>&2; exit 1 ) - cvs2cl -r --usermap $(USERMAP) - cvs ci -m "update for next release" ChangeLog + install -d -m 755 $(PUBLISHDIR)/developers-reference + rm -f $(PUBLISHDIR)/developers-reference/*.html + rm -f en && ln -sf . en + $(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;)) + ln -sf index.en.html $(PUBLISHDIR)/developers-reference/index.html + ln -sf developers-reference.en.pdf $(PUBLISHDIR)/developers-reference/developers-reference.pdf + ln -sf developers-reference.en.txt $(PUBLISHDIR)/developers-reference/developers-reference.txt + +.PHONY: developers-reference.html %/developers-reference.html +developers-reference.html: $(CURDIR)/index.html +%/developers-reference.html: $(addprefix %/,index.html) + @true + +.PRECIOUS: %/index.html +index.html: $(CURDIR)/developers-reference.html +%/index.html: $(addprefix %/,$(SOURCES)) + cd $(@D) && $(XP) $(DBK2HTML) index.dbk + +# There must be an easier way than recursive make! +.PRECIOUS: %.dbk %.ent +ifndef LINGUA +%.dbk %.ent: FORCE + $(MAKE) $@ LINGUA=`basename $(@D)` + +FORCE: +else +$(LINGUA)/%.dbk: %.dbk $(patsubst %.dbk,po4a/$(LINGUA)/%.po,%.dbk) +# "-a ?" is only possible with po4a version in Squeeze, build is broken in Lenny with it + $(TRANSLATE) -m $< -p po4a/$(@:.dbk=.po) -l $@ # -a ?po4a/$(@:.dbk=.add) + +$(LINGUA)/common.ent: common.ent + cd $(@D) && ln -sf ../$(@F) . +endif + +developers-reference.txt: $(CURDIR)/developers-reference.txt +%/developers-reference.txt: $(addprefix %/,$(SOURCES)) + $(XP) $(DBK2HTML1) $(@D)/index.dbk \ + | w3m -o display_charset=UTF-8 -cols 70 -dump -no-graph -T text/html > $@ + +developers-reference.pdf: $(CURDIR)/developers-reference.pdf +%/developers-reference.pdf: $(addprefix %/,$(SOURCES)) + TOP=`pwd` && cd $(@D) && $(DBLATEX) index.dbk \ + && mv index.dbk.pdf $(@F) + +.PHONY: pot +pot: $(patsubst %.dbk,po4a/po/%.pot,$(SOURCES)) +po4a/po/%.pot: %.dbk + po4a-gettextize --format docbook --master $< --po $@ + +ifdef LINGUA +.PHONY: updatepo +updatepo: $(patsubst %.dbk,po4a/$(LINGUA)/%.po,$(SOURCES)) +po4a/$(LINGUA)/%.po: %.dbk + po4a-updatepo --previous --format docbook --master $< --po $@ +endif + +tidypo: + for po in $(wildcard po4a/*/*.po po4a/*/*.pot); do \ + msgcat $$po > $$po.tmp && mv $$po.tmp $$po; \ + done + +checkpo: + @for po in $(wildcard po4a/*/*.po po4a/*/*.pot); do \ + echo $$po; \ + msgfmt --check --verbose $$po; \ + done + +%/version.ent: + echo '' > $@ + echo '' >> $@ .PHONY: clean clean: - rm -rf developers-reference*.html - rm -f developers-reference*.txt developers-reference*.pdf \ - developers-reference*.ps developers-reference*.lout* lout.li \ - developers-reference*.sasp* developers-reference*.tex \ - developers-reference*.aux developers-reference*.toc \ - developers-reference*.idx developers-reference*.log \ - developers-reference*.out developers-reference*.dvi + rm -f *.fo *.html *.pdf *.txt + for L in $(LANGS); do rm -rf `basename ./"$$L"/`; done rm -f version.ent - rm -f `find . -name "*~"` - rm -f *.validate + rm -f `find . -name "*~" -o -name "*.bak"` + rm -f *~ *.bak .#* core -developers-reference$(SRCEXT).sgml: version.ent common.ent +.PHONY: distclean +distclean: clean + rm -f *.rej *.orig -html: $(MANUAL).html +# if rule bomb out, delete the target +.DELETE_ON_ERROR: