]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Make inter-release --version output more useful.
authorJim Meyering <meyering@redhat.com>
Mon, 22 Oct 2007 17:54:52 +0000 (19:54 +0200)
committerJim Meyering <meyering@redhat.com>
Sun, 28 Oct 2007 14:29:01 +0000 (15:29 +0100)
Now, each unofficial build has a version "number" like 2.61a-19-58dd,
which indicates that it is built using the 19th change set
(in _some_ repository) following the "v2.61a" tag, and that 58dd
is a prefix of the commit SHA1.
* build-aux/git-version-gen: New file.
* configure.ac: Run it to set the version.
(AM_INIT_AUTOMAKE): Don't check NEWS here.
* Makefile.am (dist-hook): Arrange so that .version appears only
in distribution tarballs, never in a checked-out repository.
* .gitignore: Add .version here, too.  Just in case.
* tests/Makefile.am ($(srcdir)/package.m4): Depend on Makefile,
not configure.ac, now that the version number changes automatically.

Ensure that $(VERSION) is up to date for dist-related targets.
* GNUmakefile: Arrange to rerun autoconf, if the version reported by
git-version-gen doesn't match $(VERSION), but only for dist targets.

.gitignore
ChangeLog
GNUmakefile
Makefile.am
README-hacking
build-aux/git-version-gen [new file with mode: 0755]
configure.ac
tests/Makefile.am

index 92162b43c5852a5862f4f2744cad68d122372384..66c7aae3e2f81a713db5b325e33aa1eebc6ae4bc 100644 (file)
@@ -1,6 +1,7 @@
 *.log
 *~
 .#*
+.version
 CVS
 Makefile
 Makefile.in
index 18c9fe4f2b8d46b0db12ad8ae504903e2b79efb3..96547a8c8c67bc1ff72ee030e74e093b2a2f30ad 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2007-10-28  Jim Meyering  <meyering@redhat.com>
+
+       Make inter-release --version output more useful.
+
+       Now, each unofficial build has a version "number" like 2.61a-19-58dd,
+       which indicates that it is built using the 19th change set
+       (in _some_ repository) following the "v2.61a" tag, and that 58dd
+       is a prefix of the commit SHA1.
+       * build-aux/git-version-gen: New file.
+       * configure.ac: Run it to set the version.
+       (AM_INIT_AUTOMAKE): Don't check NEWS here.
+       * Makefile.am (dist-hook): Arrange so that .version appears only
+       in distribution tarballs, never in a checked-out repository.
+       * .gitignore: Add .version here, too.  Just in case.
+       * tests/Makefile.am ($(srcdir)/package.m4): Depend on Makefile,
+       not configure.ac, now that the version number changes automatically.
+
+       Ensure that $(VERSION) is up to date for dist-related targets.
+       * GNUmakefile: Arrange to rerun autoconf, if the version reported by
+       git-version-gen doesn't match $(VERSION), but only for dist targets.
+
 2007-10-27  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
 
        Fix `Deep Package' failure with a configure script early in PATH
index 7a1b0d2b2fe43de18ec94fee6929ec863c1577c2..30fdcc42a6bb14732f74427566e8dc636cdfb803 100644 (file)
@@ -39,6 +39,20 @@ ifeq ($(have-Makefile),yes)
 export TAR_OPTIONS = --owner=0 --group=0 --numeric-owner
 
 include Makefile
+
+# Ensure that $(VERSION) is up to date for dist-related targets, but not
+# for others: rerunning autoconf and recompiling everything isn't cheap.
+ifeq (0,$(MAKELEVEL))
+  _is-dist-target = $(filter dist% alpha beta major,$(MAKECMDGOALS))
+  ifneq (,$(_is-dist-target))
+    _curr-ver := $(shell build-aux/git-version-gen .version)
+    ifneq ($(_curr-ver),$(VERSION))
+      $(info INFO: rerunning autoconf for new version string: $(_curr-ver))
+      dummy := $(shell rm -rf autom4te.cache; $(AUTOCONF))
+    endif
+  endif
+endif
+
 include $(srcdir)/Makefile.cfg
 include $(srcdir)/Makefile.maint
 
index 9c01c5c85e6ceb7b3da54b65ae01bb77c9059c9c..a74088bca7e3937fa2e36c11b11468675e71e92b 100644 (file)
@@ -86,3 +86,8 @@ autom4te-update:
        for file in $(autom4te_files); do \
          $(move_if_change) Fetchdir/$$file $(srcdir)/lib/$$file || exit; \
        done
+
+# Arrange so that .version appears only in distribution tarballs,
+# never in a checked-out repository.
+dist-hook:
+       echo $(VERSION) > $(distdir)/.version
index 0f0aa2950fd7e13a8de68275753380806ea31a4b..cbf275457ebc06d59a275d08cbe11ae902017e5c 100644 (file)
@@ -29,6 +29,7 @@ You can get a copy of the source repository like this:
 
 The next step is to generate files like configure and Makefile.in:
 
+       $ cd autoconf
        $ aclocal -I m4
        $ automake
        $ autoconf
diff --git a/build-aux/git-version-gen b/build-aux/git-version-gen
new file mode 100755 (executable)
index 0000000..812ffb9
--- /dev/null
@@ -0,0 +1,65 @@
+#!/bin/sh
+# Print a version string.
+# This script is derived from GIT-VERSION-GEN from GIT: http://git.or.cz/.
+# It may be run two ways:
+# - from a git repository in which the git-describe command below
+#   produces useful output (thus requiring at least one signed tag)
+# - from a non-git-repo directory containing a .version file, which
+#   presumes this script is invoked like "./git-version-gen .version".
+
+case $# in
+    1) ;;
+    *) echo 1>&2 "Usage: $0 \$srcdir/.version"; exit 1;;
+esac
+
+tarball_version_file=$1
+nl='
+'
+
+# First see if there is a tarball-only version file.
+# then try git-describe, then default.
+if test -f $tarball_version_file
+then
+    v=`cat $tarball_version_file` || exit 1
+    case $v in
+       *$nl*) v= ;; # reject multi-line output
+       [0-9]*) ;;
+       *) v= ;;
+    esac
+    test -z "$v" \
+       && echo "$0: WARNING: $tarball_version_file seems to be damaged" 1>&2
+fi
+
+if test -n "$v"
+then
+    : # use $v
+elif test -d .git \
+    && v=`git describe --abbrev=4 HEAD 2>/dev/null` \
+    && case $v in
+        # FIXME: remove this after v6.10.
+        COREUTILS-[0-9]*) v=`echo "$v" | sed 's/^COREUTILS-//;s/_/./g'` ;;
+        v[0-9]*) ;;
+        *) (exit 1) ;;
+       esac
+then
+    # Remove the "g" in git-describe's output string.
+    v=`echo "$v" | sed 's/\(.*\)-g/\1-/'`;
+else
+    v=UNKNOWN
+fi
+
+v=`echo "$v" |sed 's/^v//'`
+
+git-status > /dev/null 2>&1
+dirty=`sh -c 'git diff-index --name-only HEAD' 2>/dev/null` || dirty=
+case "$dirty" in
+    '') ;;
+    *) # Append the suffix only if there isn't one already.
+       case $v in
+         *-dirty) ;;
+         *) v="$v-dirty" ;;
+       esac ;;
+esac
+
+# Omit the trailing newline, so that m4_esyscmd can use the result directly.
+echo "$v" | tr -d '\012'
index 1a32ea329c7428a4cab5764654fbb29043411b9e..4f9a71eb7b40848bb466cbf03db2a228a39464d1 100644 (file)
 # We need AC_CONFIG_TESTDIR.
 AC_PREREQ([2.59])
 
-AC_INIT([GNU Autoconf], [2.61b], [bug-autoconf@gnu.org])
+AC_INIT([GNU Autoconf], m4_esyscmd([build-aux/git-version-gen .version]),
+       [bug-autoconf@gnu.org])
 AC_SUBST([PACKAGE_NAME])dnl
 AC_CONFIG_SRCDIR([ChangeLog])
 
 AC_CONFIG_AUX_DIR([build-aux])
 
-AM_INIT_AUTOMAKE([check-news 1.7.9 dist-bzip2 readme-alpha])
+AM_INIT_AUTOMAKE([1.7.9 dist-bzip2 readme-alpha])
 
 # We use `/bin/sh -n script' to check that there are no syntax errors
 # in the scripts.  Although incredible, there are /bin/sh that go into
index c1141c62bdfb81bccd3c84c12a168e3150f50978..4c3ad1a7474877589ab131a364f3fe3852bc7ee5 100644 (file)
@@ -34,7 +34,7 @@ include ../lib/freeze.mk
 ## package.m4.  ##
 ## ------------ ##
 
-$(srcdir)/package.m4: $(top_srcdir)/configure.ac
+$(srcdir)/package.m4: Makefile
        {                                       \
          echo '# Signature of the current package.'; \
          echo 'm4_define([AT_PACKAGE_NAME],      [$(PACKAGE_NAME)])'; \