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

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

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

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

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

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

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

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