#! /bin/sh
#
# $Id: arch,v 5.1.1.2 90/01/11 17:04:47 jsp Exp Locker: jsp $
#
# Copyright (c) 1989 Jan-Simon Pendry
# Copyright (c) 1989 Imperial College of Science, Technology & Medicine
# Copyright (c) 1989 The Regents of the University of California.
# All rights reserved.
#
# This code is derived from software contributed to Berkeley by
# Jan-Simon Pendry at Imperial College, London.
#
# Redistribution and use in source and binary forms are permitted
# provided that the above copyright notice and this paragraph are
# duplicated in all such forms and that any documentation,
# advertising materials, and other materials related to such
# distribution and use acknowledge that the software was developed
# by Imperial College of Science, Technology and Medicine, London, UK.
# The names of the College and University may not be used to endorse
# or promote products derived from this software without specific
# prior written permission.
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#
#	%W% (Berkeley) %G%
#
# Figure out machine architecture
#

PATH=/bin:/usr/bin:/usr/ucb:/etc:/usr/local/bin:${PATH} export PATH

#
# First try to find a standard command
#
a=arch		# Sun compat
m=machine	# BSD compat
u=uname		# Sys5 compat

if [ -f /etc/$a -o -f /bin/$a -o -f /usr/bin/$a -o -f /usr/local/bin/$a ]
then
	exec $a
elif [ -f /etc/$m -o -f /bin/$m -o -f /usr/bin/$m -o -f /usr/ucb/$m -o -f /usr/local/bin/$m ]
then
	exec $m
elif [ -f /etc/$u -o -f /bin/$u -o -f /usr/bin/$u -o -f /usr/local/bin/$u ]
then
	ARCH="`uname`"
	case "$ARCH" in
		AIX*) MACH="`uname -m`"
			case "$MACH" in
			10*) echo ibm032; exit 0;;
			20*) echo ibm032; exit 0;;
			esac
			;;
		A/UX) echo macII ; exit 0 ;;
		*) ;;
	esac
fi

#
# Take a pot-shot at your machine architecture
#
echo "	... No ARCH= option specified; dynamically determining architecture" >&2

case "`head -1 /etc/motd`" in
*"HP-UX"*)		ARCH=hp9000;;
*"Ultrix"*)		ARCH=vax;;
*"RISC iX"*)		ARCH=arm;;
*"Umax 4.2"*)		ARCH=encore;;
*)			ARCH=unknown;
			if [ -d /usr/include/caif ]; then
				ARCH=ibm032
			fi;;
esac

echo "	... architecture appears to be \"${ARCH}\"" >&2
echo $ARCH

case "$ARCH" in
unknown) exit 1
esac

exit 0
