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

3
# check for git short hash
4
revision=$(cd "$1" && git describe --always 2> /dev/null)
5

6
# no revision number found
7
test "$revision" || revision=$(cd "$1" && cat RELEASE 2> /dev/null)
8

9
# releases extract the version number from the VERSION file
10
version=$(cd "$1" && cat VERSION 2> /dev/null)
11
test "$version" || version=$revision
12

13 14
test -n "$3" && version=$version-$3

15 16 17 18 19
if [ -z "$2" ]; then
    echo "$version"
    exit
fi

20
NEW_REVISION="#define LIBAV_VERSION \"$version\""
21
OLD_REVISION=$(cat "$2" 2> /dev/null)
22 23 24

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