#!/bin/sh
#
# Makesrc - make SunOS (Solaris 1.x and 2.x) source files
#
# WARNING: This script assumes it is running from the main directory
#	   of the lsof, version 3 distribution.
#
# One environment variable applies:
#
# LSOF_MKC	is the method for creating the source files.
#		It defaults to "ln -s".  A common alternative is "cp".
#
#		Cp may be used when it is necessary to assemble a
#		source module from fragments.
#
# $Id: Mksrc,v 1.12 96/02/21 08:08:51 abe Exp $


D=dialects/sun
F=dialects/common
L="dlsof.h dnode.c dnode1.c dproto.h dsock.c dstore.c machine.h"

for i in $L
do
  rm -f $i
  $LSOF_MKC $D/$i $i
  echo "$LSOF_MKC $D/$i $i"
done

# Assemble kernelbase.h for SunOS and Solaris < 2.5 (5.5)

NM=kernelbase.h
rm -f $NM
if test "X$1" != "Xsolaris" -o `uname -r` != "5.5"
then
  if test "X$1" = "Xsolaris"
  then
    A=`uname -m`
    if test "$A" = "i86pc"
    then
      H=/usr/include/sys/machparam.h
    else
      H=/usr/src/uts/$A/sys/machparam.h
    fi
  else
    H=/usr/include/machine/param.h
  fi
  echo "#if	!defined(KERNELSIZE)" > $NM
  grep "^#define[ 	]*KERNELSIZE" $H >> $NM
  echo "#endif" >> $NM
  echo "#if	!defined(KERNELBASE)" >> $NM
  grep "^#define[ 	]*KERNELBASE" $H >> $NM
  echo "#endif" >> $NM
else

# To keep the dependency list for dproc.o simple in the Makefile,
# create an empty kernelbase.h for Solaris 2.5 (5.5) and above.

  touch $NM
fi
echo "$NM assembled."

# Assemble ddev.c.

NM=ddev.c
P="$D/$NM $F/dvch.frag $F/fchi.frag $F/lkud.frag"
rm -f $NM
cat $P > $NM
echo "$NM assembled."

# Assemble dfile.c.

NM=dfile.c
P="$D/$NM $F/ckfa.frag"
rm -f $NM
cat $P > $NM
echo "$NM assembled."

# Assemble dmnt.c.

NM=dmnt.c
P="$D/$NM $F/cvfs.frag"
rm -f $NM
cat $P > $NM
echo "$NM assembled."

# Assemble dproc.c.

NM=dproc.c
P="$D/$NM $F/rnch.frag"
rm -f $NM
cat $P > $NM
echo "$NM assembled."
