#!/bin/sh 
#
# Determine Pyramid kernel options for lsof.
#
# $Id: MkKernOpts,v 1.3 97/10/24 18:58:21 abe Exp $

# Get an lsof-style version number from the package parameter VERSION value.

if test "X$PYRAMID_DCOSXVERS" = "X"
then
  PYRAMID_DCOSXVERS=`/bin/pkgparam dcosx VERSION`
fi
V=`echo $PYRAMID_DCOSXVERS | /bin/sed 's/\([0-9\.]*\).*/\1/; s/\./ /g' | /bin/awk '{printf "%d%02d%02d", $1, $2, $3;}'`

# Get the architecture type.

if test "X$PYRAMID_ARCH" = "X"
then
  PYRAMID_ARCH=`/bin/pkgparam dcosx ARCH`
fi

# Check the system name and base further processing on it.

if test "X$PYRAMID_SYSNM" = "X"
then
  PYRAMID_SYSNM=`/bin/uname -s`
fi
/bin/echo $PYRAMID_SYSNM | /bin/grep -i reliant > /dev/null
if /bin/test $? -eq 0
then

  # This is a Reliant UNIX system.

  # Get the processor type from the system name: if it has ``-M'' in it,
  # this is an MP system; otherwise, it's an SP system.

  if /bin/test "X$PYRAMID_ARCH" = "Xmesh"
  then

    # If the architecture type is MESH,  the processor type (MP or SP)
    # doesn't matter.  However, the machine hardware name does matter;
    # If it is RM600, some diferent definitions are required.

    if /bin/test "X`/bin/uname -m`" = "XRM600"
    then
      /bin/echo "-DR4K_BIGPAGE -DRELIANTV=$V -DRELIANTRMP -DSNI_R4000 -DSTRNET"
    else
      /bin/echo "-D_BIGPAGE -DRELIANTV=$V -DSTRNET"
    fi
    exit
  fi

  # Since the architecture type is not MESH, base the reply on the processor
  # type -- MP or SP.

  /bin/echo $PYRAMID_SYSNM | /bin/grep -i -- -M > /dev/null
  if /bin/test $? -eq 0
  then
    /bin/echo "-D_BIGPAGE -DRELIANTV=$V -DSTRNET"
  else
    /bin/echo "-DRELIANTV=$V -DSTRNET"
  fi
  exit
fi

# By default this is a DC/OSx system -- i.e., it's not a Reliant UNIX system.
#
# The necessary reply values are the DC/OSx version number, -DSTRNET, an
# optional -DR4000, and an optional -D_BIGPAGE.

RV="-DDCOSXV=$V -DSTRNET"
if test "X$PYRAMID_PROC" = "X"
then
  PYRAMID_PROC=`/bin/uname -p`
fi
echo $PYRAMID_PROC | /bin/grep r4.00 > /dev/null
if test $? -eq 0
then
  RV="$RV -DR4000"
fi
if test "X$PYRAMID_ARCH" = "Xnile"
then
  RV="$RV -D_BIGPAGE"
fi
/bin/echo $RV
exit 0
