#ident	"@(#)mk::mksyshead	35.2"
#
#	Install UNIX System 'sys', 'net' and 'netinet' header files
#
SRCDIR=${SRC:-$ROOT/usr/src}/uts
TARGDIR=$ROOT/usr/include/sys
NETTARG=$ROOT/usr/include
trap "rm -fr $TARGDIR/[a-m]* ; rm -fr $TARGDIR/* ; rm -fr $NETTARG/net ; rm -fr $NETTARG/netinet ; exit 1" 1 2 3 15
if m68k
then
	MACH=m68k/sys
	NETSRC=${SRC:-$ROOT/usr/src}/uts/m68k
elif vax
then
	MACH=vax/sys
elif pdp11
then
	MACH=pdp11/sys
elif u3b
then
	MACH=3b/sys
elif u3b2
then
	MACH=3b2/sys
elif u3b5
then
	MACH=3b5/sys
fi
#
rm -fr $TARGDIR/[a-m]* ; rm -fr $TARGDIR/*
for DIR in sys $MACH
do
	if [ -d $SRCDIR/$DIR ]
	then (
		cd $SRCDIR/$DIR
		echo "Installing $SRCDIR/$DIR into $TARGDIR:"; ls -Rx
#			Don't copy SCCS files to /usr/include/sys MSW
		find ./?[!.]* -type f -print | cpio -pdu $TARGDIR
	) fi
done
rm -fr $NETTARG/net ; rm -fr $NETTARG/netinet
for NETDIR in net netinet
do
	if [ -d $NETSRC ]
	then (
		mkdir $NETTARG/$NETDIR
		cd $NETSRC/$NETDIR
		echo "\nInstalling $NETSRC/$NETDIR into $NETTARG/$NETDIR:"; ls -Rx
		find ./  -type f -print | cpio -pdu $NETTARG/$NETDIR
	) fi
done
#	Set file and directory permissions
#	Do the net stuff separately or the argument list gets too long.
DIRS=`find $TARGDIR -type d -print`
NDIRS=`find $NETTARG/net $NETTARG/netinet -type d -print`
chmod 755 $DIRS 
chmod 755 $NDIRS 
FILES=`find $TARGDIR -type f -print`
NFILES=`find $NETTARG/net $NETTARG/netinet -type f -print`
chmod 664 $FILES
chmod 664 $NFILES
#	If native build then set owner and group
if [ "$ROOT" = "" ]
then
	chgrp bin $FILES
	chown bin $FILES
	chgrp bin $DIRS
	chown bin $DIRS
	chgrp bin $NFILES
	chown bin $NFILES
	chgrp bin $NDIRS
	chown bin $NDIRS
fi
exit 0
