5 echo "$1" | sed -e 's%\\\\%/%g' | sed -e 's%^\([A-Za-z]\):%/\1%'
9 if [ -z "$MAXIMA_VERSION" ]; then
10 MAXIMA_VERSION="@VERSION@"
12 prefix=`unixize "@prefix@"`
13 exec_prefix=`unixize "@exec_prefix@"`
15 top_srcdir=`unixize "@expanded_top_srcdir@"`
16 libdir=`unixize "@libdir@"`
17 if [ -n "$MAXIMA_LAYOUT_AUTOTOOLS" ]; then
18 layout_autotools="$MAXIMA_LAYOUT_AUTOTOOLS"
20 layout_autotools=@default_layout_autotools@
22 if [ "$layout_autotools" = "true" ]; then
23 MAXIMA_DEFAULT_IMAGESDIR=$libdir/$PACKAGE/$MAXIMA_VERSION
25 MAXIMA_DEFAULT_IMAGESDIR=$top_srcdir/src
27 if [ -d "$MAXIMA_DEFAULT_IMAGESDIR" ]; then
28 MAXIMA_IMAGESDIR="$MAXIMA_DEFAULT_IMAGESDIR"
30 if [ "$layout_autotools" = "true" ]; then
31 MAXIMA_IMAGESDIR=`unixize "$MAXIMA_PREFIX"`/lib/$PACKAGE/$MAXIMA_VERSION
33 MAXIMA_IMAGESDIR=`unixize "$MAXIMA_PREFIX"`/src
36 MAXIMA_DEFAULT_LISP=@DEFAULTLISP@
37 # If the the binary directory for the default lisp is not present,
38 # choose the first one we find.
39 if [ ! -d "$MAXIMA_IMAGESDIR/binary-$MAXIMA_DEFAULT_LISP" ]; then
40 MAXIMA_DEFAULT_LISP=`ls -1 $MAXIMA_IMAGESDIR 2>/dev/null | head -n 1 | sed 's/binary-//'`
42 if [ -z "$MAXIMA_LISP" ]; then
43 MAXIMA_LISP=$MAXIMA_DEFAULT_LISP
48 unset MAXIMA_IMAGESDIR
52 process_userdir_argument() {
55 --userdir ) MAXIMA_USERDIR=$2 ; shift;;
56 --userdir=* ) MAXIMA_USERDIR=`echo "$1" | sed 's/--userdir=//'` ;;
60 if [ -n "$MAXIMA_USERDIR" ]; then
65 # make a special check for --userdir argument, because it influences location
66 # of maximarc, which is sourced before other command-line options are
68 process_userdir_argument "$@"
70 if [ -z "$MAXIMA_USERDIR" ]; then
71 maximarc_path="$HOME/.maxima/maximarc"
73 maximarc_path="`unixize \"$MAXIMA_USERDIR\"`/maximarc"
75 if [ -f "$maximarc_path" ]; then
79 # For some reason TeXmacs sets MAXIMA_DIRECTORY to the empty string,
80 # which breaks maxima's internal path logic. This is a workaround.
81 if [ -z "$MAXIMA_DIRECTORY" ]; then
82 unset MAXIMA_DIRECTORY
85 # GCL in its default settings tends to run out of memory frequently quickly.
86 # For example 8 Gigabytes of RAM aren't enough to run the testbench when sbcl
87 # and clisp need <0,5 Gigabytes by default.
88 # The following lines make GCL's garbage collector more aggressive by default.
89 if [ -z "$GCL_GC_PAGE_THRESH" ]; then
90 export GCL_GC_PAGE_THRESH=0.2
92 if [ -z "$GCL_GC_ALLOC_MIN" ]; then
93 export GCL_GC_ALLOC_MIN=0.01
95 if [ -z "$GCL_GC_PAGE_MAX" ]; then
96 export GCL_GC_PAGE_MAX=0.05
100 # GCL also by default tells the garbage collector to limit the memory usage to
101 # allocate half of the physical RAM installed in the current machine.
102 # Which works fine in a single-user system and even takes in account the amount
103 # of memory the other gcl processes use but is too far in the multitasking versus
104 # speed tradeoff for us.
107 # https://lists.gnu.org/archive/html/gcl-devel/2017-09/msg00000.html
108 if [ -z "$GCL_MEM_MULTIPLE" ]; then
109 export GCL_MEM_MULTIPLE=0.2
112 # process the command line arguments. This must be done in a function, because
113 # "shift" should only shift the function parameters, not the global parameters.
114 process_commandline_arguments() {
115 while [ -n "$1" ]; do
117 -l|--lisp ) MAXIMA_LISP=$2 ; shift;;
118 --lisp=*) MAXIMA_LISP=`echo "$1" | sed 's/--lisp=//'` ;;
119 -u|--use-version ) MAXIMA_VERSION=$2 ; shift;;
120 --use-version=*) MAXIMA_VERSION=`echo "$1" | sed 's/--use-version=//'` ;;
121 -X|--lisp-options) MAXIMA_LISP_OPTIONS="$2" ; shift ;;
122 --lisp-options=*) MAXIMA_LISP_OPTIONS=`echo "$1" | sed 's/--lisp-options=//'` ;;
123 --userdir ) : ; shift;; # noop; handled by process_userdir_argument
124 --userdir=*) : ;; # noop; handled by process_userdir_argument
125 -v|--verbose ) verbose=true;;
132 process_commandline_arguments "$@"
135 # Allow ccl as an alias of openmcl.
136 if [ "$MAXIMA_LISP" = "ccl" ]; then
143 if [ ! -d "$MAXIMA_IMAGESDIR" ]; then
144 # Have we been moved?
145 MAXIMA_PREFIX=`(cd "\`dirname "$0"\`" 1>/dev/null 2>/dev/null; dirname "\`pwd\`")`
149 if [ ! -d "$MAXIMA_IMAGESDIR" ]; then
150 echo "$0: unable to determine MAXIMA_PREFIX" 1>&2
155 # This step should only be necessary in order to be in sync with the windows
157 if [ -d "$MAXIMA_INITIAL_FOLDER" ]; then
158 cd "$MAXIMA_INITIAL_FOLDER"
161 maxima_image_base="$MAXIMA_IMAGESDIR/binary-$MAXIMA_LISP/maxima"
163 if [ "$verbose" = "true" ]; then
166 if [ "$MAXIMA_LISP" = "clisp" ]; then
167 if [ "$layout_autotools" = "true" ]; then
168 if [ -x "$MAXIMA_IMAGESDIR/binary-$MAXIMA_LISP/maxima" ]; then
169 exec "$MAXIMA_IMAGESDIR/binary-$MAXIMA_LISP/maxima" $MAXIMA_LISP_OPTIONS -q "" -- "$@"
171 exec "$MAXIMA_IMAGESDIR/binary-$MAXIMA_LISP/@CLISP_RUNTIME@" $MAXIMA_LISP_OPTIONS -q -M "$maxima_image_base.mem" "" -- "$@"
174 if [ -x "$maxima_image_base" ]; then
175 exec "$maxima_image_base" $MAXIMA_LISP_OPTIONS -q "" -- "$@"
177 exec "@CLISP_NAME@" $MAXIMA_LISP_OPTIONS -q -M "$maxima_image_base.mem" "" -- "$@"
180 elif [ "$MAXIMA_LISP" = "cmucl" ]; then
181 # CMUCL can use either an executable image or a regular lisp core
182 # file. Check for the executable image and run that if possible.
183 # Otherwise, fallback and use the lisp core file.
184 if [ "$layout_autotools" = "true" ]; then
185 if [ -x "$MAXIMA_IMAGESDIR/binary-$MAXIMA_LISP/maxima" ]; then
186 exec "$MAXIMA_IMAGESDIR/binary-$MAXIMA_LISP/maxima" $MAXIMA_LISP_OPTIONS -quiet -- "$@"
188 exec "$MAXIMA_IMAGESDIR/binary-$MAXIMA_LISP/@CMUCL_RUNTIME@" $MAXIMA_LISP_OPTIONS -quiet -core "$maxima_image_base.core" -eval '(cl-user::run)' -- "$@"
191 if [ -x "$maxima_image_base" ]; then
192 exec "$maxima_image_base" $MAXIMA_LISP_OPTIONS -quiet -- "$@"
194 exec "@CMUCL_NAME@" $MAXIMA_LISP_OPTIONS -quiet -core "$maxima_image_base.core" -eval '(cl-user::run)' -- "$@"
197 elif [ "$MAXIMA_LISP" = "scl" ]; then
198 if [ "$layout_autotools" = "true" ]; then
199 exec "$MAXIMA_IMAGESDIR/binary-$MAXIMA_LISP/@SCL_RUNTIME@" $MAXIMA_LISP_OPTIONS -quiet -core "$maxima_image_base.core" -eval '(cl-user::run)' -- "$@"
201 exec "@SCL_NAME@" $MAXIMA_LISP_OPTIONS -quiet -core "$maxima_image_base.core" -eval '(cl-user::run)' -- "$@"
203 elif [ "$MAXIMA_LISP" = "gcl" ]; then
204 exec "$maxima_image_base" -eval '(cl-user::run)' $MAXIMA_LISP_OPTIONS -f -- "$@"
205 elif [ "$MAXIMA_LISP" = "acl" ]; then
206 # FIXME: arguments need in a manner consistent with the way they are extracted
207 # in the function get-application-args in command-line.lisp
208 exec "@ACL_NAME@" -I "$maxima_image_base.dxl" $MAXIMA_LISP_OPTIONS -e '(cl-user::run)' -- "$@"
209 elif [ "$MAXIMA_LISP" = "openmcl" ]; then
210 # OPENMCL can use either an executable image or a regular lisp core
211 # file. Check for the executable image and run that if possible.
212 # Otherwise, fallback and use the lisp core file.
213 # FIXME: arguments need in a manner consistent with the way they are extracted
214 # in the function get-application-args in command-line.lisp
215 if [ -x "$MAXIMA_IMAGESDIR/binary-$MAXIMA_LISP/maxima" ]; then
216 exec "$MAXIMA_IMAGESDIR/binary-$MAXIMA_LISP/maxima" $MAXIMA_LISP_OPTIONS -e '(cl-user::run)' -- "$@"
218 exec "@OPENMCL_NAME@" -I "$maxima_image_base.image" $MAXIMA_LISP_OPTIONS -e '(cl-user::run)' -- "$@"
220 elif [ "$MAXIMA_LISP" = "ccl64" ]; then
221 # Ccl64 can use either an executable image or a regular lisp core
222 # file. Check for the executable image and run that if possible.
223 # Otherwise, fallback and use the lisp core file.
224 # FIXME: arguments need in a manner consistent with the way they are extracted
225 # in the function get-application-args in command-line.lisp
226 if [ -x "$MAXIMA_IMAGESDIR/binary-$MAXIMA_LISP/maxima" ]; then
227 exec "$MAXIMA_IMAGESDIR/binary-$MAXIMA_LISP/maxima" $MAXIMA_LISP_OPTIONS -e '(cl-user::run)' -- "$@"
229 exec "@CCL64_NAME@" -I "$maxima_image_base.image" $MAXIMA_LISP_OPTIONS -e '(cl-user::run)' -- "$@"
232 elif [ "$MAXIMA_LISP" = "ecl" ]; then
233 exec "$maxima_image_base" --frame-stack 4096 --lisp-stack 65536 $MAXIMA_LISP_OPTIONS -- "$@"
235 elif [ "$MAXIMA_LISP" = "abcl" ]; then
236 export MAXIMA_LISP_OPTIONS
237 export MAXIMA_IMAGESDIR
238 $MAXIMA_IMAGESDIR/binary-abcl/maxima "$@"
240 elif [ "$MAXIMA_LISP" = "sbcl" ]; then
241 # Use executable image if it exists.
242 # Since compiling lapack already needed >1200 Megabytes of RAM in August of 2015
243 # one has to extend the amount of memory sbcl will be able to claim by using the
244 # switch --dynamic-space-size in order to do so.
245 if [ -x "$MAXIMA_IMAGESDIR/binary-$MAXIMA_LISP/maxima" ]; then
246 exec "$MAXIMA_IMAGESDIR/binary-$MAXIMA_LISP/maxima" --noinform $MAXIMA_LISP_OPTIONS --end-runtime-options --eval '(cl-user::run)' --end-toplevel-options "$@"
248 exec "@SBCL_NAME@" --core "$maxima_image_base.core" --noinform $MAXIMA_LISP_OPTIONS --end-runtime-options --eval '(cl-user::run)' --end-toplevel-options "$@"
252 echo "$0: lisp=\"$MAXIMA_LISP\" not known. Use --list-avail to see possible options." >&2