#!/bin/sh
#
# Examine the CCOPTS for building the IRIX kernel and make an
# appropriate set for building lsof.

# Get the kernel's CC options.

KM=/var/sysgen/system/irix.sm
CCOPTS=`grep CCOPTS $KM`

# Preset the options of interest: _HIBERNATORII, _PAGESZ, and _SHAREII.

RH=""
RP=""
RS=""

# Scan the kernel's CC options.

for i in $CCOPTS
do
  case $i in
  -D_PAGESZ*)
    RP=$i
    ;;
  -D_SHAREII)
    RS=$i;
    ;;
  -D_HIBERNATORII)
    RH=$i
    ;;
  esac
done

# Assemble the result.
#
# Always accept _HIBERNATORII and _SHAREII.

if test "X$RH" != "X"
then
  R=$RH
fi
if test "X$RS" != "X"
then
  if test "X$R" = "X"
  then
    R=$RS
  else
    R="$R $RS"
  fi
fi

# Accept _PAGESZ only if neither _HIBERNATORII nor _SHAREII is defined.

if test "X$RP" != "X"
then
  if test "X$RH" = "X" -a "X$RS" = "X"
  then
    if test "X$R" = "X"
    then
      R=$RP
    else
      R="$R $RP"
    fi
  fi
fi

# Echo the result.

echo $R
