PERF-VERSION-GEN 901 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. fi
  19. if test -z "$TAG"
  20. then
  21. TAG=$(MAKEFLAGS= make -sC ../.. kernelversion)
  22. fi
  23. VN="$TAG$CID"
  24. if test -n "$CID"
  25. then
  26. # format version string, strip trailing zero of sublevel:
  27. VN=$(echo "$VN" | sed -e 's/-/./g;s/\([0-9]*[.][0-9]*\)[.]0/\1/')
  28. fi
  29. VN=$(expr "$VN" : v*'\(.*\)')
  30. if test -r $GVF
  31. then
  32. VC=$(sed -e 's/^#define PERF_VERSION "\(.*\)"/\1/' <$GVF)
  33. else
  34. VC=unset
  35. fi
  36. test "$VN" = "$VC" || {
  37. echo >&2 "PERF_VERSION = $VN"
  38. echo "#define PERF_VERSION \"$VN\"" >$GVF
  39. }