#!/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.10 95/06/28 13:27:56 abe Exp $


D=dialects/sun
F=dialects/common
L="dlsof.h dnode.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.

NM=kernelbase.h
rm -f $NM
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
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."
