1 ############################################################
3 # Copyright (C) 1998 William F. Schelter #
4 # For distribution under GNU public License. See COPYING. #
6 # Time-stamp: "2021-04-06 13:58:37 villate" #
7 ############################################################
9 # Attach this near the bottom of the xmaxima code to find the paths needed
10 # to start up the interface.
13 global env maxima_priv autoconf tcl_platform
15 if {$tcl_platform(platform
) == "windows"} {
16 # Make sure the signals thread is started
17 set env
(MAXIMA_SIGNALS_THREAD
) "1"
19 # Assume the executable is one level down from the top
20 # for 5.6 this was src/ and for 5.9 its bin/
21 set up
[file dir
[file dir
[info name
]]]
23 if {[info exists autoconf
] && \
24 [info exists autoconf
(prefix
)] && \
25 [info exists autoconf
(exec_prefix
)] && \
26 [info exists autoconf
(libdir
)] && \
27 [info exists autoconf
(libexecdir
)] && \
28 [info exists autoconf
(datadir
)] && \
29 [info exists autoconf
(infodir
)] && \
30 [info exists autoconf
(version
)] && \
31 [info exists autoconf
(package)] && \
32 [file isdir
$autoconf(datadir
)] && \
34 [file join $autoconf(datadir
) \
35 $autoconf(package) $autoconf(version
)]]} {
36 # Assume it's CYGWIN or MSYS in /usr/local
37 } elseif
{[file isdir
$up/lib
] && \
38 [file isdir
$up/bin
] && \
39 [file isdir
$up/libexec
] && \
40 [file isdir
$up/info] && \
41 [file isdir
$up/share
]} {
42 set autoconf
(prefix
) $up
43 set env
(MAXIMA_PREFIX
) $up
44 set autoconf
(exec_prefix
) $up
45 set autoconf
(libdir
) "$up/lib"
46 set autoconf
(libexecdir
) "$up/libexec"
47 set autoconf
(datadir
) "$up/share"
48 set autoconf
(infodir
) "$up/info"
49 # These two should be valid
50 # set autoconf(package) "maxima"
51 # set autoconf(version) "5.9.0rc1"
53 # Old windows 5.5 layout
54 # Assume we are in the same directory as saved_maxima
55 if {[file isfile
[set exe
$up/src
/saved_maxima.exe
]]} {
56 set env
(MAXIMA_DIRECTORY
) $up
57 set maxima_priv
(maxima_verpkgdatadir
) \
58 $env(MAXIMA_DIRECTORY
)
59 set maxima_priv
(xmaxima_maxima
) $exe
60 set maxima_priv
(maxima_xmaximadir
) [file dir
$exe]
62 # This should be unused
63 set maxima_priv
(maxima_verpkglibdir
) \
64 $env(MAXIMA_DIRECTORY
)
65 set maxima_priv
(maxima_verpkgdatadir
) \
66 $env(MAXIMA_DIRECTORY
)
68 # This should be unused
69 set maxima_priv
(maxima_prefix
) \
70 $env(MAXIMA_DIRECTORY
)
74 #mike Could someone document all of these environment variables?
75 # autoconf(prefix) does not seem to me to be the equivalent of
76 # $env(MAXIMA_DIRECTORY) so I don't understand the next statement
78 # jfa: MAXIMA_PREFIX supersedes MAXIMA_DIRECTORY. (Why? Because the
79 # option to configure is --prefix. MAXIMA_PREFIX is thus a runtime
80 # change of --prefix.)
81 # Yes, MAXIMA_DIRECTORY means the same thing. We only include
82 # it for some level of backward compatibility.
83 if { [info exists env
(MAXIMA_DIRECTORY
)] } {
84 set env
(MAXIMA_PREFIX
) $env(MAXIMA_DIRECTORY
)
87 # jfa: This whole routine is a disaster. The general plan for maxima
88 # paths is as follows:
89 # 1) Use the environment variables if they exist.
90 # 2) Otherwise, attempt to use the compile-time settings from
92 # 3) If the entire package has been moved to a prefix other than
93 # that given at compile time, use the location of the (x)maxima
94 # executable to determine the new prefix.
95 # The corresponding path setting procedure in the maxima source can
96 # be found in init-cl.lisp.
98 # The following section should be considered temporary work-around.
99 if { [info exists env
(MAXIMA_VERPKGDATADIR
)] } {
100 set maxima_priv
(maxima_verpkgdatadir
) $env(MAXIMA_VERPKGDATADIR
)
102 # End temporary workaround. It's only a workaround because the next
103 # section is backwards:
105 #mike Is it correct to assume that autoconf exists and is valid
106 # for binary windows distributions? I think it would be better
107 # to make (MAXIMA_DIRECTORY) take precedence, and work off
108 # [info nameofexe] if necessary.
110 if {[info exists maxima_priv
(maxima_prefix
)]} {
112 } elseif
{ [info exists env
(MAXIMA_PREFIX
)] } {
113 set maxima_priv
(maxima_prefix
) $env(MAXIMA_PREFIX
)
115 set maxima_priv
(maxima_prefix
) $autoconf(prefix
)
117 if {[info exists maxima_priv
(maxima_verpkgdatadir
)]} {
120 if { [info exists env
(MAXIMA_DATADIR
)] } {
121 set maxima_datadir
$env(MAXIMA_DATADIR
)
122 } elseif
{ [info exists env
(MAXIMA_PREFIX
)] } {
124 [file join $env(MAXIMA_PREFIX
) share
]
126 set maxima_datadir
$autoconf(datadir
)
128 # maxima_datadir is unused outside of this proc
130 if {![file isdir
$maxima_datadir]} {
131 tide_notify
[M
[mc
"Maxima data directory not found in '%s'"] \
132 [file native
$maxima_datadir]]
134 set maxima_priv
(maxima_verpkgdatadir
) \
135 [file join $maxima_datadir $autoconf(package) \
139 # omplotdata messages
140 #::msgcat::mcload [file join $maxima_priv(maxima_verpkgdatadir) msgs]
142 if {[info exists maxima_priv
(maxima_verpkglibdir
)]} {
144 } elseif
{ [info exists env
(MAXIMA_VERPKGLIBDIR
)] } {
145 set maxima_priv
(maxima_verpkglibdir
) $env(MAXIMA_VERPKGLIBDIR
)
146 } elseif
{ [info exists env
(MAXIMA_PREFIX
)] } {
147 set maxima_priv
(maxima_verpkglibdir
) \
148 [file join $env(MAXIMA_PREFIX
) lib
$autoconf(package) \
151 set maxima_priv
(maxima_verpkglibdir
) \
152 [file join $autoconf(libdir
) $autoconf(package) \
155 if {[info exists maxima_priv
(maxima_xmaximadir
)]} {
157 } elseif
{ [info exists env
(MAXIMA_XMAXIMADIR
)] } {
158 set maxima_priv
(maxima_xmaximadir
) $env(MAXIMA_XMAXIMADIR
)
160 set maxima_priv
(maxima_xmaximadir
) \
161 [file join $maxima_priv(maxima_verpkgdatadir
) xmaxima
]
165 ::msgcat::mcload [file join $maxima_priv(maxima_xmaximadir
) msgs
]
167 # Define maxima_lang_subdir
168 if { [info exists env
(MAXIMA_LANG_SUBDIR
)] } {
169 set maxima_priv
(maxima_lang_subdir
) $env(MAXIMA_LANG_SUBDIR
)
171 if { $tcl_platform(platform
) == "windows" } {
172 set wlocale
[ ::msgcat::mclocale ]
175 if { [info exists env
(LC_ALL
)] } {
176 set wlocale
$env(LC_ALL
)
177 } elseif
{ [info exists env
(LC_MESSAGES
)] } {
178 set wlocale
$env(LC_MESSAGES
)
179 } elseif
{ [info exists env
(LANG
)] } {
180 set wlocale
$env(LANG
) }
182 # Only languages known to Maxima
183 set wlocale
[string tolower
$wlocale]
184 switch -glob $wlocale {
186 set maxima_priv
(maxima_lang_subdir
) "es.utf8"
189 set maxima_priv
(maxima_lang_subdir
) "es"
192 set maxima_priv
(maxima_lang_subdir
) "pt_BR.utf8"
195 set maxima_priv
(maxima_lang_subdir
) "pt_BR"
198 set maxima_priv
(maxima_lang_subdir
) "pt.utf8"
201 set maxima_priv
(maxima_lang_subdir
) "pt"
204 set maxima_priv
(maxima_lang_subdir
) "de.utf8"
207 set maxima_priv
(maxima_lang_subdir
) "de"
210 set maxima_priv
(maxima_lang_subdir
) "fr.utf8"
213 set maxima_priv
(maxima_lang_subdir
) "fr"
216 set maxima_priv
(maxima_lang_subdir
) "it.utf8"
219 set maxima_priv
(maxima_lang_subdir
) "it"
222 set maxima_priv
(maxima_lang_subdir
) "ru.utf8"
225 set maxima_priv
(maxima_lang_subdir
) "ru.koi8r"
228 set maxima_priv
(maxima_lang_subdir
) "ru"
232 set maxima_priv
(maxima_lang_subdir
) ""
235 #puts $maxima_priv(maxima_lang_subdir)
238 # On Windows ::msgcat::mclocale is a good way to derive locale
239 if { $tcl_platform(platform
) == "windows" } {
240 set env
(LANG
) [ ::msgcat::mclocale ]
243 # Bring derived quantities up here too so we can see the
244 # side effects of setting the above variables
246 # used in Menu.tcl CMMenu.tcl
247 if {[file isdir
[set dir
[file join $maxima_priv(maxima_verpkgdatadir
) info]]]} {
249 set maxima_priv
(pReferenceToc
) \
250 [file join $dir maxima_toc.html
]
251 } elseif
{[file isdir
[set dir
[file join $maxima_priv(maxima_verpkgdatadir
) doc
]]]} {
253 # first choose the HTML documentation
254 if { $maxima_priv(maxima_lang_subdir
) != "" && \
255 [file exists
[file join $dir html
$maxima_priv(maxima_lang_subdir
) maxima_toc.html
] ] } {
256 set maxima_priv
(pReferenceToc
) [file join $dir html
$maxima_priv(maxima_lang_subdir
) maxima_toc.html
]
258 set maxima_priv
(pReferenceToc
) [file join $dir html maxima_toc.html
]
260 # if the platform is Windows and Maxima is running localized, try the following help files
262 # 1st priority: localized CHM
263 # 2nd priority: localized HTML
264 # 3rd priority: english CHM
265 # 4th priority: english HTML
266 if { $tcl_platform(platform
) == "windows" } {
267 if { $maxima_priv(maxima_lang_subdir
) != "" } {
268 if {[file exists
[file join $dir chm
$maxima_priv(maxima_lang_subdir
) maxima.chm
] ] } {
269 set maxima_priv
(pReferenceToc
) [file join $dir chm
$maxima_priv(maxima_lang_subdir
) maxima.chm
]
271 if {[file exists
[file join $dir html
$maxima_priv(maxima_lang_subdir
) maxima_toc.html
] ] } {
272 set maxima_priv
(pReferenceToc
) [file join $dir html
$maxima_priv(maxima_lang_subdir
) maxima_toc.html
]
274 if {[file exists
[file join $dir chm maxima.chm
] ] } {
275 set maxima_priv
(pReferenceToc
) [file join $dir chm maxima.chm
]
277 set maxima_priv
(pReferenceToc
) [file join $dir html maxima_toc.html
]
282 if {[file exists
[file join $dir chm maxima.chm
] ] } {
283 set maxima_priv
(pReferenceToc
) [file join $dir chm maxima.chm
]
285 set maxima_priv
(pReferenceToc
) [file join $dir html maxima_toc.html
]
289 # Platform != windows, just choose the HTML documentation
290 if { $maxima_priv(maxima_lang_subdir
) != "" && \
291 [file exists
[file join $dir html
$maxima_priv(maxima_lang_subdir
) maxima_toc.html
] ] } {
292 set maxima_priv
(pReferenceToc
) [file join $dir html
$maxima_priv(maxima_lang_subdir
) maxima_toc.html
]
294 set maxima_priv
(pReferenceToc
) [file join $dir html maxima_toc.html
]
298 tide_notify
[M
[mc
"Documentation not found in '%s'"] \
299 [file native
$maxima_priv(maxima_verpkgdatadir
)]]
302 # used in Menu.tcl CMMenu.tcl
303 if {[file isdir
[set dir
[file join $maxima_priv(maxima_verpkgdatadir
) tests
]]]} {
305 set maxima_priv
(pTestsDir
) $dir
306 } elseif
{[file isdir
[set dir
[file join $maxima_priv(maxima_verpkgdatadir
) doc
]]]} {
308 set maxima_priv
(pTestsDir
) $dir
312 set file [file join $maxima_priv(maxima_xmaximadir
) "intro.html"]
313 if {![file isfile
$file]} {
314 tide_notify
[M
[mc
"Starting documentation not found in '%s'"] \
316 set maxima_priv
(firstUrl
) ""
318 if {$tcl_platform(platform
) == "windows"} {
320 set file [file dir
$file]/[file tail
$file]
322 # FIXME: This is bogus - need a FileToUrl
323 set maxima_priv
(firstUrl
) file:/$file
325 # set up for autoloading
327 set dir
[file join $maxima_priv(maxima_xmaximadir
) Tkmaxima
]
328 if {[file isdir
$dir]} {
329 lappend auto_path
$dir
331 # jfa: Windows 98 users were seeing long startup times because
332 # MAXIMA_USERDIR defaults to HOME, which is usually C:\.
333 # Make the default something else under Windows 98 as a workaround.
335 if {$tcl_platform(os
) == "Windows 95"} {
336 if {![info exists env
(MAXIMA_USERDIR
)]} {
337 set env
(MAXIMA_USERDIR
) "$maxima_priv(maxima_prefix)/user"
340 # jfa: extend path so that gcl can see gcc in windows package
341 # I don't know that this is the best place for this
342 if {$tcl_platform(platform
) == "windows"} {
343 # jfa: This is an attempt to get a working path designation
344 # on various Windows versions.
345 if {$tcl_platform(os
) == "Windows 95"} {
346 # Windows 95 or Windows 98
347 regsub -all {/} "$maxima_priv(maxima_prefix)\\BIN" {\\} maxbinpath
349 # Other versions of Windows
350 set maxbinpath
"$maxima_priv(maxima_prefix)/bin"
352 set env
(PATH
) "$maxbinpath;$env(PATH)"
356 proc vMAXSetMaximaCommand
{} {
357 global maxima_priv tcl_platform env
359 set maxima_priv
(localMaximaServer
) ""
360 if {[info exists maxima_priv
(xmaxima_maxima
)] && \
361 $maxima_priv(xmaxima_maxima
) != ""} {
362 if {[set exe
[auto_execok $maxima_priv(xmaxima_maxima
)]] == "" } {
364 tide_failure
[M
[mc
"Error: Maxima executable not found\n%s\n\n Try setting the environment variable XMAXIMA_MAXIMA."] \
365 [file native
$maxima_priv(xmaxima_maxima
)]]
368 } elseif
{ [info exists env
(XMAXIMA_MAXIMA
)] } {
369 set maxima_priv
(xmaxima_maxima
) $env(XMAXIMA_MAXIMA
)
370 if {[set exe
[auto_execok $maxima_priv(xmaxima_maxima
)]] == "" } {
371 tide_failure
[M
[concat [mc
"Error2: maxima executable not found."] "\n%s\nXMAXIMA_MAXIMA=$env(XMAXIMA_MAXIMA)"]]
375 set maxima_priv
(xmaxima_maxima
) maxima
376 if {[set exe
[auto_execok $maxima_priv(xmaxima_maxima
)]] == "" } {
377 tide_failure
[M
[mc
"Error: Maxima executable not found\n\n Try setting the environment variable XMAXIMA_MAXIMA."]]
379 # jfa: bypass maxima script on windows
380 # vvz: on Windows 9X/ME only
381 if {$tcl_platform(os
) == "Windows 95"} {
382 # maybe it's in lib - I don't like this
383 set dir
$maxima_priv(maxima_verpkglibdir
)
384 # FIXME - need autoconf(lisp) so we don't need glob
385 set exes
[glob -nocomplain $dir/binary-
*/maxima.exe
]
386 if {[llength $exes] != "1" ||
\
387 [set exe
[lindex $exes 0]] == "" ||
\
388 ![file isfile
$exe]} {
389 tide_failure
[M
[mc
"Error: Maxima executable not found\n\n Try setting the environment variable XMAXIMA_MAXIMA."]]
393 set maxima_priv
(xmaxima_maxima
) maxima
394 if {[set exe
[auto_execok $maxima_priv(xmaxima_maxima
)]] == "" } {
395 tide_failure
[M
[mc
"Error: Maxima executable not found\n\n Try setting the environment variable XMAXIMA_MAXIMA."]]
401 eval lappend command
$maxima_priv(opts
)
402 lappend command
-s PORT
403 if {$tcl_platform(platform
) == "windows"} {
404 lappend command
> NUL
406 lappend command
> /dev
/null
409 set maxima_priv
(localMaximaServer
) $command