#!/bin/sh
#
# Mksrc - make Solaris 2.x source files for lslk
#
# WARNING: This script assumes it is running from the main directory
#	   of the lslk distribution.
#
# One environment variable applies:
#
# LSLK_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.1 96/06/12 12:47:19 abe Exp $


D=dialects/solaris
F=dialects/common
L="dlock.c dmnt.c dlslk.h dproto.h dstore.c machine.h"

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

# Assemble kernelbase.h

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 dlock.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 ???

#NM=???
#P="$D/$NM $F/???"
#rm -f $NM
#cat $P > $NM
#echo "$NM assembled."
