version.sh 736 B

12345678910111213141516171819202122
  1. #!/bin/sh
  2. #
  3. # This script extracts the version from the project header file
  4. #
  5. project=$1
  6. if [ ! -f include/$project.h ]; then
  7. echo "version.sh: error: include/$project.h does not exist" 1>&2
  8. exit 1
  9. fi
  10. MAJOR=`egrep '^#define .*_VERSION_MAJOR +[0-9]+$' include/$project.h`
  11. MINOR=`egrep '^#define .*_VERSION_MINOR +[0-9]+$' include/$project.h`
  12. PATCH=`egrep '^#define .*_VERSION_PATCH +[0-9]+$' include/$project.h`
  13. if [ -z "$MAJOR" -o -z "$MINOR" -o -z "$PATCH" ]; then
  14. echo "version.sh: error: could not extract version from include/$project.h" 1>&2
  15. exit 1
  16. fi
  17. MAJOR=`echo $MAJOR | awk '{ print $3 }'`
  18. MINOR=`echo $MINOR | awk '{ print $3 }'`
  19. PATCH=`echo $PATCH | awk '{ print $3 }'`
  20. echo $MAJOR.$MINOR.$PATCH | tr -d '\n'