From dbb60355bba0c6fdfc4f4886cb3e3ac4fc46954d Mon Sep 17 00:00:00 2001 From: Manatsawin Hanmongkolchai Date: Sat, 27 Feb 2016 15:16:06 +0700 Subject: [PATCH] Add environment variable detection support to _autosetup --- _autosetup | 51 ++++++++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/_autosetup b/_autosetup index 3fda0ee039..2a3fc11552 100755 --- a/_autosetup +++ b/_autosetup @@ -6,7 +6,7 @@ ## 'echo -n' is not portable.. case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in *c*,-n*) ECHO_N= ECHO_C=' -' ECHO_T=' ' ;; +' ECHO_T=' ' ;; *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; *) ECHO_N= ECHO_C='\c' ECHO_T= ;; esac @@ -25,30 +25,35 @@ check_version() desired=`echo $2 | awk -F. '{print $1*100+$2}'` echo $ECHO_N "Checking version of '$1' >= $desired... $ECHO_C" name=$1 + app_var_name=`echo $name | tr '[:lower:]-' '[:upper:]_'` + if [ ! -z ${!app_var_name+x} ]; then + name=${!app_var_name} + fi + fullpath=`type $name | awk '{ print $(NF) }'`; if [ -x "$fullpath" ]; then - foundit=yes; + foundit=yes; fi if [ "$foundit" != yes ]; then - echo "Didn't find application"; - version=0 - success=no + echo "Didn't find application"; + version=0 + success=no else - cmdline="$fullpath --version"; - if version=`($cmdline 2>/dev/null)` 2>/dev/null; then - echo >/dev/null - else - version="0"; - fi - if [ -n "${version}" ]; then - version=`echo $version | awk '{ for (i=1;i<=NF;i++) { split($i,j,"."); m=j[1]*100+j[2] ; if ((m*1)>0) { print m ; break; } } }'` - if [ -z "$version" ]; then version=0; fi - success=`echo "$version" "$desired" | awk '{ if ($1 >= $2) { print "yes";} else {print "no";}} '` - else - version=0 - success=no - fi + cmdline="$fullpath --version"; + if version=`($cmdline 2>/dev/null)` 2>/dev/null; then + echo >/dev/null + else + version="0"; + fi + if [ -n "${version}" ]; then + version=`echo $version | awk '{ for (i=1;i<=NF;i++) { split($i,j,"."); m=j[1]*100+j[2] ; if ((m*1)>0) { print m ; break; } } }'` + if [ -z "$version" ]; then version=0; fi + success=`echo "$version" "$desired" | awk '{ if ($1 >= $2) { print "yes";} else {print "no";}} '` + else + version=0 + success=no + fi fi cd $dir @@ -75,11 +80,11 @@ check_version() echo >/dev/null else if check_version gmake 3.79; then - have_gmake=yes; + have_gmake=yes; else - echo "Couldn't find a new-enough version of GNU 'make', please install one!"; - echo "If you have a newer version, set the environment variable 'MAKE' to its path"; - exit 1; + echo "Couldn't find a new-enough version of GNU 'make', please install one!"; + echo "If you have a newer version, set the environment variable 'MAKE' to its path"; + exit 1; fi fi