version.sh 722 B

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