author | wenzelm |
Thu, 01 Mar 2012 14:42:05 +0100 | |
changeset 46741 | a29006291f2b |
parent 40544 | 34e56a6668ba |
child 48002 | 6de952f4069f |
permissions | -rwxr-xr-x |
10555 | 1 |
#!/usr/bin/env bash |
2302 | 2 |
# |
9789 | 3 |
# Author: Markus Wenzel, TU Muenchen |
2313 | 4 |
# |
5708 | 5 |
# SML/NJ startup script (for 110 or later). |
9977 | 6 |
|
31317
1f5740424c69
removed "compress" option from isabelle-process and isabelle usedir -- this is always enabled;
wenzelm
parents:
31315
diff
changeset
|
7 |
export -n INFILE OUTFILE MLTEXT TERMINATE NOWRITE |
2302 | 8 |
|
9 |
||
10 |
## diagnostics |
|
11 |
||
40544 | 12 |
function fail() |
13 |
{ |
|
14 |
echo "$1" >&2 |
|
15 |
exit 2 |
|
16 |
} |
|
17 |
||
2349 | 18 |
function fail_out() |
2302 | 19 |
{ |
40544 | 20 |
fail "Unable to create output heap file: \"$OUTFILE\"" |
2302 | 21 |
} |
22 |
||
5063 | 23 |
function check_mlhome_file() |
24 |
{ |
|
40544 | 25 |
[ ! -f "$1" ] && fail "Unable to locate \"$1\"" |
5063 | 26 |
} |
27 |
||
6078 | 28 |
function check_heap_file() |
29 |
{ |
|
30 |
if [ ! -f "$1" ]; then |
|
31 |
echo "Expected to find ML heap file $1" >&2 |
|
32 |
return 1 |
|
33 |
else |
|
34 |
return 0 |
|
35 |
fi |
|
36 |
} |
|
37 |
||
38 |
||
5063 | 39 |
|
40 |
## compiler binaries |
|
41 |
||
40544 | 42 |
[ -z "$ML_HOME" ] && fail "Missing ML installation (ML_HOME)" |
43 |
||
5063 | 44 |
SML="$ML_HOME/sml" |
45 |
ARCH_N_OPSYS="$ML_HOME/.arch-n-opsys" |
|
46 |
||
47 |
check_mlhome_file "$SML" |
|
48 |
check_mlhome_file "$ARCH_N_OPSYS" |
|
49 |
||
50 |
||
2302 | 51 |
|
3046 | 52 |
## prepare databases |
53 |
||
4505 | 54 |
if [ -z "$INFILE" ]; then |
55 |
EXIT="fun exit 0 = (OS.Process.exit OS.Process.success): unit | exit _ = OS.Process.exit OS.Process.failure;" |
|
56 |
DB="" |
|
57 |
else |
|
58 |
EXIT="" |
|
3046 | 59 |
DB="@SMLload=$INFILE" |
2349 | 60 |
fi |
61 |
||
4505 | 62 |
if [ -z "$OUTFILE" ]; then |
39619 | 63 |
COMMIT='fun commit () = false;' |
64 |
MLEXIT="" |
|
4505 | 65 |
else |
66 |
COMMIT="fun commit () = not (SMLofNJ.exportML\"$OUTFILE\");" |
|
67 |
[ -f "$OUTFILE" ] && { chmod +w "$OUTFILE" || fail_out; } |
|
39619 | 68 |
MLEXIT="commit();" |
4505 | 69 |
fi |
2302 | 70 |
|
71 |
||
72 |
## run it! |
|
73 |
||
4505 | 74 |
MLTEXT="$EXIT $COMMIT $MLTEXT" |
2302 | 75 |
|
4505 | 76 |
if [ -z "$TERMINATE" ]; then |
77 |
FEEDER_OPTS="" |
|
2302 | 78 |
else |
4505 | 79 |
FEEDER_OPTS="-q" |
2302 | 80 |
fi |
81 |
||
9789 | 82 |
"$ISABELLE_HOME/lib/scripts/feeder" -p -h "$MLTEXT" -t "$MLEXIT" $FEEDER_OPTS | \ |
83 |
{ read FPID; "$SML" $ML_OPTIONS "$DB"; RC="$?"; kill -HUP "$FPID"; exit "$RC"; } |
|
84 |
RC="$?" |
|
4505 | 85 |
|
86 |
||
87 |
## fix heap file name and permissions |
|
3046 | 88 |
|
4505 | 89 |
if [ -n "$OUTFILE" ]; then |
9789 | 90 |
eval $("$ARCH_N_OPSYS") |
6078 | 91 |
[ -z "$HEAP_SUFFIX" ] && HEAP_SUFFIX="$ARCH-$OPSYS" |
92 |
HEAP="$OUTFILE.$HEAP_SUFFIX" |
|
93 |
check_heap_file "$HEAP" && mv "$HEAP" "$OUTFILE" && \ |
|
4505 | 94 |
[ -n "$NOWRITE" ] && chmod -w "$OUTFILE" |
95 |
fi |
|
3503 | 96 |
|
9789 | 97 |
exit "$RC" |