#!/bin/sh

while [ "$*" != "" ]; do
        arg=$1; shift
        case $arg in
		-o)
			outputfile="$1"; shift
			;;
		-g)
			;;
		-Os)	
			;;
		-f*)
			;;
		--std=*)
			;;
		--target-help)
			options="$options --help"
			;;
		-S)
			options="$options -c"
			;;
		-*)
			options="$options $arg"
			;;
		*)
			inputfile="$arg"
			;;
	esac
done

if [ -n "$inputfile" ]; then
	inputname=$(basename "$inputfile")
	cmocoutput="${inputname%%.c}.asm"
fi

cmoc $options "$inputfile"
ret=$?

if [ $ret = 0 -a -n "$outputfile" ]; then
	mv $cmocoutput $outputfile
fi
exit $ret
