2008-01-14 11:31:59 +01:00
|
|
|
#!/bin/sh
|
|
|
|
# Syntax:
|
|
|
|
# $0 <path-to-top_srcdir> <version-stamp-file>
|
|
|
|
#
|
|
|
|
# <path-to-top_srcdir> may be relative
|
|
|
|
# <version-stamp-file> is relative to src/build topdir
|
|
|
|
|
|
|
|
top_srcdir="${1-.}"
|
|
|
|
test -d "$top_srcdir" || { \
|
|
|
|
echo "Could not change to top_srcdir '$1'" >&2; \
|
|
|
|
exit 1; \
|
|
|
|
}
|
|
|
|
version_stamp="${2-version-stamp}"
|
|
|
|
|
2008-01-25 12:59:17 +01:00
|
|
|
# If GIT_DIR is set, use it. If not, try top_srcdir/.git.
|
|
|
|
if test -n "$GIT_DIR"; then :;
|
|
|
|
else GIT_DIR="$top_srcdir/.git"; export GIT_DIR
|
|
|
|
fi
|
|
|
|
|
2008-01-14 11:31:59 +01:00
|
|
|
if test -f "$top_srcdir/$version_stamp"; then # dist source tree
|
|
|
|
cat "$top_srcdir/$version_stamp" | ${TR-tr} -d '\012'
|
2008-01-25 12:59:17 +01:00
|
|
|
elif test -d "$GIT_DIR"; then # git source tree
|
|
|
|
git_describe=`${GIT-git} describe 2>/dev/null || echo devel`
|
2008-01-14 11:31:59 +01:00
|
|
|
echo "$git_describe" | ${SED-sed} -e 's/^v//' -e 's/-/./g' | ${TR-tr} -d '\012'
|
|
|
|
else # ???
|
|
|
|
echo "devel" | ${TR-tr} -d '\012'
|
|
|
|
fi
|