#!/bin/sh
#			Copyright (c) 1993 by
#			Advanced Visual Systems Inc.
#			All Rights Reserved
#	
#	This software comprises unpublished confidential information of
#	Advanced Visual Systems Inc. and may not be used, copied or made
#	available to anyone, except in accordance with the license
#	under which it is furnished.
#	
#	This file is under Perforce control
#	$Id: //depot/express/fcs70/build/xp_exec.sh#1 $
#	
#
# This script can be executed whenever a user needs to start a machine
# dependent executable.  It is used particularly by the xp_start shell script
# to start up a process from an "rsh" or whatever command. 
#
ARGS=""
while [ $# -gt 0 ] ; do
  case $1 in
    -path)	XP_PATH=$2
		export XP_PATH
		shift
		;;
    *)		ARGS="$ARGS $1"
		;;
  esac
  shift
done

BIN_PATH=""
for path in $XP_PATH ; do
   BIN_PATH="$BIN_PATH:$path/bin"
   if [ "$MACHINE" = "" ] ; then
      if [ -x $path/bin/xp_mach ] ; then
         MACHINE=`$path/bin/xp_mach`
      fi
   fi
done

if [ "$MACHINE" = "" ] ; then
   echo "xp_exec: no defined value for MACHINE variable"
   exit 1
fi

XP_LIB_PATH=""
for path in $XP_PATH ; do
   BIN_PATH="$BIN_PATH:$path/bin/$MACHINE"
   XP_LIB_PATH="$XP_LIB_PATH:$path/lib/$MACHINE"
done

PATH="$PATH:$BIN_PATH"
export PATH

# For HP's
SHLIB_PATH="$SHLIB_PATH:$XP_LIB_PATH"
export SHLIB_PATH

# For the rest of the known universe
LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$XP_LIB_PATH"
export LD_LIBRARY_PATH

if $ARGS ; then
  :
else
  echo "xp_exec: unable to execute program: $ARGS on host: `hostname`"
  echo "xp_exec: using PATH: $PATH"
fi

exit 0
