PERF-VERSION-GEN 1010 B

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