Let's take the simple program example presented earlier see section Writing Programs. First, you need to create a package directory for this program. Let's say you create a directory ~/m3/simple for this purpose. Then you need to create a subdirectory called 'src' in that directory to hold the m3makefile and source code file main.m3. So you should have the following two files in the given directories:
Finally, cd ~/m3/simple
and enter the m3build
command. If
your m3makefile is correctly formatted and the main.m3 is correct, the compiler
will create a build directory ~/m3/simple/SPARC (or whatever your platform is)
and place in it the executable file myprog
. So to execute, enter the
command SPARC/myprog
at the command prompt.
If this seems like a lot of work for a simple program, it is. That's why it's convenient to keep a test directory and m3makefile in place to test small programs. At any rate, Modula-3 is designed to manage large programs, composed of several packages, and this system works well for that purpose.