#!/bin/sh

SYSDIR=`dirname $0`

case $1 in
'-elf' ) LD='/usr/bin/ld -m elf_i386 -rpath /lib/elf' ;
	 PRE='/usr/lib/crt1.o /usr/lib/crti.o /usr/lib/crtbegin.o' ;
	 RTS=$SYSDIR/M2RTS-elf.o ;
	 POST='/usr/lib/crtend.o /usr/lib/crtn.o'
	 shift ;;
*      ) LD='/usr/bin/ld' ;
	 PRE='/usr/lib/crt0.o' ;
	 RTS=$SYSDIR/M2RTS-aout.o ;
	 POST= ;;
esac;

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

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

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

$LD -o $program $STAT $PRE $RTS $modules $LIB $POST
