#!/bin/sh
# @(#)apold	1.5 09/18/91 CERN CN-SW/DC Frederic Hemmer
#
echo "SHIFT apollo/Ultra loader"
tempfile=/tmp/bind.tmp$$
library=/lib/clib
userlibs=""
userpath=""
while [ x"$1" != x ]; do
	case $1 in
		-x) set -x
		    shift
		    continue;;
		-o) binary=$2
		    shift
		    shift
		    continue;;
		-m) map="-map "
		    shift
		    continue;;
		-ultra) ultra="-luutil -lulsock "
		    shift
		    continue;;
		-ftn) ftnlibs="-lU77 -lF77 -lI77 "
                    shift
                    continue;;
		-l*) userlibs="$userlibs $1"
                    shift
                    continue;;
		-L*) userpath="$userpath $1"
                    shift
                    continue;;
		*) objects="$objects $1"
		   if [ ! -f $1 ]; then
			echo "No such file: $1";
			exit 1;
		   fi
		    shift
		    continue;;
	esac
done
if [ x"$binary" = x ]; then
	echo "No destination file";
	exit 1;
fi
ld -A cpu,$ISP -r -o $tempfile /usr/lib/crt0.o $objects $userpath $userlibs $ftnlibs $ultra
/com/bind -allmark -allkeepmark -allocbs -nomultires -nomessage $map -binary $binary $tempfile $library
chmod +x $binary
rm -f $tempfile
