1 ############################################################
3 # Copyright (C) 1998 William F. Schelter #
4 # For distribution under GNU public License. See COPYING. #
6 # Time-stamp: "2024-03-26 13:42:55 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 tk_messageBox -title Warning
-icon warning
-message \
132 [mc
"Maxima data directory not found in '%s'" \
133 [file native
$maxima_datadir]]
135 set maxima_priv
(maxima_verpkgdatadir
) \
136 [file join $maxima_datadir $autoconf(package) \
140 # omplotdata messages
141 #::msgcat::mcload [file join $maxima_priv(maxima_verpkgdatadir) msgs]
143 if {[info exists maxima_priv
(maxima_verpkglibdir
)]} {
145 } elseif
{ [info exists env
(MAXIMA_VERPKGLIBDIR
)] } {
146 set maxima_priv
(maxima_verpkglibdir
) $env(MAXIMA_VERPKGLIBDIR
)
147 } elseif
{ [info exists env
(MAXIMA_PREFIX
)] } {
148 set maxima_priv
(maxima_verpkglibdir
) \
149 [file join $env(MAXIMA_PREFIX
) lib
$autoconf(package) \
152 set maxima_priv
(maxima_verpkglibdir
) \
153 [file join $autoconf(libdir
) $autoconf(package) \
156 if {[info exists maxima_priv
(maxima_xmaximadir
)]} {
158 } elseif
{ [info exists env
(MAXIMA_XMAXIMADIR
)] } {
159 set maxima_priv
(maxima_xmaximadir
) $env(MAXIMA_XMAXIMADIR
)
161 set maxima_priv
(maxima_xmaximadir
) \
162 [file join $maxima_priv(maxima_verpkgdatadir
) xmaxima
]
166 ::msgcat::mcload [file join $maxima_priv(maxima_xmaximadir
) msgs
]
168 # Define maxima_lang_subdir
169 if { [info exists env
(MAXIMA_LANG_SUBDIR
)] } {
170 set maxima_priv
(maxima_lang_subdir
) $env(MAXIMA_LANG_SUBDIR
)
172 if { $tcl_platform(platform
) == "windows" } {
173 set wlocale
[ ::msgcat::mclocale ]
176 if { [info exists env
(LC_ALL
)] } {
177 set wlocale
$env(LC_ALL
)
178 } elseif
{ [info exists env
(LC_MESSAGES
)] } {
179 set wlocale
$env(LC_MESSAGES
)
180 } elseif
{ [info exists env
(LANG
)] } {
181 set wlocale
$env(LANG
) }
183 # Only languages known to Maxima
184 set wlocale
[string tolower
$wlocale]
185 switch -glob $wlocale {
187 set maxima_priv
(maxima_lang_subdir
) "es.utf8"
190 set maxima_priv
(maxima_lang_subdir
) "es"
193 set maxima_priv
(maxima_lang_subdir
) "pt_BR.utf8"
196 set maxima_priv
(maxima_lang_subdir
) "pt_BR"
199 set maxima_priv
(maxima_lang_subdir
) "pt.utf8"
202 set maxima_priv
(maxima_lang_subdir
) "pt"
205 set maxima_priv
(maxima_lang_subdir
) "de.utf8"
208 set maxima_priv
(maxima_lang_subdir
) "de"
211 set maxima_priv
(maxima_lang_subdir
) "fr.utf8"
214 set maxima_priv
(maxima_lang_subdir
) "fr"
217 set maxima_priv
(maxima_lang_subdir
) "it.utf8"
220 set maxima_priv
(maxima_lang_subdir
) "it"
223 set maxima_priv
(maxima_lang_subdir
) "ru.utf8"
226 set maxima_priv
(maxima_lang_subdir
) "ru.koi8r"
229 set maxima_priv
(maxima_lang_subdir
) "ru"
233 set maxima_priv
(maxima_lang_subdir
) ""
236 #puts $maxima_priv(maxima_lang_subdir)
239 # On Windows ::msgcat::mclocale is a good way to derive locale
240 if { $tcl_platform(platform
) == "windows" } {
241 set env
(LANG
) [ ::msgcat::mclocale ]
244 # Bring derived quantities up here too so we can see the
245 # side effects of setting the above variables
247 # used in Menu.tcl CMMenu.tcl
248 if {[file isdir
[set dir
[file join $maxima_priv(maxima_verpkgdatadir
) info]]]} {
250 set maxima_priv
(pReferenceToc
) \
251 [file join $dir index.html
]
252 } elseif
{[file isdir
[set dir
[file join $maxima_priv(maxima_verpkgdatadir
) doc
]]]} {
254 # first choose the HTML documentation
255 if { $maxima_priv(maxima_lang_subdir
) != "" && \
256 [file exists
[file join $dir html
$maxima_priv(maxima_lang_subdir
) index.html
] ] } {
257 set maxima_priv
(pReferenceToc
) [file join $dir html
$maxima_priv(maxima_lang_subdir
) index.html
]
259 set maxima_priv
(pReferenceToc
) [file join $dir html index.html
]
261 # if the platform is Windows and Maxima is running localized, try the following help files
263 # 1st priority: localized CHM
264 # 2nd priority: localized HTML
265 # 3rd priority: english CHM
266 # 4th priority: english HTML
267 if { $tcl_platform(platform
) == "windows" } {
268 if { $maxima_priv(maxima_lang_subdir
) != "" } {
269 if {[file exists
[file join $dir chm
$maxima_priv(maxima_lang_subdir
) maxima.chm
] ] } {
270 set maxima_priv
(pReferenceToc
) [file join $dir chm
$maxima_priv(maxima_lang_subdir
) maxima.chm
]
272 if {[file exists
[file join $dir html
$maxima_priv(maxima_lang_subdir
) index.html
] ] } {
273 set maxima_priv
(pReferenceToc
) [file join $dir html
$maxima_priv(maxima_lang_subdir
) index.html
]
275 if {[file exists
[file join $dir chm maxima.chm
] ] } {
276 set maxima_priv
(pReferenceToc
) [file join $dir chm maxima.chm
]
278 set maxima_priv
(pReferenceToc
) [file join $dir html index.html
]
283 if {[file exists
[file join $dir chm maxima.chm
] ] } {
284 set maxima_priv
(pReferenceToc
) [file join $dir chm maxima.chm
]
286 set maxima_priv
(pReferenceToc
) [file join $dir html index.html
]
290 # Platform != windows, just choose the HTML documentation
291 if { $maxima_priv(maxima_lang_subdir
) != "" && \
292 [file exists
[file join $dir html
$maxima_priv(maxima_lang_subdir
) index.html
] ] } {
293 set maxima_priv
(pReferenceToc
) [file join $dir html
$maxima_priv(maxima_lang_subdir
) index.html
]
295 set maxima_priv
(pReferenceToc
) [file join $dir html index.html
]
299 tk_messageBox -title Warning
-icon warning
-message \
300 [mc
"Documentation not found in '%s'" \
301 [file native
$maxima_priv(maxima_verpkgdatadir
)]]
304 # used in Menu.tcl CMMenu.tcl
305 if {[file isdir
[set dir
[file join $maxima_priv(maxima_verpkgdatadir
) tests
]]]} {
307 set maxima_priv
(pTestsDir
) $dir
308 } elseif
{[file isdir
[set dir
[file join $maxima_priv(maxima_verpkgdatadir
) doc
]]]} {
310 set maxima_priv
(pTestsDir
) $dir
314 set file [file join $maxima_priv(maxima_xmaximadir
) "intro.html"]
315 if {![file isfile
$file]} {
316 tk_messageBox -title Warning
-icon warning
-message \
317 [mc
"Starting documentation not found in '%s'" [file native
$file]]
318 set maxima_priv
(firstUrl
) ""
320 if {$tcl_platform(platform
) == "windows"} {
322 set file [file dir
$file]/[file tail
$file]
324 # FIXME: This is bogus - need a FileToUrl
325 set maxima_priv
(firstUrl
) file:/$file
327 # set up for autoloading
329 set dir
[file join $maxima_priv(maxima_xmaximadir
) Tkmaxima
]
330 if {[file isdir
$dir]} {
331 lappend auto_path
$dir
333 # jfa: Windows 98 users were seeing long startup times because
334 # MAXIMA_USERDIR defaults to HOME, which is usually C:\.
335 # Make the default something else under Windows 98 as a workaround.
337 if {$tcl_platform(os
) == "Windows 95"} {
338 if {![info exists env
(MAXIMA_USERDIR
)]} {
339 set env
(MAXIMA_USERDIR
) "$maxima_priv(maxima_prefix)/user"
342 # jfa: extend path so that gcl can see gcc in windows package
343 # I don't know that this is the best place for this
344 if {$tcl_platform(platform
) == "windows"} {
345 # jfa: This is an attempt to get a working path designation
346 # on various Windows versions.
347 if {$tcl_platform(os
) == "Windows 95"} {
348 # Windows 95 or Windows 98
349 regsub -all {/} "$maxima_priv(maxima_prefix)\\BIN" {\\} maxbinpath
351 # Other versions of Windows
352 set maxbinpath
"$maxima_priv(maxima_prefix)/bin"
354 set env
(PATH
) "$maxbinpath;$env(PATH)"
358 proc vMAXSetMaximaCommand
{} {
359 global maxima_priv tcl_platform env
361 set maxima_priv
(localMaximaServer
) ""
362 if {[info exists maxima_priv
(xmaxima_maxima
)] && \
363 $maxima_priv(xmaxima_maxima
) != ""} {
364 if {[set exe
[auto_execok $maxima_priv(xmaxima_maxima
)]] == "" } {
366 tk_messageBox -title Error
-icon error -message \
367 [mc
"Maxima executable not found\n%s\n\n Try setting the environment variable XMAXIMA_MAXIMA." \
368 [file native
$maxima_priv(xmaxima_maxima
)]]
371 } elseif
{ [info exists env
(XMAXIMA_MAXIMA
)] } {
372 set maxima_priv
(xmaxima_maxima
) $env(XMAXIMA_MAXIMA
)
373 if {[set exe
[auto_execok $maxima_priv(xmaxima_maxima
)]] == "" } {
374 tk_messageBox -title Error
-icon error -message \
375 [concat [mc
"Maxima executable not found."] "\n%s\nXMAXIMA_MAXIMA=$env(XMAXIMA_MAXIMA)"]
379 set maxima_priv
(xmaxima_maxima
) maxima
380 if {[set exe
[auto_execok $maxima_priv(xmaxima_maxima
)]] == "" } {
381 tk_messageBox -title Error
-icon error -message \
382 [mc
"Maxima executable not found\n\n Try setting the environment variable XMAXIMA_MAXIMA."]
384 # jfa: bypass maxima script on windows
385 # vvz: on Windows 9X/ME only
386 if {$tcl_platform(os
) == "Windows 95"} {
387 # maybe it's in lib - I don't like this
388 set dir
$maxima_priv(maxima_verpkglibdir
)
389 # FIXME - need autoconf(lisp) so we don't need glob
390 set exes
[glob -nocomplain $dir/binary-
*/maxima.exe
]
391 if {[llength $exes] != "1" ||
\
392 [set exe
[lindex $exes 0]] == "" ||
\
393 ![file isfile
$exe]} {
394 tk_messageBox -title Error
-icon error -message \
395 [mc
"Maxima executable not found\n\n Try setting the environment variable XMAXIMA_MAXIMA."]
399 set maxima_priv
(xmaxima_maxima
) maxima
400 if {[set exe
[auto_execok $maxima_priv(xmaxima_maxima
)]] == "" } {
401 tk_messageBox -title Error
-icon error -message \
402 [mc
"Maxima executable not found\n\n Try setting the environment variable XMAXIMA_MAXIMA."]
408 eval lappend command
$maxima_priv(opts
)
409 lappend command
-s PORT
410 if {$tcl_platform(platform
) == "windows"} {
411 lappend command
> NUL
413 lappend command
> /dev
/null
416 set maxima_priv
(localMaximaServer
) $command