Back to home page

OSCL-LXR

 
 

    


0001 #!/bin/sh
0002 # SPDX-License-Identifier: GPL-2.0
0003 
0004 if [ $# -eq 1 ]  ; then
0005         OUTPUT=$1
0006 fi
0007 
0008 GVF=${OUTPUT}PERF-VERSION-FILE
0009 
0010 LF='
0011 '
0012 
0013 #
0014 # Always try first to get the version from the kernel Makefile
0015 #
0016 CID=
0017 TAG=
0018 if test -d ../../.git -o -f ../../.git
0019 then
0020         TAG=$(MAKEFLAGS= make -sC ../.. kernelversion)
0021         CID=$(git log -1 --abbrev=12 --pretty=format:"%h" 2>/dev/null) && CID="-g$CID"
0022 else
0023         TAG=$(cut -d' ' -f3 ../../PERF-VERSION-FILE | sed -e 's/\"//g')
0024 fi
0025 
0026 VN="$TAG$CID"
0027 if test -n "$CID"
0028 then
0029         # format version string, strip trailing zero of sublevel:
0030         VN=$(echo "$VN" | sed -e 's/-/./g;s/\([0-9]*[.][0-9]*\)[.]0/\1/')
0031 fi
0032 
0033 VN=$(expr "$VN" : v*'\(.*\)')
0034 
0035 if test -r $GVF
0036 then
0037         VC=$(sed -e 's/^#define PERF_VERSION "\(.*\)"/\1/' <$GVF)
0038 else
0039         VC=unset
0040 fi
0041 test "$VN" = "$VC" || {
0042         echo >&2 "  PERF_VERSION = $VN"
0043         echo "#define PERF_VERSION \"$VN\"" >$GVF
0044 }
0045 
0046