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