Here we describe how you can compile a simple program using "cm3".
What if I you wanted to use the command line interface? Here we describe how to build a simple program that we presented earlier in Writing Programs. First, you need to create a package directory for this program. Let's say you create a directory ~/proj/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. (You don't have to create an "src" directory, but most Modula-3 packages do so as a convention.)
So you should have the following two files in the given directories:
While in ~/proj/simple directory, issue the "cm3
" command
to build your program. If your m3makefile
is correctly formatted and the
Main.m3
is correct, the compiler will create a build directory ~/proj/simple/TARGET (where
TARGET is the name of your platform, e.g., SPARC
or NT386) and place in it the executable file myprog.
To execute the program, enter the command SPARC/myprog at the
command prompt.
For very simple program such as this one, you could have easily created an Main.m3 file, and just typed:
$ cm3 Main.m3
at the command line, even without an m3makefile.
For large programs, however, you will find that the structuring tools available with Modula-3 will help you easily create very sophisticated multi-platform programs.