autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Make inter-release --version output more useful.


From: Jim Meyering
Subject: [PATCH] Make inter-release --version output more useful.
Date: Sat, 27 Oct 2007 19:38:23 +0200

Now that the generated files are no longer version-controlled,
this patch is possible.  FYI, using the resulting version of autoconf
to build configure for coreutils, I get this:

  $ head -3 configure
  #! /bin/sh
  # Guess values for system-dependent variables and create Makefiles.
  # Generated by GNU Autoconf 2.61a-244-2d95d for GNU coreutils 6.9-351-1f05c.

Any objections?
Once something like this is in, I'll start making snapshots available.

---
 .gitignore                |    1 +
 ChangeLog                 |   20 ++++++++++++++
 GNUmakefile               |   14 ++++++++++
 Makefile.am               |    5 +++
 build-aux/git-version-gen |   64 +++++++++++++++++++++++++++++++++++++++++++++
 configure.ac              |    5 ++-
 tests/Makefile.am         |    2 +-
 7 files changed, 108 insertions(+), 3 deletions(-)
 create mode 100755 build-aux/git-version-gen

diff --git a/ChangeLog b/ChangeLog
index 18c9fe4..608c8f0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,26 @@

 2007-10-27  Jim Meyering  <address@hidden>

+       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  Jim Meyering  <address@hidden>
+
        Remove all generated files from version control.
        * aclocal.m4: Remove.
        * configure: Remove.
diff --git a/.gitignore b/.gitignore
index 92162b4..66c7aae 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,7 @@
 *.log
 *~
 .#*
+.version
 CVS
 Makefile
 Makefile.in
diff --git a/GNUmakefile b/GNUmakefile
index 7a1b0d2..30fdcc4 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -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

diff --git a/Makefile.am b/Makefile.am
index 9c01c5c..a74088b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -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
diff --git a/build-aux/git-version-gen b/build-aux/git-version-gen
new file mode 100755
index 0000000..c433c26
--- /dev/null
+++ b/build-aux/git-version-gen
@@ -0,0 +1,64 @@
+#!/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//'`
+
+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'
diff --git a/configure.ac b/configure.ac
index 1a32ea3..4f9a71e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -20,13 +20,14 @@
 # We need AC_CONFIG_TESTDIR.
 AC_PREREQ([2.59])

-AC_INIT([GNU Autoconf], [2.61b], address@hidden)
+AC_INIT([GNU Autoconf], m4_esyscmd([build-aux/git-version-gen .version]),
+       address@hidden)
 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
diff --git a/tests/Makefile.am b/tests/Makefile.am
index c1141c6..1972d6c 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -34,7 +34,7 @@ include ../lib/freeze.mk
 ## package.m4.  ##
 ## ------------ ##

-$(srcdir)/package.m4: $(top_srcdir)/configure.ac
+$(srcdir)/package.m4: $(builddir)/Makefile
        {                                       \
          echo '# Signature of the current package.'; \
          echo 'm4_define([AT_PACKAGE_NAME],      [$(PACKAGE_NAME)])'; \
--
1.5.3.4.383.gd90a7




reply via email to

[Prev in Thread] Current Thread [Next in Thread]