: $Workfile:   kixasm.sh  $ $Revision:   1.0  $
#**********************************************************************#
#*                                                                    *#
#* Copyright (c) 2001 by Sun Microsystems, Inc.                       *#
#* All rights reserved.                                               *#
#*                                                                    *#
#**********************************************************************#


# kixasm
# call kixbms processor
# params: -c	generate copy file
#	  -l	generate listing file
#	  -o	outputfile name
#	  -y	terminal device	used
#	  -9	temporary output file name
#	  <filename> file to process

ASMOPT=""

FOUTPUT=OFF
LISTBMS=OFF

set -- `getopt clo:y:9:	$*`

# while	options	to process
while test "$1"	!= "--"
do
    case $1 in
    -y)
	shift
	TTYNAME=$1
	;;
    -9)
	shift
	FOUTNAME=$1
	FOUTPUT=YES
	;;
    -o)
	shift
	NEWFILE=$1
	;;
    -c)
	ASMOPT="$ASMOPT	-c"
	;;
    -l)
	ASMOPT="$ASMOPT	-l"
	LISTBMS=YES
	;;
    *)
	exit 1
	# illegal option encountered
	;;
    esac
    shift
done

trap "/bin/rm -f $FOUTNAME*; exit 1" 1 2 3

# echo "Processing $2, please wait..."

if test	$FOUTPUT = "YES"
then
    ####  kixbms output	 #### >$FOUTNAME
    /bin/rm -f $NEWFILE	"`dirname $NEWFILE`/`basename $NEWFILE .map`" \
	>> $FOUTNAME
    $UNIKIX/bin/kixbms -o $NEWFILE $ASMOPT $2 1>>$FOUTNAME.1 2>>$FOUTNAME.2
    cat	$FOUTNAME.1 >> $FOUTNAME
    cat	$FOUTNAME.2 >> $FOUTNAME
    if test $LISTBMS = "YES"
    then
	cat $2 >> $FOUTNAME
    fi
    /bin/rm -f $FOUTNAME.*
else
    /bin/rm -f $NEWFILE	"`dirname $NEWFILE`/`basename $NEWFILE .map`"
    $UNIKIX/bin/kixbms -o $NEWFILE $2 1>/dev/null 2>/dev/null
fi
# vi $FOUTNAME <$TTYNAME >$TTYNAME
# /bin/rm -f $FOUTNAME
exit 0
