SCM Repository
Annotation of /sml/trunk/config/_run-sml
Parent Directory
|
Revision Log
Revision 937 - (view) (download)
1 : | monnier | 211 | #!@SHELL@ |
2 : | # | ||
3 : | # The standard driver for SML/NJ under the new runtime system | ||
4 : | # | ||
5 : | |||
6 : | CMD=`basename $0` | ||
7 : | |||
8 : | # | ||
9 : | # for /bin/ksh, disable reading user's environment file | ||
10 : | # | ||
11 : | unset ENV | ||
12 : | |||
13 : | ############################################################################# | ||
14 : | # | ||
15 : | # BEGIN SITE SPECIFIC STUFF | ||
16 : | # | ||
17 : | ############################################################################# | ||
18 : | |||
19 : | # | ||
20 : | # SITE SPECIFIC CONFIGURATION INFO | ||
21 : | # | ||
22 : | |||
23 : | # the path of the directory in which executables (like this file) are kept. | ||
24 : | BIN_DIR=@BINDIR@ | ||
25 : | monnier | 214 | if [ ! -d "$BIN_DIR" ]; then |
26 : | cmddir=`dirname $0` | ||
27 : | case "$cmddir" in | ||
28 : | /* ) BIN_DIR="$cmddir";; | ||
29 : | * ) BIN_DIR=`cd $cmddir; pwd` ;; | ||
30 : | esac | ||
31 : | fi | ||
32 : | monnier | 211 | |
33 : | # the path of the directory in which the runtime system executables are kept. | ||
34 : | RUN_DIR=$BIN_DIR/.run | ||
35 : | |||
36 : | # the path of the directory in which the heap images are kept. | ||
37 : | HEAP_DIR=$BIN_DIR/.heap | ||
38 : | |||
39 : | # | ||
40 : | # the following could be replaced with some site specific code | ||
41 : | # | ||
42 : | ARCH_N_OPSYS=`$BIN_DIR/.arch-n-opsys` | ||
43 : | if [ "$?" != "0" ]; then | ||
44 : | echo "$CMD: unable to determine architecture/operating system" | ||
45 : | exit 1 | ||
46 : | fi | ||
47 : | eval $ARCH_N_OPSYS | ||
48 : | |||
49 : | ############################################################################# | ||
50 : | # | ||
51 : | # END SITE SPECIFIC STUFF | ||
52 : | # | ||
53 : | ############################################################################# | ||
54 : | |||
55 : | monnier | 214 | # special shortcut for frequent use (and for Linux' binfmt) |
56 : | blume | 902 | if [ `basename $0` = sml ] ; then |
57 : | case "$1" in | ||
58 : | /* | ./* | ../* ) | ||
59 : | case "$1" in | ||
60 : | *.cm | *.sml | *.sig | *.fun ) | ||
61 : | ;; | ||
62 : | * ) | ||
63 : | HEAP="@SMLload=$1" | ||
64 : | shift | ||
65 : | ;; | ||
66 : | esac | ||
67 : | ;; | ||
68 : | esac | ||
69 : | fi | ||
70 : | monnier | 214 | |
71 : | blume | 569 | ALLOC="" |
72 : | |||
73 : | monnier | 211 | # |
74 : | # Process command line arguments | ||
75 : | # | ||
76 : | while [ "$#" != "0" ]; do | ||
77 : | blume | 937 | arg=$1 |
78 : | monnier | 211 | case $arg in |
79 : | @SMLrun=*) | ||
80 : | blume | 937 | shift |
81 : | monnier | 211 | RUN=`echo $arg | sed 's/@SMLrun=//'` |
82 : | ;; | ||
83 : | @SMLload=*) | ||
84 : | blume | 937 | shift |
85 : | HEAP=$arg | ||
86 : | monnier | 211 | ;; |
87 : | @SMLappl) | ||
88 : | blume | 937 | shift |
89 : | monnier | 211 | if [ "$#" = "0" ]; then |
90 : | echo "$CMD: missing argument for @SMLappl option" | ||
91 : | exit 1 | ||
92 : | fi | ||
93 : | blume | 937 | APPL=$1 |
94 : | shift | ||
95 : | monnier | 211 | ;; |
96 : | @SMLversion) | ||
97 : | echo "$CMD @VERSION@" | ||
98 : | exit 0 | ||
99 : | ;; | ||
100 : | blume | 569 | @SMLalloc=*) |
101 : | blume | 937 | shift |
102 : | blume | 569 | ALLOC=$arg |
103 : | ;; | ||
104 : | monnier | 211 | *) |
105 : | blume | 937 | break |
106 : | monnier | 211 | ;; |
107 : | esac | ||
108 : | done | ||
109 : | |||
110 : | blume | 569 | # |
111 : | # Try to figure out the CPU's cache size and set the allocation area | ||
112 : | # size accordingly. This is majorly important for Celeron systems | ||
113 : | # which suffer badly when the allocation area is too big. | ||
114 : | # | ||
115 : | if [ "$ALLOC" = "" ] ; then | ||
116 : | if [ -f /proc/cpuinfo ] ; then | ||
117 : | # "head" is called to make sure we consider only one matching line. | ||
118 : | # (On linux SMP systems there is more than one such line.) | ||
119 : | cache=`fgrep 'cache size' </proc/cpuinfo | head -1` | ||
120 : | george | 722 | if [ "x$cache" = "x" ] ; then |
121 : | blume | 715 | # No cache info in /proc/cputype. No we are checking the CPU |
122 : | # type.... | ||
123 : | cpu=`fgrep 'cpu ' </proc/cpuinfo | head -1` | ||
124 : | cputype=`echo $cpu | sed -e 's/^.*:[ \t]*\(.*\)$/\1/'` | ||
125 : | case $cputype in | ||
126 : | 586) | ||
127 : | # An old Pentium. Seems to work best with 64k. | ||
128 : | # Some extreme cases run best with even less | ||
129 : | # (32k, 16k, or even just 8k). | ||
130 : | ALLOC="@SMLalloc=64k" | ||
131 : | ;; | ||
132 : | *) | ||
133 : | ;; | ||
134 : | esac | ||
135 : | else | ||
136 : | blume | 569 | kb=`echo $cache | sed -e 's/^[^0-9]*\([0-9]*\).*$/\1/'` |
137 : | case $kb in | ||
138 : | 128) | ||
139 : | # This is the Celeron case. | ||
140 : | ALLOC="@SMLalloc=32k" | ||
141 : | ;; | ||
142 : | 256) | ||
143 : | # Do CPUs like this exist? | ||
144 : | ALLOC="@SMLalloc=128k" | ||
145 : | ;; | ||
146 : | 512) | ||
147 : | # The Pentium II case... | ||
148 : | monnier | 661 | ALLOC="@SMLalloc=256k" |
149 : | blume | 569 | ;; |
150 : | *) | ||
151 : | ;; | ||
152 : | esac | ||
153 : | fi | ||
154 : | fi | ||
155 : | fi | ||
156 : | |||
157 : | monnier | 211 | if [ "$RUN" = "" ]; then |
158 : | # | ||
159 : | # Construct the runtime system path from the ARCH and OS | ||
160 : | # | ||
161 : | RUN="$RUN_DIR/run.$ARCH-$OPSYS" | ||
162 : | if [ ! -x "$RUN" ]; then | ||
163 : | if [ "$ALT_OPSYS" = "" ]; then | ||
164 : | echo "$CMD: cannot find runtime system $RUN" | ||
165 : | exit 1 | ||
166 : | else | ||
167 : | RUN="$RUN_DIR/run.$ARCH-$ALT_OPSYS" | ||
168 : | if [ ! -x "$RUN" ]; then | ||
169 : | echo "$CMD: cannot find runtime system $RUN" | ||
170 : | exit 1 | ||
171 : | fi | ||
172 : | fi | ||
173 : | fi | ||
174 : | fi | ||
175 : | |||
176 : | if [ "$HEAP" = "" ]; then | ||
177 : | # | ||
178 : | # Construct the heap image path from the APPL and ARCH | ||
179 : | # | ||
180 : | if [ "$APPL" = "" ]; then | ||
181 : | APPL=$CMD | ||
182 : | fi | ||
183 : | HEAP="@SMLload=$HEAP_DIR/$APPL" | ||
184 : | fi | ||
185 : | |||
186 : | # | ||
187 : | # run the sucker! | ||
188 : | # | ||
189 : | blume | 937 | exec $RUN @SMLcmdname=$0 $HEAP $ALLOC "$@" |
root@smlnj-gforge.cs.uchicago.edu | ViewVC Help |
Powered by ViewVC 1.0.0 |