PERF-VERSION-GEN 773 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/bin/sh
  2. if [ $# -eq 1 ] ; then
  3. OUTPUT=$1
  4. fi
  5. GVF=${OUTPUT}PERF-VERSION-FILE
  6. LF='
  7. '
  8. # First check if there is a .git to get the version from git describe
  9. # otherwise try to get the version from the kernel makefile
  10. if test -d ../../.git -o -f ../../.git &&
  11. VN=$(git describe --abbrev=4 HEAD 2>/dev/null) &&
  12. case "$VN" in
  13. *$LF*) (exit 1) ;;
  14. v[0-9]*)
  15. git update-index -q --refresh
  16. test -z "$(git diff-index --name-only HEAD --)" ||
  17. VN="$VN-dirty" ;;
  18. esac
  19. then
  20. VN=$(echo "$VN" | sed -e 's/-/./g');
  21. else
  22. VN=$(MAKEFLAGS= make -sC ../.. kernelversion)
  23. fi
  24. VN=$(expr "$VN" : v*'\(.*\)')
  25. if test -r $GVF
  26. then
  27. VC=$(sed -e 's/^PERF_VERSION = //' <$GVF)
  28. else
  29. VC=unset
  30. fi
  31. test "$VN" = "$VC" || {
  32. echo >&2 "PERF_VERSION = $VN"
  33. echo "PERF_VERSION = $VN" >$GVF
  34. }