X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=build-aux%2Fgit-version-gen;h=c7a58af54edbd851587a4585d65fbb983492dae2;hb=4e0358a6af54a597c5a3a8f7558a7e856758b141;hp=6d7144665dfbfb9f607fd0728c46018b946e8c5f;hpb=c596dce2525adef145e3ec2e1d3c89dc044ac8e8;p=gnulib.git diff --git a/build-aux/git-version-gen b/build-aux/git-version-gen index 6d7144665..c7a58af54 100755 --- a/build-aux/git-version-gen +++ b/build-aux/git-version-gen @@ -1,6 +1,6 @@ #!/bin/sh # Print a version string. -scriptversion=2011-07-31.12; # UTC +scriptversion=2011-11-13.13; # UTC # Copyright (C) 2007-2011 Free Software Foundation, Inc. # @@ -44,8 +44,10 @@ scriptversion=2011-07-31.12; # UTC # files to pick up a version string change; and leave it stale to # minimize rebuild time after unrelated changes to configure sources. # -# It is probably wise to add these two files to .gitignore, so that you -# don't accidentally commit either generated file. +# As with any generated file in a VC'd directory, you should add +# /.version to .gitignore, so that you don't accidentally commit it. +# .tarball-version is never generated in a VC'd directory, so needn't +# be listed there. # # Use the following line in your configure.ac, so that $(VERSION) will # automatically be up-to-date each time configure is run (and note that @@ -67,15 +69,59 @@ scriptversion=2011-07-31.12; # UTC # dist-hook: # echo $(VERSION) > $(distdir)/.tarball-version -case $# in - 1|2) ;; - *) echo 1>&2 "Usage: $0 \$srcdir/.tarball-version" \ - '[TAG-NORMALIZATION-SED-SCRIPT]' - exit 1;; -esac -tarball_version_file=$1 -tag_sed_script="${2:-s/x/x/}" +me=$0 + +version="git-version-gen $scriptversion + +Copyright 2011 Free Software Foundation, Inc. +There is NO warranty. You may redistribute this software +under the terms of the GNU General Public License. +For more information about these matters, see the files named COPYING." + +usage="\ +Usage: $me [OPTION]... \$srcdir/.tarball-version [TAG-NORMALIZATION-SED-SCRIPT] +Print a version string. + +Options: + + --prefix prefix of git tags (default 'v') + + --help display this help and exit + --version output version information and exit + +Running without arguments will suffice in most cases." + +while test $# -gt 0; do + case $1 in + --help) echo "$usage"; exit 0;; + --version) echo "$version"; exit 0;; + --prefix) shift; prefix="$1";; + -*) + echo "$0: Unknown option \`$1'." >&2 + echo "$0: Try \`--help' for more information." >&2 + exit 1;; + *) + if test -z "$tarball_version_file"; then + tarball_version_file="$1" + elif test -z "$tag_sed_script"; then + tag_sed_script="$1" + else + echo "$0: extra non-option argument \`$1'." >&2 + exit 1 + fi;; + esac + shift +done + +if test -z "$tarball_version_file"; then + echo "$usage" + exit 1 +fi + +tag_sed_script="${tag_sed_script:-s/x/x/}" +prefix="${prefix:-v}" + nl=' ' @@ -104,11 +150,11 @@ then # directory, and "git describe" output looks sensible, use that to # derive a version string. elif test "`git log -1 --pretty=format:x . 2>&1`" = x \ - && v=`git describe --abbrev=4 --match='v*' HEAD 2>/dev/null \ + && v=`git describe --abbrev=4 --match="$prefix*" HEAD 2>/dev/null \ || git describe --abbrev=4 HEAD 2>/dev/null` \ && v=`printf '%s\n' "$v" | sed "$tag_sed_script"` \ && case $v in - v[0-9]*) ;; + $prefix[0-9]*) ;; *) (exit 1) ;; esac then @@ -141,7 +187,7 @@ else v=UNKNOWN fi -v=`echo "$v" |sed 's/^v//'` +v=`echo "$v" |sed "s/^$prefix//"` # Test whether to append the "-dirty" suffix only if the version # string we're using came from git. I.e., skip the test if it's "UNKNOWN"