File: babel.in

package info (click to toggle)
babel 0.10.2-1
  • links: PTS
  • area: contrib
  • in suites: sarge
  • size: 43,932 kB
  • ctags: 29,707
  • sloc: java: 74,695; ansic: 73,142; cpp: 40,649; sh: 18,411; f90: 10,062; fortran: 6,727; python: 6,406; makefile: 3,866; xml: 118; perl: 48
file content (258 lines) | stat: -rwxr-xr-x 6,802 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
#! @SHELL@
## File:        babel
## Package:     Babel binary
## Copyright:   (c) 2000-2001 The Regents of the University of California
## Revision:    $Revision: 4434 $
## Modified:    $Date: 2005-03-17 09:05:29 -0800 (Thu, 17 Mar 2005) $
## Description: main babel run script
##

# 
# This whole script exists to hide the fact that the babel
# compiler is written in java.  It launches the babel-x.x.x.jar
# file with a java virtual machine, sets the classpaths, and 
# usually also adds the default repository (unless specifically excluded
# by a commandline option).
# 

#
# Settings determined at configure time.
#
VERSION="@VERSION@"
PACKAGE="@PACKAGE@"
prefix="@prefix@"
exec_prefix="@exec_prefix@"
datadir="@datadir@"
bindir="@bindir@"
JAVA="@JAVA@"
WHICH_JAVA="@WHICH_JAVA@"
TEST_EF="@TEST_EF@"
abs_top_builddir="@abs_top_builddir@"
python="@PYTHON@"

samefile() 
{
  # returns 0 if first two arguments are files with the same inode
  # returns 1 if less than two arguments, or either are not found, 
  #           or they are not the same inode
  if test "$TEST_EF" = "None"; then
    if $verbose; then 
      echo "samefile() using $python"
    fi
    if test -e "$1"; then 
      if test -e "$2"; then 
        return `$python - "$1" "$2" <<EOF
import os.path
import sys
print not os.path.samefile( sys.argv[1], sys.argv[2] )
EOF`
      fi
    fi
    return 1;
  else
    if $verbose; then 
      echo "samefile() using $TEST_EF";
    fi
    $TEST_EF "$1" -ef "$2"
    return $?
  fi;
}

#
# Remove ./path and path1/./path2 from non-arguments for AIX JVM.  
# Also detect if we are debugging or need extra verbiage.
#
args=""
debug=false;
verbose=false;
quiet=true;
default_repo=true;
override_installpath=false;
for a in $@; do
  case "$a" in
    --debug) debug=true; a=;;
    --verbose) verbose=true; quiet=false; a=;;
    --noquiet) quiet=false; a=;;
    --no-default-repository | -!) default_repo=false; a=;;
    --override-installpath) override_installpath=true; a=;;
    -*) ;;
    *) a=`echo $a | sed -e 's,^\./,,g' -e 's,/\./,/,g'`;;
  esac
  args="$args $a"
done

#
# make sure user's environment isn't incompatible with installation
#
THIS_JAVA="$WHICH_JAVA"
THIS_JDB="jdb"
my_java=`which ${JAVA}`
java_found=$?
if test "x${my_java}" != "x${WHICH_JAVA}"; then
  if samefile ${my_java} ${WHICH_JAVA}; then 
    :
  else
    if test "$override_installpath" = "false"; then
      echo "warning: Babel configured for ${WHICH_JAVA},"
      echo "         your environment set up for ${my_java}."
      echo "         Babel will use what it was configured for,"
      echo "         You can override with the --override-installpath option"
    else
      THIS_JAVA="$JAVA"
    fi;
  fi;
fi; 

#
# Test if we are running under cywin.
#
case "`uname`" in
  CYGWIN*) cygwin=true;;
  *) cygwin=false;;
esac


#
# Now we need to determine where the jar-files are.
#

#test if $0 is the same inode as where babel script is installed.
path2me=$0
myname=babel
SYSJAR=/usr/share/java
is_installed="false"
if samefile ${bindir}/${myname} $path2me; then 
  is_installed="true"
  BABELJAR="${datadir}/java"
  if $verbose; then 
     echo "Just use paths determined at configure time to find jar files..."
  fi
else
  if $verbose; then 
     echo "Make a best effort to chase down symbolic links to find the jar files..."
  fi
  # 
  PWD_SAVE=`pwd`
  done="false"
  while test $done = "false"; do
    if $verbose; then 
       echo "loop: path2me = "$path2me
    fi
    # first chase down symbolic links in directories
    cd `dirname $path2me`                      # cd to the directory where I exist
    mydir=`pwd`
    myname=`basename $path2me`
    newpath2me="$mydir/$myname"                # get new path2me from current working directory
    # next chase down symbolic links in files
    for i in `ls -l $newpath2me`; do
      :
    done
    if test "$i" = "$path2me"; then
      done="true"
    fi
    path2me=$i
  done
  mypath=`dirname $path2me`
  cd "$mypath/.."
  exec_prefix=`pwd`
  if test -e ${exec_prefix}/lib/${PACKAGE}-${VERSION}.jar; then
    prefix=${exec_prefix}
  elif test -e ${exec_prefix}/../lib/${PACKAGE}-${VERSION}.jar; then
    prefix=`(cd ${exec_prefix} && pwd)`
  else
    echo "ERROR: $0 " >&2
    echo "    This script to launch Babel is not located in installation directory" >&2 
    echo "    (as set by configure).  It tried to find the required JAR files based" >&2
    echo "    its the location (chasing down links, if necessary), but failed." >&2
    echo "    Has this script been separated from the rest of the Babel package?" >&2
    exit -1 
  fi 
  cd $PWD_SAVE
  BABELJAR="${prefix}/lib"
fi
if $verbose; then 
  echo "  prefix=\"${prefix}\""
  echo "  exec_prefix=\"${exec_prefix}\""
  echo "  is_installed=\"${is_installed}\""
fi

#
# Set the CLASSPATH based on the BABEL home directory
#
if test -e ${BABELJAR}/${PACKAGE}-${VERSION}.jar; then
  if $verbose; then
    echo "Looking for jar files in \"${BABELJAR}\"...";
  fi
else 
  echo "ERROR: $0 " >&2
  echo "   Expected to find ${BABELJAR}/${PACKAGE}-${VERSION}.jar" >&2
  exit 1
fi

BABELCP=${BABELJAR}/${PACKAGE}-${VERSION}.jar:${SYSJAR}/gnu-getopt.jar:${SYSJAR}/xercesImpl.jar:${SYSJAR}/xmlParserAPIs.jar:${SYSJAR}/xml-apis.jar
if test "X$CLASSPATH" = "X"; then
  CLASSPATH=${BABELCP}
else
  CLASSPATH=${BABELCP}:${CLASSPATH}
fi
unset BABELCP

#
# If the SIDL repository exists, then add it to the default repository path.
#

REPOSITORY=
REPOSITORY_PATH=
if $default_repo; then
  if test $is_installed = "true"; then 
    REPOSITORY="${datadir}/${PACKAGE}-${VERSION}/repository"
  else
    REPOSITORY="${abs_top_builddir}/share/repository"
  fi
  if test -d ${REPOSITORY}; then
    if $verbose; then 
      echo "Looking for SIDL XMLs in \"${REPOSITORY}\"...";
    fi 
    if $cygwin; then
      REPOSITORY=`cygpath --path --windows "${REPOSITORY}"`
      REPOSITORY_PATH="--repository-path=\"${REPOSITORY}\""
    else 
      REPOSITORY_PATH="--repository-path=${REPOSITORY}"
    fi
  else
    echo "ERROR: $0 " >&2
    echo "    The default XML repository of SIDL types was expected in" >&2
    echo "       ${REPOSITORY}" >&2
    exit -1
  fi
fi

#
# Modify other paths for Cygwin if necessary.
#
if $cygwin; then
  exec_prefix=`cygpath --path --windows "${exec_prefix}"`
  prefix=`cygpath --path --windows "${prefix}"`
  CLASSPATH=`cygpath --path --windows "${CLASSPATH}"`
fi

#
# Run the babel command line driver
#
if $debug; then
  THIS_JAVA=$THIS_JDB
fi

if test $quiet = false; then 
  echo "CLASSPATH = ${CLASSPATH}"
  echo ${THIS_JAVA} gov.llnl.babel.CommandLineDriver ${REPOSITORY_PATH} ${args}
fi;
export CLASSPATH
${THIS_JAVA} gov.llnl.babel.CommandLineDriver ${REPOSITORY_PATH} ${args}

exitstat=$?
if test $quiet = false; then
  echo exit status = $exitstat
fi;

exit $exitstat