Code

src/Makefile: Print some useful information after a successful built.
[lm2latex.git] / version-gen.sh
1 #! /bin/sh
3 DEFAULT_VERSION="0.0.0.git"
5 VERSION="$( git describe --tags 2> /dev/null \
6         | sed -e 's/lm2latex-//' || true )"
8 if test -z "$VERSION"; then
9         VERSION="$DEFAULT_VERSION"
10 else
11         git update-index -q --refresh || true
12         if test -n "$( git diff-index --name-only HEAD || true )"; then
13                 VERSION="$VERSION-dirty"
14         fi
15 fi
17 VERSION="$( echo "$VERSION" | sed -e 's/-/./g' )"
18 echo -n "$VERSION"
20 OLD_VERSION=""
21 if test -e version; then
22         OLD_VERSION=$( sed -ne 's/^VERSION="\(.*\)"/\1/p' version )
23 fi
25 if test "$OLD_VERSION" != "$VERSION"; then
26         VERSION_MAJOR=$( echo $VERSION | cut -d'.' -f1 )
27         VERSION_MINOR=$( echo $VERSION | cut -d'.' -f2 )
28         VERSION_PATCH=$( echo $VERSION | cut -d'.' -f3 )
29         VERSION_EXTRA="\"$( echo $VERSION | cut -d'.' -f4- )\""
30         test -z "$VERSION_EXTRA" || VERSION_EXTRA=".$VERSION_EXTRA"
31         (
32          echo "VERSION=\"$VERSION\""
33          echo "VERSION_MAJOR=$VERSION_MAJOR"
34          echo "VERSION_MINOR=$VERSION_MINOR"
35          echo "VERSION_PATCH=$VERSION_PATCH"
36          echo "VERSION_EXTRA=\"$VERSION_EXTRA\""
37          echo "VERSION_STRING=\"$VERSION_MAJOR.$VERSION_MINOR.$VERSION_PATCH\""
38         ) > version
39 fi