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 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
20 test -z "$(git diff-index --name-only HEAD --)" ||
24 VN
=$
(echo "$VN" |
sed -e 's/-/./g');
29 VN
=$
(expr "$VN" : v
*'\(.*\)')
32 [[ -z "$GVF" ]] && exit 0
33 if [[ -r "$GVF" ]]; then
34 pattern
='^#define GIT_VERSION "'
35 VC
=$
(grep "$pattern" < "$GVF" |
sed -e "s/$pattern//; s/\"$//")
36 [[ "$VN" == "$VC" ]] && exit 0
38 echo >&2 "new git version: $VN"
39 echo "/** \\file ${GVF##*/} Auto-generated version file. Do not edit. */" >$GVF
40 echo "#define GIT_VERSION \"$VN\"" >> $GVF