regen.sh: Use libtoolize -i, and .gitignore generated build-tools
[openafs.git] / build-tools / git-version
1 #!/bin/sh
2
3 srcdir=$1
4 fallback=$2
5
6 if [ "x$fallback" = "x" ]; then
7   fallback=UNKNOWN
8 fi
9
10 if [ -f $srcdir/.version ] ; then
11   git_version=`cat $srcdir/.version`
12 else
13   if which git > /dev/null; then
14     cd $srcdir
15     git_version=`git describe --abbrev=4 HEAD 2>/dev/null`
16     if [ $? = 0 ]; then
17       # Is the working tree dirty?
18       if git diff-index --quiet --cached HEAD && \
19          git diff-files --quiet ; then
20          :
21       else
22         git_version="$git_version-dirty"
23       fi
24     else
25       git_version=$fallback
26     fi
27   else
28     git_version=$fallback
29   fi
30 fi
31
32 echo "$git_version" | sed -e 's/openafs-[^-]*-//' -e 's/_/./g' | tr -d '\012'