#!/bin/bash
# gas68 batch file
# Jacky Baltes, UWA - U Auckland - U Winnipeg, 2001

# apapt the following path if necessary
EYEBOTDIR=/user/res/uwarobot/mc
GCCDIR=/usr/local/m68k-coff/bin

# 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" ' '`

CC=$GCCDIR/m68k-coff-gcc
OBJCOPY=$GCCDIR/m68k-coff-objcopy
SREC2BIN=$GCCDIR/srec2bin

WARN="-Wall"
CPU=-m68332
LIBS="-L$EYEBOTDIR/lib -limpro -lc -lgcc -lrobi -lc"
LDSCRIPT=$EYEBOTDIR/ldfiles/robi-ram.ld

CFLAGS="-I$EYEBOTDIR/include"

# run gcc for a list of .c source files

link_only="0"

for opt in $* 
do
  if [ $opt = -c ] 
    then
        link_only="1"
        break
  fi
done

if [ $link_only = "1" ] 
then
  $CC $CPU $CFLAGS $WARN -Wa,-I$EYEBOTDIR/include,--register-prefix-optional $*
else
  $CC $CPU $CFLAGS $WARN -Wa,-I$EYEBOTDIR/include,--register-prefix-optional -Wl,--script=$LDSCRIPT $* $LIBS 
fi

