#!/bin/sh 
#
# Determine Pyramid kernel options for lsof.
#
# $Id: MkKernOpts,v 1.6 98/09/14 13:41:34 abe Exp $

# Get the version number.

if test "X$PYRAMID_DCOSXVERS" = "X"	# {
then
  PYRAMID_DCOSXVERS=`/bin/pkgparam dcosx VERSION 2>/dev/null`
  if test "X$PYRAMID_DCOSXVERS" = "X"	# {
  then
    PYRAMID_DCOSXVERS=`uname -r`
  fi	# }
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 2>/dev/null`
  if test "X$PYRAMID_ARCH" = "X"	# {
  then
    if test -x /bin/meshstat	# {
    then
      /bin/meshstat > /dev/null 2>&1
      if test $? -eq 0	# {
      then
	PYRAMID_ARCH="mesh"
      fi	# }
    fi	# }
    if test "X$PYRAMID_ARCH" = "X"	# {
    then
      PYRAMID_ARCH=`uname -m`
    fi	# }
  fi	# }
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.

    RV="-DRELIANTV=$V"

  if /bin/test $V -ge 54400	# {
  then

  # Handle ReliantUNIX version 5.44 and above specially.

  # Preset version, 64 bit compilation, and compiler warning message
  # suppression.

    RV="$RV -Klp64 -DSTRNET"
    RV="$RV -R suppress,CFE1881,CFE1177,CFE1932,CFE1807,CFE1808,CFE1859"
    IDCC=/etc/conf/bin/IDCC_FLAGS

  # Extract options from /etc/conf/bin/IDCC_FLAGS.

    if test ! -r $IDCC	# {
    then

    # If /etc/conf/bin/IDCC_FLAGS isn't readable, use default values.

      /bin/echo "$RV -DPAGESIZE_16K -DSNI_HEADERS -DSNI_R4000"
      exit
    fi	# }

  # Propogate selected options from IDCC_FLAGS.

    for i in `cat $IDCC`
    do
    case $i in	# {
      -D_SMP)
	RV="$RV $i"
	;;
      -D_SMP_CLUSTER)
	RV="$RV $i"
	;;
      -D_SHAREII)
	RV="$RV $i"
	;;
      -DPYRCSP)
	RV="$RV $i"
	;;
      -DPYRSEC)
	RV="$RV $i"
	;;
      -DXTI_SUPPORT)
	RV="$RV $i"
	;;
      -DSTRSTAT)
	RV="$RV $i"
	;;
      -DNET_STATIS)
	RV="$RV $i"
	;;
      -DTRACEX)
	RV="$RV $i"
	;;
      -D_AUDIT_MIN)
	RV="$RV $i"
	;;
      -D_AUDIT)
	RV="$RV $i"
	;;
      -DSNI_ABIAIO)
	RV="$RV $i"
	;;
      -DFLOCK)
	RV="$RV $i"
	;;
      -D_CHK_ETXTBSY)
	RV="$RV $i"
	;;
      -DSNI_HEADERS)
	RV="$RV $i"
	;;
      -DB20R)
	RV="$RV $i"
	;;
      -DSNI_R4000)
	RV="$RV $i"
	;;
      -DSNI_R10K)
	RV="$RV $i"
	;;
      -DSNI)
	RV="$RV $i"
	;;
      -DPAGESIZE_16K)
	RV="$RV $i"
	;;
      -DR4K_BIGPAGE)
	RV="$RV $i"
	;;
      -D_BIGPAGE)
	RV="$RV $i"
	;;
      -DDISCLAIM)
	RV="$RV $i"
	;;
      -DCPU_POOL)
	RV="$RV $i"
	;;
      -DCOR_PAGE)
	RV="$RV $i"
	;;
      -DK_WINDOW)
	RV="$RV $i"
	;;
      -DBOARD_DISPATCHING)
	RV="$RV $i"
	;;
      -DSEGSHM)
	RV="$RV $i"
	;;
      -D_PAGEMOD)
	RV="$RV $i"
	;;
      -D_LFS64_LARGEFILE)
	RV="$RV $i"
	;;
      -DLARGE_DATA_LCK)
	RV="$RV $i"
	;;
    esac	# }
    done
    /bin/echo "$RV"
    exit
  fi	# }

  # 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 "$RV -DR4K_BIGPAGE -DRELIANTRMP -DSNI_R4000 -DSTRNET"
    else	# }{
      /bin/echo "$RV -D_BIGPAGE -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 "$RV -D_BIGPAGE -DSTRNET"
  else	# }{
    /bin/echo "$RV -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
