#!/bin/sh
#
# usage:        arch.sh
#
# abstract:     This Bourne Shell script sets the variable Arch to
#		reflect the current machine architecture.
#
#		Arch	  - Machine architecture
#
# note(s):	1. This routine must be called using a . (period)
#
# Copyright (c) 1986-95 by The MathWorks, Inc.
# $Revision: 1.24 $  $Date: 1995/04/28 19:41:28 $
#----------------------------------------------------------------------------
#
   Arch="unknown"
#
   if [ -f /bin/uname ]; then
   	case "`/bin/uname`" in
	    SunOS)					# sun4 and sol2
	        if [ -d /dev/pts ]; then
		    Arch="sol2"
	        else
		    Arch="sun4"
	        fi
	        ;;
	    HP-UX)					# hp300 and hp700
    	        if [ -f /bin/hp9000s300 ]; then
		    (/bin/hp9000s300) > /dev/null 2>&1
		    if [ $? -eq 0 ]; then
	    	        Arch="hp300"
	            fi
		fi
	        if [ -f /bin/hp9000s700 ]; then
		    (/bin/hp9000s700) > /dev/null 2>&1
		    if [ $? -eq 0 ]; then
	    	        Arch="hp700"
		    fi
	        fi
	        ;;
	    IRIX)					# sgi
    	        if [ -f /bin/4d ]; then
		    (/bin/4d) > /dev/null 2>&1
		    if [ $? -eq 0 ]; then
	    	        Arch="sgi"
		    fi
	        fi
	        ;;
	    IRIX64)					# sgi IRIX 6 64 bit OS
    	        if [ -f /bin/4d ]; then
		    (/bin/4d) > /dev/null 2>&1
		    if [ $? -eq 0 ]; then
	    	        Arch="sgi"
		    fi
	        fi
	        ;;
	    ULTRIX)					# dec_risc
    	        if [ -f /ultrixboot ]; then
		    Arch=`file /ultrixboot`
		    if [ `expr "$Arch" : ".*mipsel.*"` -gt 0 ]; then
	    	        Arch="dec_risc"
		    else
	    	        Arch="vax_unix"
		    fi
	        fi
	        ;;
	    OSF1)					# alpha
	    	Arch="alpha"
	        ;;
	    AIX*)					# ibm_rs
#
# With AIX 4.1, uname can return more than just 'AIX'
#
	        Arch="ibm_rs"
	        ;;
	    DomainOS)					# System V apollo
                if [ -d /usr/apollo/bin ]; then
	            Arch="apollo"
	        fi
	        ;;
	    Linux)
		Arch="lnx86"
		;;
	    *)
		if [ "`/bin/uname -a | grep CRAY`" != "" ]; then 
		    Arch="cray"
		fi
	        ;;
        esac
   elif [ -f /bin/arch ]; then				# early sun4
	Arch="`/bin/arch`"
   elif [ -d /usr/apollo/bin ]; then			# BSD apollo
	Arch="apollo"
   elif [ -f /ultrixboot ]; then			# early ultrix
	typefile=`file /ultrixboot`
	if [ `expr "$typefile" : ".*mipsel.*"` -gt 0 ]; then
	    Arch="dec_risc"
	else
	    Arch="vax_unix"
	fi
   elif [ -d $MATLAB/bin/c2mp ]; then
	Arch="c2mp"
   fi
