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