2009-04-20 20:00:56 +07:00
|
|
|
#!/bin/sh
|
|
|
|
|
2010-03-28 00:30:45 +07:00
|
|
|
if [ $# -eq 1 ] ; then
|
|
|
|
OUTPUT=$1
|
|
|
|
fi
|
|
|
|
|
|
|
|
GVF=${OUTPUT}PERF-VERSION-FILE
|
2009-04-20 20:00:56 +07:00
|
|
|
|
|
|
|
LF='
|
|
|
|
'
|
|
|
|
|
2012-10-30 15:54:41 +07:00
|
|
|
#
|
2010-07-05 15:00:15 +07:00
|
|
|
# First check if there is a .git to get the version from git describe
|
2012-10-30 15:54:41 +07:00
|
|
|
# otherwise try to get the version from the kernel Makefile
|
|
|
|
#
|
2013-05-08 16:43:34 +07:00
|
|
|
CID=
|
|
|
|
TAG=
|
|
|
|
if test -d ../../.git -o -f ../../.git
|
2009-04-20 20:00:56 +07:00
|
|
|
then
|
2013-05-08 16:43:34 +07: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"
|
|
|
|
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 20:00:56 +07:00
|
|
|
fi
|
|
|
|
|
|
|
|
VN=$(expr "$VN" : v*'\(.*\)')
|
|
|
|
|
|
|
|
if test -r $GVF
|
|
|
|
then
|
2013-01-16 18:59:53 +07:00
|
|
|
VC=$(sed -e 's/^#define PERF_VERSION "\(.*\)"/\1/' <$GVF)
|
2009-04-20 20:00:56 +07:00
|
|
|
else
|
|
|
|
VC=unset
|
|
|
|
fi
|
|
|
|
test "$VN" = "$VC" || {
|
|
|
|
echo >&2 "PERF_VERSION = $VN"
|
2013-01-16 18:59:53 +07:00
|
|
|
echo "#define PERF_VERSION \"$VN\"" >$GVF
|
2009-04-20 20:00:56 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|