From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-949168-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by finch.gentoo.org (Postfix) with ESMTPS id C1FBA139694
	for <garchives@archives.gentoo.org>; Thu, 11 May 2017 04:57:00 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id BDA8EE0E07;
	Thu, 11 May 2017 04:56:34 +0000 (UTC)
Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id 8C7A3E0E07
	for <gentoo-commits@lists.gentoo.org>; Thu, 11 May 2017 04:56:29 +0000 (UTC)
Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id EFBD6341659
	for <gentoo-commits@lists.gentoo.org>; Thu, 11 May 2017 04:56:27 +0000 (UTC)
Received: from localhost.localdomain (localhost [IPv6:::1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id 5D3F37441
	for <gentoo-commits@lists.gentoo.org>; Thu, 11 May 2017 04:56:26 +0000 (UTC)
From: "Ulrich Müller" <ulm@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: 8bit
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Ulrich Müller" <ulm@gentoo.org>
Message-ID: <1494268781.9ba8db2d110e28ea85783c8061652ba27336d565.ulm@gentoo>
Subject: [gentoo-commits] proj/pms:master commit in: /
X-VCS-Repository: proj/pms
X-VCS-Files: Makefile
X-VCS-Directories: /
X-VCS-Committer: ulm
X-VCS-Committer-Name: Ulrich Müller
X-VCS-Revision: 9ba8db2d110e28ea85783c8061652ba27336d565
X-VCS-Branch: master
Date: Thu, 11 May 2017 04:56:26 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
X-Archives-Salt: 8119c9ed-5b47-461d-9963-191b66296227
X-Archives-Hash: 56cc60930262c03ac7f94c96d019e5e1

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: