Move the sources to trunk
[opencv] / autotools / aclocal / version_at_least.m4
1 # Contributed by Mark Asbach
2 # 2006-05-17, asbach@ient.rwth-aachen.de
3
4 # AC_VERSION_AT_LEAST([given-version = N[.N[.N]]],[required-version = N[.N[.N]]])
5 #
6 # Compare given-version to required-version and set ac_version_at_least to
7 # 'yes' or 'no' as the result. Nothing is AC_SUBSTed or AC_DEFINEd.
8 #
9 # Thanks to Eric Blake, Stephan Kasal, Paul Eggert and Harald Dunkel of
10 # the GNU Autoconf mailing list for providing the core implementation.
11 #
12 # Author: Mark Asbach <asbach@ient.rwth-aachen.de>
13 #
14 AC_DEFUN([AC_VERSION_AT_LEAST],[
15   # check if both parameters were given
16   if test -n "$1"; then
17     if test -n "$2"; then
18       :
19     else
20       AC_MSG_ERROR([no required-version supplied])
21     fi
22   else
23     AC_MSG_ERROR([no given-version supplied])
24   fi
25   #
26   # recombine version strings
27   tmp_both=`echo "$2
28 $1" | sed 's/\.0*/./g'`
29   tmp_sorted=`
30     echo "$tmp_both" | { 
31       # Use POSIX sort first, falling back on traditional sort.
32       sort -t. -k1,1n -k1,1 -k2,2n -k2,2 -k3,3n -k3,3 -k4,4n -k4,4 2>/dev/null || 
33       sort -t. +0n -1 +0 -1 +1n -2 +1 -2 +2n -3 +2 -3 +3n -4 +3 -4 
34     }
35   `
36   #
37   # set result value
38   if test "x$tmp_both" = "x$tmp_sorted"; then
39     ac_version_at_least=yes
40   else
41     ac_version_at_least=no
42   fi
43 ])