1 # Compare two strings possibly containing shell variables as version strings.
4 # Derek R. Price, Ximbiot <http://ximbiot.com>,
5 # and the Free Software Foundation, Inc.
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2, or (at your option)
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
22 # ASX_VERSION_COMPARE(VERSION-1, VERSION-2,
23 # [ACTION-IF-LESS], [ACTION-IF-EQUAL], [ACTION-IF-GREATER])
24 # -----------------------------------------------------------------------------
25 # Compare two strings possibly containing shell variables as version strings.
26 AC_DEFUN([ASX_VERSION_COMPARE],
27 [if test "x[$1]" = "x[$2]"; then
28 # the strings are equal. run ACTION-IF-EQUAL and bail
30 m4_ifvaln([$3$5], [else
31 # first unletter the versions
32 # this only works for a single trailing letter
33 dnl echo has a double-quoted arg to allow for shell expansion.
34 asx_version_1=`echo "[$1]" |
35 sed 's/\([abcedfghi]\)/.\1/;
36 s/\([jklmnopqrs]\)/.1\1/;
37 s/\([tuvwxyz]\)/.2\1/;
38 y/abcdefghijklmnopqrstuvwxyz/12345678901234567890123456/;'`
39 asx_version_2=`echo "[$2]" |
40 sed 's/\([abcedfghi]\)/.\1/;
41 s/\([jklmnopqrs]\)/.1\1/;
42 s/\([tuvwxyz]\)/.2\1/;
43 y/abcdefghijklmnopqrstuvwxyz/12345678901234567890123456/;'`
48 for vsub1 in $asx_version_1; do
49 vsub2=`echo "$asx_version_2" |awk -F. "{print \\\$$asx_count}"`
50 if test -z "$vsub2" || test $vsub1 -gt $vsub2; then
53 elif test $vsub1 -lt $vsub2; then
56 asx_count=`expr $asx_count + 1`
59 if test $asx_retval -eq -1; then
65 ]) # ASX_VERSION_COMPARE