3 # check for git short hash
4 if ! test "$revision"; then
5 revision=$(cd "$1" && git describe --tags --match N 2> /dev/null)
8 # Shallow Git clones (--depth) do not have the N tag:
9 # use 'git-YYYY-MM-DD-hhhhhhh'.
10 test "$revision" || revision=$(cd "$1" &&
11 git log -1 --pretty=format:"git-%cd-%h" --date=short 2> /dev/null)
13 # Snapshots from gitweb are in a directory called ffmpeg-hhhhhhh or
14 # ffmpeg-HEAD-hhhhhhh.
15 if [ -z "$revision" ]; then
16 srcdir=$(cd "$1" && pwd)
18 */ffmpeg-[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f])
19 git_hash="${srcdir##*-}";;
20 */ffmpeg-HEAD-[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##*-}";;
25 # no revision number found
26 test "$revision" || revision=$(cd "$1" && cat RELEASE 2> /dev/null)
28 # Append the Git hash if we have one
29 test "$revision" && test "$git_hash" && revision="$revision-$git_hash"
31 # releases extract the version number from the VERSION file
32 version=$(cd "$1" && cat VERSION 2> /dev/null)
33 test "$version" || version=$revision
35 test -n "$3" && version=$version-$3
42 NEW_REVISION="#define FFMPEG_VERSION \"$version\""
43 OLD_REVISION=$(cat version.h 2> /dev/null)
45 # Update version.h only on revision changes to avoid spurious rebuilds
46 if test "$NEW_REVISION" != "$OLD_REVISION"; then
47 echo "$NEW_REVISION" > "$2"