:
#
#
# gennttab generates ntcontab.o
# usage: gennttab [ -n protocol-name  ... ]
#    -n: do not include protocol adapters with given names
#
# generates .s file for SunOS 5, AIXRIOS, SVR4_386, NCR 
#           .c file for all others
#

if [ "$ORACLE_TRACE" ]; then
  set -x
fi

  UNAME=/bin/uname
  PLATFORM=`$UNAME`

if [ $PLATFORM = "SunOS" ] || [ $PLATFORM = "SOL" ]; then
 NM=/usr/ccs/bin/nm
 SED=/usr/bin/sed
 AWK=/usr/bin/awk
 GREP=/usr/bin/grep
 EXPR=/usr/bin/expr
 LN=/usr/bin/ln
 ECHO=/usr/bin/echo
elif [ $PLATFORM = "Linux" ]; then
 NM=/usr/bin/nm
 SED=/bin/sed
 AWK=/usr/bin/awk
 GREP=/bin/grep
 EXPR=/usr/bin/expr
 LN=/bin/ln
 ECHO=/bin/echo
else
 NM=/usr/bin/nm
 SED=/usr/bin/sed
 AWK=/usr/bin/awk
 GREP=/usr/bin/grep
 EXPR=/usr/bin/expr
 LN=/usr/bin/ln
 ECHO=/usr/bin/echo
fi

if [ -z "$TMPDIR" ] ; 
then
  TMPDIR=/tmp

fi

VER=10

##################################
NMOPTS=

##################################

if [ "x$1" = "x-64" ] ; then
	LIB=lib64
else
	LIB=lib
fi

LIBPATH=${ORACLE_HOME}/${LIB}
LIBNET="libn${VER}"
LIBNETPATH=${LIBPATH}/${LIBNET}
TRANSPORTS="US TCP BEQ TCPS DCE NMP RAW SDP"
TtoINI="US:ntusini TCP:nttini BEQ:ntpini TCPS:ntzini DCE:ntodrini NMP:ntnini RAW:ntrini SDP:nttsdpini"
TtoBAS="US:ntus TCP:ntt BEQ:ntp TCPS:ntz DCE:ntodr NMP:ntn RAW:ntr SDP:ntt"
TtoNAM="US:IPC TCP:TCP/IP BEQ:BEQueath TCPS:SSL DCE:DCE NMP:NamedPipes RAW:RAW SDP:SDP"
TtoLIB="US:us TCP:tcp BEQ:beq TCPS:tcps DCE:dce NMP:nmp RAW:raw SDP:tcp"

trap 'rm -f ${TMPDIR}/net$$; for T in $TRANSPORTS; do ; rm -f ${TMPDIR}/${T}$$; done ; exit 0' 1 2 15

  $NM $NMOPTS ${LIBNETPATH}.* > $TMPDIR/net$$ 2> /dev/null

for T in $TRANSPORTS; do
# Default is to use all available drivers
  eval NTUSE$T="true"

  LIB=`$ECHO ${TtoLIB}  | $SED 's/ /\\
/g' | $GREP "^${T}:" | $AWK -F: '{print $2}'`
  INI=`$ECHO ${TtoINI}  | $SED 's/ /\\
/g' | $GREP "^${T}:" | $AWK -F: '{print $2}'`
  BAS=`$ECHO ${TtoBAS} | $SED 's/ /\\
/g' | $GREP "^${T}:" | $AWK -F: '{print $2}'`

  if [ -z "${LIB}" ] ; then
    $LN -s $TMPDIR/net$$ $TMPDIR/${T}$$
  else

    $NM $NMOPTS ${LIBPATH}/libn${LIB}${VER}.* > ${TMPDIR}/${T}$$ 2> /dev/null

  fi

  if [ "`$GREP ${INI} ${TMPDIR}/${T}$$ 2> /dev/null`" = "" ]; then

    eval NTUSE${T}="false"
  fi
done

# clean up temp files
rm -f ${TMPDIR}/net$$
for T in $TRANSPORTS; do 
  rm -f ${TMPDIR}/${T}$$
done 
#
# Now begins the big divide between SunOS 5 and the rest of the world...
#
#
# Now begins the big divide between AIXRIOS and the rest of the world...
#
USE_AS=${USE_AS:=false}
if [ "$USE_AS" = "true" ] && [ "$SRCHOME" = "" ]; then
	$ECHO ""

else  # USE_AS

$ECHO '/*'
$ECHO '**'
$ECHO '** This file is GENERATED by gennttab'
$ECHO '**'
$ECHO '*/
'

$ECHO "#include <sys/types.h>
"

# the following is taken from ntdrv.h
$ECHO '/* NT driver descriptor */
struct ntdrv
{
    char   *ntdrvdes;                               /* NT driver designator */
    void  (*ntdrvini)(            /* NTCONNECT - NT driver init function */
             /*_ ptr_t gbl, struct ntpa *pactx _*/ );
    char   *ntdrvsini;                                 /* Name of INIT func */
    char   *ntdrvmod;                                   /* NT driver module */
};
typedef struct ntdrv ntdrv;
'

if [ "${NTUSEDCE}" = "true" ]
then
$ECHO "void ntodrini();"
fi

if [ "${NTUSETCP}" = "true" ]
then
$ECHO "void nttini();"
fi

if [ "${NTUSETCPS}" = "true" ]; then
$ECHO "void ntzini();"
fi

if [ "${NTUSESDP}" = "true" ]; then
$ECHO "void nttsdpini();"
fi

$ECHO "void ntrini();"

$ECHO "void ntpini();"

$ECHO "void ntusini();"

if [ "${NTUSENMP}" = "true" ]
then
$ECHO "void ntnini();"
fi

# the protocol table
$ECHO "ntdrv ntcontab[] = {"
#Add the DCE adapter
if [ "${NTUSEDCE}" = "true" ]
then
$ECHO '
 { "dce", ntodrini, "_NTODRINI", "ntodr" },
'
fi

# Add the TCP adapter
if [ "${NTUSETCP}" = "true" ]
then
$ECHO '
 { "tcp", nttini, "NTTINI", "ntt" },
'
fi

# Add the SSL adapter
if [ "${NTUSETCPS}" = "true" ]; then
$ECHO '
 { "tcps", ntzini, "NTZINI", "ntcps" },
'
fi

# Add the SDP adapter
if [ "${NTUSESDP}" = "true" ]; then
$ECHO '
 { "sdp", nttsdpini, "NTTSDPINI", "ntt" },
'
fi

# RAW Bequeath and IPC PAs always included
$ECHO '
 { "raw", ntrini, "_NTRINI", "ntr" },
'
$ECHO '
{ "beq", ntpini, "_NTPINI", "ntp" },
'
$ECHO '
{ "ipc", ntusini, "_NTUSINI", "ntus" },
'
# Add the Named pipes adapter
if [ "${NTUSENMP}" = "true" ]
then
$ECHO '
{ "nmp", ntnini, "_NTNINI", "ntn" },
'
fi
# Add the OSI adapter
if [ "${NTUSEOSI}" = "true" ]
then

$ECHO '
{  "osi4", snto4in, "_snto4in",  "nto4" },
'

fi
# Add the LU6.2 adapter
if [ "${NTUSELU62}" = "true" ]
then
$ECHO '
{  "lu62", ntlini, "_ntlini",  "ntl" },
'
fi
# Add the async adapter
if [ "${NTUSEASYNC}" = "true" ]
then
$ECHO '
{  "async", ntasgini, "_ntasgini",  "ntas" },
'
fi

$ECHO " { 0, 0, 0, 0}};"

$ECHO '/* no. of connect table entries */
'

$ECHO "const int ntconent = sizeof(ntcontab)/sizeof(ntcontab[0]) - 1;"

fi # USE_AS
