The GNU Modula-2 front end to GCC

GNU Modula-2 related environment variables

This section descibes the environment variables used by GNU Modula-2 and how they can be used to switch between releases of the compiler. Other environment variables can be set to modify the default library path. Initially we will consider environment variables most likely used by the end user. These two environment variables are GM2IPATH and GM2OPATH.

For example suppose a compile and link on the command line looks like this:

$ gm2 -g -c -I. -I../project -I../project/unix foo.mod
$ gm2 -fonlylink -g -I. -I../project -I../project/unix \
  -fobject-path=../project/obj -Iobject-path=../project/unix/obj -I. foo.mod

they can be simplified by utilising two environment variables to do exactly the same compile and link.

$ export GM2IPATH=../project:../project/unix
$ export GM2OPATH=../project/obj:../project/unix/obj
$ gm2 -g -I. foo.mod

It is important to note that the two environment variables GM2IPATH and GM2OPATH have a lower priority than any -I or -fobject-path= command line option. The search order for compiling and linking is: command line switches followed by environment variable paths followed by default runtime libraries or Modula-2 dialect libraries. If in doubt include the -v option to see the search path used between the compiler subcomponents.

Lastly there is the GM2_ROOT environment variable which determines where the compiler subcomponents reside in the filesystem. This environment variable overrides the compiler time configure option --prefix=. For example suppose the compiler was built to reside in /usr/local and the system administrator decided to move the entire compiler tree to /architecture/i386/usr. Once the tree is moved then a system wide environment variable (GM2_ROOT) could be set to:

$ export GM2_ROOT=/architecture/i386/usr

The system administrator needs to ensure that the front end binary gm2 can be seen by the users path. At that point a user can invoke gm2 -g -c -I. hello.mod from the command line and all subcomponents will be picked up from /architecture/i386/usr. This allows users to try out different GNU Modula-2 releases and also allows system administrators to install compiler binaries at different locations to where they were initially configured to reside.

The environment variable GM2_ROOT has no effect if either the LIBRARY_PATH or COMPILE_PATH is set. The last two environment variables are used by gcc. However if by mistake GM2_ROOT and either LIBRARY_PATH or COMPILE_PATH is set then an error message is issued.