You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
1.0KB

  1. #!/bin/sh
  2. # check for SVN revision number
  3. revision=$(cat snapshot_version 2> /dev/null)
  4. test $revision || revision=$(cd "$1" && LC_ALL=C svn info 2> /dev/null | grep Revision | cut -d' ' -f2)
  5. test $revision || revision=$(cd "$1" && grep revision .svn/entries 2>/dev/null | cut -d '"' -f2)
  6. test $revision || revision=$(cd "$1" && sed -n -e '/^dir$/{n
  7. p
  8. q
  9. }' .svn/entries 2>/dev/null)
  10. test $revision && revision=SVN-r$revision
  11. # check for git short hash
  12. if ! test $revision; then
  13. revision=$(cd "$1" && git log -1 --pretty=format:%h)
  14. test $revision && revision=git-$revision
  15. fi
  16. # no revision number found
  17. test $revision || revision=UNKNOWN
  18. # releases extract the version number from the VERSION file
  19. version=$(cat VERSION 2> /dev/null)
  20. test $version || version=$revision
  21. test -n "$3" && version=$version-$3
  22. NEW_REVISION="#define FFMPEG_VERSION \"$version\""
  23. OLD_REVISION=$(cat version.h 2> /dev/null)
  24. # Update version.h only on revision changes to avoid spurious rebuilds
  25. if test "$NEW_REVISION" != "$OLD_REVISION"; then
  26. echo "$NEW_REVISION" > "$2"
  27. fi