Inference rules are templates from which the Make utility infers what to do with a description block when no commands are given. Only those extensions defined in a .SUFFIXES list can have inference rules. The extensions .c, .obj, .asm and .exe are automatically included in .SUFFIXES.
When the Make utility encounters a description block with no commands, it looks for an inference rule that specifies how to create the target from the dependent files, given the two files' extensions. Similarly, if a dependent file does not exist, the Make utility looks for an inference rule that specifies how to create the dependent file from another file with the same base name.
The Make utility applies an inference rule only if the base name of the file it is trying to create matches the base name of a file that already exists.
In effect, inference rules are useful only when there is a one-to-one correspondence between the files with the "from" extension and the files with the "to" extension. You cannot, for example, define an inference rule that inserts a number of modules into a library.
The use of inference rules eliminates the need to put the same commands in several description blocks. For example, you can use inference rules to specify a single ICC command that changes any C source file (with a .C extension) to an object file (with a .OBJ extension).
.OBJ.EXE: LINK $<; EXAMPLE1.EXE: EXAMPLE1.OBJ EXAMPLE2.EXE: EXAMPLE2.OBJ LINK /CO EXAMPLE2,,,LIBV3.LIB
The first line above defines an inference rule that causes the LINK command to create an executable file whenever a change is made in the corresponding object file. The file name in the inference rule is specified with the special macro $< so that the rule applies to any .OBJ file with an out-of-date executable file.
When the Make utility does not find any commands in the first description block, it checks for a rule that might apply and finds the rule defined on the first two lines of the description file. The Make utility applies the rule, replacing $< with EXAMPLE1.OBJ when it executes the command, so that the LINK command becomes
LINK EXAMPLE1.OBJ
The Make utility does not search for an inference rule when examining the second description block, because a command is explicitly given.
You can specify a path where the Make utility should look for target and dependent files used in inference rules. If no path is specified, and there is no rule in the description file, it looks for inference rules in the TOOLS.INI file.
![]()
Define an
Inference rule
Run the Make
Utility