author | wenzelm |
Tue, 27 Apr 2010 15:23:05 +0200 | |
changeset 36420 | 66fd989c8e15 |
parent 31317 | 1f5740424c69 |
permissions | -rwxr-xr-x |
21653 | 1 |
#!/usr/bin/env bash |
2 |
# |
|
3 |
# Author: Makarius |
|
4 |
# |
|
26213 | 5 |
# Poly/ML 5.0 startup script. |
21653 | 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 |
21653 | 8 |
|
9 |
||
10 |
## diagnostics |
|
11 |
||
12 |
function fail_out() |
|
13 |
{ |
|
14 |
echo "Unable to create output heap file: \"$OUTFILE\"" >&2 |
|
15 |
exit 2 |
|
16 |
} |
|
17 |
||
18 |
function check_file() |
|
19 |
{ |
|
20 |
if [ ! -f "$1" ]; then |
|
21 |
echo "Unable to locate $1" >&2 |
|
22 |
echo "Please check your ML system settings!" >&2 |
|
23 |
exit 2 |
|
24 |
fi |
|
25 |
} |
|
26 |
||
27 |
||
28 |
## compiler executables and libraries |
|
29 |
||
30 |
POLY="$ML_HOME/poly" |
|
31 |
check_file "$POLY" |
|
32 |
||
33 |
if [ "$(basename "$ML_HOME")" = bin ]; then |
|
34 |
POLYLIB="$(cd "$ML_HOME"; cd "$(pwd -P)"; cd ../lib; pwd)" |
|
35 |
else |
|
36 |
POLYLIB="$ML_HOME" |
|
37 |
fi |
|
38 |
||
39 |
export LD_LIBRARY_PATH="$POLYLIB:$LD_LIBRARY_PATH" |
|
40 |
export DYLD_LIBRARY_PATH="$POLYLIB:$DYLD_LIBRARY_PATH" |
|
41 |
||
42 |
||
43 |
## prepare databases |
|
44 |
||
45 |
if [ -z "$INFILE" ]; then |
|
21713
85722dc0fc81
more careful evaluation of ML text, prevents spurious output;
wenzelm
parents:
21711
diff
changeset
|
46 |
PRG="$POLY" |
21653 | 47 |
EXIT="fun exit 0 = (OS.Process.exit OS.Process.success): unit | exit _ = OS.Process.exit OS.Process.failure;" |
48 |
else |
|
49 |
check_file "$INFILE" |
|
21713
85722dc0fc81
more careful evaluation of ML text, prevents spurious output;
wenzelm
parents:
21711
diff
changeset
|
50 |
PRG="$INFILE" |
21653 | 51 |
EXIT="" |
52 |
fi |
|
53 |
||
54 |
if [ -z "$OUTFILE" ]; then |
|
55 |
COMMIT='fun commit () = (TextIO.output (TextIO.stdErr, "Error - Database is not opened for writing.\n"); false);' |
|
56 |
else |
|
31317
1f5740424c69
removed "compress" option from isabelle-process and isabelle usedir -- this is always enabled;
wenzelm
parents:
31315
diff
changeset
|
57 |
COMMIT="fun commit () = (PolyML.shareCommonData PolyML.rootFunction; TextIO.output (TextIO.stdOut, \"Exporting $OUTFILE\n\"); PolyML.export (\"$OUTFILE\", PolyML.rootFunction); true);" |
21653 | 58 |
[ -f "$OUTFILE" ] && { chmod +w "$OUTFILE" || fail_out; } |
59 |
rm -f "${OUTFILE}.o" || fail_out |
|
60 |
fi |
|
61 |
||
62 |
||
63 |
## run it! |
|
64 |
||
25124
a7dd8d3bf969
maintain PolyML.Compiler.printInAlphabeticalOrder in polyml.ML;
wenzelm
parents:
24480
diff
changeset
|
65 |
MLTEXT="$EXIT $COMMIT $MLTEXT" |
21653 | 66 |
MLEXIT="commit();" |
67 |
||
68 |
if [ -z "$TERMINATE" ]; then |
|
69 |
FEEDER_OPTS="" |
|
70 |
else |
|
71 |
FEEDER_OPTS="-q" |
|
72 |
fi |
|
73 |
||
26375
234f10289d97
back to feeder -- Isabelle ML setup no longer evaluates command line;
wenzelm
parents:
26213
diff
changeset
|
74 |
"$ISABELLE_HOME/lib/scripts/feeder" -p -h "$MLTEXT" -t "$MLEXIT" $FEEDER_OPTS | \ |
234f10289d97
back to feeder -- Isabelle ML setup no longer evaluates command line;
wenzelm
parents:
26213
diff
changeset
|
75 |
{ read FPID; "$PRG" -q $ML_OPTIONS; RC="$?"; kill -HUP "$FPID"; exit "$RC"; } |
21653 | 76 |
RC="$?" |
77 |
||
78 |
if [ -n "$OUTFILE" ]; then |
|
79 |
if [ -e "${OUTFILE}.o" ]; then |
|
24480
97c0ef49fa8f
renamed POLYML_LINK_OPTIONS to POLY_LINK_OPTIONS;
wenzelm
parents:
24479
diff
changeset
|
80 |
cc -o "$OUTFILE" "${OUTFILE}.o" -L"$POLYLIB" -lpolymain -lpolyml $POLY_LINK_OPTIONS || fail_out |
21653 | 81 |
rm -f "${OUTFILE}.o" |
21711
dfac729d3066
root function: restore default interrupt handler;
wenzelm
parents:
21653
diff
changeset
|
82 |
[ -e "${OUTFILE}.exe" ] && mv "${OUTFILE}.exe" "$OUTFILE" |
21653 | 83 |
fi |
84 |
[ -f "$OUTFILE" -a -n "$NOWRITE" ] && chmod -w "$OUTFILE" |
|
85 |
fi |
|
86 |
||
87 |
exit "$RC" |