version.sh 831 Bytes
Newer Older
1 2
#!/bin/sh

3
revision=$(cd "$1" && cat snapshot_version 2> /dev/null)
Mans Rullgard's avatar
Mans Rullgard committed
4
test "$revision" && revision=SVN-r$revision
5

6
# check for git short hash
Mans Rullgard's avatar
Mans Rullgard committed
7
if ! test "$revision"; then
8
    revision=$(cd "$1" && git describe --always 2> /dev/null)
Mans Rullgard's avatar
Mans Rullgard committed
9
    test "$revision" && revision=git-$revision
10 11
fi

12
# no revision number found
Mans Rullgard's avatar
Mans Rullgard committed
13
test "$revision" || revision=UNKNOWN
14

15
# releases extract the version number from the VERSION file
16
version=$(cd "$1" && cat VERSION 2> /dev/null)
Mans Rullgard's avatar
Mans Rullgard committed
17
test "$version" || version=$revision
18

19 20
test -n "$3" && version=$version-$3

21 22 23 24 25
if [ -z "$2" ]; then
    echo "$version"
    exit
fi

26
NEW_REVISION="#define LIBAV_VERSION \"$version\""
27
OLD_REVISION=$(cat version.h 2> /dev/null)
28 29 30

# Update version.h only on revision changes to avoid spurious rebuilds
if test "$NEW_REVISION" != "$OLD_REVISION"; then
31
    echo "$NEW_REVISION" > "$2"
32
fi