-
Notifications
You must be signed in to change notification settings - Fork 32
/
pvs.in
executable file
·386 lines (356 loc) · 13.2 KB
/
pvs.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
#!/bin/sh
# Script for starting PVS
# This script starts up Emacs, which in turn invokes the PVS lisp image.
# The image is in the main PVS directory, and is named
# pvs-PVSLISP-PVSARCH
# where PVSLISP reflects the lisp name and version, and PVSARCH is determined
# from the system on which PVS is invoked.
# command line arguments:
# -h | -help | --help prints a help line and exits
# -version | --version prints the PVS version
# -emacs emacsref emacs, xemacs, or pathname
# -lisp name lisp image name - allegro or sbclisp
# -runtime use the runtime image (devel is default, if there)
# -image imagename use user SBCL image (see make-new-pvs-image in utils.lisp)
# -patchlevel indicates the patch level: 0 for no patches
# -batch run in batch mode
# -timeout seconds to timeout commands or proofs - only allowed in batch
# -nobg don't run PVS in the background
# -port number start XML-RPC server on port number num
# -raw run PVS without Emacs
# -v the (verbose) level number - 0-3 (mostly for batch mode)
# -q do not load ~/.emacs, ~/.pvsemacs, or ~/.pvs.lisp files
# -e expr evaluate the given Emacs expression
# -l efile load the given Emacs file before PVS emacs files
# -load-after efile loads Emacs file after PVS emacs files
# -E expr
# -L lfile load the given Lisp file (after PVS initializes)
# any other emacs parameters (e.g. -u or -nw)
# any X window parameters (e.g. -geometry 80x60+0-0)
# Other arguments will simply pass through, but they are likely not to work
# with different Emacs/Lisp combinations
#
# If the corresponding command line argument is not given, the following
# environment variables are used if set:
# PVSLISP - corresponds to the -lisp argument
# PVSEMACS - corresponds to the -emacs argument
# PVSPATCHLEVEL - corresponds to the -patchlevel argument
# PVSPORT - corresponds to the -port argument
# PVSVERBOSE - corresponds to the -v argument
# PVSXINIT - X window parameters; e.g., "-g '-0-0'"
#
# The following environment variables are used by PVS, and are set below:
# PVSPATH pvs system path - this should not normally be set by the user
# PVSARCH ix86 or ix86_64
#
# The PVS binary paths are appended to the front of the PATH variable
# --------------------------------------------------------------------
# PVS
# Copyright (C) 2006, SRI International. All Rights Reserved.
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# --------------------------------------------------------------------
# PVSPATH should be set after installation by <PVS>/bin/relocate or by hand
# to the location of the PVS installation
PVSPATH=@PVSPATH@
#-------------------------------------------------
# Nothing below this line should need modification
# Initialize/set local variables
batch=
dotemacs=
emacs_args=
emacscmd=
evalflag=
emacsargs=
getversion=
loadafter=
nobg=
noinit=
nowin=
opsys=`uname -s`
otherargs=
pvsemacsinit=
pvsimagepath=
pvsruntime=
rawmode=
# Process the command-line options
# Note that if emacsargs are repeated, the aruments are appended if that makes
# sence, otherwise the last occurence is used
while [ $# -gt 0 ]
do
case $1 in
-emacs) emacscmd="$2"
shift;;
-lisp)
case $2 in
allegro) PVSLISP=allegro;;
sbclisp) PVSLISP=sbclisp;;
*) echo "Only allegro and sbclisp are currently available"
exit 1;;
esac
shift;;
-image) PVSIMAGE="$2"
shift;;
-load-after) loadafter=$loadafter" -load $2"
shift;;
-runtime) pvsruntime=1;;
-port) PVSPORT=$2
if expr $PVSPORT : '\([0-9]*\)' != $PVSPORT > /dev/null; then
echo "The -port must be an integer"
exit 1
fi
shift;;
-nw) nowin=1;;
-nobg) nobg=1;;
-patchlevel)
case $2 in
none) PVSPATCHLEVEL=0;;
rel) PVSPATCHLEVEL=1;;
test) PVSPATCHLEVEL=2;;
exp) PVSPATCHLEVEL=3;;
0|1|2|3) PVSPATCHLEVEL=$2;;
*) echo "The patchlevel must be none, rel, test, exp, or 0-3"
exit 1;;
esac
shift;;
-batch) PVSNONINTERACTIVE=t
batch="$1";;
-timeout) PVSTIMEOUT=$2
if expr $PVSTIMEOUT : '\([0-9]*\)' != $PVSTIMEOUT > /dev/null; then
echo "The -timeout must be an integer"
exit 1
fi
shift;;
-raw) rawmode=1;;
-v) case $2 in
0|1|2|3) PVSVERBOSE=$2
shift;;
*) echo "The -v argument must be in the range 0-3"
exit 1;;
esac;;
-name|-title|-xrm) emacsargs="$emacsargs $1 $2"
shift;;
-q|-no-init-file) emacsargs="$emacsargs $1"
PVSMINUSQ="-q"
dotemacs= ;;
-E) PVSEVALLOAD="$PVSEVALLOAD $2"
shift;;
-L) PVSEVALLOAD="$PVSEVALLOAD (load \"$2\")"
shift;;
-e) emacsargs="$emacsargs --eval $2"
shift;;
-l) emacsargs="$emacsargs --load $2"
shift;;
-ee|-eval)
echo "Use -E, not $1, for lisp evaluation argument to PVS"
exit 1;;
--eval)
echo "Use -E/-e, not $1, for lisp/emacs evaluation argument to PVS"
exit 1;;
-load)
echo "Use -L, not $1, for loading lisp files in PVS"
exit 1;;
-where|--where) echo $PVSPATH
exit 0;;
-version|--version) getversion=1;;
-h|-help|--help) echo "usage:
pvs [-options ...] [file]
where options include:
-h | -help | --help print out this message
-version | --version show the PVS version number
-emacs emacsref emacs, xemacs, or pathname
-load-after efile loads emacs file after PVS emacs files
-lisp name lisp name (allegro or sbclisp)
-image name see make-new-pvs-image in src/utils.lisp
-runtime use the runtime image
-patchlevel level patchlevel (none, rel, test, exp or 0-3, resp.)
-batch run in batch mode
-timeout number use a timeout for commands or proofs in batch mode
-nobg don't put PVS in the background
-port number run PVS as XML-RPC server on port number
-raw run PVS without Emacs
-v number verbosity level for batch mode (0-3)
-q do not load ~/.emacs, ~/.pvsemacs, or ~/.pvs.lisp files
-e expr evaluate the Emacs expression
-l efile load the given Emacs file (before PVS emacs files)
-E expr evaluate the Lisp expression
-L lfile load the given Lisp file (after PVS initializes)
and any Emacs or X window options
To change the title and icon names, use -title and -xrm, for example,
pvs -title foo -xrm \"pvs*iconName:bar\""
exit 0;;
*) otherargs="$otherargs $1";;
esac
shift
done # command line args have been processed
# Check for Emacs - complain if -raw and certain emacs emacsargs are given
# emacsargs are: (-e -l -name -title -xrm) -batch is treated special, as it must appear
# as the first argument to Emacs
if [ -n "${rawmode}" ] # -raw given, hence no Emacs
then if [ -n "${emacscmd}" ] # -emacs given
then echo "ERROR: -raw and -emacs flags should not both be given."; exit 1
elif [ -n "${emacsargs}" ]
then echo "ERROR: -raw with -e or -l emacs flags not allowed."; exit 1
elif [ -n "${batch}" ] # -batch
then echo "ERROR: -raw with -batch emacs flags not allowed."; exit 1
else unset PVSEMACS # In case it's set as an environment variable
fi
else if [ -n "${emacscmd}" ]
then PVSEMACS=${emacscmd}
else PVSEMACS=${PVSEMACS:-"emacs"}
fi
# Exit if PVSEMACS is not executable
if [ ! -x `which ${PVSEMACS}` ]
then echo ${PVSEMACS} is not executable; exit 1
fi
# Exit if running XEmacs - considered obsolete and inconsistent with cl-lib
emacsversion="`${PVSEMACS} -q --version 2>&1 | grep Emacs | head -1`"
case $emacsversion in
*XEmacs*) echo "XEmacs is no longer supported"; exit 1;;
esac
pvsemacsinit="-load ${PVSPATH}/emacs/go-pvs.el ${emacs_args} ${loadafter}"
if [ -f ${HOME}/.emacs ]
then dotemacs="-l ${HOME}/.emacs"
fi
PVSINEMACS=1
fi
# If we have any -E or -L args, wrap them in a progn
if [ -n "$PVSEVALLOAD" ]
then PVSEVALLOAD="(progn $PVSEVALLOAD)"
fi
# Determine the system type and set PVSARCH accordingly
case $opsys in
Linux|FreeBSD) case `uname -m` in
x86_64) PVSARCH=ix86_64 ;;
*86*) PVSARCH=ix86 ;;
*) PVSARCH=`uname -p`;;
esac
[ -n "${DISPLAY}" ] || nowin=1
;;
Darwin) case `uname -p` in
i*86) PVSARCH=ix86;;
*) PVSARCH=`uname -p`;;
esac
opsys=MacOSX
export LC_ALL="en_US.UTF-8"
;;
*) echo "PVS only runs under Linux, FreeBSD (linux-enabled), or MacOSX"; exit 1
esac
PVSBINPATH=$PVSPATH/bin/$PVSARCH-$opsys
# Check if this is a 64-bit platform, but only 32-bit available
if [ "$PVSARCH" = "ix86_64" -a ! -x "$PVSBINPATH" ]
then PVSBINPATH=$PVSPATH/bin/ix86-$opsys
fi
# Check which lisp to use
if [ -z "$PVSLISP" ]
then if [ -x $PVSBINPATH/devel/pvs-allegro ]
then PVSLISP=allegro
elif [ -x $PVSBINPATH/runtime/pvs-allegro ]
then PVSLISP=allegro
elif [ -x $PVSBINPATH/devel/pvs-sbclisp ]
then PVSLISP=sbclisp
elif [ -x $PVSBINPATH/runtime/pvs-sbclisp ]
then PVSLISP=sbclisp
else echo "No executable available in $PVSBINPATH"
exit 1
fi
fi
# If PVSIMAGE is set, PVSLISP must be sbclisp
if [ -n "$PVSIMAGE" ]; then PVSLISP=sbclisp; fi
# Set PVSIMAGE if not already given
PVSIMAGE=${PVSIMAGE:=pvs-$PVSLISP}
# Set path related environment variables
if [ -d $PVSBINPATH/devel -a -e $PVSBINPATH/devel/$PVSIMAGE -a -z "$pvsruntime" ]
then
PATH=$PVSBINPATH/devel:$PVSBINPATH:$PVSPATH/bin:$PATH
LD_LIBRARY_PATH=$PVSBINPATH/devel:$LD_LIBRARY_PATH
DYLD_LIBRARY_PATH=$PVSBINPATH/devel:$DYLD_LIBRARY_PATH
pvsimagepath=$PVSBINPATH/devel/$PVSIMAGE
elif [ -d $PVSBINPATH/runtime -a -e $PVSBINPATH/runtime/$PVSIMAGE ]
then
PATH=$PVSBINPATH/runtime:$PVSBINPATH:$PVSPATH/bin:$PATH
LD_LIBRARY_PATH=$PVSBINPATH/runtime:$LD_LIBRARY_PATH
DYLD_LIBRARY_PATH=$PVSBINPATH/runtime:$DYLD_LIBRARY_PATH
pvsimagepath=$PVSBINPATH/runtime/$PVSIMAGE
else
echo "Cannot find $PVSBINPATH/runtime/$PVSIMAGE"
echo "Check the values of PVSPATH and PVSLISP"
exit 1
fi
# Here is where we handle the different emacsargs for the different lisps
case $PVSLISP in
allegro)
ALLEGRO_CL_HOME=$PVSPATH/bin/$PVSARCH-$opsys/home
noinit="-qq"
evalflag="-e"
;;
sbclisp)
noinit="--no-userinit"
evalflag="--eval"
;;
esac
# Set and export various environment variables
PVSPATCHLEVEL=${PVSPATCHLEVEL:-2}
case $PVSPATCHLEVEL in
none) PVSPATCHLEVEL=0;;
rel) PVSPATCHLEVEL=1;;
test) PVSPATCHLEVEL=2;;
exp) PVSPATCHLEVEL=3;;
esac
if [ -n "$PVSVERBOSE" -a -z "$batch" ]
then echo "The -verbose flag only makes sense with -batch; it will be ignored"
fi
if [ -n "$PVSTIMEOUT" -a -z "$batch" ]
then echo "The -timeout flag only makes sense with -batch; it will be ignored"
fi
PVSVERBOSE=${PVSVERBOSE:-0}
export ALLEGRO_CL_HOME DISPLAY LD_LIBRARY_PATH
export PVSARCH PVSIMAGE PVSPATH PVSBINPATH PATH PVSLISP PVSVERBOSE PVSTIMEOUT
export PVSPORT PVSPATCHLEVEL PVSMINUSQ PVSNONINTERACTIVE PVSEVALLOAD PVSEMACS
export PVSINEMACS # Will be obsolete soon
# if -version, simply call pvs lisp image and return it
# Do this right after the environment variables are exported
if [ -n "${getversion}" ]
then
export PVS_LIBRARY_PATH=
echo `${pvsimagepath} ${noinit} ${evalflag} "(progn(pvs::pvs-version)(terpri)(pvs::exit-pvs))"`
exit 0
fi
# Warn about for PVS_LIBRARY_PATH conflicts
if [ -n "$PVS_LIBRARY_PATH" -a -z "$rawmode" ]
then
plibs=`for plib in ${PVSPATH}/lib/*; do if [ -d $plib -a -f $plib/.pvscontext ]; then basename $plib; fi; done`
for path in `echo $PVS_LIBRARY_PATH | tr ':' ' '`
do for plib in $plibs
do if [ -d $path/$plib ]
then echo "Warning: PVS_LIBRARY_PATH $path/$plib"
echo " conflicts with $PVSPATH/lib/$plib"
echo " $plib will default to $path/$plib"
fi
done
done
fi
# Now run pvs, either through Emacs or the raw PVS image
# emacsargs is the arguments not otherwise hendled while processing the command line args
if [ -n "${rawmode}" ] # No Emacs involved - PVSEMACS is not set
then ${pvsimagepath} ${noinit} ${otherargs}
elif [ -n "${batch}" ] # Emacs, but no windows
then ${PVSEMACS} ${batch} ${dotemacs} ${pvsemacsinit} ${emacsargs} ${otherargs} 2>&1
elif [ -n "${nowin}" ]
then ${PVSEMACS} -nw ${pvsemacsinit} ${emacsargs} ${otherargs}
else
pvsrun="${PVSEMACS} -name pvs ${pvsemacsinit} ${PVSXINIT} ${emacsargs} ${otherargs}"
if [ -z ${nobg} ]
then (${pvsrun} &)
else ${pvsrun}
fi
fi