blob: ac418a1255e6c2b715b94fbc71239f1a73283cd1 [file] [log] [blame]
Ingo Molnar07800602009-04-20 15:00:56 +02001#!/bin/sh
2
Arnaldo Carvalho de Meloc29ede62010-03-27 14:30:45 -03003if [ $# -eq 1 ] ; then
4 OUTPUT=$1
5fi
6
7GVF=${OUTPUT}PERF-VERSION-FILE
Ingo Molnar07800602009-04-20 15:00:56 +02008
9LF='
10'
11
Ingo Molnar0e2af952012-10-30 09:54:41 +010012#
Thavidu Ranatunga869599c2010-07-05 18:00:15 +100013# First check if there is a .git to get the version from git describe
Ingo Molnar0e2af952012-10-30 09:54:41 +010014# otherwise try to get the version from the kernel Makefile
15#
Thavidu Ranatunga869599c2010-07-05 18:00:15 +100016if test -d ../../.git -o -f ../../.git &&
Ingo Molnar0e2af952012-10-30 09:54:41 +010017 VN=$(echo $(git tag -l "v[0-9].[0-9]*" | tail -1)"-g"$(git log -1 --abbrev=4 --pretty=format:"%h" HEAD) 2>/dev/null)
Ingo Molnar07800602009-04-20 15:00:56 +020018then
19 VN=$(echo "$VN" | sed -e 's/-/./g');
20else
Andy Whitcroft37aa9a22011-06-15 14:35:00 +010021 VN=$(MAKEFLAGS= make -sC ../.. kernelversion)
Ingo Molnar07800602009-04-20 15:00:56 +020022fi
23
24VN=$(expr "$VN" : v*'\(.*\)')
25
26if test -r $GVF
27then
28 VC=$(sed -e 's/^PERF_VERSION = //' <$GVF)
29else
30 VC=unset
31fi
32test "$VN" = "$VC" || {
33 echo >&2 "PERF_VERSION = $VN"
34 echo "PERF_VERSION = $VN" >$GVF
35}
36
37