aboutsummaryrefslogtreecommitdiffstats
path: root/build-aux/git-version-gen
blob: 331faef04146e3304c373a3c84c5d9021aa99810 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/bin/sh

if [ "$#" -ne 1 ]
then
  echo "usage: git-version-gen <verfile>" >&2
  exit 1
fi

VERFILE="$1"

if [ -d '.git' ]
then
  VERSION=`git describe --abbrev=4 --match='v[0-9]*' --dirty 2>/dev/null`
  VERSION=`echo "$VERSION" | sed 's/^v//'`
  [ -n "$VERSION" ] && echo -n "$VERSION" > "$VERFILE"
fi

if [ -f "$VERFILE" ]
then
  cat "$VERFILE"
else
  echo "git-version-gen: unknown version number." >&2
  exit 1
fi