| Ingo Molnar | 0780060 | 2009-04-20 15:00:56 +0200 | [diff] [blame] | 1 | #!/bin/sh | 
 | 2 |  | 
| Arnaldo Carvalho de Melo | c29ede6 | 2010-03-27 14:30:45 -0300 | [diff] [blame] | 3 | if [ $# -eq 1 ]  ; then | 
 | 4 | 	OUTPUT=$1 | 
 | 5 | fi | 
 | 6 |  | 
 | 7 | GVF=${OUTPUT}PERF-VERSION-FILE | 
| Ingo Molnar | 0780060 | 2009-04-20 15:00:56 +0200 | [diff] [blame] | 8 |  | 
 | 9 | LF=' | 
 | 10 | ' | 
 | 11 |  | 
| Ingo Molnar | 0e2af95 | 2012-10-30 09:54:41 +0100 | [diff] [blame] | 12 | # | 
| Thavidu Ranatunga | 869599c | 2010-07-05 18:00:15 +1000 | [diff] [blame] | 13 | # First check if there is a .git to get the version from git describe | 
| Ingo Molnar | 0e2af95 | 2012-10-30 09:54:41 +0100 | [diff] [blame] | 14 | # otherwise try to get the version from the kernel Makefile | 
 | 15 | # | 
| Thavidu Ranatunga | 869599c | 2010-07-05 18:00:15 +1000 | [diff] [blame] | 16 | if test -d ../../.git -o -f ../../.git && | 
| Arnaldo Carvalho de Melo | 688b2c2 | 2012-10-30 13:44:40 -0200 | [diff] [blame] | 17 | 	VN=$(git tag 2>/dev/null | tail -1 | grep -E "v[0-9].[0-9]*") | 
| Ingo Molnar | 0780060 | 2009-04-20 15:00:56 +0200 | [diff] [blame] | 18 | then | 
| Arnaldo Carvalho de Melo | 688b2c2 | 2012-10-30 13:44:40 -0200 | [diff] [blame] | 19 | 	VN=$(echo $VN"-g"$(git log -1 --abbrev=4 --pretty=format:"%h" HEAD)) | 
| Ingo Molnar | 0780060 | 2009-04-20 15:00:56 +0200 | [diff] [blame] | 20 | 	VN=$(echo "$VN" | sed -e 's/-/./g'); | 
 | 21 | else | 
| Andy Whitcroft | 37aa9a2 | 2011-06-15 14:35:00 +0100 | [diff] [blame] | 22 | 	VN=$(MAKEFLAGS= make -sC ../.. kernelversion) | 
| Ingo Molnar | 0780060 | 2009-04-20 15:00:56 +0200 | [diff] [blame] | 23 | fi | 
 | 24 |  | 
 | 25 | VN=$(expr "$VN" : v*'\(.*\)') | 
 | 26 |  | 
 | 27 | if test -r $GVF | 
 | 28 | then | 
| Namhyung Kim | 3cecaa2 | 2013-01-16 20:59:53 +0900 | [diff] [blame] | 29 | 	VC=$(sed -e 's/^#define PERF_VERSION "\(.*\)"/\1/' <$GVF) | 
| Ingo Molnar | 0780060 | 2009-04-20 15:00:56 +0200 | [diff] [blame] | 30 | else | 
 | 31 | 	VC=unset | 
 | 32 | fi | 
 | 33 | test "$VN" = "$VC" || { | 
 | 34 | 	echo >&2 "PERF_VERSION = $VN" | 
| Namhyung Kim | 3cecaa2 | 2013-01-16 20:59:53 +0900 | [diff] [blame] | 35 | 	echo "#define PERF_VERSION \"$VN\"" >$GVF | 
| Ingo Molnar | 0780060 | 2009-04-20 15:00:56 +0200 | [diff] [blame] | 36 | } | 
 | 37 |  | 
 | 38 |  |