#!/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 $@ - printf needed so echo doesn't gobble up our arguments
# eg when calling the preprocessor (gcc -E)
Arguments=`printf "%s\n" "$*" | sed 's#-m64##'` 

# Compiling, call it with -m32
$RealCC -m32 $Arguments

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