diff --git a/version-gen.sh b/version-gen.sh
index 5b9c1712bb9e6797e2e90de75d4d740c2cf373f5..b9d8c967048522484bd9a062daf3dbf89fd0b662 100755 (executable)
--- a/version-gen.sh
+++ b/version-gen.sh
#! /bin/sh
-DEFAULT_VERSION="0.0.0"
+DEFAULT_VERSION="0.0.0.git"
-VERSION="$( git describe 2> /dev/null | sed -e 's/foobar-//' )"
+VERSION="$( git describe --tags 2> /dev/null \
+ | sed -e 's/foobar-//' || true )"
if test -z "$VERSION"; then
VERSION="$DEFAULT_VERSION"
+else
+ git update-index -q --refresh || true
+ if test -n "$( git diff-index --name-only HEAD || true )"; then
+ VERSION="$VERSION-dirty"
+ fi
fi
VERSION="$( echo "$VERSION" | sed -e 's/-/./g' )"
echo -n "$VERSION"
+OLD_VERSION=""
+if test -e version; then
+ OLD_VERSION=$( sed -ne 's/^VERSION="\(.*\)"/\1/p' version )
+fi
+
+if test "$OLD_VERSION" != "$VERSION"; then
+ VERSION_MAJOR=$( echo $VERSION | cut -d'.' -f1 )
+ VERSION_MINOR=$( echo $VERSION | cut -d'.' -f2 )
+ VERSION_PATCH=$( echo $VERSION | cut -d'.' -f3 )
+ VERSION_EXTRA="\"$( echo $VERSION | cut -d'.' -f4- )\""
+ test -z "$VERSION_EXTRA" || VERSION_EXTRA=".$VERSION_EXTRA"
+ (
+ echo "VERSION=\"$VERSION\""
+ echo "VERSION_MAJOR=$VERSION_MAJOR"
+ echo "VERSION_MINOR=$VERSION_MINOR"
+ echo "VERSION_PATCH=$VERSION_PATCH"
+ echo "VERSION_EXTRA=\"$VERSION_EXTRA\""
+ echo "VERSION_STRING=\"$VERSION_MAJOR.$VERSION_MINOR.$VERSION_PATCH\""
+ ) > version
+fi
+