#! /bin/ksh
#
# ident "@(#)scdsbuilder.ksh 1.12     01/02/13 SMI"
#
# Copyright (c) 1999-2001 by Sun Microsystems, Inc.
# All rights reserved.
#

# Define msg. file name and location
# NOTE: TEXTDOMAIN must be kept in sync with the TEXT_DOMAIN var in the
# makefiles.
typeset -x TEXTDOMAIN=SUNW_SC_CMD
typeset -x TEXTDOMAINDIR=/usr/cluster/lib/locale

export PATH=/bin:/usr/bin:/usr/cluster/bin:/usr/sbin:$PATH
# first find out if the c ompiler -- cc -- exists in user's path
whence cc 1>/dev/null
if [[ $? != 0 ]]; then

	# cc does not exist
	if [[ -f rtconfig ]]; then
		# rtconfig file exists in the current dir, i.e. there already
		# exists a RT in the current dir

		# retrieve the RT_NAME and the SOURCE_TYPE
		RT_NAME=`nawk -F= '/^RT_NAME/ {print $2}' rtconfig`
		SOURCE_TYPE=`nawk -F= '/^SOURCE_TYPE/ {print $2}' rtconfig`

		# if it is C then exit immediately, because can't load
		# the RT in the current directory
		if [[ $SOURCE_TYPE == C ]]; then
			lmsg=`gettext '\n\
Resource Type <%s> found in the current directory requires C compiler,\n\
which was not found in your path.\n\
Please make sure cc is in your path.\n\
Or run the Builder from a different directory.\n\
Exiting ...'`
			printf "${lmsg}\n\n" "$RT_NAME"
			exit 1
		fi
	fi

	# Either no RT exists in the current directory, or
	# it's not a C RT
	# So launch the Wizard with the -k option, indicating that cc was not
	# found. we only set the KSH variable here, which will be used while
	# launching the Wizard later.
	KSH=-k
fi

java -classpath /usr/cluster/lib/scdsbuilder/classes \
	com.sun.scdsbuilder.SCDSBuilder $KSH
