#!/bin/bash
# Copyright (C) 2007  Frederick Emmott <mail@fredemmott.co.uk>
# This file is part of the Slamd64 Linux project (www.slamd64.com)

# Distributed under the GNU General Public License, version 2, as
# published by the Free Software Foundation.

# Firstly, find where we are
if [ `dirname $0` = "." ]; then
	HERE=`pwd`
else
	HERE=`dirname $0`
fi

# Now find the "real" gcc
RealCC=$(PATH="$(echo $PATH | sed "s#.*:\?$HERE/\?:\?##")" which `basename $0`)

# Filter out -m64 from $@
declare -a Arguments
for i; do
	case "$i" in 
		-m64)
			;;
		*)
			Arguments[${#Arguments[@]}]="$i"
			;;
	esac
done

# Compiling, call it with -m32
$RealCC -m32 "${Arguments[@]}"

# Exit with $RealCC's exit code
exit $?