
o=a.com P= Q= S= C= O="-DIBMDOS -Uvax -Dibm"
X= Y=crt1.d Z=
trap "rm -f $T.i $T.b86; exit 1" 1 2 15

for A in $*
do
	if test $o
	then
	case $A in
	-P)	P=XXX; set O="$O -P" ;;
	-S)	S=XXX ;;
	-O)	Q=XXX ;;
	-c)	C=XXX ;;
	-p)	X="-Xp" Y=/nial/lib86/mcrt0.b ;;
	-o)	o= ;;
	-[IDU]*)        O="$O $A" ;;
	-*)     echo >&2 "bad bb86 option: $A"; exit 1;;
	*.d)	Z="$Z $A" ;;
	*.b86)	T=`basename $A .b86`
		/user/staff/ofarrell/8086/a86/a86 $T
		Z="$Z $T.d";;
	*.c)	T=`basename $A .c`
		if /lib/cpp -I/user/staff/ofarrell/lib86/include $O $A >$T.i
		then	if test $P
			then :
			else	if /user/staff/ofarrell/8086/c86/c86 $X <$T.i >$T.b86
				then	if test $Q
					then	mv $T.b86 $T.o
						o86 <$T.o >$T.b86
						rm -f $T.o
					fi
					if test $S
					then :
					else	/user/staff/ofarrell/8086/a86/a86 $T; rm -f $T.b86
					 	Z="$Z $T.d"
					fi
				else rm -f $T.b86
				fi
				rm -f $T.i
			fi
		else	rm -f $T.i
		fi;;
	*)	echo >&2 "bad bb86 argument: $A"; rm -f $T.i $T.b86; exit 1
	esac
	else o=$A.com
	fi
done

if test $o
then	:
else	echo >&2 "bb86: filename expected following -o"
	exit 1
fi

if test x$C != x -o x$S != x -o x$P != x
then	:
else	oo=`basename $o .com`.ld
	if /user/staff/ofarrell/8086/ld/ld -o $oo -8 2f7 -s $Y $Z lsyscalls.d  /user/staff/ofarrell/8086/lib86/libc.a  &&\
	   mv $oo $o
	then :
	else rm -f $oo; exit 1
	fi
fi
