#!/bin/tcsh -f
#
# the getARCH
#
# Parameters: none
#
# Thomas Gauweiler  14-Feb-95
#
# Changes:
#
# 14-feb-95	created (based on prototype for the main driver)	[TG]
#
# version 1.0
#

#
# determine machine architecture (what type of machine we're on!)
# by examining return values of "uname", "arch", or "machine"
#


if (-x `which uname`) then
    set SRC_ARCH=`uname -m`
else if (-x `which arch`) then
    set SRC_ARCH=`arch`
else if (-x `which machine`) then
    set SRC_ARCH=`machine`
endif

if (! $?SRC_ARCH) then			# could architecture not be determined ?
    echo 'Error: could not determine source architecture'
    exit 2
else if ("$SRC_ARCH" =~ sun4* ) then	# CPU = SPARC
    set SRC_ARCH="SUN4"			# SunOS 4.x (default)
    if (-x `which uname`) then
        if ("`uname -r`" =~ 5*) then
            set SRC_ARCH="SUN5"         # SunOS 5.x (default) = single-threaded Solaris 2.x
            if (-x `which mpstat`) then
                if (`mpstat | wc -l` > 2) then    # more than one CPU present ?
                    set SRC_ARCH="SOL2"           # multi-threaded Solaris 2.x
                endif
            else if (-x `which psrinfo`) then
                if !(`psrinfo | wc -l` > 1) then  # more than one CPU present ?
                    set SRC_ARCH="SOL2"           # multi-threaded Solaris 2.x
                endif
            endif

            set SRC_ARCH="SUN5"         # for tests

        endif
    endif
else if ("$SRC_ARCH" =~ sun3*) then	# Sun-3 with 680x0 CPU
    set SRC_ARCH="SUN3"
else if ("$SRC_ARCH" =~ i?86*) then	# CPU = 386/486/Pentium
    set SRC_ARCH="I386"			# BSDI (default)
    if (-x `which uname`) then
        if ("`uname -s`" =~ *Linux*) then
            set SRC_ARCH="LINX"         # Linux
        endif
    endif
else if ("$SRC_ARCH" =~ ksr?*) then	# KSR-1 or KSR-2
    set SRC_ARCH="KSRP"
else if ("$SRC_ARCH" =~ RISC* || "$SRC_ARCH" =~ mips*) then	# CPU = MIPS
    set SRC_ARCH="MIPS"			# DECstation (default)
    if (-x `which uname`) then
        if ("`uname -v`" =~ *MP*) then
            set SRC_ARCH="MASP"   	# MasPar MP-1 or MP-2 frontend
        endif
    endif
else
    echo 'Error: unknown source architecture "'$SRC_ARCH'"'
    exit 2
endif

echo $SRC_ARCH




