smalltalk
changeset 1326 e6197baf42c8
parent 1274 d087caa28ae3
child 1432 1e235b190ee3
equal deleted inserted replaced
1325:5aa619c7670d 1326:e6197baf42c8
    25 # -ldd    show ldd-output (to debug, which libs are loaded)
    25 # -ldd    show ldd-output (to debug, which libs are loaded)
    26 #
    26 #
    27 # all other args go to stx & the user classes
    27 # all other args go to stx & the user classes
    28 #
    28 #
    29 
    29 
    30 if [ "$1" = "--help" ]
       
    31 then
       
    32     echo
       
    33     echo "usage: smalltalk [-x prog] [-X dir] [--ldd] [--gdb] 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 "   --gdb      run with gdb-Debugger (type r in debugger to start)"
       
    40     echo "   --cgdb     run with cgdb-Debugger (type r in debugger to start)"
       
    41     echo "   --callgrind  run under callgrind profiler tool"
       
    42     echo "   stx-args   stx arguments as follows."
       
    43     echo
       
    44     echo "STX args:"
       
    45 fi
       
    46 
       
    47 STX=stx
    30 STX=stx
    48 STX_BINDIR=.
    31 STX_BINDIR=.
    49 DEBUGGER=
    32 DEBUGGER=
       
    33 
    50 
    34 
    51 if test -x `dirname $0`/stx; then
    35 if test -x `dirname $0`/stx; then
    52     STX_BINDIR=`dirname $0`
    36     STX_BINDIR=`dirname $0`
    53     STX=$STX_BINDIR/stx
    37     STX=$STX_BINDIR/stx
    54 #    cd $STX_BINDIR
    38 #    cd $STX_BINDIR
    56 
    40 
    57 if [ "$STX_LIBDIR" != "" ]
    41 if [ "$STX_LIBDIR" != "" ]
    58 then
    42 then
    59     if [ ! -f $STX_LIBDIR/smalltalk.rc ]
    43     if [ ! -f $STX_LIBDIR/smalltalk.rc ]
    60     then
    44     then
    61 	echo "smalltalk [warning]: ignore wrong STX_LIBDIR setting"
    45        echo "smalltalk [warning]: ignore wrong STX_LIBDIR setting"
    62 	STX_LIBDIR=""
    46        STX_LIBDIR=""
    63     fi
    47     fi
    64 fi
    48 fi
    65 
    49 
    66 
    50 
    67 # notice: STXLIBDIR is filled in here by install-sh script
    51 # notice: STXLIBDIR is filled in here by install-sh script
    68 if test -z "$STX_LIBDIR"
    52 if test -z "$STX_LIBDIR"
    69 then
    53 then
    70 	bindir=`dirname $0`
    54     bindir=`dirname $0`
    71 	case "$bindir" in
    55     case "$bindir" in
    72 	    /* )
    56         /* )
    73 		;;
    57         ;;
    74 	    .* )
    58         .* )
    75 		bindir=`( cd $bindir; pwd ) 2> /dev/null`
    59         bindir=`( cd $bindir; pwd ) 2> /dev/null`
    76 		;;
    60         ;;
    77 	esac
    61     esac
    78 	if [ -d ${bindir}/../lib ]
    62     if [ -d ${bindir}/../lib ]
    79 	then
    63     then
    80 	    STX_LIBDIR=`cd ${bindir}/../lib ; pwd`
    64         STX_LIBDIR=`cd ${bindir}/../lib ; pwd`
    81 	fi
    65     fi
    82 fi
    66 fi
    83 
    67 
    84 if [ -z "$STX_LIBDIR" ]
    68 if [ -z "$STX_LIBDIR" ]
    85 then
    69 then
    86     if [ -d ../lib ]
    70     if [ -d ../lib ]
    87     then
    71     then
    88 	STX_LIBDIR=`cd ../lib ; pwd`
    72         STX_LIBDIR=`cd ../lib ; pwd`
    89     fi
    73     fi
    90 fi
    74 fi
    91 if [ ! -d "$STX_LIBDIR" ]
    75 if [ ! -d "$STX_LIBDIR" ]
    92 then
    76 then
    93     if [ -d ../lib ]
    77     if [ -d ../lib ]
    94     then
    78     then
    95 	STX_LIBDIR=`cd ../lib ; pwd`
    79         STX_LIBDIR=`cd ../lib ; pwd`
    96     fi
    80     fi
    97 fi
    81 fi
    98 
    82 
    99 if test -z "$STX_PACKAGEDIR"
    83 if test -z "$STX_PACKAGEDIR"
   100 then
    84 then
   101     if [ -d ../packages ]
    85     if [ -d ../packages ]
   102     then
    86     then
   103 	STX_PACKAGEDIR=`cd .. ; pwd`
    87         STX_PACKAGEDIR=`cd .. ; pwd`
   104     else
    88     else
   105 	if [ -d $STX_LIBDIR/../packages ]
    89         if [ -d $STX_LIBDIR/../packages ]
   106 	then
    90         then
   107 	    STX_PACKAGEDIR=`cd $STX_LIBDIR/../packages ; pwd`
    91             STX_PACKAGEDIR=`cd $STX_LIBDIR/../packages ; pwd`
   108 	else
    92         else
   109 	    if [ -f $STX_BINDIR/smalltalk.rc ]
    93             if [ -f $STX_BINDIR/smalltalk.rc ]
   110 	    then
    94             then
   111 		STX_PACKAGEDIR=`cd $STX_BINDIR/../../.. ; pwd`
    95                 STX_PACKAGEDIR=`cd $STX_BINDIR/../../.. ; pwd`
   112 	    fi
    96             fi
   113 	fi
    97         fi
   114     fi
    98     fi
   115 fi
    99 fi
       
   100 
       
   101 
   116 
   102 
   117 if test -z "$STX_TOPDIR"
   103 if test -z "$STX_TOPDIR"
   118 then
   104 then
   119     if [ -f ../lib/smalltalk.rc ]
   105     if [ -f ../lib/smalltalk.rc ]
   120     then
   106     then
   121 	STX_TOPDIR=`cd .. ; pwd`
   107         STX_TOPDIR=`cd .. ; pwd`
   122     else
   108     else
   123 	if [ -f $STX_LIBDIR/../lib/smalltalk.rc ]
   109        if [ -f $STX_LIBDIR/../lib/smalltalk.rc ]
   124 	then
   110        then
   125 	    STX_TOPDIR=`cd $STX_LIBDIR/.. ; pwd`
   111            STX_TOPDIR=`cd $STX_LIBDIR/.. ; pwd`
   126 	else
   112        else
   127 	    if [ -f $STX_BINDIR/smalltalk.rc ]
   113            if [ -f $STX_BINDIR/smalltalk.rc ]
   128 	    then
   114            then
   129 		STX_TOPDIR=`cd $STX_BINDIR/../.. ; pwd`
   115               STX_TOPDIR=`cd $STX_BINDIR/../.. ; pwd`
   130 	    fi
   116            fi
   131 	fi
   117        fi
   132     fi
   118     fi
   133 fi
   119 fi
   134 
   120 
   135 # echo STX_LIBDIR is $STX_LIBDIR
   121 # echo STX_LIBDIR is $STX_LIBDIR
   136 # echo STX_TOPDIR is $STX_TOPDIR
   122 # echo STX_TOPDIR is $STX_TOPDIR
   138 
   124 
   139 export STX_LIBDIR STX_PACKAGEDIR STX_TOPDIR
   125 export STX_LIBDIR STX_PACKAGEDIR STX_TOPDIR
   140 
   126 
   141 # echo STX is $STX
   127 # echo STX is $STX
   142 
   128 
       
   129 
       
   130 if [ "$1" = "--help" ]
       
   131 then    
       
   132     echo "
       
   133 usage: smalltalk [-x prog] [-X dir] [--ldd] [--gdb] 
       
   134 
       
   135 args to startup script:
       
   136    -x prog ................ use prog instead of stx as executable
       
   137    -X dir ................. use stx from dir instead of default (PATH)
       
   138    --ldd .................. show which shared libraries are used
       
   139    --gdb .................. run with gdb-Debugger (type r in debugger to start)
       
   140    --cgdb ................. run with cgdb-Debugger (type r in debugger to start)
       
   141    --callgrind ............ run under callgrind profiler tool
       
   142    --stap SCRIPT .......... run given systemtap script, passing stx command as 
       
   143                             stap -c 'stx ...' Systemtap may not be compiled in.
       
   144 "
       
   145     exec $STX --help
       
   146     exit 0
       
   147 fi
       
   148 
   143 if [ "$1" = "-x" ]
   149 if [ "$1" = "-x" ]
   144 then
   150 then
   145     shift
   151     shift
   146     STX=$1
   152     STX=$1
   147     shift
   153     shift
   170 then
   176 then
   171     shift
   177     shift
   172     DEBUGGER="valgrind --tool=callgrind --instr-atstart=no"
   178     DEBUGGER="valgrind --tool=callgrind --instr-atstart=no"
   173 fi
   179 fi
   174 
   180 
       
   181 if [ "$1" = "--stap" ]
       
   182 then
       
   183     shift
       
   184     if [ -z "$1" ]; then 
       
   185         echo "--stap requires systemtap script to run"
       
   186         exit 1
       
   187     fi
       
   188     if [ ! -r "$1" ]; then
       
   189         echo "$1 is not a readable systemtap script"
       
   190         echo "--stap requires systemtap script to run"
       
   191         exit 1
       
   192     fi
       
   193     STAPSCRIPT=$1
       
   194     shift
       
   195 fi
   175 
   196 
   176 
   197 
   177 if [ "$1" = "--ldd" ]
   198 if [ "$1" = "--ldd" ]
   178 then
   199 then
   179     shift
   200     shift
   186 #
   207 #
   187 if [ -d /usr/openwin/lib ]
   208 if [ -d /usr/openwin/lib ]
   188 then
   209 then
   189     if [ "$LD_LIBRARY_PATH" != "" ]
   210     if [ "$LD_LIBRARY_PATH" != "" ]
   190     then
   211     then
   191 	LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/openwin/lib:/usr/local/lib/smalltalk/lib
   212     LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/openwin/lib:/usr/local/lib/smalltalk/lib
   192     else
   213     else
   193 	LD_LIBRARY_PATH=/usr/openwin/lib:/usr/local/lib/smalltalk/lib
   214     LD_LIBRARY_PATH=/usr/openwin/lib:/usr/local/lib/smalltalk/lib
   194     fi
   215     fi
   195     if [ "$SHLIB_PATH" != "" ]
   216     if [ "$SHLIB_PATH" != "" ]
   196     then
   217     then
   197 	SHLIB_PATH=$SHLIB_PATH:/usr/openwin/lib:/usr/local/lib/smalltalk/lib
   218     SHLIB_PATH=$SHLIB_PATH:/usr/openwin/lib:/usr/local/lib/smalltalk/lib
   198     else
   219     else
   199 	SHLIB_PATH=/usr/openwin/lib:/usr/local/lib/smalltalk/lib
   220     SHLIB_PATH=/usr/openwin/lib:/usr/local/lib/smalltalk/lib
   200     fi
   221     fi
   201 else
   222 else
   202     if [ "$LD_LIBRARY_PATH" != "" ]
   223     if [ "$LD_LIBRARY_PATH" != "" ]
   203     then
   224     then
   204 	LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/smalltalk/lib
   225     LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/smalltalk/lib
   205     else
   226     else
   206 	LD_LIBRARY_PATH=/usr/local/lib/smalltalk/lib
   227     LD_LIBRARY_PATH=/usr/local/lib/smalltalk/lib
   207     fi
   228     fi
   208     if [ "$SHLIB_PATH" != "" ]
   229     if [ "$SHLIB_PATH" != "" ]
   209     then
   230     then
   210 	SHLIB_PATH=$SHLIB_PATH:/usr/local/lib/smalltalk/lib
   231     SHLIB_PATH=$SHLIB_PATH:/usr/local/lib/smalltalk/lib
   211     else
   232     else
   212 	SHLIB_PATH=/usr/local/lib/smalltalk/lib
   233     SHLIB_PATH=/usr/local/lib/smalltalk/lib
   213     fi
   234     fi
   214 fi
   235 fi
   215 
   236 
   216 #
   237 #
   217 # my own libs may be found in STX_LIBDIR/lib
   238 # my own libs may be found in STX_LIBDIR/lib
   221 
   242 
   222 if [ "$STX_LIBDIR" != "" ]
   243 if [ "$STX_LIBDIR" != "" ]
   223 then
   244 then
   224     if [ "$STX_LIBDIR" != "/usr/local/smalltalk" ]
   245     if [ "$STX_LIBDIR" != "/usr/local/smalltalk" ]
   225     then
   246     then
   226 	LD_LIBRARY_PATH=$STX_LIBDIR:$STX_LIBDIR/lib:$LD_LIBRARY_PATH
   247     LD_LIBRARY_PATH=$STX_LIBDIR:$STX_LIBDIR/lib:$LD_LIBRARY_PATH
   227 	SHLIB_PATH=$STX_LIBDIR:$STX_LIBDIR/lib:$SHLIB_PATH
   248     SHLIB_PATH=$STX_LIBDIR:$STX_LIBDIR/lib:$SHLIB_PATH
   228     fi
   249     fi
   229 else
   250 else
   230     STX_LIBDIR=$STX_BINDIR
   251     STX_LIBDIR=$STX_BINDIR
   231 fi
   252 fi
   232 
   253 
   236 
   257 
   237 if [ "$STX_BINDIR" != "" ]
   258 if [ "$STX_BINDIR" != "" ]
   238 then
   259 then
   239     if [ "$STX_BINDIR" != "/usr/local/bin" ]
   260     if [ "$STX_BINDIR" != "/usr/local/bin" ]
   240     then
   261     then
   241 	LD_LIBRARY_PATH=$STX_BINDIR:$LD_LIBRARY_PATH
   262     LD_LIBRARY_PATH=$STX_BINDIR:$LD_LIBRARY_PATH
   242 	SHLIB_PATH=$STX_BINDIR:$SHLIB_PATH
   263     SHLIB_PATH=$STX_BINDIR:$SHLIB_PATH
   243     fi
   264     fi
   244 fi
   265 fi
   245 
   266 
   246 LD_LIBRARY_PATH=.:./lib:$LD_LIBRARY_PATH
   267 LD_LIBRARY_PATH=.:./lib:$LD_LIBRARY_PATH
   247 SHLIB_PATH=.:./lib:$SHLIB_PATH
   268 SHLIB_PATH=.:./lib:$SHLIB_PATH
   252 # if started via ./smalltalk, prepend . to the PATH 
   273 # if started via ./smalltalk, prepend . to the PATH 
   253 # (to allow test of ./stx even when stx is found along the PATH)
   274 # (to allow test of ./stx even when stx is found along the PATH)
   254 #
   275 #
   255 case $0 in
   276 case $0 in
   256     ./*)
   277     ./*)
   257 	PATH=.:$PATH
   278     PATH=.:$PATH
   258 	export PATH
   279     export PATH
   259 	;;
   280     ;;
   260 esac
   281 esac
   261 
   282 
   262 #
   283 #
   263 # debugging which stx & shared libs are used ...
   284 # debugging which stx & shared libs are used ...
   264 #
   285 #
   311 
   332 
   312 PATH=$PATH:$STX_BINDIR
   333 PATH=$PATH:$STX_BINDIR
   313 export PATH
   334 export PATH
   314 # echo PATH is $PATH
   335 # echo PATH is $PATH
   315 # echo DISPLAY is $DISPLAY
   336 # echo DISPLAY is $DISPLAY
       
   337 
       
   338 
       
   339 
       
   340 if [ ! -z "$STAPSCRIPT" ]; then
       
   341     echo "$STX_TOPDIR/stx/hacking/tapset"
       
   342     CMD="$STX $@"
       
   343     echo "$CMD"
       
   344     exec stap --unprivileged $STAPSCRIPT -I "$STX_TOPDIR/hacking/tapset" -c "$CMD"
       
   345 fi
       
   346 
       
   347 
       
   348 
   316 exec $DEBUGGER $STX ${1+"$@"}
   349 exec $DEBUGGER $STX ${1+"$@"}