#!/usr/bin/sh
# *****************************************************************************
# *****************************************************************************
# lef2oa
#
# This script is wrapper for lef2oa.  You can set the following options
# depending on how you would like to use lef2oa.
#
# Mode:
# The default use is to run the optimized mode.  To specify debug mode
# for all programs, you should set the OA_MODE environment variable to 'dbg'.
#
# To set the mode to 'dbg' on an individual program you should
# set the BINARYNAME_MODE environment variable to 'dbg'.
#
# Bit:
# The default use is to run 64bit code.  To specify 32bit for all
# programs, set the OA_BIT environment variable to '32'.
#
# To specify the bit as '32' for a specific program, you should
# set the BINARYNAME_BIT environment variable to '32'.
#
# DataModel:
# The default use is to run with data model 4. To specify another data model,
# set the OA_DATAMODEL environment variable to the intended data model.
#
# *****************************************************************************
# Except as specified in the OpenAccess terms of use of Cadence or Silicon
# Integration Initiative, this material may not be copied, modified,
# re-published, uploaded, executed, or distributed in any way, in any medium,
# in whole or in part, without prior written permission from Cadence.
#
#                Copyright 2002-2011 Cadence Design Systems, Inc.
#                           All Rights Reserved.
#
# $Author: dell $
# $Revision: #2 $
# $Date: 2017/05/16 $
# $State: Exp $
#
# *****************************************************************************
# *****************************************************************************



PROGRAM=lef2oa
INSTALL_ROOT=`dirname $0`
unset cdpath
INSTALL_ROOT=`cd $INSTALL_ROOT/..;pwd`

BIT=${OA_BIT:-64}
BIT=${LEF2OA_BIT:-$BIT}

MODE=${OA_MODE:-opt}
MODE=${LEF2OA_MODE:-$MODE}

if [ -n "$OA_NOINFO" ] ; then
  NOINFO="-noInfo $OA_NOINFO"
fi

echo "$@" | egrep -e '-dataModel ' > /dev/null
if [ $? -ne 0 ]
then
  if [ -n "$OA_DATAMODEL" ] ; then
    ARGS="-dataModel $OA_DATAMODEL"
  else
    if [ -r $INSTALL_ROOT/data/OA.DATAMODEL ] ; then
      ARGS="-dataModel `cat $INSTALL_ROOT/data/OA.DATAMODEL`"
    fi
  fi
fi

exec $INSTALL_ROOT/bin/runExe $PROGRAM $INSTALL_ROOT $BIT $MODE $ARGS $NOINFO "$@"
