#!/bin/sh
#
# RoBIOS batch file for gnu-68000-asm

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

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

export PATH=$gccdir/bin:/bin

export CC="m68k-coff-gcc -B$gccparts/"
export WARN="-W -Wall -ansi -pedantic"
export CPU=-m68332
export LIBS="-limpro -lmym -lmyc -lmygcc -lrobi"
export TMP=/tmp
export LDSCRIPT=-T$mc/ldfiles/robi-ram.ld

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

# run gcc for a list of .c source files

for file in $files; do
    name=`basename $file .c`
    tmpfile=$TMP/$name

    echo FILE $file
    echo c-compiler
    if $CC $CFLAGS -S -c $file
    then true; else
      echo "Error: c-compiler failed"
    fi

    echo 68332-assembler
    if m68k-coff-as -o $name.o $name.s
    then true; else
      echo "Error: 68332-assembler failed"
    fi

    /bin/rm $name.s

    echo " "
done
