:
# 
# $Header: gensyslib.pp 1.1 95/03/07 18:55:58 rdhoopar Osd<unix> $ gensyslib.pp Copyr (c) 1989 Oracle
# 

#
# Generate a list of system and vendor libraries that can be added at the
# end of the link line. gensyslib writes a string to lib/sysliblist
# which is the list of libraies that have to be added to the link line.
# syslibname will be 'cat'ed in all shipped makefiles.
#
# File osntab.c is no longer inspected because V1 driver is obsolete. Only
# ntcontab.c is inspected.

# Dependence: It depends on network/lib/ntcontab.c
# Usage: gensyslib
#
# Porting note: Please include additional network dirvers to the following
# list that is writen to KEY_FILE with the following format:
# Driver name in upper case:corresponding module in osntab.c:marketing name
#
# ${Drivername}LIB; the list of system libraries to be added to the link line
# should be defined for new ports.
#

DFL_SYSLIB="-lnsl -lsocket -lgen -ldl -lsched"

DNTPALIB="/opt/SUNWconn/dni/lib/libdni.a"
LU62PALIB="/opt/SUNWappc/liblu62.a"
OSIPALIB="/opt/SUNWconn/osinet/lib/libapli.a"
# This is for chkadptrs so we don't install unless it exists.
SPXPAEXE="/opt/SUNWipx/bin/ipxd"

KEY_FILE=tmp$$

trap '\rm -f $KEY_FILE ; exit' 1 2 3 15

cat <<!> $KEY_FILE
DNTPA:ntidini:DECNet TLI Protocol Adapter
LU62PA:ntlini:LU62 Protocol Adapter
OSIPA:ntio4ini:OSI4 TLI Protocol Adapter
!

NETDRIVERS=`awk -F: '{print $1}' $KEY_FILE`
#list of system libraries.

SYSLIBNAMES=${DFL_SYSLIB-}

INS_DRIVER= 			#List of installed drivers

for net in $NETDRIVERS
do
   OSN_NAME=`grep ${net}: $KEY_FILE | awk -F: '{print $2}'`
   MKTG_NAME=`grep ${net}: $KEY_FILE | awk -F: '{print $3}'`

   if [ "`(nm $ORACLE_HOME/lib/ntcontab.o |grep $OSN_NAME) 2>/dev/null`" != "" ]

   then

      NETLIBS=\$${net}LIB
      for slib in `eval "echo $NETLIBS"`
      do

	if [ "`echo $slib | grep '^/'`" = "" ] #if first char different from /
	then

	   if [ ! -f /lib/lib${slib}.a -a ! -f /usr/lib/lib${slib}.a ] ; then
	      echo ""
 	      echo "Cannot locate /lib/lib${slib}.a nor /usr/lib/lib${slib}.a."

 	      echo "Cannot install $MKTG_NAME driver."

           else
               SYSLIBNAMES="$SYSLIBNAMES -l${slib}"
           fi
	else	    # if library name starts with "/", it is a full pathname
	   if [ ! -f $slib ] ; then
	       echo "Cannot locate $slib."
	       echo "Cannot install $MKTG_NAME driver."

	   else

               SYSLIBNAMES="$SYSLIBNAMES $slib"

	   fi
	fi

      done

   fi
done

\rm -f $KEY_FILE

cat <<! >$ORACLE_HOME/lib/sysliblist
$SYSLIBNAMES
!

