| 1 | #!/bin/sh |
| 2 | |
| 3 | if [ $# -eq 1 ] ; then |
| 4 | OUTPUT=$1 |
| 5 | fi |
| 6 | |
| 7 | GVF=${OUTPUT}PERF-VERSION-FILE |
| 8 | |
| 9 | LF=' |
| 10 | ' |
| 11 | |
| 12 | # |
| 13 | # First check if there is a .git to get the version from git describe |
| 14 | # otherwise try to get the version from the kernel Makefile |
| 15 | # |
| 16 | if test -d ../../.git -o -f ../../.git && |
| 17 | VN=$(git tag 2>/dev/null | tail -1 | grep -E "v[0-9].[0-9]*") |
| 18 | then |
| 19 | VN=$(echo $VN"-g"$(git log -1 --abbrev=4 --pretty=format:"%h" HEAD)) |
| 20 | VN=$(echo "$VN" | sed -e 's/-/./g'); |
| 21 | else |
| 22 | VN=$(MAKEFLAGS= make -sC ../.. kernelversion) |
| 23 | fi |
| 24 | |
| 25 | VN=$(expr "$VN" : v*'\(.*\)') |
| 26 | |
| 27 | if test -r $GVF |
| 28 | then |
| 29 | VC=$(sed -e 's/^#define PERF_VERSION "\(.*\)"/\1/' <$GVF) |
| 30 | else |
| 31 | VC=unset |
| 32 | fi |
| 33 | test "$VN" = "$VC" || { |
| 34 | echo >&2 "PERF_VERSION = $VN" |
| 35 | echo "#define PERF_VERSION \"$VN\"" >$GVF |
| 36 | } |
| 37 | |
| 38 | |