cd $root/src

notice "$MENUTRUE" "Looking for wget..."
if [ -x /bin/wget ] || [ -x /usr/bin/wget ] || [ -x /usr/local/bin/wget ] || [ -x wget ] || [ -x /opt/sfw/bin/wget ] || [ -x $HOME/bin/wget ]
then
 echo " [$DONE]"
 wth WGET wget


for i in / /usr /usr/local /opt/sfw $HOME; do
	test -x $i/bin/wget && WGET_DIR=$i
done


else
 echo " [$TXT_FALSE]"
 echo " WGet utility not installed..."

IsYNLoop "Do you want to try and download it right now with lynx and install it?"
        case "$?" in
            $NO)
                echo -e "Moving on without wget, please make sure all the sources you'll need are in \"$root/src\"!\n
		You can get them from http://www.apachetoolbox.com/data/cvs/src/ if you need to."
                HitAnyKey
                ;;
            $YES)


	  if [ ! -f wget-$WGET.tar.gz ]; then
	   echo "wget-$WGET.tar.gz detection failed, downloading..."
	   $LYNX -dump ftp://ftp.gnu.org/gnu/wget/wget-$WGET.tar.gz > wget-$WGET.tar.gz
	  fi

	  if [ ! -f wget-$WGET.tar.gz ]; then
	   echo "wget-$WGET.tar.gz download failed from ftp.gnu.org, trying from apachetoolbox.com..."
	   $LYNX -dump http://www.apachetoolbox.com/data/cvs/src/wget-$WGET.tar.gz > wget-$WGET.tar.gz
	  fi

	  if [ ! -f wget-$WGET.tar.gz ]; then
	   echo "failed to download wget-$WGET.tar.gz from anywhere. exiting."
	   exit 1
	  fi


	 explode "wget-$WGET.tar.gz"
	 echo uncompressed wget...
	 cd wget-$WGET

	notice $MENUTRUE " Configuring..."
	 ./configure --prefix=$LOCAL_PATH > $logdir/wget-configure.log
	 testcheck $? wget-configure.log
	echo " [$DONE]"

	notice $MENUTRUE " Compiling..."
	 $MAKE > $logdir/wget-compile.log
	 testcheck $? wget-compile.log
	echo " [$DONE]"

	notice $MENUTRUE " Installing into $LOCAL_PATH..."
	 inst wget
	 testcheck $? wget-install.log
	echo " [$DONE]"

	 cd ..
	 rm -rf $root/src/wget-$WGET
	 if [ ! -x $LOCAL_PATH/bin/wget ];then notice "$MENUFALSE" "WGet was't automatically installed, manually install it.\n"; exit; fi
     ;;
        esac

fi
cd $root
