Crossware

Table of Contents        Previous topic       

PROGRAM MAINTENANCE UTILITY->Inference rules

Inference rules define how a file with on extension can be created from a file with another extension.  They provide a convenient shorthand for commonly used operations.

There are predefined inference rules which are listed later and additional inference rules can be defined in the description file.

MAKE will use an inference rule in the following circumstances:

 when a description block has no commands, MAKE will search for an inference rule that matches the extensions of the target and dependency files.

 when a dependency line does not contain any dependency files, MAKE will search for an inference rule which tells it how to create the missing dependent filename.

 when a description block has no dependency files and no commands (ie only targets are listed), MAKE will use an inference rule to create the target.

The format for an inference rule is:

.<dependent extension>.<target extension> : ;command
 command
 command
 ...

The first period must be at the beginning of the line with no preceding spaces.

The commands are those that which will be run if the target is out-of-date.

A command can optionally be placed after colon but must be preceded by a semi-colon.

An example of an inference rule definition is:

.c.obj :
 cl /c $*.c
This inference rule tells MAKE how to build a .OBJ file from a .C file.  The predefined macro $* expands to the base name of the current target file.

A description block consisting of just:

sample.obj :

is then sufficient for MAKE to be able to create the target sample.obj and it will use the command:

cl /c sample.c

The predefined inference rules are:

RuleCommandDefault command
.c.objcl /c $(CFLAGS) $*.ccl /c $*.c
.c.cl $(CFLAGS) $(LFLAGS) $*.ccl $*.c
.asm.objxasm $(XFLAGS) $*;xasm $*;
.asmxl $(XFLAGS) $(LFLAGS) $*.asmxl $*.asm
.objlink $(LFLAGS) $*;link $*;

where CFLAGS, XFLAGS and LFLAGS are user defined
macros specifying the command line options for the C
compiler, cross assembler and linker respectively.

By default, macros CFLAGS, XFLAGS and LFLAGS are
undefined and the default command column above shows the
inference rules that result in these default cases.