git-version-gen [was: release 1.4.10b]

Eric Blake <[email protected]>
Newsgroups gmane.comp.gnu.m4.patches
Message-ID <[email protected]>
Eric Blake <ebb9 <at> byu.net> writes:

> And this makes --version information more informative on the branch.  I
> can't quite port it to head until head has a signed tag of the form v1.9x;
> I'm also waiting for git 1.5.5 to come out with the "git describe --match
> 'v[0-9]*'" command.  I'm not sure whether I want to cut the release for
> 1.9b to alpha.gnu.org right now, or just tag a non-released version just
> to have something for git-version-gen to work with.

I ended up pushing a tag for v1.9a at the point where we decided the master 
branch was no longer going to be named 1.5.  The 'git tag --help' documentation 
wasn't accurate: it claimed 'GIT_AUTHOR_DATE=date git tag' is sufficient to 
create a backdated tag, but I had to resort to manual editing and 'git mktag'; 
I'll report that to the git list separately.  With this patch, and new enough 
git installed, 'm4 --version' now reports 1.9a.414-0b84 (while if you don't 
have git 1.5.5 yet, it remains unchanged at 1.9a).

From 0b8410450c789102f46f2ee21aaeb304737e828b Mon Sep 17 00:00:00 2001
From: Eric Blake <[email protected]>
Date: Tue, 8 Apr 2008 12:12:53 -0600
Subject: [PATCH] Overhaul inter-version releases to work with git.

* configure.ac (version): New variable, which has nicer version
contents when using git 1.5.5+, hardcoded to 1.9a otherwise.
(TIMESTAMP): Delete, since CVS id expansion died with transition
to git.
(AM_INIT_AUTOMAKE): Use version to decide gnu vs. gnits.
* build-aux/mkstamp: Delete, no longer used.
* Makefile.am (CONFIG_STATUS_DEPENDENCIES): Kill, to speed up
rebuilds when timestamps don't matter.
(MKSTAMP): Delete, no longer used.
(EXTRA_DIST): No longer worry about mkstamp.
(.version): New rule and distributed file.
(doc/m4.1, tests/package.m4): Depend on .version, not
configure.ac, for timestamp.
* ltdl/m4/gnulib-cache.m4: Import git-version-gen module.
* modules/gnu.c (__m4_version__): TIMESTAMP no longer exists.
* src/main.c (main): Likewise.

Signed-off-by: Eric Blake <[email protected]>
---
 .cvsignore              |    3 +++
 .gitignore              |    3 +++
 ChangeLog               |   22 ++++++++++++++++++++--
 Makefile.am             |   21 +++++++++++----------
 build-aux/.cvsignore    |   13 -------------
 build-aux/.gitignore    |   13 -------------
 build-aux/mkstamp       |   38 --------------------------------------
 configure.ac            |   22 +++++-----------------
 ltdl/m4/gnulib-cache.m4 |    4 ++--
 modules/gnu.c           |    2 +-
 src/main.c              |    3 +--
 11 files changed, 46 insertions(+), 98 deletions(-)
 delete mode 100644 build-aux/.cvsignore
 delete mode 100644 build-aux/.gitignore
 delete mode 100755 build-aux/mkstamp

diff --git a/.cvsignore b/.cvsignore
index 4f6a6be..c83be60 100644
--- a/.cvsignore
+++ b/.cvsignore
@@ -1,9 +1,12 @@
 .git
 .patch_number
+.tarball-version
+.version
 ABOUT-NLS
 aclocal.m4
 aclocal.m4t
 autom4te.cache
+build-aux
 config.cache
 config.h
 config-h.in
diff --git a/.gitignore b/.gitignore
index 2f710ab..9077a31 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,10 +3,13 @@
 .patch_number
 *.orig
 *.rej
+.tarball-version
+.version
 ABOUT-NLS
 aclocal.m4
 aclocal.m4t
 autom4te.cache
+build-aux
 config.cache
 config.h
 config-h.in
diff --git a/ChangeLog b/ChangeLog
index 7c3e174..32593ea 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2008-04-08  Eric Blake  <[email protected]>
+
+	Overhaul inter-version releases to work with git.
+	* configure.ac (version): New variable, which has nicer version
+	contents when using git 1.5.5+, hardcoded to 1.9a otherwise.
+	(TIMESTAMP): Delete, since CVS id expansion died with transition
+	to git.
+	(AM_INIT_AUTOMAKE): Use version to decide gnu vs. gnits.
+	* build-aux/mkstamp: Delete, no longer used.
+	* Makefile.am (CONFIG_STATUS_DEPENDENCIES): Kill, to speed up
+	rebuilds when timestamps don't matter.
+	(MKSTAMP): Delete, no longer used.
+	(EXTRA_DIST): No longer worry about mkstamp.
+	(.version): New rule and distributed file.
+	(doc/m4.1, tests/package.m4): Depend on .version, not
+	configure.ac, for timestamp.
+	* ltdl/m4/gnulib-cache.m4: Import git-version-gen module.
+	* modules/gnu.c (__m4_version__): TIMESTAMP no longer exists.
+	* src/main.c (main): Likewise.
+
 2008-03-28  Eric Blake  <[email protected]>
 
 	Use GNUmakefile module.
@@ -10575,8 +10595,6 @@
 
 	-----
 
-	$Revision$ $Date$
-
 	Local Variables:
 	coding: utf-8
 	End:
diff --git a/Makefile.am b/Makefile.am
index ac0279d..9ae8189 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -50,22 +50,23 @@ EXTRA_LTLIBRARIES=
 # Include Libtool's rules.
 include ltdl/Makefile.inc
 
-# Additional configuration.
+# Additional configuration.  Version management comes from suggestions
+# given in build-aux/git-version-gen.
 AM_CPPFLAGS    += -Ignu -I$(srcdir)/gnu \
 		  -Im4 -I$(srcdir)/m4
-EXTRA_DIST     += bootstrap \
-		  $(config_aux_dir)/mkstamp \
+EXTRA_DIST     += bootstrap .version \
 		  $(config_macro_dir)/gnulib-cache.m4
+BUILT_SOURCES  += .version
+.version:
+	echo $(VERSION) > $@-t && mv $@-t $@
+dist-hook: dist-tarball-version
+dist-tarball-version:
+	echo $(VERSION) > $(distdir)/.tarball-version
 MAINTAINERCLEANFILES = \
 		  ABOUT-NLS COPYING INSTALL Makefile.in aclocal.m4 \
 		  config-h.in configure stamp-h.in \
 		  po/cat-id-tbl.c po/m4.pot po/stamp-cat-id
 
-MKSTAMP = $(SHELL) $(srcdir)/$(config_aux_dir)/mkstamp
-
-# Make sure config.status is regenerated when the version timestamp changes
-CONFIG_STATUS_DEPENDENCIES = ChangeLog
-
 
 ## ------- ##
 ## GNU M4. ##
@@ -259,7 +260,7 @@ HELP2MAN	= $(SHELL) $(srcdir)/$(config_aux_dir)/missing -
-run help2man
 # Build the man page once in the srcdir, rather than in every VPATH build
 # dir, to match how automake builds info pages.  This is safe for 'make
 # distcheck' since it is distributed pre-built.
-$(srcdir)/doc/m4.1: configure.ac src/main.c
+$(srcdir)/doc/m4.1: .version src/main.c
 	@if test -f src/m4$(EXEEXT); then \
 	  echo "Updating the \`man' page \`$@'"; \
 	  $(HELP2MAN) --name="macro processor" --source=FSF \
@@ -395,7 +396,7 @@ $(TESTSUITE): tests/package.m4 $(TESTSUITE_AT)
 	mv [email protected] $@
 
 # The leading :; works around a bug in {}>f in some bash versions.
-$(srcdir)/tests/package.m4: configure.ac
+$(srcdir)/tests/package.m4: .version
 	:; \
 	{ \
 	  echo '# Signature of the current package.'; \
diff --git a/build-aux/.cvsignore b/build-aux/.cvsignore
deleted file mode 100644
index 6da574f..0000000
--- a/build-aux/.cvsignore
+++ /dev/null
@@ -1,13 +0,0 @@
-compile
-config.*
-config.rpath
-depcomp
-gendocs.sh
-gnupload
-install-sh
-link-warning.h
-ltmain.sh
-mdate-sh
-missing
-mkinstalldirs
-texinfo.tex
diff --git a/build-aux/.gitignore b/build-aux/.gitignore
deleted file mode 100644
index 6da574f..0000000
--- a/build-aux/.gitignore
+++ /dev/null
@@ -1,13 +0,0 @@
-compile
-config.*
-config.rpath
-depcomp
-gendocs.sh
-gnupload
-install-sh
-link-warning.h
-ltmain.sh
-mdate-sh
-missing
-mkinstalldirs
-texinfo.tex
diff --git a/build-aux/mkstamp b/build-aux/mkstamp
deleted file mode 100755
index 3e81c96..0000000
--- a/build-aux/mkstamp
+++ /dev/null
@@ -1,38 +0,0 @@
-#! /bin/sh
-
-# mkstamp - extract data from Revision and Date RCS tags in a file
-# Copyright (C) 1999, 2003, 2007 Free Software Foundation, Inc.
-# Alexandre Oliva <[email protected]>
-#
-# This file is part of GNU M4.
-#
-# GNU M4 is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# GNU M4 is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-#
-# As a special exception to the GNU General Public License, if you
-# distribute this file as part of a program that contains a
-# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-# This script expects to find a line containing both Revision and Date
-# tags, and it edits this line so that it looks like ` $rev $date'
-
-# Command-line arguments are passed down to sed; additional -e cmd
-# arguments are acceptable.  If no input filename is specified in the
-# command line, sed will read from stdin.
-
-exec sed -e '
-	s%.*\$''Revision: \([^$]*\) \$.*\$''Date: \([^$]*\) \$.*% \1 \2%
-	t end
-	d
-	: end' ${1+"$@"}
diff --git a/configure.ac b/configure.ac
index 589c4b1..fdac14d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -23,7 +23,9 @@ AC_PREREQ([2.61a.347])
 ## ------------------------ ##
 ## Autoconf initialization. ##
 ## ------------------------ ##
-AC_INIT([GNU M4], [1.9a], [[email protected]])
+m4_define([version], m4_esyscmd([build-aux/git-version-gen .tarball-version]))
+m4_bmatch(m4_defn([version]), [^[0-9]], [], [m4_define([version], [1.9a])])
+AC_INIT([GNU M4], m4_defn([version]), [[email protected]])
 
 AC_CONFIG_SRCDIR([src/m4.h])
 AC_CONFIG_AUX_DIR([build-aux])
@@ -33,21 +35,6 @@ AC_CONFIG_TESTDIR([tests])
 AC_CONFIG_HEADERS([gnu/config.h:gnu/config.hin])
 AC_CONFIG_FILES([tests/m4], [chmod +x tests/m4])
 
-
-## ---------------------------------------- ##
-## Display a configure time version banner. ##
-## ---------------------------------------- ##
-TIMESTAMP=
-case AC_PACKAGE_VERSION in
-  *[[acegikmoqsuwy]])
-    TIMESTAMP=`$CONFIG_SHELL $ac_aux_dir/mkstamp < $srcdir/ChangeLog`
-    test -z "$TIMESTAMP" || TIMESTAMP=" Build:$TIMESTAMP"
-    AS_BOX([Configuring AC_PACKAGE_TARNAME][$TIMESTAMP AC_PACKAGE_VERSION])
-    echo
-    ;;
-esac
-AC_DEFINE_UNQUOTED([TIMESTAMP], ["$TIMESTAMP"],
-    [Defined to a CVS timestamp for alpha releases of M4])
 AB_INIT()
 
 
@@ -67,7 +54,8 @@ M4_default_preload="M4_DEFAULT_PRELOAD"
 ## ------------------------ ##
 ## Automake Initialization. ##
 ## ------------------------ ##
-AM_INIT_AUTOMAKE([1.10.1 subdir-objects dist-bzip2 dist-lzma gnits])
+AM_INIT_AUTOMAKE([1.10.1 subdir-objects dist-bzip2 dist-lzma]
+m4_bmatch(m4_defn([version]), [-], [gnu], [gnits]))
 
 
 
diff --git a/ltdl/m4/gnulib-cache.m4 b/ltdl/m4/gnulib-cache.m4
index 2a2a6dd..0e122ac 100644
--- a/ltdl/m4/gnulib-cache.m4
+++ b/ltdl/m4/gnulib-cache.m4
@@ -15,11 +15,11 @@
 
 
 # Specification in the form of a command-line invocation:
-#   gnulib-tool --import --dir=. --local-dir=local --lib=libgnu --source-
base=gnu --m4-base=ltdl/m4 --doc-base=doc --aux-dir=build-aux --with-tests --
libtool --macro-prefix=M4 assert autobuild avltree-oset binary-io clean-temp 
cloexec close-stream closein config-h configmake dirname error exit fdl fflush 
filenamecat flexmember fopen-safer fseeko gendocs gettext gnumakefile gnupload 
gpl-3.0 intprops memmem mkstemp obstack progname quote regex regexprops-generic 
sprintf-posix stdbool stdlib-safer strnlen strtod strtol tempname unlocked-io 
vasnprintf-posix verror xalloc xalloc-die xprintf-posix xstrndup xvasprintf-
posix
+#   gnulib-tool --import --dir=. --local-dir=local --lib=libgnu --source-
base=gnu --m4-base=ltdl/m4 --doc-base=doc --aux-dir=build-aux --with-tests --
libtool --macro-prefix=M4 assert autobuild avltree-oset binary-io clean-temp 
cloexec close-stream closein config-h configmake dirname error exit fdl fflush 
filenamecat flexmember fopen-safer fseeko gendocs gettext git-version-gen 
gnumakefile gnupload gpl-3.0 intprops memmem mkstemp obstack progname quote 
regex regexprops-generic sprintf-posix stdbool stdlib-safer strnlen strtod 
strtol tempname unlocked-io vasnprintf-posix verror xalloc xalloc-die xprintf-
posix xstrndup xvasprintf-posix
 
 # Specification in the form of a few gnulib-tool.m4 macro invocations:
 gl_LOCAL_DIR([local])
-gl_MODULES([assert autobuild avltree-oset binary-io clean-temp cloexec close-
stream closein config-h configmake dirname error exit fdl fflush filenamecat 
flexmember fopen-safer fseeko gendocs gettext gnumakefile gnupload gpl-3.0 
intprops memmem mkstemp obstack progname quote regex regexprops-generic sprintf-
posix stdbool stdlib-safer strnlen strtod strtol tempname unlocked-io 
vasnprintf-posix verror xalloc xalloc-die xprintf-posix xstrndup xvasprintf-
posix])
+gl_MODULES([assert autobuild avltree-oset binary-io clean-temp cloexec close-
stream closein config-h configmake dirname error exit fdl fflush filenamecat 
flexmember fopen-safer fseeko gendocs gettext git-version-gen gnumakefile 
gnupload gpl-3.0 intprops memmem mkstemp obstack progname quote regex 
regexprops-generic sprintf-posix stdbool stdlib-safer strnlen strtod strtol 
tempname unlocked-io vasnprintf-posix verror xalloc xalloc-die xprintf-posix 
xstrndup xvasprintf-posix])
 gl_AVOID([])
 gl_SOURCE_BASE([gnu])
 gl_M4_BASE([ltdl/m4])
diff --git a/modules/gnu.c b/modules/gnu.c
index 5309968..1cf4a60 100644
--- a/modules/gnu.c
+++ b/modules/gnu.c
@@ -93,7 +93,7 @@ m4_macro m4_macro_table[] =
 # warning Platform macro not provided
 #endif
   { "__gnu__",		"",	0,	0 },
-  { "__m4_version__",	VERSION/**/TIMESTAMP, 0, 0 },
+  { "__m4_version__",	VERSION,0,	0 },
 
   { NULL,		NULL,	0,	0 },
 };
diff --git a/src/main.c b/src/main.c
index b06a893..86f21e7 100644
--- a/src/main.c
+++ b/src/main.c
@@ -592,8 +592,7 @@ main (int argc, char *const *argv, char *const *envp)
 	  break;
 
 	case VERSION_OPTION:
-	  version_etc (stdout, PACKAGE, PACKAGE_NAME TIMESTAMP,
-		       VERSION, AUTHORS, NULL);
+	  version_etc (stdout, PACKAGE, PACKAGE_NAME, VERSION, AUTHORS, NULL);
 	  exit (EXIT_SUCCESS);
 	  break;
 
-- 
1.5.4
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.