If MODULEPATH or LOADEDMODULES is already set, do not source the
modulerc configuration file in init scripts.
As a consequence, if .modulespath sets a module path, then modulerc will
be ignored which clarifies how default configuration is loaded: if both
.modulespath and modulerc are defined, .modulespath takes precedence
over modulerc.
So if .modulespath sets a module path, all loaded modules defined in the
modulerc file will be ignored.
Introduce an 'install' target in makefiles to provide an installation
process for modules-tcl.
Defines installation paths with Makefile variables in order to avoid
having a ./configure step. Install paths are set during the 'make' step
by passing 'prefix', 'libexecdir', 'mandir', etc arguments to the make
command. If no path definitions are passed to the 'make' command,
installation will be made in '/usr/local/modules-tcl' by default.
Installation paths provided (or set from the default value found in
Makefile) are saved at the 'make' step in a .makeinstallpath file. Then
at the 'make install' step, this .makeinstallpath file is read and make
knows where to install modules-tcl.
These paths definitions are also used to translate *.in init script to
their installed version.
modulecmd.tcl script is by default set to be installed in the libexec
directory to follow FHS specification (as this script is an executable
but not directly accessed by users).
Initialize MODULEPATH variable if not defined, with an empty string or
with the content of the init/.modulespath file if it exists and it is
readable. This file contains a list of module paths, one per line or
many per line separated by colon character.
This way of initializing MODULEPATH has been retrieved from C version
init scripts in order for sysadmins to keep a familiar concept to set
default MODULEPATH.
As for MODULESHOME, get 'tclsh' location from Makefile then replace
'@TCLSH@' pattern in shell init scripts with found location rather than
guessing it in the init scripts.
By doing so, same 'tclsh' location search is applied to all init
scripts. Search is performed with 'command' to look at a predefined list
of PATHs in order to be resilient to the current PATH content.
Simplify guess of MODULESHOME location by more relying on 'make'
capabilities than 'perl'.
Adapt init scripts for the different shells to use the MODULESHOME
variable that is replaced during the 'make' process rather than
${MODULESHOME}, $env(MODULESHOME), etc.
By the way, use a replacement pattern closer to what 'configure' is using
with '@MODULESHOME@' rather than '$MODULESHOME' which was confusing in
shell scripts.
Python code used to define the module command (autoinit action) was
broken (syntax errors) and not Python3-compatible. Error rendering is
also fixed here for Python3 compliance. Code used to process x-resource
is adapted to comply with Python recommendation [1] (subprocess.Popen
should be used instead of os.popen).
Python init script is also modified by this commit to use same code as
the one generated by autoinit action with call to subprocess.Popen
rather than os.popen.
[1] https://docs.python.org/2/library/os.html#os.popen