3 (($# > 1)) && { echo >&2 "usage: $0 [<version file>]"; exit 1; }
6 DEF_VER
="unnamed_version"
10 # First see if there is a version file (included in release tarballs),
11 # then try git-describe, then gitweb, then default.
12 if [[ -f VERSION
]]; then
13 VN
=$
(cat VERSION
) || VN
="$DEF_VER"
14 elif [[ -d .git ||
-f .git
]] &&
15 VN
=$
(git describe
--abbrev=4 HEAD
2>/dev
/null
) &&
19 git update-index
-q --refresh &>/dev
/null
20 test -z "$(git diff-index --name-only HEAD --)" ||
24 VN
=$
(echo "$VN" |
sed -e 's/-/./g');
25 elif [[ "$PWD" =~ paraslash-
[a-f0-9
]{1,} ]]; then
31 VN
=$
(expr "$VN" : v
*'\(.*\)')
34 [[ -z "$GVF" ]] && exit 0
35 if [[ -r "$GVF" ]]; then
36 pattern
='^#define GIT_VERSION "'
37 VC
=$
(grep "$pattern" < "$GVF" |
sed -e "s/$pattern//; s/\"$//")
38 [[ "$VN" == "$VC" ]] && exit 0
40 echo >&2 "new git version: $VN"
41 echo "/** \\file ${GVF##*/} Auto-generated version file. Do not edit. */" >$GVF
42 echo "#define GIT_VERSION \"$VN\"" >> $GVF