#!/bin/sh
#
# Determine the current system platform
#
if [ -s /bin/arch -a -s /bin/sun ]; then	# Sun's arch
	ARCH=`/bin/arch`

elif [ -s /bin/machine ]; then			# MIPS' machine
	ARCH=`/bin/machine`

elif [ -f /bin/vax ] && /bin/vax; then
	ARCH=vax

elif [ "`echo /bin/hp*`" != '/bin/hp*' ]; then	# HP's way
	{ /bin/hp9000s800 && ARCH=hp800; } || \
	{ /bin/hp9000s500 && ARCH=hp500; } || \
	{ /bin/hp9000s300 && ARCH=hp300; } || \
	{ /bin/hp9000s200 && ARCH=hp200; } || \
	{ /bin/hp300 && ARCH=hp300; } || \
	{ /bin/hp800 && ARCH=hp800; }		# Utah HP 4.3

elif [ -d /usr/ibm -o -d /vrm ]; then		# IBM AIX or ACIS
	ARCH=ibmrt

elif [ -d /NextLibrary ]; then			# Unique to NeXT cubes
	ARCH=next

elif [ -d /usr/ucb ]; then			# desperation time
	ARCH=vax
fi

case $ARCH in

	hp*)
		if [ -f /hp-ux ]; then
			OS=hpux
		fi;;

	ibmrt)
		if [ -d /vrm ]; then
			OS=aix
		fi;;

	mips*)
		if [ -f /ultrixboot ]; then
			ARCH=mipsel
			OS=ultrix
		fi;;

	sun[234])
		if [ -f /usr/ucb/logger ]; then
			OS=os4
		elif [ -d /usr/suntools ]; then
			OS=os2
		fi;;

	next)	OS=mach;;

	vax)
		if [ -f /ultrixboot ]; then
			OS=ultrix
		fi;;

	*)	ARCH=unknown;;

esac

exec echo $ARCH${OS+-$OS}
