author | paulson |
Tue, 25 Mar 1997 10:43:01 +0100 | |
changeset 2837 | dee1c7f1f576 |
parent 2768 | bc6d915b8019 |
child 2936 | bd33e7aae062 |
permissions | -rwxr-xr-x |
2343 | 1 |
#!/bin/bash -norc |
2292 | 2 |
# |
2308 | 3 |
# $Id$ |
4 |
# |
|
2292 | 5 |
# Basic Isabelle startup script. |
6 |
||
7 |
||
8 |
## settings |
|
9 |
||
2704 | 10 |
PRG=$(basename $0) |
11 |
||
2735
29434f9b95dd
even more robust and user friendly invocation (no longer requieres
wenzelm
parents:
2711
diff
changeset
|
12 |
ISABELLE_HOME=$(dirname $0)/.. |
29434f9b95dd
even more robust and user friendly invocation (no longer requieres
wenzelm
parents:
2711
diff
changeset
|
13 |
. $ISABELLE_HOME/lib/scripts/getsettings || \ |
29434f9b95dd
even more robust and user friendly invocation (no longer requieres
wenzelm
parents:
2711
diff
changeset
|
14 |
{ echo "$PRG probably not called from its original place!"; exit 2 } |
2292 | 15 |
|
16 |
||
17 |
## diagnostics |
|
18 |
||
19 |
function usage() |
|
20 |
{ |
|
21 |
echo |
|
22 |
echo "Usage: $PRG [OPTIONS] [INPUT] [OUTPUT]" |
|
23 |
echo |
|
24 |
echo " Options are:" |
|
2395 | 25 |
echo " -c force copying of heap file (for Poly/ML)" |
2343 | 26 |
echo " -e MLTEXT pass MLTEXT to the ML session" |
2704 | 27 |
echo " -m MODE add print mode for output" |
2292 | 28 |
echo " -q non-interactive session" |
29 |
echo " -r open heap file read-only" |
|
2343 | 30 |
echo " -u pass 'exit_use_dir\".\";' to the ML session" |
2292 | 31 |
echo |
32 |
echo " INPUT (default \"$DEFAULT_LOGIC\") and OUTPUT specify in/out heaps." |
|
33 |
echo " These are either names to be searched in the Isabelle path, or actual" |
|
2343 | 34 |
echo " file names (then containing at least one /)." |
2768 | 35 |
echo " If INPUT is \"RAW_ML_SYSTEM\", just start the bare bones ML system." |
2292 | 36 |
echo |
37 |
exit 1 |
|
38 |
} |
|
39 |
||
40 |
function fail() |
|
41 |
{ |
|
2343 | 42 |
echo "$1" >&2 |
2292 | 43 |
exit 2 |
44 |
} |
|
45 |
||
46 |
||
47 |
## process command line |
|
48 |
||
49 |
# options |
|
50 |
||
51 |
COPYDB="" |
|
52 |
MLTEXT="" |
|
53 |
COPYDB="" |
|
2704 | 54 |
MODES="" |
2292 | 55 |
TERMINATE="" |
56 |
READONLY="" |
|
57 |
||
2704 | 58 |
while getopts "ce:m:qru" OPT |
2292 | 59 |
do |
60 |
case "$OPT" in |
|
61 |
c) |
|
62 |
COPYDB=true |
|
63 |
;; |
|
64 |
e) |
|
65 |
MLTEXT="$MLTEXT $OPTARG" |
|
66 |
;; |
|
2704 | 67 |
m) |
68 |
if [ -z "$MODES" ]; then |
|
69 |
MODES="\"$OPTARG\"" |
|
70 |
else |
|
2711 | 71 |
MODES="\"$OPTARG\", $MODES" |
2704 | 72 |
fi |
73 |
;; |
|
2292 | 74 |
q) |
75 |
TERMINATE=true |
|
76 |
;; |
|
77 |
r) |
|
78 |
READONLY=true |
|
79 |
;; |
|
80 |
u) |
|
2343 | 81 |
MLTEXT="$MLTEXT exit_use_dir\".\";" |
2292 | 82 |
;; |
83 |
\?) |
|
84 |
usage |
|
85 |
;; |
|
86 |
esac |
|
87 |
done |
|
88 |
||
89 |
shift $(($OPTIND - 1)) |
|
90 |
||
91 |
||
92 |
# args |
|
93 |
||
94 |
INPUT="" |
|
95 |
OUTPUT="" |
|
96 |
||
97 |
if [ $# -ge 1 ]; then |
|
98 |
INPUT="$1" |
|
99 |
shift |
|
100 |
fi |
|
101 |
||
102 |
if [ $# -ge 1 ]; then |
|
103 |
OUTPUT="$1" |
|
104 |
shift |
|
105 |
fi |
|
106 |
||
2343 | 107 |
[ $# -ne 0 ] && { echo "Bad args: $*"; usage } |
2292 | 108 |
|
109 |
||
110 |
## check ML system |
|
111 |
||
2308 | 112 |
[ -z "$ML_SYSTEM" ] && fail "Missing ML system settings! Unable to run Isabelle." |
2292 | 113 |
|
114 |
||
115 |
## input heap file |
|
116 |
||
117 |
[ -z "$INPUT" ] && INPUT="$DEFAULT_LOGIC" |
|
118 |
||
119 |
case "$INPUT" in |
|
2768 | 120 |
RAW_ML_SYSTEM) |
2292 | 121 |
INFILE="" |
122 |
;; |
|
123 |
*/*) |
|
124 |
INFILE="$INPUT" |
|
2343 | 125 |
[ ! -f "$INFILE" ] && fail "Bad heap file: \"$INFILE\"" |
2292 | 126 |
;; |
127 |
*) |
|
2308 | 128 |
ISA_PATH="" |
2292 | 129 |
INFILE="" |
130 |
for DIR in $(echo $ISABELLE_PATH | tr : " ") |
|
131 |
do |
|
2308 | 132 |
ISA_PATH="$ISA_PATH $DIR/$ML_SYSTEM-$PLATFORM" |
2292 | 133 |
[ -z "$INFILE" -a -f $DIR/$ML_SYSTEM-$PLATFORM/$INPUT ] && INFILE=$DIR/$ML_SYSTEM-$PLATFORM/$INPUT |
134 |
done |
|
2308 | 135 |
if [ -z "$INFILE" ]; then |
2343 | 136 |
echo "Unknown logic \"$INPUT\" -- no heap file found in:" >&2 |
2308 | 137 |
for DIR in $ISA_PATH |
138 |
do |
|
2343 | 139 |
echo " $DIR" >&2 |
2308 | 140 |
done |
141 |
exit 2 |
|
142 |
fi |
|
2292 | 143 |
;; |
144 |
esac |
|
145 |
||
146 |
||
147 |
## output heap file |
|
148 |
||
149 |
case "$OUTPUT" in |
|
150 |
"") |
|
151 |
[ -z "$READONLY" -a -w "$INFILE" ] && OUTFILE="$INFILE" |
|
152 |
;; |
|
153 |
*/*) |
|
154 |
OUTFILE="$OUTPUT" |
|
155 |
;; |
|
156 |
*) |
|
157 |
OUTDIR="$ISABELLE_OUTPUT/$ML_SYSTEM-$PLATFORM" |
|
158 |
mkdir -p "$OUTDIR" |
|
159 |
OUTFILE="$OUTDIR/$OUTPUT" |
|
160 |
;; |
|
161 |
esac |
|
162 |
||
163 |
||
164 |
## run it! |
|
165 |
||
166 |
ML_SYSTEM_BASE=$(echo $ML_SYSTEM | cut -f1 -d-) |
|
167 |
||
2704 | 168 |
[ -n "$MODES" ] && MLTEXT="print_mode := [$MODES]; $MLTEXT" |
169 |
||
2343 | 170 |
export INFILE OUTFILE COPYDB MLTEXT TERMINATE |
2292 | 171 |
[ -f $ISABELLE_HOME/lib/scripts/run-$ML_SYSTEM ] && exec $ISABELLE_HOME/lib/scripts/run-$ML_SYSTEM |
172 |
exec $ISABELLE_HOME/lib/scripts/run-$ML_SYSTEM_BASE |