2006-06-20 13:24:08 +03:00
|
|
|
#!/bin/sh
|
|
|
|
|
2013-11-29 03:57:49 +03:00
|
|
|
# Usage: version.sh <ffmpeg-root-dir> <output-version.h> <extra-version>
|
|
|
|
|
2007-10-20 03:07:48 +03:00
|
|
|
# check for git short hash
|
2010-10-06 17:36:58 +03:00
|
|
|
if ! test "$revision"; then
|
2014-07-28 03:40:35 +03:00
|
|
|
if (cd "$1" && grep git RELEASE 2> /dev/null >/dev/null) ; then
|
|
|
|
revision=$(cd "$1" && git describe --tags --match N 2> /dev/null)
|
|
|
|
else
|
|
|
|
revision=$(cd "$1" && git describe --tags --always 2> /dev/null)
|
|
|
|
fi
|
2007-10-20 03:07:48 +03:00
|
|
|
fi
|
|
|
|
|
2011-07-21 16:16:12 +03:00
|
|
|
# Shallow Git clones (--depth) do not have the N tag:
|
|
|
|
# use 'git-YYYY-MM-DD-hhhhhhh'.
|
|
|
|
test "$revision" || revision=$(cd "$1" &&
|
|
|
|
git log -1 --pretty=format:"git-%cd-%h" --date=short 2> /dev/null)
|
|
|
|
|
|
|
|
# Snapshots from gitweb are in a directory called ffmpeg-hhhhhhh or
|
|
|
|
# ffmpeg-HEAD-hhhhhhh.
|
|
|
|
if [ -z "$revision" ]; then
|
|
|
|
srcdir=$(cd "$1" && pwd)
|
|
|
|
case "$srcdir" in
|
|
|
|
*/ffmpeg-[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f])
|
|
|
|
git_hash="${srcdir##*-}";;
|
|
|
|
*/ffmpeg-HEAD-[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f])
|
|
|
|
git_hash="${srcdir##*-}";;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
|
2009-03-06 01:17:11 +02:00
|
|
|
# no revision number found
|
2011-06-19 20:51:20 +03:00
|
|
|
test "$revision" || revision=$(cd "$1" && cat RELEASE 2> /dev/null)
|
2007-10-20 03:05:04 +03:00
|
|
|
|
2011-07-21 16:16:12 +03:00
|
|
|
# Append the Git hash if we have one
|
|
|
|
test "$revision" && test "$git_hash" && revision="$revision-$git_hash"
|
|
|
|
|
2009-03-06 01:17:11 +02:00
|
|
|
# releases extract the version number from the VERSION file
|
2010-01-07 21:23:50 +02:00
|
|
|
version=$(cd "$1" && cat VERSION 2> /dev/null)
|
2010-10-06 17:36:58 +03:00
|
|
|
test "$version" || version=$revision
|
2008-09-27 00:37:50 +03:00
|
|
|
|
2009-03-06 01:17:11 +02:00
|
|
|
test -n "$3" && version=$version-$3
|
|
|
|
|
2010-07-27 02:43:59 +03:00
|
|
|
if [ -z "$2" ]; then
|
|
|
|
echo "$version"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2011-03-17 17:57:37 +02:00
|
|
|
NEW_REVISION="#define FFMPEG_VERSION \"$version\""
|
2013-11-29 20:57:30 +03:00
|
|
|
OLD_REVISION=$(cat "$2" 2> /dev/null | head -3 | tail -1)
|
|
|
|
|
|
|
|
# String used for preprocessor guard
|
|
|
|
GUARD=$(echo "$2" | sed 's/\//_/' | sed 's/\./_/' | tr '[:lower:]' '[:upper:]' | sed 's/LIB//')
|
2006-06-20 13:24:08 +03:00
|
|
|
|
2013-11-29 04:00:28 +03:00
|
|
|
# Update version header only on revision changes to avoid spurious rebuilds
|
2006-06-20 13:24:08 +03:00
|
|
|
if test "$NEW_REVISION" != "$OLD_REVISION"; then
|
2013-11-29 20:57:30 +03:00
|
|
|
cat << EOF > "$2"
|
|
|
|
#ifndef $GUARD
|
|
|
|
#define $GUARD
|
|
|
|
$NEW_REVISION
|
|
|
|
#endif /* $GUARD */
|
|
|
|
EOF
|
2006-06-20 13:24:08 +03:00
|
|
|
fi
|