#!/bin/sh

#
# @(#)locate_dirs	1.4 96/07/03  
#
# Copyright (c) 1994 Sun Microsystems, Inc. All Rights Reserved.
#
# Permission to use, copy, modify, and distribute this software
# and its documentation for NON-COMMERCIAL purposes and without
# fee is hereby granted provided that this copyright notice
# appears in all copies. Please refer to the file "copyright.html"
# for further important copyright and licensing information.
#
# SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
# THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
# TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
# PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
# ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
# DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
#

if [ "$_SS_DEBUG" ]
then
  set -x
fi

# Given the root of a JDK tree, set _SS_JDK_HOME to the parent directory
#	of bin,classes and lib
#
# There are two types of JDK directories. Installation areas have been obsoleted.
#
#	* build directories are identical to the JDK directory provide
#		by JavaSoft.  Not a stable area.  Iteam members are
#		discouraged from relying on this area.
#	* archive directories simply copy all content from the build
#		directory that is to be shipped to the user.  On win32,
#		redist is moved to bin.
#   jsk, 7-3-96


if [ ! -d "$_SS_JWS_HOME" ] ; then
    echo "Invalid _SS_JWS_HOME: $_SS_JWS_HOME" 1>&2 
    exit 1
fi

if [ ! -r "$_SS_JWS_HOME/lib/basicframe.properties" ] ; then
    echo "Invalid _SS_JWS_HOME: $_SS_JWS_HOME/lib/basicframe.properties" 1>&2 
    exit 1
fi

VARIANT=`$_SS_JWS_HOME/solaris/bin/variant`

if [ ! "${_SS_JDK}" ]
then
  _SS_JDK=`cd $_SS_JWS_HOME/../JDK; pwd`
  if [ ! -d $_SS_JDK ]
  then
	echo "Unknown JDK, please set _SS_JDK to the JDK's path"
	exit 1
  fi
fi

# Is this a build directory?  By reseting the _SS_JDK variable, we make both
# build and archive directories identical for the pursue of building JWS.
#  jsk 6-8-96

if [ -d $_SS_JDK/build ]
then
  _SS_JDK=$_SS_JDK/build
fi

if [ -d $_SS_JDK/bin ]
then
  # we have a JDK build or archive area containing bin, lib and classes.
  if [ ! -d $_SS_JDK/lib ]
  then
    echo "No lib directory in JDK.  Have you built it correctly?"
    exit 1
  fi
  if [ ! -f $_SS_JDK/lib/classes.zip -a ! -d $_SS_JDK/classes ]
  then
    echo "No lib/classes.zip file in JDK.  Have you built it properly?"
    exit 1
  fi
  _SS_JDK_HOME=$_SS_JDK
else
  echo "No bin directory in JDK workspace.  Have you built it?"
  exit  1
fi


# needs to be exported, because it is referenced by JWS builder
# in solaris/bin/javac
export _SS_JDK_HOME

