PERF-VERSION-GEN 729 B

1234567891011121314151617181920212223242526272829303132333435363738
  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. if test -d ../../.git -o -f ../../.git &&
  13. VN=$(git tag 2>/dev/null | tail -1 | grep -E "v[0-9].[0-9]*")
  14. then
  15. VN=$(echo $VN"-g"$(git log -1 --abbrev=4 --pretty=format:"%h" HEAD))
  16. VN=$(echo "$VN" | sed -e 's/-/./g');
  17. else
  18. VN=$(MAKEFLAGS= make -sC ../.. kernelversion)
  19. fi
  20. VN=$(expr "$VN" : v*'\(.*\)')
  21. if test -r $GVF
  22. then
  23. VC=$(sed -e 's/^#define PERF_VERSION "\(.*\)"/\1/' <$GVF)
  24. else
  25. VC=unset
  26. fi
  27. test "$VN" = "$VC" || {
  28. echo >&2 "PERF_VERSION = $VN"
  29. echo "#define PERF_VERSION \"$VN\"" >$GVF
  30. }