
:	TNIX/Unix Version
:	Keyshell Version Number 2	*/

: getcompile 

: This is a shell command subroutine that determines whether a user will
: be using any Tektronix uP compilers, and which ones.
: The list of all valid compilers in the variable 'validcomp' is passed in
: from the calling routine, kshoptions.  A valid compiler is one that 
: exists on the system for the $micro variable previously chosen by the
: user.
: The number of valid compilers is determined.  If there is one valid compiler,
: the user is queried as to its inclusion.  If there is more than one, the
: list is printed and the user is asked to specify which ones to include.

: External variables
:	$compiler - Name of compiler
: 	$micro - the microprocessor being used
: 	$kshconfig - the file that holds the configuration description
:	$kppdefs - the file that holds "#defines" for the kpp build
:	$setTEK - the file that holds the initialization commands
:	$shelltype - Bourne or cshell
:	$validcomp - The list of compilers that exist for $micro uP

: Expand the names in the validcomp list
compnames=
for i in $validcomp
do
	case $i in
	pas)
		compnames="$compnames pascal"
		;;
	*)
		compnames="$compnames $i"
		;;
	esac
done

count=`echo $compnames | wc -w | tr -d ' '`


if test $count -lt 1 ; then
	CONTINUE=no
elif test $count -eq 1 ; then
	CONTINUE=yes
elif test $count -gt 1 ; then
	CONTINUE=yes
	echo
	echo "The following $micro uP compilers are available:"
	echo
	for i in $compnames ; do
		echo "	$i"
	done
fi
if test $CONTINUE = yes ; then
	CHOSEN=
	for I in $compnames ; do
	VALID=no
	while test $VALID = no ;do
		echo
		echo -n "Do you wish to use the $I compiler ('y' or 'n')?: "
		read INPUT
		case $INPUT in
		'y' | 'Y')
			VALID=yes
			CHOSEN="$CHOSEN $I"
			;;
		'n' | 'N')
			VALID=yes
			;;
	 	*)	echo "Invalid input: Please enter 'y' or 'n'";;
		esac
	done
	done

	
	count=`echo $CHOSEN | wc -w | tr -d ' '`
	if test $count -ge 1 ; then

		echo "#define _compiler $count" >>$kppdefs
		for comtype in $CHOSEN ; do
			echo "#define _$comtype 1" >>$kppdefs
			echo " o  The $comtype compiler and related utilities are included."  >>$kshconfig
		done
	fi
fi
