version.sh 738 B

1234567891011121314151617181920212223242526272829
  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. test "$revision" && revision=git-$revision
  6. fi
  7. # no revision number found
  8. test "$revision" || revision=UNKNOWN
  9. # releases extract the version number from the VERSION file
  10. version=$(cd "$1" && cat VERSION 2> /dev/null)
  11. test "$version" || version=$revision
  12. test -n "$3" && version=$version-$3
  13. if [ -z "$2" ]; then
  14. echo "$version"
  15. exit
  16. fi
  17. NEW_REVISION="#define FFMPEG_VERSION \"$version\""
  18. OLD_REVISION=$(cat version.h 2> /dev/null)
  19. # Update version.h only on revision changes to avoid spurious rebuilds
  20. if test "$NEW_REVISION" != "$OLD_REVISION"; then
  21. echo "$NEW_REVISION" > "$2"
  22. fi