#!/bin/sh
#
# $Id: pbs_mach_type,v 2.1 1999/04/21 22:51:56 hender Exp $
#
#
# This is a simple script that generates a machine type name
# based on the output of uname.  The generated name is in the
# style of old PBS machine names and thus a hand generated
# mapping needs to take place. If you port PBS to new architectures
# you should modify the lookup table. A better way would have been
# to name the machines in a more "standard" way but it would require
# a considerable amount of effort to find all the dependencies in
# the code and documentation.    lonhyn@nas.nasa.gov
#
# The big kluge is when we are on an AIX box to figure out whether or
# not we are running on an SP2. What we do is have the user set
# --enable-sp2 when ocnfiguring. Since this script is needed by configure
# we can't perform a substitution on it based on the output of configure.
# Thus the case of the sp2 will be handled by configure.
# All of this is rather cheesy as sp2, aix3, and aix4
# are logically overlapping.
#

OS=`uname -s | tr '[A-Z]' '[a-z]'`
REL=`uname -r`
VER=`uname -v 2> /dev/null`

test "$VER" = unicosmk && OS="$VER"

bad_rel=n

verbose=""; export verbose

test "$1" = "-v" && verbose=yes

case "$OS" in 

  sun*)  case "$REL" in
           4*)  mach=sunos4 ;;
           5*)  mach=solaris5 ;;
           *)   bad_rel=y ;;
         esac ;;

  cm*)   mach=cm5 ;;

  #
  # as usual, AIX is different...
  #
  aix*) REL=`uname -v`
        case "$REL" in
          3*)  mach=aix3 ;;
          4*)  mach=aix4 ;;
          *)   bad_rel=y ;;
        esac ;;

  hp*)  mach=hpux10 ;;

  irix*)  case "$REL" in
           5*)  mach=irix5 ;;
           6*)  mach=irix6 ;;
           *)   bad_rel=y ;;
         esac ;;

  netbsd*) mach=netbsd ;;

  freebsd*) mach=freebsd ;;

  linux*) mach=linux ;;

  unicosmk*) mach=unicosmk2 ;;

  unicos*) mach=unicos8 ;;

  sn*)	if echo $OS | egrep '^sn[0-9]+$' > /dev/null ; then
	    mach=unicos8;
	else
	    echo $0: the operating system \"$OS\" is unknown >&2 ;
	    echo unknown ;
	    exit 1 ;
	fi;;

  osf*) mach=digitalunix ;;

  unix_system_v )    mach=fujitsu ;;

  *)   test -n "$verbose" && \
           echo $0: the operating system \"$OS\" is unknown >&2 ;
       echo unknown ;
       exit 1 ;;

esac


if test "$bad_rel" = y; then
  test -n "$verbose" && \
      echo $0: for operating system \"$OS\", release \"$REL\" is unknown >&2
  echo unknown
  exit 2
fi


#
# an irix6array is a machine running irix6 with the array daemon
# configured to start at boot time. The whole concept of embedding
# the release number of the OS in the machine type is retarded.
#
IRIX_ARRAY_CONF=/etc/config/array
if test "$mach" = irix6; then
  test -r "$IRIX_ARRAY_CONF" && \
    test `cat "$IRIX_ARRAY_CONF"` = on && \
    mach=irix6array
fi

echo $mach
exit 0


