2 # Print a version string.
3 # This script is derived from GIT-VERSION-GEN from GIT: http://git.or.cz/.
4 scriptversion=2007-06-30.12
6 # Copyright (C) 2007 Free Software Foundation
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 3, or (at your option)
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25 *) echo 1>&2 "Usage: $0 \$VERSION \$srcdir/.version"; exit 1;;
29 tarball_version_file=$2
33 # First see if there is a tarball-only version file.
34 # then try git-describe, then default.
35 if test -f $tarball_version_file
37 v=`cat $tarball_version_file` || exit 1
39 *$nl*) v= ;; # reject multi-line output
44 && echo "$0: WARNING: $tarball_version_file seems to be damaged" 1>&2
51 && v=`git describe --abbrev=4 HEAD 2>/dev/null` \
57 # Remove the "g" in git-describe's output string; change each - to a '.'
58 v=`echo "$v" | sed 's/\(.*\)-g/\1-/;s/-/./g'`;
63 v=`echo "$v" |sed 's/^v//'`
65 dirty=`sh -c 'git diff-index --name-only HEAD' 2>/dev/null` || dirty=
68 *) # Append the suffix only if there isn't one already.
75 # Omit the trailing newline, so that m4_esyscmd can use the result directly.
76 echo "$v" | tr -d '\012'
79 # eval: (add-hook 'write-file-hooks 'time-stamp)
80 # time-stamp-start: "scriptversion="
81 # time-stamp-format: "%:y-%02m-%02d.%02H"