libversion.sh 604 B

123456789101112131415161718
  1. #!/bin/sh
  2. toupper(){
  3. echo "$@" | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
  4. }
  5. name=lib$1
  6. ucname=$(toupper ${name})
  7. file=$2
  8. file2=$3
  9. eval $(awk "/#define ${ucname}_VERSION_M/ { print \$2 \"=\" \$3 }" "$file")
  10. if [ -f "$file2" ]; then
  11. eval $(awk "/#define ${ucname}_VERSION_M/ { print \$2 \"=\" \$3 }" "$file2")
  12. fi
  13. eval ${ucname}_VERSION=\$${ucname}_VERSION_MAJOR.\$${ucname}_VERSION_MINOR.\$${ucname}_VERSION_MICRO
  14. eval echo "${name}_VERSION=\$${ucname}_VERSION"
  15. eval echo "${name}_VERSION_MAJOR=\$${ucname}_VERSION_MAJOR"
  16. eval echo "${name}_VERSION_MINOR=\$${ucname}_VERSION_MINOR"