2001-04-15 00:26:27 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
2012-11-24 00:16:50 +01:00
|
|
|
export LC_ALL=C
|
|
|
|
|
2015-06-30 15:56:26 +02:00
|
|
|
version_h="version.h"
|
2015-07-14 23:09:44 +02:00
|
|
|
print=yes
|
2015-06-30 15:56:26 +02:00
|
|
|
|
2013-08-09 10:07:23 +02:00
|
|
|
for ac_option do
|
2015-06-30 15:56:26 +02:00
|
|
|
ac_arg=$(echo $ac_option | cut -d '=' -f 2-)
|
2013-08-09 10:07:23 +02:00
|
|
|
case "$ac_option" in
|
|
|
|
--extra=*)
|
2015-06-30 15:56:26 +02:00
|
|
|
extra="-$ac_arg"
|
|
|
|
;;
|
|
|
|
--versionh=*)
|
2015-07-11 19:03:44 +02:00
|
|
|
version_h="$(pwd)/$ac_arg"
|
2015-07-14 23:09:44 +02:00
|
|
|
print=no
|
2015-07-11 19:03:44 +02:00
|
|
|
;;
|
|
|
|
--cwd=*)
|
|
|
|
cwd="$ac_arg"
|
2013-08-09 10:07:23 +02:00
|
|
|
;;
|
|
|
|
*)
|
2015-06-30 15:56:26 +02:00
|
|
|
echo "Unknown parameter: $ac_option" >&2
|
2013-08-09 10:07:23 +02:00
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
|
|
|
|
esac
|
|
|
|
done
|
2006-06-06 14:01:34 +02:00
|
|
|
|
2015-07-11 19:03:44 +02:00
|
|
|
if test "$cwd" ; then
|
|
|
|
cd "$cwd"
|
|
|
|
fi
|
|
|
|
|
2009-02-25 00:15:26 +01:00
|
|
|
# Extract revision number from file used by daily tarball snapshots
|
2011-01-25 00:06:48 +01:00
|
|
|
# or from "git describe" output
|
2009-11-23 04:40:52 +01:00
|
|
|
git_revision=$(cat snapshot_version 2> /dev/null)
|
2014-09-16 02:50:43 +02:00
|
|
|
test "$git_revision" || test ! -e .git || git_revision="$(git rev-parse --short HEAD)"
|
|
|
|
test "$git_revision" && git_revision="git-$git_revision"
|
2013-10-14 20:05:39 +02:00
|
|
|
version="$git_revision"
|
2006-06-23 17:12:56 +02:00
|
|
|
|
2009-03-06 00:36:28 +01:00
|
|
|
# releases extract the version number from the VERSION file
|
2014-09-16 02:50:43 +02:00
|
|
|
releaseversion="$(cat VERSION 2> /dev/null)"
|
|
|
|
if test "$releaseversion" ; then
|
|
|
|
test "$version" && version="-$version"
|
2013-10-14 20:05:39 +02:00
|
|
|
version="$releaseversion$version"
|
|
|
|
fi
|
|
|
|
|
2014-09-16 02:50:43 +02:00
|
|
|
test "$version" || version=UNKNOWN
|
2009-03-06 00:36:28 +01:00
|
|
|
|
2013-08-09 10:07:23 +02:00
|
|
|
VERSION="${version}${extra}"
|
|
|
|
|
|
|
|
if test "$print" = yes ; then
|
|
|
|
echo "$VERSION"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
NEW_REVISION="#define VERSION \"${VERSION}\""
|
2015-06-30 15:56:26 +02:00
|
|
|
OLD_REVISION=$(head -n 1 "$version_h" 2> /dev/null)
|
2012-11-24 00:16:50 +01:00
|
|
|
BUILDDATE="#define BUILDDATE \"$(date)\""
|
2006-06-22 15:47:50 +02:00
|
|
|
|
|
|
|
# Update version.h only on revision changes to avoid spurious rebuilds
|
|
|
|
if test "$NEW_REVISION" != "$OLD_REVISION"; then
|
2015-06-30 15:56:26 +02:00
|
|
|
cat <<EOF > "$version_h"
|
2009-01-29 01:16:09 +01:00
|
|
|
$NEW_REVISION
|
2012-11-24 00:16:50 +01:00
|
|
|
$BUILDDATE
|
2009-01-29 01:16:09 +01:00
|
|
|
EOF
|
2006-06-22 15:47:50 +02:00
|
|
|
fi
|