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 # Will be promoted to be gcl's default. But for the time being: Allow concurrent
113 # gcl processes to communicate about how much memory each of them can use.
114 if [ -z "$GCL_DISABLE_MULTIPROCESS_MEMORY_POOL" ]; then
115 export GCL_MULTIPROCESS_MEMORY_POOL=t
118 # process the command line arguments. This must be done in a function, because
119 # "shift" should only shift the function parameters, not the global parameters.
120 process_commandline_arguments() {
121 while [ -n "$1" ]; do
123 -l|--lisp ) MAXIMA_LISP=$2 ; shift;;
124 --lisp=*) MAXIMA_LISP=`echo "$1" | sed 's/--lisp=//'` ;;
125 -u|--use-version ) MAXIMA_VERSION=$2 ; shift;;
126 --use-version=*) MAXIMA_VERSION=`echo "$1" | sed 's/--use-version=//'` ;;
127 -X|--lisp-options) MAXIMA_LISP_OPTIONS="$2" ; shift ;;
128 --lisp-options=*) MAXIMA_LISP_OPTIONS=`echo "$1" | sed 's/--lisp-options=//'` ;;
129 --userdir ) : ; shift;; # noop; handled by process_userdir_argument
130 --userdir=*) : ;; # noop; handled by process_userdir_argument
131 -v|--verbose ) verbose=true;;
138 process_commandline_arguments "$@"
141 # Allow ccl as an alias of openmcl.
142 if [ "$MAXIMA_LISP" = "ccl" ]; then
149 if [ ! -d "$MAXIMA_IMAGESDIR" ]; then
150 # Have we been moved?
151 MAXIMA_PREFIX=`(cd "\`dirname "$0"\`" 1>/dev/null 2>/dev/null; dirname "\`pwd\`")`
155 if [ ! -d "$MAXIMA_IMAGESDIR" ]; then
156 echo "$0: unable to determine MAXIMA_PREFIX" 1>&2
161 # This step should only be necessary in order to be in sync with the windows
163 if [ -d "$MAXIMA_INITIAL_FOLDER" ]; then
164 cd "$MAXIMA_INITIAL_FOLDER"
167 maxima_image_base="$MAXIMA_IMAGESDIR/binary-$MAXIMA_LISP/maxima"
169 if [ "$verbose" = "true" ]; then
172 if [ "$MAXIMA_LISP" = "clisp" ]; then
173 if [ "$layout_autotools" = "true" ]; then
174 if [ -x "$MAXIMA_IMAGESDIR/binary-$MAXIMA_LISP/maxima" ]; then
175 exec "$MAXIMA_IMAGESDIR/binary-$MAXIMA_LISP/maxima" $MAXIMA_LISP_OPTIONS -q "" -- "$@"
177 exec "$MAXIMA_IMAGESDIR/binary-$MAXIMA_LISP/@CLISP_RUNTIME@" $MAXIMA_LISP_OPTIONS -q -M "$maxima_image_base.mem" "" -- "$@"
180 if [ -x "$maxima_image_base" ]; then
181 exec "$maxima_image_base" $MAXIMA_LISP_OPTIONS -q "" -- "$@"
183 exec "@CLISP_NAME@" $MAXIMA_LISP_OPTIONS -q -M "$maxima_image_base.mem" "" -- "$@"
186 elif [ "$MAXIMA_LISP" = "cmucl" ]; then
187 # CMUCL can use either an executable image or a regular lisp core
188 # file. Check for the executable image and run that if possible.
189 # Otherwise, fallback and use the lisp core file.
190 if [ "$layout_autotools" = "true" ]; then
191 if [ -x "$MAXIMA_IMAGESDIR/binary-$MAXIMA_LISP/maxima" ]; then
192 exec "$MAXIMA_IMAGESDIR/binary-$MAXIMA_LISP/maxima" $MAXIMA_LISP_OPTIONS -quiet -- "$@"
194 exec "$MAXIMA_IMAGESDIR/binary-$MAXIMA_LISP/@CMUCL_RUNTIME@" $MAXIMA_LISP_OPTIONS -quiet -core "$maxima_image_base.core" -eval '(cl-user::run)' -- "$@"
197 if [ -x "$maxima_image_base" ]; then
198 exec "$maxima_image_base" $MAXIMA_LISP_OPTIONS -quiet -- "$@"
200 exec "@CMUCL_NAME@" $MAXIMA_LISP_OPTIONS -quiet -core "$maxima_image_base.core" -eval '(cl-user::run)' -- "$@"
203 elif [ "$MAXIMA_LISP" = "scl" ]; then
204 if [ "$layout_autotools" = "true" ]; then
205 exec "$MAXIMA_IMAGESDIR/binary-$MAXIMA_LISP/@SCL_RUNTIME@" $MAXIMA_LISP_OPTIONS -quiet -core "$maxima_image_base.core" -eval '(cl-user::run)' -- "$@"
207 exec "@SCL_NAME@" $MAXIMA_LISP_OPTIONS -quiet -core "$maxima_image_base.core" -eval '(cl-user::run)' -- "$@"
209 elif [ "$MAXIMA_LISP" = "gcl" ]; then
210 exec "$maxima_image_base" -eval '(cl-user::run)' $MAXIMA_LISP_OPTIONS -f -- "$@"
211 elif [ "$MAXIMA_LISP" = "acl" ]; then
212 # FIXME: arguments need in a manner consistent with the way they are extracted
213 # in the function get-application-args in command-line.lisp
214 exec "@ACL_NAME@" -I "$maxima_image_base.dxl" $MAXIMA_LISP_OPTIONS -e '(cl-user::run)' -- "$@"
215 elif [ "$MAXIMA_LISP" = "openmcl" ]; then
216 # OPENMCL can use either an executable image or a regular lisp core
217 # file. Check for the executable image and run that if possible.
218 # Otherwise, fallback and use the lisp core file.
219 # FIXME: arguments need in a manner consistent with the way they are extracted
220 # in the function get-application-args in command-line.lisp
221 if [ -x "$MAXIMA_IMAGESDIR/binary-$MAXIMA_LISP/maxima" ]; then
222 exec "$MAXIMA_IMAGESDIR/binary-$MAXIMA_LISP/maxima" $MAXIMA_LISP_OPTIONS -e '(cl-user::run)' -- "$@"
224 exec "@OPENMCL_NAME@" -I "$maxima_image_base.image" $MAXIMA_LISP_OPTIONS -e '(cl-user::run)' -- "$@"
226 elif [ "$MAXIMA_LISP" = "ccl64" ]; then
227 # Ccl64 can use either an executable image or a regular lisp core
228 # file. Check for the executable image and run that if possible.
229 # Otherwise, fallback and use the lisp core file.
230 # FIXME: arguments need in a manner consistent with the way they are extracted
231 # in the function get-application-args in command-line.lisp
232 if [ -x "$MAXIMA_IMAGESDIR/binary-$MAXIMA_LISP/maxima" ]; then
233 exec "$MAXIMA_IMAGESDIR/binary-$MAXIMA_LISP/maxima" $MAXIMA_LISP_OPTIONS -e '(cl-user::run)' -- "$@"
235 exec "@CCL64_NAME@" -I "$maxima_image_base.image" $MAXIMA_LISP_OPTIONS -e '(cl-user::run)' -- "$@"
238 elif [ "$MAXIMA_LISP" = "ecl" ]; then
239 exec "$maxima_image_base" --frame-stack 4096 --lisp-stack 65536 $MAXIMA_LISP_OPTIONS -- "$@"
241 elif [ "$MAXIMA_LISP" = "abcl" ]; then
242 export MAXIMA_LISP_OPTIONS
243 export MAXIMA_IMAGESDIR
244 $MAXIMA_IMAGESDIR/binary-abcl/maxima "$@"
246 elif [ "$MAXIMA_LISP" = "sbcl" ]; then
247 # Use executable image if it exists.
248 # Since compiling lapack already needed >1200 Megabytes of RAM in August of 2015
249 # one has to extend the amount of memory sbcl will be able to claim by using the
250 # switch --dynamic-space-size in order to do so.
251 if [ -x "$MAXIMA_IMAGESDIR/binary-$MAXIMA_LISP/maxima" ]; then
252 exec "$MAXIMA_IMAGESDIR/binary-$MAXIMA_LISP/maxima" --noinform $MAXIMA_LISP_OPTIONS --end-runtime-options --eval '(cl-user::run)' --end-toplevel-options "$@"
254 exec "@SBCL_NAME@" --core "$maxima_image_base.core" --noinform $MAXIMA_LISP_OPTIONS --end-runtime-options --eval '(cl-user::run)' --end-toplevel-options "$@"
258 echo "$0: lisp=\"$MAXIMA_LISP\" not known. Use --list-avail to see possible options." >&2