abi_version.sh 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #!/bin/sh
  2. # Copyright (c) 2013 Luca Barbato
  3. #
  4. # Permission is hereby granted, free of charge, to any person obtaining a copy
  5. # of this software and associated documentation files (the "Software"),
  6. # to deal in the Software without restriction, including without limitation
  7. # the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. # and/or sell copies of the Software, and to permit persons to whom
  9. # the Software is furnished to do so, subject to the following conditions:
  10. #
  11. # The above copyright notice and this permission notice shall be included
  12. # in all copies or substantial portions of the Software.
  13. #
  14. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  17. # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. # IN THE SOFTWARE.
  21. version="include/bdsm.h"
  22. PREFIX="BDSM"
  23. if [ ! -f $version ]; then
  24. echo "abi_version.sh: error: $version does not exist" 1>&2
  25. exit 1
  26. fi
  27. CURRENT=`egrep "^#define +${PREFIX}_VERSION_CURRENT +[0-9]+$" $version`
  28. REVISION=`egrep "^#define +${PREFIX}_VERSION_REVISION +[0-9]+$" $version`
  29. AGE=`egrep "^#define +${PREFIX}_VERSION_AGE +[0-9]+$" $version`
  30. if [ -z "$CURRENT" -o -z "$REVISION" -o -z "$AGE" ]; then
  31. echo "abi_version.sh: error: could not extract version from $version" 1>&2
  32. exit 1
  33. fi
  34. CURRENT=`echo $CURRENT | awk '{ print $3 }'`
  35. REVISION=`echo $REVISION | awk '{ print $3 }'`
  36. AGE=`echo $AGE | awk '{ print $3 }'`
  37. case $1 in
  38. -libtool)
  39. printf '%s' "$CURRENT:$REVISION:$AGE"
  40. ;;
  41. *)
  42. printf '%s' "$CURRENT.$REVISION.$AGE"
  43. ;;
  44. esac