| 1 | #!/bin/shscip-shell filesystem . . `/bin/sh`. |
| 2 | # SPDX-License-Identifier: GPL-2.0 |
| 3 | |
| 4 | if [scip-shell system . . `[`. $# -eq 1 ] ; then |
| 5 | OUTPUT=$1 |
| 6 | fi |
| 7 | |
| 8 | GVF=${OUTPUT}PERF-VERSION-FILE |
| 9 | |
| 10 | LF=' |
| 11 | ' |
| 12 | |
| 13 | # |
| 14 | # Use version from kernel Makefile unless not in a git repository and |
| 15 | # PERF-VERSION-FILE exists |
| 16 | # |
| 17 | CID= |
| 18 | TAG= |
| 19 | if testscip-shell system . . test. -d ../../.git -o -f ../../.git |
| 20 | then |
| 21 | TAG=$(MAKEFLAGS= makescip-shell system . . make. -sC ../.. kernelversion) |
| 22 | CID=$(gitscip-shell system . . git. log -1 --abbrev=12 --pretty=format:"%h" --no-show-signature 2>/dev/nullscip-shell filesystem . . `/dev/null`.) && CID="-g$CID" |
| 23 | elif testscip-shell system . . test. -f ../../PERF-VERSION-FILE |
| 24 | then |
| 25 | TAG=$(cutscip-shell system . . cut. -d' ' -f3 ../../PERF-VERSION-FILE | sedscip-shell system . . sed. -e 's/\"//g') |
| 26 | fi |
| 27 | if testscip-shell system . . test. -z "$TAG" |
| 28 | then |
| 29 | TAG=$(MAKEFLAGS= makescip-shell system . . make. -sC ../.. kernelversion) |
| 30 | fi |
| 31 | |
| 32 | VN="$TAG$CID" |
| 33 | if testscip-shell system . . test. -n "$CID" |
| 34 | then |
| 35 | # format version string, strip trailing zero of sublevel: |
| 36 | VN=$(echoscip-shell system . . echo. "$VN" | sedscip-shell system . . sed. -e 's/-/./g;s/\([0-9]*[.][0-9]*\)[.]0/\1/') |
| 37 | fi |
| 38 | |
| 39 | VN=$(exprscip-shell system . . expr. "$VN" : v*'\(.*\)') |
| 40 | |
| 41 | if testscip-shell system . . test. -r $GVF |
| 42 | then |
| 43 | VC=$(sedscip-shell system . . sed. -e 's/^#define PERF_VERSION "\(.*\)"/\1/' <$GVF) |
| 44 | else |
| 45 | VC=unset |
| 46 | fi |
| 47 | testscip-shell system . . test. "$VN" = "$VC" || { |
| 48 | echoscip-shell system . . echo. >&2 " PERF_VERSION = $VN" |
| 49 | echoscip-shell system . . echo. "#define PERF_VERSION \"$VN\"" >$GVF |
| 50 | } |
| 51 | |
| 52 |