#!/bin/sh
##---------------------------------------------------------------------- 
##   Copyright 2010 Cadence, Inc. 
##   Copyright 2011 Mentor Graphics Corporation
##   All Rights Reserved Worldwide 
## 
##   Licensed under the Apache License, Version 2.0 (the 
##   "License"); you may not use this file except in 
##   compliance with the License.  You may obtain a copy of 
##   the License at 
## 
##       http://www.apache.org/licenses/LICENSE-2.0 
## 
##   Unless required by applicable law or agreed to in 
##   writing, software distributed under the License is 
##   distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 
##   CONDITIONS OF ANY KIND, either express or implied.  See 
##   the License for the specific language governing 
##   permissions and limitations under the License. 
##----------------------------------------------------------------------
for i in "$@" ; do
        case $i in 
                -tool) OPT_TOOL=1
                        shift ;;
                --) shift ; break ;;
        esac
done

function checkPath() {
	IFS=':'
	for dir in $PATH ; do if [ -x "$dir/$1" ];then return 0; fi ; done
	return 1
}

arch=`dirname $0`/uvm_os_name
arch=`$arch`

if [ "x" != "x${MTI_HOME}" ]; then
	tool="questa"
elif checkPath ncroot; then
	tool="ius"
elif [ "x" != "x${VCS_HOME}" ]; then
	tool="vcs"
else	
	tool="unknown"
fi

      
if [ $OPT_TOOL ]; then
	echo $tool
else
 	relpath=`dirname $0`/../lib/$arch/libuvm_$tool.so
	D=`dirname "$relpath"`
	B=`basename "$relpath"`
	abspath="`cd \"$D\" 2>/dev/null && pwd || echo \"$D\"`/$B"
      
	echo $abspath
fi



                      
