#!/sbin/sh

########
# Product:  GraphicsCommon
# Fileset:  STAR-RUN
# configure
#
# $Source: /hmstmp/update.25011/./release/SD/GraphicsCommon/STAR-RUN/configure,v $
# $Revision: 550.2 $
# $Date: 96/07/16 11:09:43 $
#
########
#
# (c) Copyright Hewlett-Packard Company 1994
#
########

	set -a       					# export all vars
	exitval=0					# anticipate success

	UTILS="/usr/lbin/sw/control_utils"
	if [[ ! -f $UTILS ]]
	then
		echo "ERROR:    Cannot find UTILS"
		exit 1
	fi
	. $UTILS

################################################################################
#set -x # For debugging purposes.  _Never_ ship uncommented!!


	SW_INSTALL_DIR="/"

	##
	## Test to see if either SW_ROOT_DIRECTORY or SW_LOCATION is
	## set to something other than /.  If so, set up SW_INSTALL_DIR
	## so it will not have spurious /'s in the path name.
	##
	
	if [ $SW_ROOT_DIRECTORY != / -o $SW_LOCATION != / ]
	then
		if [ $SW_ROOT_DIRECTORY != / ]
		then
			if [ $SW_LOCATION != / ]
			then
				SW_INSTALL_DIR="${SW_ROOT_DIRECTORY}${SW_LOCATION}"
			else
				SW_INSTALL_DIR="${SW_ROOT_DIRECTORY}"
			fi
		else
			if [ $SW_LOCATION != / ]
			then
				SW_INSTALL_DIR="${SW_LOCATION}"
			fi
		fi
	fi

	##
	## Emit notification of dropping support for RAW mode.  This support
	## was dropped at release 9.05.
	##
	## echo "NOTE:    Support for Raw Mode graphics was discontinued"
	## echo "         beginning with the HP-UX 9.05 release.  All graphics"
	## echo "         must be done using the X Windows system."
	## echo "         See ReleaseNotes for more information."

	DEFAULTS_FILE="config/defaults"
	STROKE_DIR="stroke"
	RASTER_DIR="raster"
	ETC_OPT_DIR="${SW_ROOT_DIRECTORY}etc/opt/starbase"

	DEFAULTS_SYM_LINK="$ETC_OPT_DIR/defaults"
	STROKE_SYM_LINK="$ETC_OPT_DIR/stroke"
	RASTER_SYM_LINK="$ETC_OPT_DIR/raster"

	DEFAULTS_TARGET="${SW_INSTALL_DIR}${DEFAULTS_FILE}"
	STROKE_TARGET="${SW_INSTALL_DIR}${STROKE_DIR}"
	RASTER_TARGET="${SW_INSTALL_DIR}${RASTER_DIR}"

	##
	## Create the "defaults" symbolic link (if it doesn't already
	## exist) from the /etc/opt/starbase directory to the defaults
	## file in /opt/graphics/common/config/defaults.
	##

	##
	## Is the directory already there?  If not, create it.
	##
	if [ ! -d $ETC_OPT_DIR ]
	then
		mkdir -p $ETC_OPT_DIR > /dev/null 2>&1
	fi

	##
	## Is the symbolic link for the defaults file already there?  If
	## not, check to see if it may be a user's defaults file.  DON'T 
	## stomp on a user's custom defaults file!  If there is no file
	## present, it is safe to test for and then create a symbolic link
	## if required.
	##
	if [ ! -f $DEFAULTS_SYM_LINK ]
	then
		##
		## No file present.  Test to see if a symbolic link is
		## present.
		##
		if [ ! -h $DEFAULTS_SYM_LINK ]
		then
			##
			## Create the symbolic link
			##
			ln -s $DEFAULTS_TARGET $DEFAULTS_SYM_LINK > /dev/null 2>&1
		fi
	fi

	##
	## Create the "stroke" symbolic link (if it doesn't already exist)
	## from the /etc/opt/starbase/ directory to the /opt/graphics/common.
	##

	##
	## Is the symbolic link for stroke fonts already there?  If
	## is no link present or no directory of that name is present,
	## it is safe to test for and then create the symbolic link.
	##
	if [ ! -h $STROKE_SYM_LINK -o ! -d $STROKE_SYM_LINK ]
	then
		##
		## Create the symbolic link
		##
		ln -s $STROKE_TARGET $STROKE_SYM_LINK > /dev/null 2>&1
	fi

	##
	## Create the "raster" symbolic link (if it doesn't already exist)
	## from the /etc/opt/starbase/ directory to the /opt/graphics/common.
	##

	##
	## Is the symbolic link for raster fonts already there?  If
	## is no link present or no directory of that name is present,
	## it is safe to test for and then create the symbolic link.
	##
	if [ ! -h $RASTER_SYM_LINK -o ! -d $RASTER_SYM_LINK ]
	then
		##
		## Create the symbolic link
		##
		ln -s $RASTER_TARGET $RASTER_SYM_LINK > /dev/null 2>&1
	fi

	exit $exitval
################################################################################
