#!/bin/sh
#
# RoBIOS batch file for gnu-68000-asm
#
# Bugs:
# - Linker scripts does not handle exception, using -fno-exceptions.

# Need to do this before we reset the PATH below
files=`echo $*|tr ' ' "\n"|grep -v ^-`
opts=`echo $*|tr ' ' "\n"|grep ^-`

# apapt the following path if necessary
export basedir=/user/res/uwarobot
export gccdir=$basedir/gcc-m68k
export gccparts=$gccdir/lib/gcc-lib/m68k-coff/2.7.2
export libc=$basedir/libc/include
export mc=$basedir/mc

export PATH=$gccdir/bin:/bin

export CC="m68k-coff-c++ -B$gccparts/"
export WARN="-W -Wall -ansi -pedantic"
export CPU=-m68332

export CFLAGS="$WARN -I$mc/include -I$libc  $CPU -O -fno-exceptions -msoft-float  $opts"

# run c++ for a list of .cc source files

for file in $files; do
    name=`basename $file .cc`

    echo FILE $file
    echo c-compiler
    $CC $CFLAGS -S -c $file

    echo 68332-assembler
    m68k-coff-as -o $name.o $name.s

    /bin/rm $name.s

    echo " "
done

