#!/bin/sh

WRAPPER=sb_gcc_wrapper

PROGRAMS="addr2line ar as c++ c++filt cpp g++ g++-3.3 g++-3.4 g++-4.0 g++-4.1 g++-4.2 g++-4.3 gcc gcc-3.3 gcc-3.4 gcc-4.0 gcc-4.1 gcc-4.2 gcc-4.3 cc gccbug gcov ld nm objcopy objdump ranlib readelf size strings strip dlltool windres dllwrap"

PREFICES="host- arm-linux- arm-linux-gnueabi- i386-linux- i486-linux-gnu- i686-linux- powerpc-linux- mips-linux- i386-pc- i386-pc-mingw32- mingw32- i586-pc-mingw32-"

if [ x"$SBOX_UTILS_DIR" = x ]; then
	SBOX_UTILS_DIR="/scratchbox/compilers/bin";
fi

function do_links()
{
	for PROG in $PROGRAMS; do
		ln -sf $WRAPPER $PROG
		for PREFIX in $PREFICES; do
			ln -sf $WRAPPER $PREFIX$PROG
		done
	done
}

function remove_links()
{
	for PROG in $PROGRAMS; do
		rm -f $PROG
		for PREFIX in $PREFICES; do
			rm -f $PREFIX$PROG
		done
	done
}



case $1 in
	create)
		do_links;
		;;
	remove)
		remove_links;
		;;
	*)
		echo "usage: ${0/*\//} [create | remove]";
		exit 1;
		;;
esac

