commit: 9ba8db2d110e28ea85783c8061652ba27336d565 Author: Ulrich Müller <ulm <AT> gentoo <DOT> org> AuthorDate: Mon May 8 18:39:41 2017 +0000 Commit: Ulrich Müller <ulm <AT> gentoo <DOT> org> CommitDate: Mon May 8 18:39:41 2017 +0000 URL: https://gitweb.gentoo.org/proj/pms.git/commit/?id=9ba8db2d
Makefile: Major rewrite. Move pms.pdf and eapi-cheatsheet into one rule, since they cannot be built independently. Saner lists of prerequisites. Loop over latex and mk4ht until their output converges. Remove aux-clean target. Add .DELETE_ON_ERROR in order to delete corrupted or incomplete target files. Use all-caps for .PHONY target or it will have no effect. Makefile | 91 ++++++++++++++++++++++++++++++++++++---------------------------- 1 file changed, 52 insertions(+), 39 deletions(-) diff --git a/Makefile b/Makefile index bc1ee51..53ccaa7 100644 --- a/Makefile +++ b/Makefile @@ -1,31 +1,37 @@ -all : pms.pdf -html : pms.html +LATEXFILES := $(filter-out vc.tex,$(wildcard *.tex)) pms.cls +SOURCES = $(LATEXFILES) pms.bib vc vc-git.awk Makefile -clean : - rm -f *~ *.pdf *.dvi *.log *.aux *.bbl *.blg *.toc *.lol *.loa *.lox \ - *.lot *.out *.html *.css *.png *.4ct *.4tc *.idv *.lg *.tmp *.xref +# latex chokes on aux files produced by tex4ht, so remove them +aux-clean = if grep -q rEfLiNK pms.aux 2>/dev/null; then rm -f *.aux; fi -maintainer-clean: clean - rm -f vc.tex +all: pms.pdf -aux-clean: - @# latex chokes on aux files produced by tex4ht, so remove them - if grep -q rEfLiNK pms.aux 2>/dev/null; then rm -f *.aux; fi +html: pms.html -LATEXFILES := $(filter-out vc.tex,$(wildcard *.tex)) pms.cls +pms.pdf: $(LATEXFILES) pms.bbl vc.tex + $(aux-clean) + set -e; \ + while true; do \ + pdflatex eapi-cheatsheet; \ + pdflatex pms; \ + grep -q 'Warning.*Rerun' eapi-cheatsheet.log pms.log || break; \ + done -pms.pdf: $(LATEXFILES) pms.bbl vc.tex eapi-cheatsheet.pdf aux-clean - pdflatex pms - pdflatex pms - pdflatex eapi-cheatsheet - pdflatex pms +pms.dvi: $(LATEXFILES) pms.bbl vc.tex + $(aux-clean) + set -e; \ + while true; do \ + latex pms; \ + grep -q 'Warning.*Rerun' pms.log || break; \ + done pms.html: $(LATEXFILES) pms.bbl vc.tex - @# need to do it twice to make the big env var table work ... - @# ... and a third time for the eapi features table - mk4ht xhlatex pms xhtml,fn-in - mk4ht xhlatex pms xhtml,fn-in - mk4ht xhlatex pms xhtml,fn-in + set -e; sum=''; \ + while true; do \ + mk4ht xhlatex pms xhtml,fn-in; \ + oldsum=$${sum}; sum=$$(cksum $@); \ + test "$${sum}" != "$${oldsum}" || break; \ + done @# some www servers ignore meta tags, resulting in a wrong charset. @# therefore recode the very few non-ascii characters recode -d l1..h3 $@ @@ -37,36 +43,43 @@ pms.html: $(LATEXFILES) pms.bbl vc.tex @# remove redundant span elements LC_ALL=C sed -i -e ':x;/<span\(\s\+[^>]*\)\?$$/{N;bx;};:y;s/\(<span\s\+[^>]*>\)\([^<]*\)<\/span>\1/\1\2/;ty' $@ -pms.bbl: pms.bib pms.tex vc.tex eapi-cheatsheet.pdf +pms.bbl: $(LATEXFILES) pms.bib + $(aux-clean) latex pms bibtex pms -eapi-cheatsheet.pdf: vc.tex aux-clean - pdflatex eapi-cheatsheet - -eapi-cheatsheet-nocombine.pdf: vc.tex aux-clean - @# cheat sheet with separate pages, for proofreading - pdflatex -jobname eapi-cheatsheet-nocombine \ - '\PassOptionsToClass{nocombine}{leaflet}\input{eapi-cheatsheet.tex}' - -vc.tex: $(LATEXFILES) vc vc-git.awk +vc.tex: $(SOURCES) /bin/sh ./vc -pms.dvi: $(LATEXFILES) pms.bbl vc.tex aux-clean - latex pms - latex pms - latex pms +eapi-cheatsheet.pdf: pms.pdf + @# nothing to do here, since this is also part of the main document -dist: $(LATEXFILES) pms.bib vc vc-git.awk vc.tex Makefile +eapi-cheatsheet-nocombine.pdf: pms.pdf + @# cheat sheet with separate pages, for proofreading + set -e; \ + while true; do \ + pdflatex -jobname eapi-cheatsheet-nocombine \ + '\PassOptionsToClass{nocombine}{leaflet}\input{eapi-cheatsheet}'; \ + grep -q 'Warning.*Rerun' eapi-cheatsheet-nocombine.log || break; \ + done + +dist: $(SOURCES) vc.tex @if test -z $(PV); then \ echo "Usage: $(MAKE) $@ PV=<version>"; false; \ fi tar -cJf pms-$(PV).tar.xz --transform='s%^%pms-$(PV)/%' $^ -upload: +upload: pms.pdf pms.html scp pms.pdf eapi-cheatsheet.pdf pms*.html pms.css \ dev.gentoo.org:public_html/pms/head/ -.default: all +clean: + rm -f *~ *.pdf *.dvi *.log *.aux *.bbl *.blg *.toc *.lol *.loa *.lox \ + *.lot *.out *.html *.css *.png *.4ct *.4tc *.idv *.lg *.tmp *.xref + +maintainer-clean: clean + rm -f vc.tex + +.PHONY: all html dist upload clean maintainer-clean -.phony: clean maintainer-clean aux-clean dist upload +.DELETE_ON_ERROR: