PageRenderTime 46ms CodeModel.GetById 8ms RepoModel.GetById 0ms app.codeStats 0ms

/trunk/Tools/config/ac_compare_version.m4

#
m4 | 40 lines | 37 code | 2 blank | 1 comment | 0 complexity | 96cd3b2a4ea63f33e8b5f7f9dbffc726 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. dnl @synopsis AC_COMPARE_VERSION\
  2. dnl (version-a, version-b, action-if-greater, action-if-equal, action-if-less)
  3. dnl
  4. dnl This macro compares two version numbers and executes the indicated action
  5. dnl based on whether they're equal or one is greater than the other.
  6. dnl It's needed to determine whether ocaml is new enough that the incompatible
  7. dnl change 'loc' -> '_loc' is present in this version of camlp4.
  8. dnl
  9. dnl It's implemented from scratch just for SWIG by arty.
  10. dnl
  11. dnl @category Misc
  12. dnl @author arty
  13. dnl @version 2006-11-02
  14. dnl @license GPLWithACException
  15. AC_DEFUN([AC_COMPARE_VERSION], [
  16. # Split the version into units.
  17. ver_a="[$1]"
  18. ver_b="[$2]"
  19. nodots_a=`echo $ver_a | sed -e 's/\./ /g'`
  20. condition="equal"
  21. isolate_b_regex='\([[0-9]]\+\).*'
  22. for ver_part in $nodots_a ; do
  23. b_ver_part=`echo "$ver_b" | sed -e 's/'"$isolate_b_regex"'/\1/'`
  24. if test \( "$ver_part" -lt "$b_ver_part" \) -a \( "x$condition" == "xequal" \) ; then
  25. condition=less
  26. elif test \( "$ver_part" -gt "$b_ver_part" \) -a \( "x$condition" == "xequal" \) ; then
  27. condition=greater
  28. fi
  29. isolate_b_regex='[[0-9]]\+\.'"$isolate_b_regex"
  30. done
  31. if test "x$condition" == "xequal" ; then
  32. [$4]
  33. elif test "x$condition" == "xless" ; then
  34. [$3]
  35. elif test "x$condition" == "xgreater" ; then
  36. [$5]
  37. fi
  38. ])