version.sh 673 B

1234567891011121314151617181920212223242526
  1. #!/bin/sh
  2. # check for git short hash
  3. revision=$(cd "$1" && git describe --always 2> /dev/null)
  4. # no revision number found
  5. test "$revision" || revision=$(cd "$1" && cat RELEASE 2> /dev/null)
  6. # releases extract the version number from the VERSION file
  7. version=$(cd "$1" && cat VERSION 2> /dev/null)
  8. test "$version" || version=$revision
  9. test -n "$3" && version=$version-$3
  10. if [ -z "$2" ]; then
  11. echo "$version"
  12. exit
  13. fi
  14. NEW_REVISION="#define LIBAV_VERSION \"$version\""
  15. OLD_REVISION=$(cat "$2" 2> /dev/null)
  16. # Update version.h only on revision changes to avoid spurious rebuilds
  17. if test "$NEW_REVISION" != "$OLD_REVISION"; then
  18. echo "$NEW_REVISION" > "$2"
  19. fi