blob: c7671cd12e8b3fb2eb2f8f24af9d0cb03f7cd200 [file] [log] [blame] [raw]
#!/bin/sh
[ -n "$TMPDIR" ] && cd "$TMPDIR" || cd /tmp || exit
[ "$1" = --version ] && exec owcc -v 2>&1
flags=
[ -n "$ONLY_STAGE" ] && flags="-$ONLY_STAGE"
[ -n "$OPTIMIZATION" ] && flags="$flags -O$OPTIMIZATION"
[ -n "$DEBUG" ] && flags="$flags -g"
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"
name="${MAIN_CLASS_NAME##*/}"
[ -z "$name" ] && name=program
set -e
TMPDIR="`mktemp -d`"
trap 'cd / && rm -rf "$TMPDIR"' EXIT
cd "$TMPDIR"
cat > "$name.c"
owcc $flags "$@" "$name.c"
case "$ONLY_STAGE" in
S)
cat "$name.s"
;;
c)
cat "$name.o"
;;
"")
cat a.out
;;
esac