#! /bin/sh
# ident "@(#)doit 3.1 98/09/29 SMI"
# Copyright (c) 09/29/98, by Sun Microsystems, Inc.
# All rights reserved.
#

. /etc/opt/SUNWconn/jaw/conf/jaw.env

if [ $# -lt 2 ]; then
	echo "Usage: $0 <kstat module name> <kstat instance name>"
	echo "       example :"
	echo "                $0 le le0"
	exit 1
fi

MODNAME=$1
INSTANCE=$2

#
#
# echo "Modname = ${MODNAME} Instance = ${INSTANCE}"

# exit 0
#
java examples.mo.kstat.build ${MODNAME} ${INSTANCE}

if [ -f ${INSTANCE}.java ]; then

	echo "Compiling ${INSTANCE}.java..."
	javac -d . ${INSTANCE}.java

	echo "Generating JAW interface and stub..."
	mogen examples.mo.kstat.${INSTANCE}

	if [ -f ${INSTANCE}MO.java ]; then
		echo "Compiling the interface..."
		javac -d . ${INSTANCE}MO.java

		echo "You now can use examples.mo.kstat.${INSTANCE}"
		exit 0
	else
		echo "$0: Can not build ${INSTANCE}MO.java"
		exit 1
	fi
else 
	echo "$0: Can not build ${MODNAME} ${INSTANCE}"
	exit 1
fi
