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