#!/sbin/sh

########
#  Product: GraphicsPHIGSDK
#  Fileset: PHIGS-DEMO
#  postinstall
#  @(#) $Revision: 206.1 $
########
#
# (c) Copyright Hewlett-Packard Company, 1993
#
########

	UTILS="/usr/lbin/sw/control_utils"

	if [[ ! -f $UTILS ]]
	then
		echo "ERROR: Cannot find $UTILS"
		exit 1
	fi

	. $UTILS

	exitval=$SUCCESS

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

	##
	## Set up local environment variables
	##

	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

	PHIGS_DIR="${SW_INSTALL_DIR}"
	PHIGS_HOME_DIR="${SW_LOCATION}"

	##
	##  Handy dandy function to create a symbolic link and add the name
	##  to the IPD for this Product/Fileset.
	##
	link_and_add_IPD ()
	{
		LINK_TARGET=$1
		LINK_NAME=$2
		if [ -h $LINK_NAME ]
		then
			rm -f $LINK_NAME > /dev/null 2>&1
		fi
		ln -s $LINK_TARGET $LINK_NAME > /dev/null 2>&1

		##
		## Do not try to add the sym_link to the IPD unless
		## the target exists under the same product directory.
		##
		echo $LINK_TARGET | fgrep "$PHIGS_HOME_DIR" > /dev/null 2>&1
		STATUS="$?"

		if [ -f "${SW_ROOT_DIRECTORY}$LINK_TARGET" -a "$STATUS" = "0" ]
		then
			IPD_addfile $LINK_NAME
		fi
	}


	##
	## Symbolically link the western_europe.h file from the
	## namesets directory to the input directory.
	##
	WEST_EURP_TARGET="${PHIGS_HOME_DIR}examples/OReilly/namesets/western_europe.h"
	WEST_EURP_LINK_NAME="${PHIGS_DIR}examples/OReilly/input/western_europe.h"

	link_and_add_IPD $WEST_EURP_TARGET $WEST_EURP_LINK_NAME

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