3 # Usage: version.sh <ffmpeg-root-dir> <output-version.h> <extra-version>
5 # check for git short hash
6 if ! test "$revision"; then
7 revision=$(cd "$1" && git describe --tags --match N 2> /dev/null)
10 # Shallow Git clones (--depth) do not have the N tag:
11 # use 'git-YYYY-MM-DD-hhhhhhh'.
12 test "$revision" || revision=$(cd "$1" &&
13 git log -1 --pretty=format:"git-%cd-%h" --date=short 2> /dev/null)
15 # Snapshots from gitweb are in a directory called ffmpeg-hhhhhhh or
16 # ffmpeg-HEAD-hhhhhhh.
17 if [ -z "$revision" ]; then
18 srcdir=$(cd "$1" && pwd)
20 */ffmpeg-[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f])
21 git_hash="${srcdir##*-}";;
22 */ffmpeg-HEAD-[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f])
23 git_hash="${srcdir##*-}";;
27 # no revision number found
28 test "$revision" || revision=$(cd "$1" && cat RELEASE 2> /dev/null)
30 # Append the Git hash if we have one
31 test "$revision" && test "$git_hash" && revision="$revision-$git_hash"
33 # releases extract the version number from the VERSION file
34 version=$(cd "$1" && cat VERSION 2> /dev/null)
35 test "$version" || version=$revision
37 test -n "$3" && version=$version-$3
44 NEW_REVISION="#define FFMPEG_VERSION \"$version\""
45 OLD_REVISION=$(cat "$2" 2> /dev/null | head -3 | tail -1)
47 # String used for preprocessor guard
48 GUARD=$(echo "$2" | sed 's/\//_/' | sed 's/\./_/' | tr '[:lower:]' '[:upper:]' | sed 's/LIB//')
50 # Update version header only on revision changes to avoid spurious rebuilds
51 if test "$NEW_REVISION" != "$OLD_REVISION"; then