author | Claus Gittinger <cg@exept.de> |
Fri, 26 Oct 2001 19:49:18 +0200 | |
changeset 476 | 25c3df1d5c43 |
parent 454 | e8676bb3d081 |
child 482 | 94e7d89d7844 |
permissions | -rwxr-xr-x |
151 | 1 |
#!/bin/sh |
2 |
||
3 |
# $Header$ |
|
4 |
# |
|
5 |
# |
|
6 |
# startup script for smalltalk |
|
7 |
# actually, simply calls stx, passing all arguments. |
|
8 |
# |
|
9 |
||
10 |
# In previous versions, smalltalk used to be the executable itself. |
|
11 |
# This lead to problems on systems, where things like LD_LIBRARY_PATH |
|
12 |
# should be set in advance. |
|
13 |
# Now, here is a place to do such things ... |
|
14 |
||
164 | 15 |
# |
192 | 16 |
# -x name specifies an explicit executable |
277 | 17 |
# to avoid executing another stx from some directory along the PATH |
18 |
# (i.e to force use: ./smalltalk -x ./stx) |
|
192 | 19 |
# |
277 | 20 |
# -X name specifies an explicit path to the stx executable |
21 |
# to avoid executing another stx from some directory along the PATH |
|
22 |
# (i.e to force use: ./smalltalk -X .) |
|
341 | 23 |
# [almost the same as above] |
277 | 24 |
# |
25 |
# -ldd show ldd-output (to debug, which libs are loaded) |
|
26 |
# |
|
281 | 27 |
# all other args go to stx & the user classes |
277 | 28 |
# |
29 |
||
341 | 30 |
if [ "$1" = "--help" ] |
31 |
then |
|
32 |
echo |
|
33 |
echo "usage: smalltalk [-x prog] [-X dir] [-ldd] stx-args" |
|
34 |
echo |
|
35 |
echo "Args to the smalltalk startup shell script:" |
|
36 |
echo " -x prog use prog instead of stx as executable" |
|
37 |
echo " -X dir use stx from dir instead of default (PATH)" |
|
38 |
echo " -ldd show which shared libraries are used" |
|
39 |
echo " stx-args stx arguments as follows." |
|
40 |
echo |
|
41 |
echo "STX args:" |
|
42 |
fi |
|
43 |
||
277 | 44 |
STX=stx |
452 | 45 |
STX_BINDIR=. |
439 | 46 |
DEBUGGER= |
47 |
||
452 | 48 |
if test -x `dirname $0`/stx; then |
49 |
STX_BINDIR=`dirname $0` |
|
454
e8676bb3d081
Don't do a cd to projects/smalltalk if called with absolute pathname
Stefan Vogel <sv@exept.de>
parents:
452
diff
changeset
|
50 |
STX=$STX_BINDIR/stx |
e8676bb3d081
Don't do a cd to projects/smalltalk if called with absolute pathname
Stefan Vogel <sv@exept.de>
parents:
452
diff
changeset
|
51 |
# cd $STX_BINDIR |
452 | 52 |
fi |
53 |
||
476
25c3df1d5c43
ignore invalid STX_LIBDIR setting
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
54 |
if [ "$STX_LIBDIR" != "" ] |
25c3df1d5c43
ignore invalid STX_LIBDIR setting
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
55 |
then |
25c3df1d5c43
ignore invalid STX_LIBDIR setting
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
56 |
if [ ! -f $STX_LIBDIR/smalltalk.rc ] |
25c3df1d5c43
ignore invalid STX_LIBDIR setting
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
57 |
then |
25c3df1d5c43
ignore invalid STX_LIBDIR setting
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
58 |
echo "smalltalk [warning]: ignore wrong STX_LIBDIR setting" |
25c3df1d5c43
ignore invalid STX_LIBDIR setting
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
59 |
STX_LIBDIR="" |
25c3df1d5c43
ignore invalid STX_LIBDIR setting
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
60 |
fi |
25c3df1d5c43
ignore invalid STX_LIBDIR setting
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
61 |
fi |
25c3df1d5c43
ignore invalid STX_LIBDIR setting
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
62 |
|
25c3df1d5c43
ignore invalid STX_LIBDIR setting
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
63 |
|
383 | 64 |
# notice: STXLIBDIR is filled in here by install-sh script |
319 | 65 |
if test -z "$STX_LIBDIR" |
66 |
then |
|
67 |
bindir=`dirname $0` |
|
68 |
case "$bindir" in |
|
69 |
/* ) |
|
70 |
;; |
|
71 |
.* ) |
|
72 |
bindir=`( cd $bindir; pwd ) 2> /dev/null` |
|
73 |
;; |
|
74 |
esac |
|
434
f073cdbe422f
oops - LIBDIR/TOPDIR & PACKAGEDIR detection failed,
Claus Gittinger <cg@exept.de>
parents:
401
diff
changeset
|
75 |
if [ -d ${bindir}/../lib ] |
449 | 76 |
then |
77 |
STX_LIBDIR=`cd ${bindir}/../lib ; pwd` |
|
78 |
fi |
|
319 | 79 |
fi |
452 | 80 |
|
476
25c3df1d5c43
ignore invalid STX_LIBDIR setting
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
81 |
if [ -z "$STX_LIBDIR" ] |
25c3df1d5c43
ignore invalid STX_LIBDIR setting
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
82 |
then |
25c3df1d5c43
ignore invalid STX_LIBDIR setting
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
83 |
if [ -d ../lib ] |
25c3df1d5c43
ignore invalid STX_LIBDIR setting
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
84 |
then |
25c3df1d5c43
ignore invalid STX_LIBDIR setting
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
85 |
STX_LIBDIR=`cd ../lib ; pwd` |
25c3df1d5c43
ignore invalid STX_LIBDIR setting
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
86 |
fi |
25c3df1d5c43
ignore invalid STX_LIBDIR setting
Claus Gittinger <cg@exept.de>
parents:
454
diff
changeset
|
87 |
fi |
435 | 88 |
if [ ! -d "$STX_LIBDIR" ] |
383 | 89 |
then |
90 |
if [ -d ../lib ] |
|
91 |
then |
|
92 |
STX_LIBDIR=`cd ../lib ; pwd` |
|
93 |
fi |
|
94 |
fi |
|
452 | 95 |
|
399 | 96 |
if test -z "$STX_PACKAGEDIR" |
97 |
then |
|
98 |
if [ -d ../packages ] |
|
99 |
then |
|
100 |
STX_PACKAGEDIR=`cd .. ; pwd` |
|
434
f073cdbe422f
oops - LIBDIR/TOPDIR & PACKAGEDIR detection failed,
Claus Gittinger <cg@exept.de>
parents:
401
diff
changeset
|
101 |
else |
f073cdbe422f
oops - LIBDIR/TOPDIR & PACKAGEDIR detection failed,
Claus Gittinger <cg@exept.de>
parents:
401
diff
changeset
|
102 |
if [ -d $STX_LIBDIR/../packages ] |
f073cdbe422f
oops - LIBDIR/TOPDIR & PACKAGEDIR detection failed,
Claus Gittinger <cg@exept.de>
parents:
401
diff
changeset
|
103 |
then |
f073cdbe422f
oops - LIBDIR/TOPDIR & PACKAGEDIR detection failed,
Claus Gittinger <cg@exept.de>
parents:
401
diff
changeset
|
104 |
STX_PACKAGEDIR=`cd $STX_LIBDIR/../packages ; pwd` |
452 | 105 |
else |
106 |
if [ -f $STX_BINDIR/smalltalk.rc ] |
|
107 |
then |
|
108 |
STX_PACKAGEDIR=`cd $STX_BINDIR/../../.. ; pwd` |
|
109 |
fi |
|
434
f073cdbe422f
oops - LIBDIR/TOPDIR & PACKAGEDIR detection failed,
Claus Gittinger <cg@exept.de>
parents:
401
diff
changeset
|
110 |
fi |
399 | 111 |
fi |
112 |
fi |
|
452 | 113 |
|
401 | 114 |
if test -z "$STX_TOPDIR" |
115 |
then |
|
116 |
if [ -f ../lib/smalltalk.rc ] |
|
117 |
then |
|
118 |
STX_TOPDIR=`cd .. ; pwd` |
|
434
f073cdbe422f
oops - LIBDIR/TOPDIR & PACKAGEDIR detection failed,
Claus Gittinger <cg@exept.de>
parents:
401
diff
changeset
|
119 |
else |
f073cdbe422f
oops - LIBDIR/TOPDIR & PACKAGEDIR detection failed,
Claus Gittinger <cg@exept.de>
parents:
401
diff
changeset
|
120 |
if [ -f $STX_LIBDIR/../lib/smalltalk.rc ] |
f073cdbe422f
oops - LIBDIR/TOPDIR & PACKAGEDIR detection failed,
Claus Gittinger <cg@exept.de>
parents:
401
diff
changeset
|
121 |
then |
f073cdbe422f
oops - LIBDIR/TOPDIR & PACKAGEDIR detection failed,
Claus Gittinger <cg@exept.de>
parents:
401
diff
changeset
|
122 |
STX_TOPDIR=`cd $STX_LIBDIR/.. ; pwd` |
452 | 123 |
else |
124 |
if [ -f $STX_BINDIR/smalltalk.rc ] |
|
125 |
then |
|
126 |
STX_TOPDIR=`cd $STX_BINDIR/../.. ; pwd` |
|
127 |
fi |
|
434
f073cdbe422f
oops - LIBDIR/TOPDIR & PACKAGEDIR detection failed,
Claus Gittinger <cg@exept.de>
parents:
401
diff
changeset
|
128 |
fi |
401 | 129 |
fi |
130 |
fi |
|
383 | 131 |
|
434
f073cdbe422f
oops - LIBDIR/TOPDIR & PACKAGEDIR detection failed,
Claus Gittinger <cg@exept.de>
parents:
401
diff
changeset
|
132 |
# echo STX_LIBDIR is $STX_LIBDIR |
f073cdbe422f
oops - LIBDIR/TOPDIR & PACKAGEDIR detection failed,
Claus Gittinger <cg@exept.de>
parents:
401
diff
changeset
|
133 |
# echo STX_TOPDIR is $STX_TOPDIR |
f073cdbe422f
oops - LIBDIR/TOPDIR & PACKAGEDIR detection failed,
Claus Gittinger <cg@exept.de>
parents:
401
diff
changeset
|
134 |
# echo STX_PACKAGEDIR is $STX_PACKAGEDIR |
f073cdbe422f
oops - LIBDIR/TOPDIR & PACKAGEDIR detection failed,
Claus Gittinger <cg@exept.de>
parents:
401
diff
changeset
|
135 |
|
401 | 136 |
export STX_LIBDIR STX_PACKAGEDIR STX_TOPDIR |
452 | 137 |
|
138 |
# echo STX is $STX |
|
277 | 139 |
|
193 | 140 |
if [ "$1" = "-x" ] |
192 | 141 |
then |
142 |
shift |
|
143 |
STX=$1 |
|
144 |
shift |
|
277 | 145 |
fi |
146 |
||
147 |
if [ "$1" = "-X" ] |
|
148 |
then |
|
149 |
shift |
|
150 |
STX=$1/stx |
|
151 |
shift |
|
192 | 152 |
fi |
153 |
||
439 | 154 |
if [ "$1" = "-gdb" ] |
155 |
then |
|
156 |
shift |
|
157 |
DEBUGGER=gdb |
|
158 |
fi |
|
159 |
||
262 | 160 |
if [ "$1" = "-ldd" ] |
161 |
then |
|
162 |
shift |
|
341 | 163 |
DEBUGLIB=yes |
262 | 164 |
fi |
165 |
||
192 | 166 |
# |
167 |
# |
|
164 | 168 |
# some have Xlibs in /usr/openwin/lib ... |
169 |
# |
|
157 | 170 |
if [ -d /usr/openwin/lib ] |
171 |
then |
|
234
861d75db3bec
do not clobber existing LD_LIBRARY_PATH
Claus Gittinger <cg@exept.de>
parents:
193
diff
changeset
|
172 |
if [ "$LD_LIBRARY_PATH" != "" ] |
861d75db3bec
do not clobber existing LD_LIBRARY_PATH
Claus Gittinger <cg@exept.de>
parents:
193
diff
changeset
|
173 |
then |
276 | 174 |
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/openwin/lib:/usr/local/lib/smalltalk/lib |
234
861d75db3bec
do not clobber existing LD_LIBRARY_PATH
Claus Gittinger <cg@exept.de>
parents:
193
diff
changeset
|
175 |
else |
276 | 176 |
LD_LIBRARY_PATH=/usr/openwin/lib:/usr/local/lib/smalltalk/lib |
234
861d75db3bec
do not clobber existing LD_LIBRARY_PATH
Claus Gittinger <cg@exept.de>
parents:
193
diff
changeset
|
177 |
fi |
315 | 178 |
if [ "$SHLIB_PATH" != "" ] |
179 |
then |
|
180 |
SHLIB_PATH=$SHLIB_PATH:/usr/openwin/lib:/usr/local/lib/smalltalk/lib |
|
181 |
else |
|
182 |
SHLIB_PATH=/usr/openwin/lib:/usr/local/lib/smalltalk/lib |
|
183 |
fi |
|
157 | 184 |
else |
234
861d75db3bec
do not clobber existing LD_LIBRARY_PATH
Claus Gittinger <cg@exept.de>
parents:
193
diff
changeset
|
185 |
if [ "$LD_LIBRARY_PATH" != "" ] |
861d75db3bec
do not clobber existing LD_LIBRARY_PATH
Claus Gittinger <cg@exept.de>
parents:
193
diff
changeset
|
186 |
then |
276 | 187 |
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/smalltalk/lib |
234
861d75db3bec
do not clobber existing LD_LIBRARY_PATH
Claus Gittinger <cg@exept.de>
parents:
193
diff
changeset
|
188 |
else |
276 | 189 |
LD_LIBRARY_PATH=/usr/local/lib/smalltalk/lib |
234
861d75db3bec
do not clobber existing LD_LIBRARY_PATH
Claus Gittinger <cg@exept.de>
parents:
193
diff
changeset
|
190 |
fi |
315 | 191 |
if [ "$SHLIB_PATH" != "" ] |
192 |
then |
|
193 |
SHLIB_PATH=$SHLIB_PATH:/usr/local/lib/smalltalk/lib |
|
194 |
else |
|
195 |
SHLIB_PATH=/usr/local/lib/smalltalk/lib |
|
196 |
fi |
|
157 | 197 |
fi |
164 | 198 |
|
199 |
# |
|
200 |
# my own libs may be found in STX_LIBDIR/lib |
|
247 | 201 |
# STX_LIBDIR is to be set to the top of the smalltalk installation |
202 |
# (i.e. where all the .rc files are located) |
|
164 | 203 |
# |
242 | 204 |
|
164 | 205 |
if [ "$STX_LIBDIR" != "" ] |
206 |
then |
|
243 | 207 |
if [ "$STX_LIBDIR" != "/usr/local/smalltalk" ] |
208 |
then |
|
398 | 209 |
LD_LIBRARY_PATH=$STX_LIBDIR:$STX_LIBDIR/lib:$LD_LIBRARY_PATH |
210 |
SHLIB_PATH=$STX_LIBDIR:$STX_LIBDIR/lib:$SHLIB_PATH |
|
243 | 211 |
fi |
452 | 212 |
else |
213 |
STX_LIBDIR=$STX_BINDIR |
|
214 |
fi |
|
215 |
||
216 |
# |
|
217 |
# and in STX_BINDIR |
|
218 |
# |
|
219 |
||
220 |
if [ "$STX_BINDIR" != "" ] |
|
221 |
then |
|
222 |
if [ "$STX_BINDIR" != "/usr/local/bin" ] |
|
223 |
then |
|
224 |
LD_LIBRARY_PATH=$STX_BINDIR:$LD_LIBRARY_PATH |
|
225 |
SHLIB_PATH=$STX_BINDIR:$SHLIB_PATH |
|
226 |
fi |
|
164 | 227 |
fi |
228 |
||
276 | 229 |
LD_LIBRARY_PATH=.:./lib:$LD_LIBRARY_PATH |
315 | 230 |
SHLIB_PATH=.:./lib:$SHLIB_PATH |
155 | 231 |
export LD_LIBRARY_PATH |
315 | 232 |
export SHLIB_PATH |
247 | 233 |
|
234 |
# |
|
314
7fbaf542c38c
prepend . to the path, if command was executed as ./xxxx
Claus Gittinger <cg@exept.de>
parents:
286
diff
changeset
|
235 |
# if started via ./smalltalk, prepend . to the PATH |
7fbaf542c38c
prepend . to the path, if command was executed as ./xxxx
Claus Gittinger <cg@exept.de>
parents:
286
diff
changeset
|
236 |
# (to allow test of ./stx even when stx is found along the PATH) |
7fbaf542c38c
prepend . to the path, if command was executed as ./xxxx
Claus Gittinger <cg@exept.de>
parents:
286
diff
changeset
|
237 |
# |
7fbaf542c38c
prepend . to the path, if command was executed as ./xxxx
Claus Gittinger <cg@exept.de>
parents:
286
diff
changeset
|
238 |
case $0 in |
7fbaf542c38c
prepend . to the path, if command was executed as ./xxxx
Claus Gittinger <cg@exept.de>
parents:
286
diff
changeset
|
239 |
./*) |
7fbaf542c38c
prepend . to the path, if command was executed as ./xxxx
Claus Gittinger <cg@exept.de>
parents:
286
diff
changeset
|
240 |
PATH=.:$PATH |
7fbaf542c38c
prepend . to the path, if command was executed as ./xxxx
Claus Gittinger <cg@exept.de>
parents:
286
diff
changeset
|
241 |
export PATH |
7fbaf542c38c
prepend . to the path, if command was executed as ./xxxx
Claus Gittinger <cg@exept.de>
parents:
286
diff
changeset
|
242 |
;; |
7fbaf542c38c
prepend . to the path, if command was executed as ./xxxx
Claus Gittinger <cg@exept.de>
parents:
286
diff
changeset
|
243 |
esac |
7fbaf542c38c
prepend . to the path, if command was executed as ./xxxx
Claus Gittinger <cg@exept.de>
parents:
286
diff
changeset
|
244 |
|
7fbaf542c38c
prepend . to the path, if command was executed as ./xxxx
Claus Gittinger <cg@exept.de>
parents:
286
diff
changeset
|
245 |
# |
280 | 246 |
# debugging which stx & shared libs are used ... |
247 | 247 |
# |
344 | 248 |
whichOne=`/bin/sh -c "type $STX"` |
341 | 249 |
if [ "$STX" = "stx" ] |
250 |
then |
|
251 |
if [ -f stx ] |
|
252 |
then |
|
253 |
whichOne=`/bin/sh -c "type stx"` |
|
254 |
if [ "$whichOne" != "stx is ./stx" ] |
|
255 |
then |
|
256 |
echo "************* WARNING the executed" $whichOne |
|
257 |
echo "************* (may not be appropriate for used shared libs)" |
|
258 |
echo "************* Try './smalltalk -ldd' for more details" |
|
259 |
echo "************* or force the local stx to be used with" |
|
260 |
echo "************* './smalltalk -x ./stx'" |
|
261 |
echo |
|
262 |
fi |
|
263 |
fi |
|
264 |
fi |
|
265 |
||
280 | 266 |
if [ "$DEBUGLIB" = "yes" ] |
277 | 267 |
then |
344 | 268 |
echo "used " $whichOne |
341 | 269 |
echo "used LD_LIBRARY_PATH is " $LD_LIBRARY_PATH |
270 |
echo "used SHLIB_PATH is " $SHLIB_PATH |
|
271 |
echo "used STX_LIBDIR is " $STX_LIBDIR |
|
272 |
case `uname` in |
|
273 |
HP-UX*) |
|
274 |
chatr $STX |
|
275 |
;; |
|
277 | 276 |
|
341 | 277 |
*) |
278 |
ldd -r $STX |
|
279 |
;; |
|
280 |
esac |
|
262 | 281 |
fi |
247 | 282 |
|
316 | 283 |
# |
284 |
# how did HP mess up things so badly ? |
|
285 |
# It takes a veeeery long time for stx to start |
|
286 |
# (the spinning wheel is shown when stx's main |
|
287 |
# starts to run - all the time in between is |
|
288 |
# spent in the systems loader ...) |
|
289 |
# |
|
449 | 290 |
# if [ "`uname`" = "HP-UX" ] |
291 |
# then |
|
292 |
# echo "Please be patient - hp systems are very slow." |
|
293 |
# fi |
|
316 | 294 |
|
452 | 295 |
PATH=$PATH:$STX_BINDIR |
269 | 296 |
export PATH |
452 | 297 |
# echo PATH is $PATH |
298 |
# echo DISPLAY is $DISPLAY |
|
439 | 299 |
exec $DEBUGGER $STX ${1+"$@"} |