#!/bin/sh
output=a.out
files=
verbose=
opt=
syms=
usage="Usage: plink <object file> ... [-o outputfile | ^outputfile]"

if [ x$hosttype = x ]; then
	hosttype=`/bin/athena/machtype`
fi
if [ $hosttype != inbsd ]; then
	libbsd=-lbsd
fi

if [ $# = 0 ]; then echo $usage; exit 2; fi
CLUHOME=${CLUHOME-/mit/PCLU/inbsdlib}
while [ $# != 0 ];
do
    case "$1" in
	\^*) output=`echo "$1" | sed 's/^\\^//'`;;
	-opt) opt=y;;
	-o*) output=`echo "$1" | sed 's/^-o//'`
	     test -n "$output"
	     if [ $? != 0 ]; then
		shift || exit 2
		output=$1
	     fi;;
	-v*) verbose=y;;
	-prof*) syms=-p;;
	-*) echo $usage; exit 2;;
	*) files="$files $1";;
    esac
    if [ $# -ge 1 ]; then shift; fi
done
if [ -n "$opt" ] ; then
    if [ -n "$verbose" ]; then
        echo cc $syms -o $output $files -L$CLUHOME/code -L/usr/athena/lib -lpclu_opt -lm $libbsd
    fi
    cc $syms -o $output $files -L$CLUHOME/code -L/usr/athena/lib -lpclu_opt -lm $libbsd
    exit;
fi
if [ -n "$verbose" ]; then
    echo cc $syms -o $output $files -L$CLUHOME/code -L/usr/athena/lib -lpclu -lm $libbsd
fi
cc $syms -o $output $files -L$CLUHOME/code -L/usr/athena/lib -lpclu -lm $libbsd

