| 1 | #! /bin/sh |
| 2 | # |
| 3 | # .local_perlmod_wrapper |
| 4 | # |
| 5 | |
| 6 | |
| 7 | die () { |
| 8 | message="$1" |
| 9 | echo "$tool -> .local_perlmod_wrapper: $message Exiting ..." |
| 10 | exit 1 |
| 11 | } |
| 12 | |
| 13 | ############################ main ############################## |
| 14 | |
| 15 | tool=`basename $0` |
| 16 | ARGV="$*" |
| 17 | TRE_ROOT=$DV_ROOT/tools/perlmod |
| 18 | TRE_TOOL2TOOLSET=${TRE_TOOL2TOOLSET:=$TRE_ROOT/tool2toolset} |
| 19 | |
| 20 | ### Get toolset (a.k.a. package) name from the "tool2toolset" file |
| 21 | |
| 22 | toolset=`awk '{if($1 == var)print $2}' var=$tool $TRE_TOOL2TOOLSET` |
| 23 | if [ -z "$toolset" ] ; then |
| 24 | die "flow not found!" |
| 25 | else |
| 26 | TOOLSET=`echo $toolset |tr '[a-z]' '[A-Z]'` |
| 27 | fi |
| 28 | |
| 29 | ### Version may be set either by TRE or by environment variable |
| 30 | ### 'VERSION_$TOOLSET', if case TRE_ENTRY is set to '/'. |
| 31 | ### Either way, the version MUST be set. |
| 32 | |
| 33 | eval vers=\$VERSION_$TOOLSET |
| 34 | |
| 35 | if [ ! -z "$vers" ] && [ "$TRE_ENTRY" = '/' ] ; then |
| 36 | version=$vers |
| 37 | elif [ ! -z "$TRE_SEARCH" ] && [ ! -z "$TRE_ENTRY" ] ; then |
| 38 | if [ `uname -s` = "Linux" ]; then |
| 39 | version=`$DV_ROOT/tools/Linux/x86_64/configsrch $toolset $TRE_ENTRY` || die "configsrch failed!" |
| 40 | fi |
| 41 | if [ `uname -s` = "SunOS" ]; then |
| 42 | version=`$DV_ROOT/tools/bin/configsrch $toolset $TRE_ENTRY` || die "configsrch failed!" |
| 43 | fi |
| 44 | version=`echo $version |awk '{print $1}'` |
| 45 | eval VERSION_$TOOLSET=\$version |
| 46 | eval export VERSION_$TOOLSET |
| 47 | else |
| 48 | die "TRE_SEARCH & TRE_ENTRY are not set." |
| 49 | fi |
| 50 | |
| 51 | ### VERSION_$TOOLSET **MUST** be set, even if TRE is not used. |
| 52 | |
| 53 | if [ -z "$version" ] ; then |
| 54 | die "No version set for flow '$toolset'." |
| 55 | fi |
| 56 | |
| 57 | ### try to execute the toolset member tool |
| 58 | ### (the version is passed in VERSION_$TOOLSET) |
| 59 | |
| 60 | # necessary for the moment |
| 61 | tool=midas |
| 62 | |
| 63 | # For versions at or before 3.09, use DiagBuild as the toolset |
| 64 | major=`echo $version | sed 's/\..*//'` |
| 65 | minor=`echo $version | sed 's/^.*\.//'` |
| 66 | if [ $major -le 3 ] && [ $minor -le 9 ] ; then |
| 67 | toolset='DiagBuild' |
| 68 | fi |
| 69 | |
| 70 | version=3.32 |
| 71 | |
| 72 | exe=$TRE_ROOT/$toolset/$version/bin/$tool |
| 73 | libpath=$TRE_ROOT/$toolset/$version/lib/site_perl/5.8.0 |
| 74 | |
| 75 | if [ -z "$PERL5LIB" ] ; then |
| 76 | PERL5LIB=$libpath |
| 77 | else |
| 78 | PERL5LIB=$libpath:$PERL5LIB |
| 79 | fi |
| 80 | export PERL5LIB |
| 81 | |
| 82 | if [ -x $exe ] ; then |
| 83 | exec $exe "$@" |
| 84 | else |
| 85 | die "Executable $exe not found!" |
| 86 | fi |