#!/bin/csh -f
#
# This script manages nonlocal installation of the uSystem software.
#

echo "The uSystem requires at least GNU C 1.37.1 for its installation."
echo "Your installation is currently running:"
gcc -v
while( 1 )
    echo -n "Enter valid compiler version {yes, no}: "
    set validgcc = ($<)
    switch ( $validgcc:q )
	case yes:
	    break
	case no:
	    exit
	default:
            echo "Invalid response: ${validgcc}"
            breaksw
    endsw
end

while ( 1 )
    echo -n "Enter cpu type {i386, mips, m68k, ns32k, vax, sparc}: "
    set cpu = ($<)
    switch ( $cpu:q )
        case i386:
	case mips:
	case m68k:
	case ns32k:
	case vax:
	case sparc:
            break
        default:
            echo "Invalid cpu: ${cpu}"
            breaksw
    endsw
end

while ( 1 )
    echo -n "Enter vendor name {apollo, dec, mips, sequent, sgi, sun, encore}: "
    set vendor = ($<)
    switch ( $vendor:q )
        case apollo:
	    set dmos = bsd43
	    set os = bsd43
            break
	case dec:
	    switch ( $cpu:q )
		case mips:
		    set dmos = sysvr3
		    set os = bsd43
	            break
		default:
		    set dmos = bsd43
		    set os = bsd43
	            break
	    endsw
            break
	case mips:
	    while ( 1 )
		echo -n "Enter operating system configuration {bsd43, sysvr3}: "
		set osconfig = ($<)
		switch ( $osconfig:q )
		    case bsd43:
			set dmos = bsd43vf
			break;
		    case sysvr3:
			set dmos = sysvr3
			break;
		    default:
		        echo "Invalid operating system configuration: ${osconfig}"
		        breaksw
		endsw
	    end
	    set os = bsd43
            break
        case sgi:
	    set dmos = sysvr3
	    set os = irix
            break
        case sun:
	    set dmos = bsd43
	    set os = bsd43
            break
        case sequent:
	    switch ( $cpu:q )
		case ns32k:
		    echo "WARNING!  If you wish to use the multiple processor version of the"
	  	    echo "uSystem, you must patch the GNU C compiler FIRST with the files"
        	    echo "contained in the uSystem directory ./gnu. If you have not patched"
		    echo "the compiler, interrupt this script and do so."
		    set dmos = bsd43vf
		    set os = bsd43
	            break
		default:
		    set dmos = bsd43vf
		    set os = bsd43
	            break
	    endsw
            break
	case encore:
	    echo "WARNING!  If you wish to use the multiple processor version of the"
  	    echo "uSystem, you must patch the GNU C compiler FIRST with the files"
            echo "contained in the uSystem directory ./gnu. If you have not patched"
	    echo "the compiler, interrupt this script and do so."
	    set dmos = bsd43
	    set os = umax
            break
        default:
            echo "Invalid vendor: ${vendor}"
            breaksw
    endsw
end

while ( 1 )
    echo -n "Enter documentation format - imperial (8.5in. x 11in.) or metric (A4) {imperial, metric}: "
    set pageformat = ($<)
    switch ( $pageformat:q )
        case imperial:
	case metric:
            break
        default:
            echo "Invalid page format: ${pageformat}"
            breaksw
    endsw
end

# build the system

./CONFIGURE ${vendor} ${os} ${cpu} ${pageformat} ${dmos}
