next up previous contents index
Next: Additional Libraries Up: Invocation Previous: Building Larger Programs   Contents   Index

Using Makefiles

Taking care of these dependencies is not easy but luckily make(1) is able to do this job for you. The non-trivial task to write down all dependencies of your sources in a form acceptable to make(1) may be carried out by the mmm(1) tool (make makefile for Modula-2) which is part of Ulm's Modula-2 System.

To generate a makefile for the first time, you may invoke simply mmm in the following way:

mmm -c makefile *.d *.m2

This tells mmm to create a makefile named makefile (option -c) which includes all dependencies of the given sources. Now you are free to call just make to get a final binary. Note that mmm supports any number of program modules:

The name of the binaries are by default derived from the name of the associated program module. But you are free to edit the makefile and to change these target names (is described later in 3.1).

Makefiles work fine as long as you remember that each change of the interdependencies requires an update of the makefile. Interdependencies of your modules change whenever you edit one of the FROM- or IMPORT-statements. Updating a makefile is fairly easy, you have just to invoke

mmm -u makefile

Note that the updating mechanism of mmm preserves your changes and additions of the makefile if you respect some easy-to-understand conventions of mmm. It takes all necessary parameters and informations out of the makefile - so you don't need to remember which options or sources you have specified earlier.


next up previous contents index
Next: Additional Libraries Up: Invocation Previous: Building Larger Programs   Contents   Index
Andreas Borchert 2003-12-10