#!/bin/sh
#ident "@(#)whom	201.1"
#
# Identifies the host machine type, processor & Unix O.S. Level
# mac = gx | jx | rx | xm | sx | aix | DG | lrx | l9x
# Unix = Vr3 | Vr4
# cpu = ns32532 | m88k | sparc | i386 | ppc 

unknown()
	{
	echo "unknown"
	exit 1
	}

# To help identify between Encore systems
class_file=/etc/master
if [ -r $class_file ]
then
    int_name=`grep class $class_file 2>/dev/null | cut -f1 2>/dev/null`
fi

if [ "$RCSWHOM" ]
then
    # stop the possibility of recursion
    ACTUALWHOM=$RCSWHOM
    unset RCSWHOM
    echo `$ACTUALWHOM`
    exit
fi

# Default UNIX release -
rel=Vr3

proc_name=`uname -m`

case $proc_name in
	ns32532) if [ "$int_name" = MULTIMAX ]
		 then
		     cpu=ns32532
		     mac=rx
		 else
		     unknown
		 fi ;;

	M88*)    cpu=m88k
		 mac=xm ;;

        m88k)    proc=`uname -p 2> /dev/null`
                 case $proc in
		     mc88*) cpu=m88k
                            mac=xm
                            rel=Vr4 ;;
		     *)     unknown ;;
		 esac ;;

	88k)     cpu=m88k
		 case $int_name in
		     MULTIMAX) mac=jx ;;
		     GEMINI)   mac=gx ;;
		     *)        unknown ;;
		 esac ;;

	sun*)	cpu=sparc
			mac=sun
			rel=Vr4 ;;

	i86pc)	cpu=sparc
			mac=sun
			rel=Vr4 ;;

	i386)     cpu=i386
		  mac=sx ;;

	9000/806)cpu=parisc1P1
		 mac=hp
		 rel=Vr4 ;;

	9000/800)cpu=parisc1P1 # Strictly this is parisc2P0
		 mac=hp
		 rel=Vr4 ;;

	AViiON)	mac=DG
			rel=Vr4
			case `uname -p` in
			Pentium*) cpu=i386;;
			mc88*) cpu=m88k;;
			*) cpu=unknown;;
			esac ;;

        00????????00)
                 cpu=ppc
                 mac=aix
                 rel=Vr3 ;;

	*)	case `uname -s` in
		AIX)	mac=aix
			cpu=ppc ;;

		HP-UX)	mac=hp
			cpu=parisc;;

		Linux)  # Which type of UXC to use depends on the libc version
			# The actions for redhat 7 and 9 are identical on build
			# but the install from CD has to find a different cpio image
			LibD=/lib
			[ -d /lib64 ] && LibD=/lib64
			#libcver=`ls $LibD/libc-*.so | sed -e 's/.*-//' -e s/.so//`
			# Try old-style libc location first
                        libcver=`getconf GNU_LIBC_VERSION 2>/dev/null | awk '{print $2}'`
             
			case $libcver in
			2.2.*) mac=lrx;;        # Original RedHat 7 port
			2.3.*) mac=l9x;;        # RedHat 9
			*)     mac=l9x;;        # and the rest ?
			esac
			cpu=i386
			rel=Vr4 ;;
		*)	unknown ;;
		esac ;;

esac
echo "$mac $cpu $rel"
exit 0
