#!/bin/sh

[ "$1" = --version ] && exec /usr/local/bin/icc --version

flags="-m64 -Wall -x c"
[ -n "$DEBUG" ] && flags="$flags -g"
[ -z "$OPTIMIZATION" ] && OPTIMIZATION=0
flags="$flags -O$OPTIMIZATION"
for d in $DEFINE; do flags="-D $d $flags"; done
for d in $UNDEFINE; do flags="-U $d $flags"; done
[ -n "$VERBOSE" ] && flags="$flags -v"
[ -n "$ONLY_STAGE" ] && exec /usr/local/bin/icc $flags -$ONLY_STAGE "$@" - -o /dev/stdout
output_file="`mktemp -t icc.XXXXXXXX`" || exit
/usr/local/bin/icc $flags "$@" - -o "$output_file"
r=$?
if [ $r = 0 ]; then
	cat "$output_file" || r=1
fi
rm -f "$output_file"
exit $r
