From: Chirantan E. <chi...@gm...> - 2013-01-16 00:24:56
|
Added a version comparison function to properly check if the installed version of automake is higher than the required version. Signed-off-by: Chirantan Ekbote <chi...@gm...> --- autogen.sh | 40 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/autogen.sh b/autogen.sh index 69f4f0a..26dd399 100755 --- a/autogen.sh +++ b/autogen.sh @@ -4,11 +4,42 @@ AC_VERSION= AUTOMAKE=${AUTOMAKE:-automake} AM_INSTALLED_VERSION=$($AUTOMAKE --version | sed -e '2,$ d' -e 's/.* \([0-9]*\.[0-9]*\).*/\1/') -# FIXME: we need a better way for version check later. -if [ "$AM_INSTALLED_VERSION" != "1.10" \ - -a "$AM_INSTALLED_VERSION" != "1.11" \ - -a "$AM_INSTALLED_VERSION" != "1.12" ];then +# Source: http://stackoverflow.com/a/4025065w +vercomp () { + if [[ $1 == $2 ]] + then + return 0 + fi + local IFS=. + local i ver1=($1) ver2=($2) + # fill empty fields in ver1 with zeros + for ((i=${#ver1[@]}; i<${#ver2[@]}; i++)) + do + ver1[i]=0 + done + for ((i=0; i<${#ver1[@]}; i++)) + do + if [[ -z ${ver2[i]} ]] + then + # fill empty fields in ver2 with zeros + ver2[i]=0 + fi + if ((10#${ver1[i]} > 10#${ver2[i]})) + then + # $1 is greater + return 1 + fi + if ((10#${ver1[i]} < 10#${ver2[i]})) + then + # $2 is greater + return 2 + fi + done + return 0 +} + +vercomp $AM_INSTALLED_VERSION 1.11 +if [[ $? == 2 ]];then echo echo "You must have automake > 1.10 or 1.11 installed." echo "Install the appropriate package for your distribution," -- 1.8.1 |