# $Copyright:	$
# Copyright (c) 1984, 1985, 1986, 1987, 1988, 1989, 1990 
# Sequent Computer Systems, Inc.   All rights reserved.
#  
# This software is furnished under a license and may be used
# only in accordance with the terms of that license and with the
# inclusion of the above copyright notice.   This software may not
# be provided or otherwise made available to, or used by, any
# other person.  No title to or ownership of the software is
# hereby transferred.
#ident	"$Header: :mkhead 1.15 89/12/06 $@(#)mk::mkhead	1.17"
#
#	Install UNIX System header files
#
TARGDIR=$ROOT/usr/include
SRCDIR=${SRC:-$ROOT/usr/src}/head
TMPFILE=/tmp/mkhead$$
umask 222
# Make sure there really is work to be done in this view
#
if [ ! -d $SRCDIR ]
then
        exit 0
fi

trap "rm -f $TMPFILE ; exit 1" 1 2 3 15
#
#	Determine files to be processed
if [ $# -gt 0 ]
then
	(cd $SRCDIR; ls $* | sed -e 's/sys\.[^ ]*//g' > $TMPFILE)
else
	(cd $SRCDIR; find . -type f -print | grep -v .ccsmark | sed -e '/sys\.[^ ]*/d' > $TMPFILE)
fi
#
echo "\nInstalling $SRCDIR into $TARGDIR:"
if [ ! -d $TARGDIR ]
then
	rm -rf $TARGDIR
	mkdir $TARGDIR
fi
echo "./sys.s"
cat $TMPFILE | pr -ta5
echo "\nCurses.h, unctrl.h, and term.h are installed by libcurses\n"

#
#	Copy system-dependent sysent table file
if vax
then
	cp $SRCDIR/sys.vax $TARGDIR/sys.s
elif pdp11
then
	cp $SRCDIR/sys.pdp $TARGDIR/sys.s
elif u3b2
then
	if [ -f $SRCDIR/sys.u3b15 ]
	then	cp $SRCDIR/sys.u3b15 $TARGDIR/sys.s
	elif [ -f $SRCDIR/sys.u3b5 ]
	then	cp $SRCDIR/sys.u3b5 $TARGDIR/sys.s
	fi
elif i386
then
	cp $SRCDIR/sys.i386 $TARGDIR/sys.s
fi
chmod 444 $TARGDIR/sys.s
chgrp 2 $TARGDIR/sys.s
chown 2 $TARGDIR/sys.s

#
#	Install requested files
(cd $SRCDIR; cat $TMPFILE | cpio -pdu $TARGDIR
#	Set file permissions
cd $TARGDIR
chmod 444 `cat $TMPFILE`
chgrp 2 `cat $TMPFILE`
chown 2 `cat $TMPFILE`
)
wait
rm -f $TMPFILE
date
exit 0
