next up previous contents index
Next: Customizing makefiles Up: The Makefile Generator Previous: Introduction   Contents   Index


Layout of Makefiles generated by mmm

Each makefile generated by mmm has some sections which are subject to updates of mmm and other sections which are never touched by mmm. All sections which are of significance to mmm start with a comment, followed by a keyword and sometimes parameter enclosed in braces, and extend up to the next comment (which may be the beginning of another section of mmm).

Following sections of mmm may be present in a makefile:



created or updated This section consists of the comment line only and contains (as parameter) the last time when mmm touched this makefile.
flags All flags which are valid on the command line may be given here and work as default. The last effective flag settings are always stored here and work as default on later updates. Unlike as on the command line, however, flags are specified here with a leading dash, followed by the name of the flag (always one character), and the absolute value of the flag (either + or -). This section consists of the comment line only.
rules This section contains all makefile rules which are necessary to compile Modula-2 sources.
macros Mmm defines some standard macros for the set of sources seen and the various sets of files to be generated. This may be useful for own makefile extensions.
precious This section contains the special target .PRECIOUS which depends on all targets which should not be deleted accidently by make in case of failures.
all The target all and the names of all to be generated executables are defined in this section.
linkage This section contains all macros and dependencies which are necessary to build all executables.
dependencies All dependencies which are of relevance for the Modula-2 compiler are included here.


Suppose, for example, you have a library module named Lib with source files Lib.d and Lib.m2, and a program module in the file Main.m2, then a makefile generated by

   modula$ mmm -c makefile Main.m2 Lib.d Lib.m2

may look as following:

# {updated by mmm: Tue Nov 05 16:42:22 1996 GMT}
# {flags: -a- -e- -l- -L- -m- -1- -v-}
# {rules}
.SUFFIXES:
.SUFFIXES:      .o .sy .m2 .d
MFLAGS =        
M2C =           m2c
.m2.o:
                $(M2C) -c $(MFLAGS) $*.m2
.d.sy:
                $(M2C) $(MFLAGS) $*.d
# {macros}
SRC =           Lib.d Lib.m2 Main.m2
TAGSRC =        Lib.m2 Main.m2
OBJS =          Lib.o Main.o
SYMS =          Lib.sy
REFS =          Lib.r Main.r
# {precious}
# {all}
T =             Main
all:            $T
# {linkage}
LIBS =          
LDFLAGS =       
$T:             Lib.o Main.o
                $(M2C) $(MFLAGS) -o $@ $(LDFLAGS) Lib.o Main.o $(LIBS)
# {dependencies}
Lib.sy:         
Lib.o:          Lib.sy
Main.o:         Lib.sy
#
tags:           $(TAGSRC)
                mtags $(TAGSRC)
#
clean:          ; rm -f $(OBJS) $(SYMS) $(REFS)

Don't be surprised that this newly created makefile is already marked as updated. By default, mmm takes a prototype (which may be located in your home directory or in the library directory of the Modula-2 compiler) and updates this. Only, if -C is given instead of -c or if mmm is unable to find a prototype, mmm creates a makefile from scratch. The prototype for the example above looked as following:

# {created by mmm: Fri Mar 25 17:30:30 1988 MEZ}
# {flags: -a- -e- -l- -L- -m- -1- -v-}
# {rules}
# {macros}
# {precious}
# {all}
# {linkage}
# {dependencies}
#
tags:           $(TAGSRC)
                mtags $(TAGSRC)
#
clean:          ; rm -f $(OBJS) $(SYMS) $(REFS)

Usually, prototypes for mmm contain all sections and some additional targets and rules for convenience.


next up previous contents index
Next: Customizing makefiles Up: The Makefile Generator Previous: Introduction   Contents   Index
Andreas Borchert 2003-12-10