author | wenzelm |
Sun, 29 Jul 2007 14:29:52 +0200 | |
changeset 24038 | 18182c4aec9e |
parent 21356 | 556addc67737 |
child 25123 | 8831ca91f43f |
permissions | -rwxr-xr-x |
10555 | 1 |
#!/usr/bin/env bash |
2301 | 2 |
# |
2314 | 3 |
# $Id$ |
9789 | 4 |
# Author: Markus Wenzel, TU Muenchen |
2314 | 5 |
# |
2301 | 6 |
# Poly/ML 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 |
|
16392 | 29 |
## Poly/ML executable and database |
2301 | 30 |
|
10206 | 31 |
ML_DBASE_PREFIX="" |
16374 | 32 |
|
21356 | 33 |
POLY="$ML_HOME/poly" |
10206 | 34 |
check_file "$POLY" |
2301 | 35 |
|
16392 | 36 |
if [ -z "$ML_DBASE" ]; then |
21356 | 37 |
if [ ! -e "$ML_HOME/ML_dbase" -a "$(basename "$ML_HOME")" = bin ]; then |
17051 | 38 |
ML_DBASE_HOME="$(cd "$ML_HOME"; cd "$(pwd -P)"; cd ../lib/poly; pwd)" |
39 |
else |
|
40 |
ML_DBASE_HOME="$ML_HOME" |
|
41 |
fi |
|
16392 | 42 |
if [ -z "$COPYDB" ]; then |
17051 | 43 |
ML_DBASE_PREFIX="$ML_DBASE_HOME/" |
21356 | 44 |
ML_DBASE="ML_dbase" |
16392 | 45 |
else |
21356 | 46 |
ML_DBASE="$ML_DBASE_HOME/ML_dbase" |
16392 | 47 |
fi |
21356 | 48 |
export POLYPATH="$ML_DBASE_HOME" |
16392 | 49 |
else |
21356 | 50 |
export POLYPATH="$(dirname "$ML_DBASE")" |
16392 | 51 |
fi |
10206 | 52 |
|
16392 | 53 |
DISCGARB_OPTIONS="-d -c" |
10206 | 54 |
|
16392 | 55 |
EXIT="fun exit 0 = (OS.Process.exit OS.Process.success): unit | exit _ = OS.Process.exit OS.Process.failure;" |
9765 | 56 |
|
57 |
||
2301 | 58 |
## prepare databases |
59 |
||
60 |
if [ -z "$INFILE" ]; then |
|
10206 | 61 |
check_file "$ML_DBASE_PREFIX$ML_DBASE" |
62 |
INFILE="$ML_DBASE" |
|
9765 | 63 |
MLTEXT="val use = PolyML.use; $EXIT $MLTEXT" |
16285 | 64 |
case "$ML_SYSTEM" in |
65 |
polyml-4.1.[12]) |
|
66 |
DISCGARB_OPTIONS="$DISCGARB_OPTIONS -S 180" |
|
67 |
;; |
|
18166 | 68 |
polyml-4.1.[34] | polyml-4.2.*) |
16285 | 69 |
DISCGARB_OPTIONS="$DISCGARB_OPTIONS -S max" |
70 |
;; |
|
71 |
esac |
|
10105 | 72 |
else |
73 |
COPYDB=true |
|
2301 | 74 |
fi |
75 |
||
76 |
if [ -z "$OUTFILE" ]; then |
|
77 |
DB="$INFILE" |
|
15850
30e878979457
no longer need feeder to run normal interactive sessions;
wenzelm
parents:
14981
diff
changeset
|
78 |
ML_OPTIONS="-r $ML_OPTIONS" |
2349 | 79 |
elif [ "$INFILE" -ef "$OUTFILE" ]; then |
2301 | 80 |
DB="$INFILE" |
81 |
elif [ -n "$COPYDB" ]; then |
|
2936
bd33e7aae062
fixed { ... } shell syntax to accomodate bash 2.x;
wenzelm
parents:
2605
diff
changeset
|
82 |
[ -f "$OUTFILE" ] && { rm -f "$OUTFILE" || fail_out; } |
2548 | 83 |
cp "$INFILE" "$OUTFILE" || fail_out |
2349 | 84 |
chmod +w "$OUTFILE" || fail_out |
2301 | 85 |
DB="$OUTFILE" |
86 |
else |
|
2936
bd33e7aae062
fixed { ... } shell syntax to accomodate bash 2.x;
wenzelm
parents:
2605
diff
changeset
|
87 |
[ -f "$OUTFILE" ] && { rm -f "$OUTFILE" || fail_out; } |
21356 | 88 |
echo "PolyML.make_database \"$OUTFILE\"; PolyML.quit();" | "$POLY" -r "$INFILE" |
2301 | 89 |
[ -f "$OUTFILE" ] || fail_out |
90 |
DB="$OUTFILE" |
|
91 |
fi |
|
92 |
||
93 |
||
94 |
## run it! |
|
95 |
||
16969
e26915e01d15
PolyML.Compiler.printInAlphabeticalOrder := false;
wenzelm
parents:
16393
diff
changeset
|
96 |
case "$ML_SYSTEM" in |
e26915e01d15
PolyML.Compiler.printInAlphabeticalOrder := false;
wenzelm
parents:
16393
diff
changeset
|
97 |
polyml-4.1.[12]) |
e26915e01d15
PolyML.Compiler.printInAlphabeticalOrder := false;
wenzelm
parents:
16393
diff
changeset
|
98 |
;; |
18166 | 99 |
polyml-4.1.[34] | polyml-4.2.*) |
16969
e26915e01d15
PolyML.Compiler.printInAlphabeticalOrder := false;
wenzelm
parents:
16393
diff
changeset
|
100 |
MLTEXT="PolyML.Compiler.printInAlphabeticalOrder := false; $MLTEXT" |
e26915e01d15
PolyML.Compiler.printInAlphabeticalOrder := false;
wenzelm
parents:
16393
diff
changeset
|
101 |
;; |
e26915e01d15
PolyML.Compiler.printInAlphabeticalOrder := false;
wenzelm
parents:
16393
diff
changeset
|
102 |
esac |
e26915e01d15
PolyML.Compiler.printInAlphabeticalOrder := false;
wenzelm
parents:
16393
diff
changeset
|
103 |
|
16254
1b2683e18fd2
DISCGARB_OPTIONS: proper treatment of specific polyml versions;
wenzelm
parents:
15850
diff
changeset
|
104 |
if [ -z "$TERMINATE" ]; then |
1b2683e18fd2
DISCGARB_OPTIONS: proper treatment of specific polyml versions;
wenzelm
parents:
15850
diff
changeset
|
105 |
FEEDER_OPTS="" |
1b2683e18fd2
DISCGARB_OPTIONS: proper treatment of specific polyml versions;
wenzelm
parents:
15850
diff
changeset
|
106 |
else |
1b2683e18fd2
DISCGARB_OPTIONS: proper treatment of specific polyml versions;
wenzelm
parents:
15850
diff
changeset
|
107 |
FEEDER_OPTS="-q" |
1b2683e18fd2
DISCGARB_OPTIONS: proper treatment of specific polyml versions;
wenzelm
parents:
15850
diff
changeset
|
108 |
fi |
1b2683e18fd2
DISCGARB_OPTIONS: proper treatment of specific polyml versions;
wenzelm
parents:
15850
diff
changeset
|
109 |
|
16392 | 110 |
DB_INFO="$(ls -l "$DB" 2>/dev/null)" |
15850
30e878979457
no longer need feeder to run normal interactive sessions;
wenzelm
parents:
14981
diff
changeset
|
111 |
|
16392 | 112 |
"$ISABELLE_HOME/lib/scripts/feeder" -p -h "$MLTEXT" $FEEDER_OPTS | { |
21356 | 113 |
read FPID; "$POLY" $ML_OPTIONS "$DB"; |
16392 | 114 |
RC="$?"; kill -HUP "$FPID"; exit "$RC"; } |
9789 | 115 |
RC="$?" |
2301 | 116 |
|
16392 | 117 |
NEW_DB_INFO="$(ls -l "$DB" 2>/dev/null)" |
10206 | 118 |
[ -n "$OUTFILE" -a -n "$COMPRESS" -a "$DB_INFO" != "$NEW_DB_INFO" ] && \ |
16393 | 119 |
"$POLY" $DISCGARB_OPTIONS "$OUTFILE" |
4505 | 120 |
[ -n "$OUTFILE" -a -f "$OUTFILE" -a -n "$NOWRITE" ] && chmod -w "$OUTFILE" |
2301 | 121 |
|
9789 | 122 |
exit "$RC" |