#!/bin/sh

. /etc/profile
. /etc/flenv

if [ -z $1 ]; then
	echo -n "select gcc major version [3,4]: "
	read gccver
else
	gccver=$1
fi

if [ "x$gccver" != "x3" ] && [ "x$gccver" != "x4" ]; then
	echo "ERROR: gcc major version must be 3 or 4"
	exit 1
fi

sevenz="$sevenzapath x -r -aoa -o$mingwpath"
gccarc=`find $flpath/gcc -maxdepth 1 -type f -name gcc-$gccver.\*.7z`
if [ -n "$gccarc" ] && [ -f "$gccarc" ]; then
	$sevenz $gccarc
else
	echo "ERROR: gcc archive does not exist"
	exit 1
fi

echo "INFO: gcc$gccver is now installed"
