2 # -----------------------------------------------------------------------------
3 # Title: A script to invoke the various CL implementations in a uniform way
4 # Created: 1999-01-16 16:41
5 # Author: Gilbert Baumann <unk6@rz.uni-karlsruhe.de>
6 # License: LGPL (See file GNU-LGPL for details)
7 # -----------------------------------------------------------------------------
8 # (c) copyright 1999 by Gilbert Baumann, Sam Steingold, Bruno Haible
9 # $Id: maxima-run-lisp,v 1.7 2003-03-05 01:36:25 rtoy Exp $
10 # $Source: /home/lbutler/maxima/sandbox/cvs/maxima/maxima/lisp-utils/maxima-run-lisp,v $
12 # Prior to invocation the LISPTYPE environment variable must been set to
15 # clisp uses ${CLISP} if set, else "clisp"
16 # cmucl uses ${CMUCL} if set, else "lisp"
17 # acl43 uses ${ACL43} if set, else "cl"
18 # acl5 uses ${ACL5} if set, else "cl"
19 # acl6 uses $(ACL6) if set, else "alisp
20 # gcl uses ${GCL} if set, else "gcl"
21 # sbcl uses ${SBCL} if set, else "sbcl"
22 # openmcl uses ${OPENMCL} if set, else "openmcl"
27 run-lisp
[clause ...
] [argument ...
]
28 clause
::= -i file ; load
file `file'
29 | -c file ; compile file `file'
30 | -x form ; execute form `form'
31 |
-I image
; use image
file `image'
32 | -d image ; dump to image `image
'
33 | -f initfun ; set init function of dumped image to `initfun'
34 |
--extra-args=args
; add
'args' to lisp
command line
35 |
--safety n
; set safety level
for compilation
36 |
--speed n
; set speed level
for compilation
38 Note
: Lisp specific extensions
(e.g. .dxl on ACL or .mem
for CLISP
)
39 are not to be included into the image argument
41 Anything
else is stuffed into the Lisp variable
'argv', which is
42 available
in the lexical environment forms given to
-x are
45 run-lisp
[--extra-args=args
] -run image
[-i file]
46 interactively run
'image'
47 (user
:run
) will be called upon start up.
52 echo the fasload
file extension to stdout.
53 This is useful
for Makefile
; you could
then say e.g.
54 FAS
:=$
(shell $
(TOP
)/bin
/run-lisp
-faslext)
57 echo the memory image extension _with_ dot.
59 DUMP
:=$
(shell $
(TOP
)/bin
/run-lisp
-dumpext)
61 run-lisp
-cat [fasl-file ...
]
62 Cat all the given fasl files together.
66 $ run-lisp
-x "(print argv)" foo bar baz
"Hallo Welt" foo
\"bar
67 ("foo" "bar" "baz" "Hallo Welt" "foo\"bar")
80 extra_args
=`echo $1 | sed 's/--extra-args=//'`
88 "--help" |
"-h" |
"-?" )
94 clisp | cmucl | acl43 | acl
[56] )
98 fail
"Sorry, option -cat not supported for LISPTYPE=${LISPTYPE}."
106 # This is (pathname-type (car (system::*compiled-file-types*))).
110 # This can be found via
111 # (c:backend-fasl-file-type c:*target-backend*),
112 # but for speed we look at the uname first.
113 case `uname -m 2>/dev/null` in
119 ${CMUCL-lisp} -noinit \
121 (write-string (c:backend-fasl-file-type c:*target-backend*))
131 echo 'o' # but also 'data' on same platforms
134 echo 'fasl' # How about other platforms?
147 # Since make does not stop when the exit status is 1, we simply
148 # echo LISPTYPE_NOT_SET here.
149 echo LISPTYPE_NOT_SET
150 fail
"Sorry, option -faslext not supported for LISPTYPE=${LISPTYPE}."
170 echo .core
# This is just a guess
176 # Since make does not stop when the exit status is 1, we simply
177 # echo LISPTYPE_NOT_SET here.
178 echo LISPTYPE_NOT_SET
179 fail
"Sorry, option -dumpext not supported for LISPTYPE=${LISPTYPE}."
184 # we special case on '-run' for now
186 if [ x
"$2" = x
"-i" ]; then
191 if [ -n "$load_file" ]; then
192 load_arg
="-i $load_file"
194 ${CLISP-clisp} $extra_args $load_arg -M "$1".mem
197 if [ -n "$load_file" ]; then
198 load_arg
="-load $load_file"
200 # jfa: fixme 04/24/02
201 # jfa: The -eval part of the following line is a big hack!
202 ${CMUCL-lisp} -eval "(user::run)" $extra_args $load_arg -core "$1".core
205 if [ -n "$load_file" ]; then
206 load_arg
="--load $load_file"
208 # jfa: fixme 04/24/02
209 # jfa: The --eval part of the following line is a big hack!
210 ${SBCL-sbcl} --core "$1".core
--eval "(user::run)" $extra_args $load_arg
213 if [ -n "$load_file" ]; then
214 load_arg
="-i $load_file"
216 # Why "$1"? ACL4.3 dumps executables
217 "$1" $extra_args $load_arg -e '(unwind-protect (run) (excl:exit))'
220 if [ -n "$load_file" ]; then
221 load_arg
="-i $load_file"
223 ${ACL5-cl} $extra_args $load_arg -I "$1".dxl
-e '(unwind-protect (run) (excl:exit))'
226 if [ -n "$load_file" ]; then
227 load_arg
="-i $load_file"
230 # I (RLT) am not sure the -e is quite right, but this
231 # allows us to get back to lisp when the user does
232 # to_lisp(), like the way CMUCL does it.
234 ${ACL6-alisp} $extra_args $load_arg -I "$1".dxl
-e '(user::run)'
237 if [ -n "$load_file" ]; then
238 load_arg
="-load $load_file"
240 "$1" $extra_args $load_arg -eval '(run)'
243 if [ -n "$load_file" ]; then
244 load_arg
="-l $load_file"
246 ${OPENMCL-openmcl} -I "$1.image" $load_arg
249 fail
"Sorry, option -run not supported for LISPTYPE=${LISPTYPE}."
254 # Multiple arguments.
256 todo
="" # list of forms to execute
257 args
="" # list of arguments (strings) to pass
258 while [ $# != 0 ]; do
262 fail
"missing argument for $1"
265 backslashify
='s,\(["\\]\),\\\1,g'
266 arg
=`echo "$1" | sed -e "$backslashify"`
267 todo
=$todo" (load \"${arg}\")"
272 fail
"missing argument for $1"
280 fail
"missing argument for $1"
283 backslashify
='s,\(["\\]\),\\\1,g'
284 arg
=`echo "$1" | sed -e "$backslashify"`
285 # todo=$todo" (compile-file \"${arg}\" :print nil)"
286 # truename helps, when using Franz' emacs interface
287 todo
=$todo" (compile-file (truename \"${arg}\") :print nil)"
292 fail
"missing argument for $1"
300 fail
"missing argument for $1"
306 initfun_arg
=":init-function #'$initfun"
309 initfun_arg
=":init-function #'$initfun"
312 initfun_arg
=":toplevel #'$initfun"
315 todo
=$todo" (setq si::*top-level-hook* #'$initfun)"
318 initfun_arg
=":toplevel-function #'$initfun"
321 fail
"Sorry, option -d not supported for LISPTYPE=${LISPTYPE}."
328 fail
"missing argument for $1"
331 backslashify
='s,\(["\\]\),\\\1,g'
332 arg
=`echo "$1" | sed -e "$backslashify"`
335 todo
=$todo" (#+lisp=cl ext:saveinitmem #-lisp=cl lisp:saveinitmem \"${arg}.mem\" $initfun_arg)"
338 todo
=$todo" (ext:save-lisp \"${arg}.core\" $initfun_arg)"
341 todo
=$todo" (sb-ext:save-lisp-and-die \"${arg}.core\" $initfun_arg)"
344 todo
=$todo" (excl:dumplisp :name \"${arg}\")"
347 todo
=$todo" (excl:dumplisp :name \"${arg}.dxl\")"
350 todo
=$todo" (si:save-system \"${arg}\")"
353 todo
=$todo" (ccl:save-application \"${arg}.image\" $initfun_arg)"
356 fail
"Sorry, option -d not supported for LISPTYPE=${LISPTYPE}."
363 fail
"missing argument for $1"
366 todo
=$todo" (proclaim (quote (optimize (safety "$1"))))"
371 fail
"missing argument for $1"
374 todo
=$todo" (proclaim (quote (optimize (speed "$1"))))"
378 backslashify
='s,\(["\\]\),\\\1,g'
379 arg
=`echo "$1" | sed -e "$backslashify"`
380 args
=$args" \"${arg}\""
386 # done with collecting the arguments
388 if [ x
"$LISPTYPE" = x
"sbcl" ]; then
389 todo
="(progn${todo}(sb-ext:quit))"
390 elif [ x
"$LISPTYPE" = x
"openmcl" ]; then
391 todo
="(progn ${todo} (ccl::quit))"
393 todo
="(progn${todo})"
396 todo
="(let ((argv '$args)) (declare (ignorable argv)) $todo (values))"
400 todo
="(progn (setq #+lisp=cl ext:*load-paths* #-lisp=cl lisp:*load-paths* '(#P\"\")) ${todo})"
401 test -z "$image" || image
="-M ${image}.mem";
402 echo ${CLISP-clisp} -norc -q ${image} -x "$todo"
403 exec ${CLISP-clisp} $extra_args -norc -q ${image} -x "$todo"
406 # we have to convince CMUCL to return a proper exit status.
407 todo
="(let (.res (.cond t))
409 (multiple-value-setq (.res .cond)
410 (ignore-errors (progn $todo
411 (fresh-line) (finish-output))))
412 (unix:unix-exit (if .cond 1 0))))"
413 test -z "$image" || image
="-core ${image}.core";
414 exec ${CMUCL-lisp} $extra_args -noinit ${image} -eval "$todo"
417 exec echo "$todo" |
${image-${ACL43-cl}} $extra_args -batch
420 test -z "$image" || image
="-I ${image}.dxl";
421 exec echo "$todo" |
${ACL5-cl} ${image+"-I ${image}.dxl"} $extra_args -batch
424 test -z "$image" || image
="-I ${image}.dxl";
425 exec echo "$todo" |
${ACL6-alisp} ${image+"-I ${image}.dxl"} $extra_args -batch
428 echo ${image-${GCL-gcl}} $extra_args -batch -eval "$todo"
429 ${image-${GCL-gcl}} $extra_args -batch -eval "$todo"
432 ${image-${SBCL-sbcl}} $extra_args --noinform --noprint --eval "$todo"
435 test -z "$image" || image
="-I ${image}.image";
436 echo ${OPENMCL-openmcl} ${image} -e "${todo}" $extra_args
437 ${OPENMCL-openmcl} ${image} -e "${todo}" $extra_args
440 if [ -n "$LISPTYPE" ] ; then
441 fail
"Sorry, LISPTYPE=${LISPTYPE} is not supported"
443 fail
"LISPTYPE environment variable is not set"