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