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