2009-04-20 21:00:56 +08:00
|
|
|
#!/bin/sh
|
|
|
|
|
2010-03-28 01:30:45 +08:00
|
|
|
if [ $# -eq 1 ] ; then
|
|
|
|
OUTPUT=$1
|
|
|
|
fi
|
|
|
|
|
|
|
|
GVF=${OUTPUT}PERF-VERSION-FILE
|
2009-04-20 21:00:56 +08:00
|
|
|
|
|
|
|
LF='
|
|
|
|
'
|
|
|
|
|
2012-10-30 16:54:41 +08:00
|
|
|
#
|
2010-07-05 16:00:15 +08:00
|
|
|
# First check if there is a .git to get the version from git describe
|
2012-10-30 16:54:41 +08:00
|
|
|
# otherwise try to get the version from the kernel Makefile
|
|
|
|
#
|
2013-05-08 17:43:34 +08:00
|
|
|
CID=
|
|
|
|
TAG=
|
|
|
|
if test -d ../../.git -o -f ../../.git
|
2009-04-20 21:00:56 +08:00
|
|
|
then
|
2013-05-08 17:43:34 +08:00
|
|
|
TAG=$(git describe --abbrev=0 --match "v[0-9].[0-9]*" 2>/dev/null )
|
|
|
|
CID=$(git log -1 --abbrev=4 --pretty=format:"%h" 2>/dev/null) && CID="-g$CID"
|
2013-11-06 23:55:35 +08:00
|
|
|
elif test -f ../../PERF-VERSION-FILE
|
|
|
|
then
|
|
|
|
TAG=$(cut -d' ' -f3 ../../PERF-VERSION-FILE | sed -e 's/\"//g')
|
2013-05-08 17:43:34 +08:00
|
|
|
fi
|
|
|
|
if test -z "$TAG"
|
|
|
|
then
|
|
|
|
TAG=$(MAKEFLAGS= make -sC ../.. kernelversion)
|
|
|
|
fi
|
|
|
|
VN="$TAG$CID"
|
|
|
|
if test -n "$CID"
|
|
|
|
then
|
|
|
|
# format version string, strip trailing zero of sublevel:
|
|
|
|
VN=$(echo "$VN" | sed -e 's/-/./g;s/\([0-9]*[.][0-9]*\)[.]0/\1/')
|
2009-04-20 21:00:56 +08:00
|
|
|
fi
|
|
|
|
|
|
|
|
VN=$(expr "$VN" : v*'\(.*\)')
|
|
|
|
|
|
|
|
if test -r $GVF
|
|
|
|
then
|
2013-01-16 19:59:53 +08:00
|
|
|
VC=$(sed -e 's/^#define PERF_VERSION "\(.*\)"/\1/' <$GVF)
|
2009-04-20 21:00:56 +08:00
|
|
|
else
|
|
|
|
VC=unset
|
|
|
|
fi
|
|
|
|
test "$VN" = "$VC" || {
|
2013-10-09 17:49:28 +08:00
|
|
|
echo >&2 " PERF_VERSION = $VN"
|
2013-01-16 19:59:53 +08:00
|
|
|
echo "#define PERF_VERSION \"$VN\"" >$GVF
|
2009-04-20 21:00:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|