Merge branch 'x86-mm-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[pandora-kernel.git] / tools / perf / util / PERF-VERSION-GEN
1 #!/bin/sh
2
3 if [ $# -eq 1 ]  ; then
4         OUTPUT=$1
5 fi
6
7 GVF=${OUTPUT}PERF-VERSION-FILE
8 DEF_VER=v0.0.2.PERF
9
10 LF='
11 '
12
13 # First see if there is a version file (included in release tarballs),
14 # then try git-describe, then default.
15 if test -f version
16 then
17         VN=$(cat version) || VN="$DEF_VER"
18 elif test -d .git -o -f .git &&
19         VN=$(git describe --abbrev=4 HEAD 2>/dev/null) &&
20         case "$VN" in
21         *$LF*) (exit 1) ;;
22         v[0-9]*)
23                 git update-index -q --refresh
24                 test -z "$(git diff-index --name-only HEAD --)" ||
25                 VN="$VN-dirty" ;;
26         esac
27 then
28         VN=$(echo "$VN" | sed -e 's/-/./g');
29 else
30         VN="$DEF_VER"
31 fi
32
33 VN=$(expr "$VN" : v*'\(.*\)')
34
35 if test -r $GVF
36 then
37         VC=$(sed -e 's/^PERF_VERSION = //' <$GVF)
38 else
39         VC=unset
40 fi
41 test "$VN" = "$VC" || {
42         echo >&2 "PERF_VERSION = $VN"
43         echo "PERF_VERSION = $VN" >$GVF
44 }
45
46