Skip to content

Commit

Permalink
Ensure correct version in dist tarball
Browse files Browse the repository at this point in the history
That adds an additional dist hook that verifies that the PACKAGE_VERSION
that configure records is the same as the _current_ version reported by
`git describe`.  PACKAGE_VERSION is only updated when _autoconf_ is
run, so if you've made several commits, the version number will be out
of date.  You have to explicitly re-run autogen.sh to regenerate the
correct package version.

h/t https://stackoverflow.com/a/46222039
  • Loading branch information
dcreager committed May 9, 2020
1 parent fe4b1bc commit 7eb3eb3
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 4 deletions.
28 changes: 24 additions & 4 deletions Makefile.am
Expand Up @@ -4,13 +4,33 @@
# Please see the COPYING file in this distribution for license details.
# ------------------------------------------------------------------------------

#-------------------------------------------------------------------------------
# Dist hooks

dist-hook: dist-check-git-version dist-stamps

#-------------------------------------------------------------------------------
# .commit-stamp and .version-stamp

# These should only appear in distribution tarballs.
dist-hook:
echo $(GIT_SHA1) > $(distdir)/.commit-stamp
echo $(VERSION) > $(distdir)/.version-stamp
dist-check-git-version:
: # Verify that the version that configure.ac recorded matches the
: # current version from git tags.
@if test -n $(top_srcdir)/.version-stamp; then \
git_ver=`$(top_srcdir)/build-aux/calculate version`; \
if test "x$${git_ver}" != "x$(PACKAGE_VERSION)"; then \
echo "ERROR: PACKAGE_VERSION and 'git describe' version do not match:"; \
echo " current 'git describe' version: $${git_ver}"; \
echo " current PACKAGE_VERSION: $(PACKAGE_VERSION)"; \
echo "Update PACKAGE_VERSION by running $(top_srcdir)/autogen.sh."; \
rm -rf "$(top_srcdir)/autom4te.cache"; \
exit 1; \
fi \
fi

dist-stamps:
@: # Generate version stamps for dist tarball.
@echo $(GIT_SHA1) > $(distdir)/.commit-stamp
@echo $(VERSION) > $(distdir)/.version-stamp

#-------------------------------------------------------------------------------
# Preliminaries
Expand Down
17 changes: 17 additions & 0 deletions autogen.sh
@@ -0,0 +1,17 @@
#!/bin/sh
# ------------------------------------------------------------------------------
# Copyright © 2020, libcork authors.
# Please see the COPYING file in this distribution for license details.
# ------------------------------------------------------------------------------

set -e

cd "$(dirname "$0")"

AUTORECONF=${AUTORECONF:-autoreconf}
ACLOCAL=${ACLOCAL:-aclocal}
AUTOCONF=${AUTOCONF:-autoconf}
AUTOHEADER=${AUTOHEADER:-autoheader}
AUTOMAKE=${AUTOMAKE:-automake}

"${AUTORECONF}" --verbose --install --force -I m4

0 comments on commit 7eb3eb3

Please sign in to comment.