Fix typo in display-html-help
[maxima.git] / src / maxima.bat.in
blobef34ca6e7d3969bc3ccbf923716b9f132e597cdd
1 @echo off
3 rem begin localisation of Environment Variables
4 setlocal enableextensions
7 rem Uncomment the line below and set required value to MAXIMA_LANG_SUBDIR
8 rem to get localized describe in command line Maxima
9 rem set MAXIMA_LANG_SUBDIR=es
11 rem The variable LANGUAGE is usually not set on Windows, but if Maxima is running in
12 rem Wine/Linux (e.g. for testing purposes) it is inherited from the Linux environment
13 rem and causes troubles (at least with Clisp, maybe other Lisps too),
14 rem so unset this variable.
15 set LANGUAGE=
17 set "lisp=@DEFAULTLISP@"
18 set lisp_options=
19 set "version=@VERSION@"
21 title Maxima Open Source Computer Algebra System %version%
23 rem Where is Maxima installed? Set %prefix% to exactly that directory.
24 rem The path is determined by the path of the executed maxima.bat - using the special variable: %~dp0
25 rem The following command removes the filename and the last path component (bin/maxima.bat),
26 FOR %%A IN ("%~dp0.") DO SET "prefix=%%~dpA"
27 rem remove trailing "\":
28 if "%prefix:~-1%"=="\" set "prefix=%prefix:~0,-1%"
30 rem change "\" to "/" in that path. Works too and causes less troubles (e.g. with xmaxima).
31 set "prefix=%prefix:\=/%"
32 set "maxima_prefix=%prefix%"
33 set "package=@PACKAGE@"
34 set verbose=false
35 set "path=%maxima_prefix%/gnuplot;%maxima_prefix%/gnuplot/bin;%maxima_prefix%/bin;%maxima_prefix%/vtk;%path%"
37 rem set userdir and tempdir - replace "\" with "/"
38 if not defined MAXIMA_USERDIR set "MAXIMA_USERDIR=%USERPROFILE:\=/%/maxima"
39 if not defined MAXIMA_TEMPDIR set "MAXIMA_TEMPDIR=%TEMP:\=/%"
40 rem there were reports, that the tempdir could not be found (maybe because of special characters, ut8-chars, ...)
41 rem so set a fallback (as it was before)
42 if not exist "%MAXIMA_TEMPDIR%"/ set "MAXIMA_TEMPDIR=%USERPROFILE:\=/%"
44 rem change 'short names' (e.g. "C:/Users/TESTTE~1/AppData/Local/Temp" to
45 rem long names (e.g. "C:/Users/test test/AppData/Local/Temp" -
46 rem CLISP has a problem with these short names.
47 rem Do this only if maxima_longnames.exe exists in the Maxima binary dir.
48 rem (it is not compiled and installed for example when a Lisp-only build is done).
49 if exist "%maxima_prefix%/bin/maxima_longnames.exe" for /F "tokens=* USEBACKQ" %%F in (`maxima_longnames.exe "%MAXIMA_TEMPDIR%"`) do set "MAXIMA_TEMPDIR=%%F"
52 rem read maximarc and set the Lisp type, if the user did specify MAXIMA_LISP
53 rem currently no comments or other (Unix shell) commands are understood, only (e.g):
54 rem LISP=sbcl
55 if EXIST "%MAXIMA_USERDIR%/maximarc" (
56 setlocal enabledelayedexpansion
57 for /F usebackq %%L in ("%MAXIMA_USERDIR%/maximarc") do (
58 set %%L
59 set lisp=!MAXIMA_LISP!
63 rem In order to allow maxima to find out where its files are on MS Windows maxima needs
64 rem to be started in the directory it can be found in. Which in the case of
65 rem maxima-portable might be a different folder every time.
66 rem The user, though, might want it to start in the folder the worksheet lies in, as
67 rem read_matrix, write_data etc. should be relative to that folder.
68 rem common lisp doesn't provide such a function and clisp has problems with shortnames
69 rem while sbcl has problems with non-ascii-non-unicode folder names.
70 rem The variable MAXIMA_INITIAL_FOLDER tells which folder to start maxima in
71 rem after searching for the files it is composed of.
72 if defined MAXIMA_INITIAL_FOLDER cd "%MAXIMA_INITIAL_FOLDER%"
74 :startparseargs
75 if x%1 == x-l goto foundlisp
76 if x%1 == x--lisp goto foundlisp
77 if x%1 == x-u goto foundversion
78 if x%1 == x--use-version goto foundversion
79 if x%1 == x-v goto foundverbose
80 if x%1 == x--verbose goto foundverbose
81 if x%1 == x--lisp-options goto foundlispoptions
82 if x%1 == x--userdir goto founduserdir
83 if x%1 == x-X goto foundlispoptions
85 :continueparseargs
86 shift
87 if not x%1 == x goto startparseargs
88 goto endparseargs
91 :foundlispoptions
92 set lisp_options=%~2
93 shift
94 goto continueparseargs
96 :founduserdir
97 set "MAXIMA_USERDIR=%~2"
98 shift
99 goto continueparseargs
101 :foundlisp
102 set lisp=%2
103 shift
104 goto continueparseargs
106 :foundversion
107 set version=%2
108 shift
109 goto continueparseargs
111 :foundverbose
112 set verbose=true
113 goto continueparseargs
115 :endparseargs
117 if "%MAXIMA_LAYOUT_AUTOTOOLS%" == "" goto defaultlayout
118 set layout_autotools=true
119 goto endlayout
121 :defaultlayout
122 set layout_autotools=@default_layout_autotools@
124 :endlayout
126 if "%MAXIMA_PREFIX%" == "" goto defaultvars
127 if "%layout_autotools%" == "true" goto maxim_autotools
128 set "maxima_imagesdir=%MAXIMA_PREFIX%/src"
129 goto endsetupvars
131 :maxim_autotools
132 set "maxima_imagesdir=%MAXIMA_PREFIX%/lib/%package%/%version%"
133 goto endsetupvars
135 :defaultvars
136 if "%layout_autotools%" == "true" goto defmaxim_autotools
137 set "maxima_imagesdir=%prefix%/src"
138 goto endsetupvars
140 :defmaxim_autotools
141 set "maxima_imagesdir=%prefix%/lib/%package%/%version%"
142 goto endsetupvars
144 :endsetupvars
146 set "maxima_image_base=%maxima_imagesdir%/binary-%lisp%/maxima"
148 if "%verbose%" == "true" @echo on
149 if "%lisp%" == "gcl" goto dogcl
150 if "%lisp%" == "clisp" goto doclisp
151 if "%lisp%" == "ecl" goto doecl
152 rem Allow ccl as an alias of openmcl
153 if "%lisp%" == "ccl" set lisp=openmcl
154 if "%lisp%" == "openmcl" goto doopenmcl
155 if "%lisp%" == "ccl64" goto doccl64
156 if "%lisp%" == "sbcl" goto dosbcl
157 if "%lisp%" == "abcl" goto doabcl
159 @echo Maxima error: Lisp %lisp% not known.
160 goto :EOF
162 :dogcl
163 set "path=%maxima_prefix%/lib/gcc-lib/mingw32/@GCCVER@;%path"
164 "%maxima_image_base%.exe" -eval "(cl-user::run)" %lisp_options% -f -- %*
165 goto :EOF
167 :doclisp
168 if exist "%maxima_image_base%.exe" goto doclisp_exec
170 if "%layout_autotools%" == "true" goto clisp_autotools
171 @CLISP_NAME@ %lisp_options% -q -M "%maxima_image_base%.mem" "" -- %*
172 goto :EOF
174 :clisp_autotools
175 rem ./configure sets a variable @CLISP_NAME@ which might be used instead of lisp.exe,
176 rem but when Maxima is crosscompiled on Linux, a shell script is used as 'crosscompiler',
177 rem which would be inserted here ==> do not use the variable @CLISP_NAME@ but just lisp.exe.
178 set "path=%maxima_imagesdir%/binary-%lisp%;%maxima_prefix%/clisp-2.49/base;%path%"
179 rem set codepage to unicode
180 chcp 65001 >nul
181 lisp.exe %lisp_options% -q -M "%maxima_image_base%.mem" "" -- %*
182 goto :EOF
184 :clisp_exec
185 "%maxima_image_base%.exe" %lisp_options% -q "" -- %*
186 goto :EOF
188 :doecl
189 @ECL_NAME@ -load %maxima_image_base%.fas %lisp_options% -eval "(user::run)" -- %*
190 goto :EOF
192 rem SBCL Steel Bank Common Lisp
193 :dosbcl
194 rem run executable image if it exists
195 if exist "%maxima_image_base%.exe" goto dosbcl_exec
196 if "%MAXIMA_SIGNALS_THREAD%" == "" (
197 set start_maxima="(cl-user::run)"
198 ) else (
199 set start_maxima="(progn (load (maxima::$sconcat (namestring (pathname (maxima::maxima-getenv \"MAXIMA_PREFIX\"))) \"/bin/win_signals.lisp\")) (cl-user::run))"
202 rem At least in the crosscompiled installer, SBCL_HOME is not defined - set it here
203 if not defined SBCL_HOME if exist "%maxima_prefix%/bin/sbcl.exe" set "SBCL_HOME=%~dp0"
205 rem Only on 64bit: if using sbcl (and the user does not specify anything else(!))
206 rem set the dynamic-space-size to 2GB so that load("lapack") will work.
207 rem The check for a 64 bit build is done by checking the name of the Mingw libgcc name
208 rem (which is libgcc_s_seh-1.dll for 64 and libgcc_s_sjlj-1.dll for 32 bit)
209 if exist "%maxima_prefix%/bin/libgcc_s_seh-1.dll" (
210 if "%lisp_options%"=="" set lisp_options=--dynamic-space-size^ 2000
211 ) else (
212 rem I am a 32 bit build - the SBCL workaround for load(lapack) will not work
215 rem ./configure sets a variable @SBCL_NAME@ which might be used instead of sbcl.exe,
216 rem but when Maxima is crosscompiled on Linux, a shell script is used as 'crosscompiler',
217 rem which would be inserted here ==> do not use the variable @SBCL_NAME@ but just sbcl.exe.
218 sbcl.exe --core "%maxima_image_base%.core" --noinform %lisp_options% --end-runtime-options --eval %start_maxima% --end-toplevel-options %*
219 goto :EOF
221 :dosbcl_exec
222 "%maxima_image_base%.exe" %lisp_options% --noinform --end-runtime-options --eval "(cl-user::run)" --end-toplevel-options %*
223 goto :EOF
225 :doopenmcl
226 if "%MAXIMA_SIGNALS_THREAD%" == "" (
227 set start_maxima="(cl-user::run)"
228 ) else (
229 set start_maxima="(progn (load (maxima::$sconcat (namestring (pathname (maxima::maxima-getenv \"MAXIMA_PREFIX\"))) \"/bin/win_signals.lisp\")) (cl-user::run))"
231 @OPENMCL_NAME@ -I "%maxima_image_base%" %lisp_options% -e %start_maxima% -- %*
232 goto :EOF
234 :doccl64
235 if "%MAXIMA_SIGNALS_THREAD%" == "" (
236 set start_maxima="(cl-user::run)"
237 ) else (
238 set start_maxima="(progn (load (maxima::$sconcat (namestring (pathname (maxima::maxima-getenv \"MAXIMA_PREFIX\"))) \"/bin/win_signals.lisp\")) (cl-user::run))"
240 rem set codepage to unicode
241 chcp 65001 >nul
242 wx86cl64.exe -I "%maxima_image_base%.image" %lisp_options% -e %start_maxima% -- %*
243 goto :EOF
246 :doabcl
247 set "MAXIMA_IMAGESDIR_BIN=%maxima_imagesdir%/binary-%lisp%"
249 java -jar "%MAXIMA_IMAGESDIR_BIN%/abcl.jar" %lisp_options% --eval "(load \"%MAXIMA_IMAGESDIR_BIN%/defsystem.lisp\")" --eval "(mk:add-registry-location \"%MAXIMA_IMAGESDIR_BIN%\")" --eval "(funcall (intern (symbol-name :operate-on-system) :mk) \"maxima\" :load :verbose nil)" --eval "(cl-user::run)" -- %*