#!/bin/bash

if [ $1 == "default" ]; then
	# Do nothing and assume this is SLES9 with default compiler
echo "DEBUG default compiler, no installation"
elif [ $2 == "tor" ]; then
	echo " downloading Toronto compiler..."
	mkdir /TorCompiler
	wget -q -O /TorCompiler/$1 ausgsa.ibm.com/projects/l/ltcperformance/benchmarks/compilers/$1
        if [$? -ne 0 ]; then
                echo "can't find the Toronto compiler source!!!"
                echo "Exiting...."
                exit 1
        fi
	wget -q -O /TorCompiler/installscript ausgsa.ibm.com/projects/l/ltcperformance/benchmarks/compilers/installscript
	if [$? -ne 0 ]; then
		echo "can't find the Toronto compiler installation script!!!"
		echo "Exiting...."
		exit 1
	fi

	pushd /TorCompiler > /dev/null 
	tar xzf *.tgz 
	rpm -i *.rpm

	./installscript | /opt/ibmcmp/vac/*/bin/new_install
	./installscript | /opt/ibmcmp/xlf/*/bin/new_install
	popd > /dev/null

else
	mkdir /gcc
        wget -q -O /gcc/$1 ausgsa.ibm.com/projects/l/ltcperformance/benchmarks/compilers/$1
	pushd /gcc / /dev/null
	tar xzf $1
	popd > /dev/null
fi


