Because all versions of Maple for linux share a common user initialization file, ~/.mapleinit
, this file must provide a means to branch if specific customization is desired for different versions of Maple. I've come up with a flexible, if slightly complicated, scheme for handling this.
System Initialization File
I modify the system initialization file, $maple-release/lib/init
for each installed version of maple to assign a global record variable that defines the release. This could be avoided by stripping information from a call to kernelopts(version)
, however, it isn't clear to me that its format is fixed (i.e won't change with the next release). For Maple 10 my init file is
# /usr/local/share/maple/r10/lib/init
#
# System initialization file for Maple.
# Written by Joe Riel.
#
# Assign the global record variable MapleInfo.
# The Release export is used by ~/.mapleinit
# to select the proper intialization file.
unprotect('MapleInfo'):
MapleInfo := module ()
export Release;
option record;
description "record describing this Maple; used by .mapleinit";
Release := "10";
end module:
protect('MapleInfo'):
# Local Variables:
# mode: maplev
# End:
User Initialization File
The user initialization file, ~/.mapleinit
, has a single module that loads the initialization file appropriate for the release. This didn't have to be done in a module, however, doing so allows using local variables that don't effect the global name space.
# ~/.mapleinit
#
# User initialization file for Maple.
#
#
# Read the appropriate initialization file,
# depending on the major release of Maple.
# If, for example, the major release is 9
# then the Maple file $HOME/etc/maple/maple9.mpl is read.
#
# This depends on the Maple system initialization file
# ($Maple/lib/init) assigning the global procedure MajorRelease.
module ()
local initfile;
description "read the initialization file appropriate to the release";
try
initfile := cat(NULL
,getenv("HOME")
,"/etc/maple/maple"
,MapleInfo:-Release
,".mpl");
read initfile;
catch "MapleInfo does not evaluate to a module":
error ("the system-wide initialization file %1/init "
"was not modified to assign the global record variable MapleInfo. "
"Consequently, the release dependent user initialization file "
"in ~/etc/maple was not read.\n See your system administrator about this."
,kernelopts('mapledir'))
catch "unable to read":
error "cannot read initialization file %1", initfile
end try;
end module:
# Local Variables:
# mode: maplev
# End:
Release Dependent Initialization Files
I put my user-specific release-dependent initialization files in ~/etc/maple. They are named maple9.mpl, maple9.5.mpl, and maple10.mpl (maple9.5.mpl is a symbolic link to maple9.mpl). I also have a common initialization file, maple-common.mpl, that is loaded by each of the other files. A typical release dependent initialization file consists of a single module that assigns whatever is desired, mainly setting up libname
.
# ~/etc/maple/maple10.mpl
#
# Custom user initialization file for Maple 10.
module()
local home,syruplib;
global mylib,testlib,helplib,libname,patchlib;
if not IsWorksheetInterface() then plotsetup(x11) end if;
home := getenv("HOME");
mylib := cat(home,"/maple/lib");
helplib := cat(home,"/maple/helplib");
testlib := cat(home,"/maple/testlib");
syruplib := cat(home,"/maple/syrup/lib");
libname := (testlib,mylib
,`if`(IsWorksheetInterface('Standard'),helplib,NULL)
,patchlib,libname,syruplib);
read cat(getenv("HOME"),"/etc/maple/maple-common.mpl")
end module: