#!/bin/sh
#
#ident	"@(#)cp_protolibs.sh	1.2	93/11/10 SMI"
#
# Copyright (c) 1993 by Sun Microsystems, Inc.
#
#	Copies headers and libraries (as would be created by the protolibs
# target of usr/src/Makefile) from a full proto area to a destination.
#

USAGE='usage: cp_protolibs <proto_area> <destination_area>'

if [ $# -ne 2 ]
then
	echo "$USAGE"
	exit 1
fi

if [ ! -d $1/usr/include ]
then
	echo "cp_protolibs: First argument should be an existing proto area,"
	echo "but $1/usr/include does not exist."
	echo ""
	echo "$USAGE"
	exit 1
fi

# wildcards are expanded with the eval after the cd below
#
COMMONDIRS='etc/lib usr/include usr/ucbinclude usr/lib/lib*.a usr/lib/lib*.so*
  usr/lib/libp usr/lib/pics usr/ccs/lib usr/ucblib usr/kvm/lib*
  usr/share/src/uts'

MACH=`uname -p`
case $MACH in
  sparc )  DIRLIST="$COMMONDIRS "'sun4/usr/kvm/libkvm* sun4?/usr/kvm/libkvm*' ;;
  i386 )   DIRLIST="$COMMONDIRS "'i86pc/usr/kvm/libkvm*' ;;
  ppc )   DIRLIST="$COMMONDIRS "'prep/usr/kvm/libkvm*' ;;
  * )	   echo "unknown instruction set, no protolibs copied"
	   exit 1 ;;
esac

cd $1
[ -d $2 ] || mkdir -p $2

# now the wildcards have meaning
#
#eval 'tar -cf - $DIRLIST | ( cd $2; tar -xvpf - )'
eval 'tar -cf - . | ( cd $2; tar -xvpf - )'
