1 AC_DEFUN([AX_DETECT_GIT_HEAD], [
4 AC_SUBST(GIT_HEAD_VERSION)
5 if test -f $srcdir/.git; then
6 gitdir=`GIT_DIR=$srcdir/.git git rev-parse --git-dir`
7 GIT_HEAD="$gitdir/index"
9 GIT_HEAD_ID=`GIT_DIR=$GIT_REPO git describe`
10 elif test -f $srcdir/.git/HEAD; then
11 GIT_HEAD="$srcdir/.git/index"
12 GIT_REPO="$srcdir/.git"
13 GIT_HEAD_ID=`GIT_DIR=$GIT_REPO git describe`
14 elif test -f $srcdir/GIT_HEAD_ID; then
15 GIT_HEAD_ID=`cat $srcdir/GIT_HEAD_ID`
17 mysrcdir=`(cd $srcdir; pwd)`
18 head=`basename $mysrcdir | sed -e 's/.*-//'`
19 head2=`echo $head | sed -e 's/[^0-9a-f]//'`
20 head3=`echo $head2 | sed -e 's/........................................//'`
21 if test "x$head3" = "x" -a "x$head" = "x$head2"; then
27 if test -z "$GIT_REPO" ; then
28 GIT_HEAD_VERSION="$GIT_HEAD_ID"
30 GIT_HEAD_VERSION="\`GIT_DIR=$GIT_REPO git describe\`"