# $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	"@(#)mk::mklib	1.5"
#
#	Build UNIX System libraries
#	For each directory build the library by invoking its
#	makefile (<dir>.mk).
#
trap "exit 1" 1 2 3 15
PARALLEL=2 export PARALLEL
MAKE=${MAKE:-make}
SRCDIR=${SRC:-$ROOT/usr/src}/lib

# Make sure there is really word to be done in this view
#
if [ ! -d $SRCDIR ]
then
        exit 0
fi


cd $SRCDIR
#
for ARG in $*
do (
	LIB=`basename $ARG`
	if [ -d $LIB ]
	then (
		echo "======== $LIB"
		cd $LIB
		if [ -f $LIB.mk ]
		then
			PARALLEL=20 export PARALLEL
			$MAKE -P20 -b -f $LIB.mk install I="install -i -n $ROOT/lib $ROOT/usr/lib"
			if [ $? -ne 0 ]
			then
				echo ":mklib: *** $MAKE failed using $LIB.mk"
			fi
			$MAKE -b -f $LIB.mk clobber
		else
			echo ":mklib: *** no $LIB.mk file in $SRCDIR/$LIB"
		fi
	) else
		echo ":mklib: *** no directory found for $LIB under $SRCDIR"
	fi
)
done
date
exit 0
