Rework the dist target, again
3 files changed, 18 insertions(+), 26 deletions(-)

M Makefile
M README.md
M showlabels.dtx.in
M Makefile +14 -22
@@ 5,22 5,19 @@ 
 # Making a release:
 #
 #   * check the notes in release-notes.xml are up to date
-#   * change the VERSION variable below, to remove -SNAPSHOT
 #   * commit, and tag as 'n.m.r' as appropriate
 #   * hg update to that tag
 #   * `make dist`
 #   * submit to CTAN at https://ctan.org/upload
 #   * hg update to tip,
-#     bump the version number,
-#     re-add `-SNAPSHOT back to the VERSION,
 #     and add a new release-notes block in release-notes.xml,
 #     ready for the next update
 #
 # See also the suggestions at <https://ctan.org/help/upload-pkg>.
 
-VERSION=1.9.1b1
-# RELEASEDATE comes from the repository
-DIST=showlabels-$(VERSION)
+# VERSION and RELEASEDATE comes from the repository
+# DIST is set by a recursive call from `make dist`
+DIST=XXX-call-make-dist
 
 COPYRIGHTYEARS=1999, 2001-09, 2013-21
 

          
@@ 35,7 32,11 @@ edit=sed -f version.sed
 
 all: dist
 
-dist: $(DIST).tar.gz $(DIST).zip webpage-tarball.tar
+dist: version.sed
+	$(MAKE) DIST=`echo showlabels-@VERSION@ | $(edit)` dist0
+
+# make dist0 should only be invoked by `make dist`
+dist0: $(DIST).tar.gz $(DIST).zip webpage-tarball.tar
 
 $(DIST).tar: $(DIST)/VERSION
 	rm -f $@

          
@@ 50,7 51,7 @@ dist: $(DIST).tar.gz $(DIST).zip webpage
 	cp $(DISTFILES) $(DIST)
 	$(edit) -f make-standalone.sed -e '/@RELEASENOTES@/r release-notes.html' showlabels.html >$(DIST)/showlabels.html
 	$(edit) README.md >$(DIST)/README
-	echo '@VERSIONX@' | $(edit) >$(DIST)/VERSION
+	echo '@VERSION@' | $(edit) >$(DIST)/VERSION
 
 webpage-tarball.tar: $(DIST).tar.gz $(DIST).zip $(DIST)/VERSION \
 		showlabels.html showlabels.pdf lppl.txt release-notes.html

          
@@ 96,26 97,17 @@ release-notes.tmpdtx: release-notes.xml
 
 # In version.sed, include substitutions
 #
-#   VERSION -> version from this file
-#   VERSIONX -> $(VERSION), in release versions, or $(VERSION)-mercurialid for snapshots
+#   VERSION -> release version, either {latesttag}, if {latesttagdistance} is zero,
+#              or {latesttag}+{latesttagdistance}-SNAPSHOT-{node} if not.
 #   VCSINFO -> mercurial release identifiers
 #   RELEASEDATE -> readable date
 #   RELEASEDATEN -> date in yyyy/mm/dd format required by LaTeX
 #   COPYRIGHTYEARS -> hand-maintained at the top
 version.sed: Makefile .hg
 	rm -f $@
-	if expr $(VERSION) : '.*SNAPSHOT' >/dev/null; then \
-	  { echo 's|@VERSION@|$(VERSION)|'; \
-	    echo 's|@COPYRIGHTYEARS@|$(COPYRIGHTYEARS)|'; \
-	    hg parent --template 's|@VERSIONX@|$(VERSION)-{node|short}|g\ns|@RELEASEDATE@|{date(date,"%Y %B %e")}|g\ns|@RELEASEDATEN@|{date|shortdate}|g\ns|@VCSINFO@|{node|short}, {date|rfc3339date}|\n' | sed '/DATEN/s|-|/|g' ; \
-	  } >version.sed; \
-	else \
-	  { echo 's|@VERSION@|$(VERSION)|g'; \
-	    echo 's|@VERSIONX@|$(VERSION)|g'; \
-	    echo 's|@COPYRIGHTYEARS@|$(COPYRIGHTYEARS)|'; \
-	    hg parent --template 's|@RELEASEDATE@|{date(date,"%Y %B %e")}|g\ns|@RELEASEDATEN@|{date|shortdate}|g\ns|@VCSINFO@|{node|short}, {date|rfc3339date}|\n'; \
-	  } >version.sed; \
-	fi
+	{ echo 's|@COPYRIGHTYEARS@|$(COPYRIGHTYEARS)|'; \
+	  hg parent --template 's|@VERSION@|{ifeq(latesttagdistance, 0, "{latesttag}", "{latesttag}+{latesttagdistance}-SNAPSHOT-{node|short}")}|\ns|@RELEASEDATE@|{date(date,"%Y %B %e")}|g\ns|@RELEASEDATEN@|{date(date,"%Y/%m/%d")}|g\ns|@VCSINFO@|{node|short}, {date|rfc3339date}|\n'; \
+	} >$@
 
 style.css:
 	curl -L https://nxg.me.uk/style/base.css >style.css

          
M README.md +1 -1
@@ 4,7 4,7 @@ Showlabels
 Put the names of `\labels` and other commands into the margins of a draft
 document.
 
-Version @VERSIONX@, @RELEASEDATE@;
+Version @VERSION@, @RELEASEDATE@;
 <https://purl.org/nxg/dist/showlabels>.
 
 This class option helps you keep track of all the labels in your

          
M showlabels.dtx.in +3 -3
@@ 24,8 24,8 @@ 
 
 % This is revision @VCSINFO@.
 %<+package>\NeedsTeXFormat{LaTeX2e}
-%<+package>\ProvidesPackage{showlabels}[@RELEASEDATEN@\space v@VERSIONX@]
-%<+package>\typeout{Package: `showlabels' v@VERSIONX@\space<@RELEASEDATEN@>}
+%<+package>\ProvidesPackage{showlabels}[@RELEASEDATEN@\space v@VERSION@]
+%<+package>\typeout{Package: `showlabels' v@VERSION@\space<@RELEASEDATEN@>}
 %
 %<*driver>
 \documentclass{ltxdoc}

          
@@ 64,7 64,7 @@ 
 %
 % \title{The \texttt{showlabels} package}
 % \author{Norman Gray\\|gray@nxg.name|}
-% \date{Version @VERSIONX@, @RELEASEDATE@}
+% \date{Version @VERSION@, @RELEASEDATE@}
 %
 % \maketitle
 %