#! /bin/csh

# Set default version number, typically the latest version installed;
# Set by install.vx during installation;

setenv VX_VER 4.1
setenv VX_PATH /acis/vx
setenv PWORKS_PATH 

# Setup platform;
set os_name=`uname`;
set os_ver=`uname -r`;
if ( $os_name == "IRIX" ) then
	set plat=sgi`echo $os_ver | awk -F. '{print $1}'`;
	setenv RESOURCE_NAME VX_UIF
	setenv EXTRASMENU $VX_PATH/$plat/vx_$VX_VER/supp/text_extras_menu
else if ( $os_name == "SunOS" ) then
	set plat=sun`echo $os_ver | awk -F. '{print $1}'`;
	limit descr 256
else
   echo "Wrong Hardware Platform";
	exit
endif

if ( $plat == "sun5" ) then
	setenv LD_LIBRARY_PATH $LD_LIBRARY_PATH":"/opt/SUNWits/Graphics-sw/xgl-3.0":"/opt/SUNWits/Graphics-sw/xgl-3.0/lib
endif

# parse command line arguments for version number, if any;
set found=0;
foreach word ($*)
   if ( $found == 1 ) then
      setenv VX_VER "$word";
      break
   endif
	if ( "$word" == '-v' ) then
		set found=1;
	endif
end

if ( $VX_VER == "VX_VER_HERE" ) then
   set maj = `cat vxv-* | awk -F: '{print $1}'`
	set min = `cat vxv-* | awk -F: '{print $2}'`
	set rel = `cat vxv-* | awk -F: '{print $3}'`
	setenv VX_VER $maj.$min
	setenv VX_PATH .
	setenv VX_START_HELP 1
endif

# exec vx_<ver> script; if vx_<ver> file exists;
if ( -x ./vx_$VX_VER ) then
	exec ./vx_$VX_VER $*
else if ( -x $VX_PATH/vx_$VX_VER ) then
	exec $VX_PATH/vx_$VX_VER $*
else
	echo ""
	echo "Unable to locate vx_$VX_VER."
	echo ""
	echo "Verify that the vx script contains the proper version number and path."
	echo "Verify the settings of VX_VER and VX_PATH variables in the vx script."
	echo ""
	echo "Type vx -help for valid options."
   echo ""
	exit 1
endif
