#!/bin/csh -f
#
#      $Id: sys_type,v 1.20 2003-05-16 14:53:13 haley Exp $
#
#########################################################################
#									#
#			   Copyright (C)  1992				#
#	     University Corporation for Atmospheric Research		#
#			   All Rights Reserved				#
#									#
#########################################################################
#
#	File:		sys_type
#
#	Author:		John Clyne
#			National Center for Atmospheric Research
#			PO 3000, Boulder, Colorado
#
#	Date:		Fri Sep 25 11:32:32 MDT 1992
#
#	Description:	Determine system type. If the system type cannot
#			be determined either automatically or interactively
#			sys_type exits with a non-zero exit status. Otherwise
#			exit status is zero and the system type is written
#			to the standard output. The systems that this script
#			recognizes are given by the $systems variable.
#
#
#	Usage:		sys_type -d
#
#	Environment:	LOCALDIR	path to installation system.
#
#	Files:		
#
#
#	Options: -d  select a system other than the default

if ($#argv == 1) then
  if ("$argv[1]" == "-d") then
    set select_own_system
  endif
endif

# systems we know about
#
#set systems = ( \
#		HPUX_HP9000_7xx HPUX_HP9000_8xx AIX_RS6000 SunOS_sun4 Solaris_sun4 \
#        ULTRIX_RISC IRIX_IP IRIX64_IP UNICOS_YMP UNICOS_J90 UNICOS_C90 \
#        UNICOS_T90 OSF1_alpha LINUX_PC LINUX_IA64 DARWIN_MAC CYGWIN_PC \
#        LINUX_alpha Solaris_PC UNIXSV_Fujitsu300)
set systems = ( \
		HPUX_HP9000_7xx AIX_RS6000 Solaris_sun4 IRIX_IP UNICOS_J90 \
		UNICOS_C90 OSF1_alpha LINUX_PC LINUX_IA64 DARWIN_MAC CYGWIN_PC \
		LINUX_alpha)

#
# auto-detect the system type
#
if (! $?select_own_system) then
  set line = `$LOCALDIR/uname -M -s`
  if ($status == 0) then
        echo "$line[2]_$line[1]"
        exit 0
  endif
#
#	uname failed for some reason. Try to get system name from user
#

  cat > /dev/tty << EOF

	I cannot determine your system type. 
	I only know about the following systems:


EOF

else
#
# Prompt installer to select a system from the list
#

  cat > /dev/tty << EOF

	For which system do you want to install binaries:

EOF


endif

while ( 1 )
	set i = 1
	while ($i <= $#systems) 

		echo "	$i	$systems[$i]" > /dev/tty
		@ i++
	end
	echo "" > /dev/tty
	echo "" > /dev/tty
	echo "" > /dev/tty

	echo -n "Enter the number of your system or 0 to exit : " > /dev/tty
	set answer=$<
	switch ("$answer")
	case	0:
		exit 2
		breaksw
	case	[1-$#systems]:
		echo $systems[$answer]
		exit 0
		breaksw
	default:
	endsw

	echo "" > /dev/tty
	echo "I do not understand <$answer>" > /dev/tty
	echo "Enter a number between 1 and $#systems or 0 to exit" > /dev/tty
	echo "" > /dev/tty
	echo "" > /dev/tty
	echo "" > /dev/tty
end

