author | wenzelm |
Sat, 20 Dec 2008 11:55:34 +0100 | |
changeset 29145 | b1c6f4563df7 |
parent 26215 | 94d32a7cd0fb |
child 31315 | 3c7b40548a84 |
permissions | -rwxr-xr-x |
10555 | 1 |
#!/usr/bin/env bash |
2301 | 2 |
# |
26215
94d32a7cd0fb
rearrangements to make latest Poly/ML the default, not old 4.x;
wenzelm
parents:
25123
diff
changeset
|
3 |
# Author: Makarius |
2314 | 4 |
# |
26215
94d32a7cd0fb
rearrangements to make latest Poly/ML the default, not old 4.x;
wenzelm
parents:
25123
diff
changeset
|
5 |
# Poly/ML 5.1/5.2 startup script. |
9977 | 6 |
|
10105 | 7 |
export -n INFILE OUTFILE COPYDB COMPRESS MLTEXT TERMINATE NOWRITE |
2301 | 8 |
|
9 |
||
10 |
## diagnostics |
|
11 |
||
2349 | 12 |
function fail_out() |
2301 | 13 |
{ |
2349 | 14 |
echo "Unable to create output heap file: \"$OUTFILE\"" >&2 |
2301 | 15 |
exit 2 |
16 |
} |
|
17 |
||
10206 | 18 |
function check_file() |
5063 | 19 |
{ |
20 |
if [ ! -f "$1" ]; then |
|
21 |
echo "Unable to locate $1" >&2 |
|
10206 | 22 |
echo "Please check your ML system settings!" >&2 |
5063 | 23 |
exit 2 |
24 |
fi |
|
25 |
} |
|
26 |
||
2301 | 27 |
|
26215
94d32a7cd0fb
rearrangements to make latest Poly/ML the default, not old 4.x;
wenzelm
parents:
25123
diff
changeset
|
28 |
## compiler executables and libraries |
16374 | 29 |
|
21356 | 30 |
POLY="$ML_HOME/poly" |
10206 | 31 |
check_file "$POLY" |
2301 | 32 |
|
26215
94d32a7cd0fb
rearrangements to make latest Poly/ML the default, not old 4.x;
wenzelm
parents:
25123
diff
changeset
|
33 |
if [ "$(basename "$ML_HOME")" = bin ]; then |
94d32a7cd0fb
rearrangements to make latest Poly/ML the default, not old 4.x;
wenzelm
parents:
25123
diff
changeset
|
34 |
POLYLIB="$(cd "$ML_HOME"; cd "$(pwd -P)"; cd ../lib; pwd)" |
16392 | 35 |
else |
26215
94d32a7cd0fb
rearrangements to make latest Poly/ML the default, not old 4.x;
wenzelm
parents:
25123
diff
changeset
|
36 |
POLYLIB="$ML_HOME" |
16392 | 37 |
fi |
10206 | 38 |
|
26215
94d32a7cd0fb
rearrangements to make latest Poly/ML the default, not old 4.x;
wenzelm
parents:
25123
diff
changeset
|
39 |
export LD_LIBRARY_PATH="$POLYLIB:$LD_LIBRARY_PATH" |
94d32a7cd0fb
rearrangements to make latest Poly/ML the default, not old 4.x;
wenzelm
parents:
25123
diff
changeset
|
40 |
export DYLD_LIBRARY_PATH="$POLYLIB:$DYLD_LIBRARY_PATH" |
9765 | 41 |
|
42 |
||
2301 | 43 |
## prepare databases |
44 |
||
45 |
if [ -z "$INFILE" ]; then |
|
26215
94d32a7cd0fb
rearrangements to make latest Poly/ML the default, not old 4.x;
wenzelm
parents:
25123
diff
changeset
|
46 |
INIT="" |
94d32a7cd0fb
rearrangements to make latest Poly/ML the default, not old 4.x;
wenzelm
parents:
25123
diff
changeset
|
47 |
EXIT="fun exit 0 = (OS.Process.exit OS.Process.success): unit | exit _ = OS.Process.exit OS.Process.failure;" |
10105 | 48 |
else |
26215
94d32a7cd0fb
rearrangements to make latest Poly/ML the default, not old 4.x;
wenzelm
parents:
25123
diff
changeset
|
49 |
check_file "$INFILE" |
94d32a7cd0fb
rearrangements to make latest Poly/ML the default, not old 4.x;
wenzelm
parents:
25123
diff
changeset
|
50 |
INIT="(Signal.signal (2, Signal.SIG_HANDLE (fn _ => Process.interruptConsoleProcesses ())); PolyML.SaveState.loadState \"$INFILE\" handle Fail msg => (TextIO.output (TextIO.stdErr, msg ^ \"\\n\"); OS.Process.exit OS.Process.failure));" |
94d32a7cd0fb
rearrangements to make latest Poly/ML the default, not old 4.x;
wenzelm
parents:
25123
diff
changeset
|
51 |
EXIT="" |
2301 | 52 |
fi |
53 |
||
54 |
if [ -z "$OUTFILE" ]; then |
|
26215
94d32a7cd0fb
rearrangements to make latest Poly/ML the default, not old 4.x;
wenzelm
parents:
25123
diff
changeset
|
55 |
COMMIT='fun commit () = (TextIO.output (TextIO.stdErr, "Error - Database is not opened for writing.\n"); false);' |
2301 | 56 |
else |
26215
94d32a7cd0fb
rearrangements to make latest Poly/ML the default, not old 4.x;
wenzelm
parents:
25123
diff
changeset
|
57 |
if [ -z "$COMPRESS" ]; then |
94d32a7cd0fb
rearrangements to make latest Poly/ML the default, not old 4.x;
wenzelm
parents:
25123
diff
changeset
|
58 |
COMMIT="fun commit () = (TextIO.output (TextIO.stdOut, \"Exporting $OUTFILE\n\"); PolyML.SaveState.saveState \"$OUTFILE\"; true);" |
94d32a7cd0fb
rearrangements to make latest Poly/ML the default, not old 4.x;
wenzelm
parents:
25123
diff
changeset
|
59 |
else |
94d32a7cd0fb
rearrangements to make latest Poly/ML the default, not old 4.x;
wenzelm
parents:
25123
diff
changeset
|
60 |
COMMIT="fun commit () = (PolyML.shareCommonData PolyML.rootFunction; TextIO.output (TextIO.stdOut, \"Exporting $OUTFILE\n\"); PolyML.SaveState.saveState \"$OUTFILE\"; true);" |
94d32a7cd0fb
rearrangements to make latest Poly/ML the default, not old 4.x;
wenzelm
parents:
25123
diff
changeset
|
61 |
fi |
94d32a7cd0fb
rearrangements to make latest Poly/ML the default, not old 4.x;
wenzelm
parents:
25123
diff
changeset
|
62 |
[ -f "$OUTFILE" ] && { chmod +w "$OUTFILE" || fail_out; } |
2301 | 63 |
fi |
64 |
||
65 |
||
66 |
## run it! |
|
67 |
||
26215
94d32a7cd0fb
rearrangements to make latest Poly/ML the default, not old 4.x;
wenzelm
parents:
25123
diff
changeset
|
68 |
MLTEXT="$INIT $EXIT $COMMIT $MLTEXT" |
94d32a7cd0fb
rearrangements to make latest Poly/ML the default, not old 4.x;
wenzelm
parents:
25123
diff
changeset
|
69 |
MLEXIT="commit();" |
94d32a7cd0fb
rearrangements to make latest Poly/ML the default, not old 4.x;
wenzelm
parents:
25123
diff
changeset
|
70 |
|
16254
1b2683e18fd2
DISCGARB_OPTIONS: proper treatment of specific polyml versions;
wenzelm
parents:
15850
diff
changeset
|
71 |
if [ -z "$TERMINATE" ]; then |
1b2683e18fd2
DISCGARB_OPTIONS: proper treatment of specific polyml versions;
wenzelm
parents:
15850
diff
changeset
|
72 |
FEEDER_OPTS="" |
1b2683e18fd2
DISCGARB_OPTIONS: proper treatment of specific polyml versions;
wenzelm
parents:
15850
diff
changeset
|
73 |
else |
1b2683e18fd2
DISCGARB_OPTIONS: proper treatment of specific polyml versions;
wenzelm
parents:
15850
diff
changeset
|
74 |
FEEDER_OPTS="-q" |
1b2683e18fd2
DISCGARB_OPTIONS: proper treatment of specific polyml versions;
wenzelm
parents:
15850
diff
changeset
|
75 |
fi |
1b2683e18fd2
DISCGARB_OPTIONS: proper treatment of specific polyml versions;
wenzelm
parents:
15850
diff
changeset
|
76 |
|
26215
94d32a7cd0fb
rearrangements to make latest Poly/ML the default, not old 4.x;
wenzelm
parents:
25123
diff
changeset
|
77 |
"$ISABELLE_HOME/lib/scripts/feeder" -p -h "$MLTEXT" -t "$MLEXIT" $FEEDER_OPTS | \ |
94d32a7cd0fb
rearrangements to make latest Poly/ML the default, not old 4.x;
wenzelm
parents:
25123
diff
changeset
|
78 |
{ read FPID; "$POLY" -q $ML_OPTIONS; RC="$?"; kill -HUP "$FPID"; exit "$RC"; } |
9789 | 79 |
RC="$?" |
2301 | 80 |
|
4505 | 81 |
[ -n "$OUTFILE" -a -f "$OUTFILE" -a -n "$NOWRITE" ] && chmod -w "$OUTFILE" |
2301 | 82 |
|
9789 | 83 |
exit "$RC" |