#!/bin/sh

SYSDIR=`dirname $0`

case $1 in
'-elf' ) echo 'ELF format not supported' ;
	 exit 1 ;;
*      ) LD='/usr/bin/ld' ;
	 PRE='/usr/lib/crt0.o' ;
	 RTS=$SYSDIR/M2RTS.o ;
	 POST= ;;
esac;

case $1 in
'-static' ) STAT='-Bstatic' ; shift ;;
*         ) STAT= ;;
esac;

case $1 in
'-g' ) LIB='-lc' ; shift ;;
*    ) LIB='-lc' ;;
esac;

program=$1 ; shift ; modules="$*"

$LD -e start -dp -o $program $STAT $PRE $RTS $modules $LIB -lgcc $POST
