Inference rules can be combined with specified target/dependency paths for each rule. Given the inference rule below, if a dependent file with the given extension is found in the dep_path directory during inference rule processing, then the target will be updated in the specified target_path directory. These paths are specified in the inference rules inside curly braces. Only single paths are supported inside curly braces on inference rules. However, multiple inference rules using the same extensions and different paths can be specified. The first matching inference rule is the rule that is used if multiple inference rules are specified in the description file.

{dep_path}.extension1{target_path}.extension2:
    command block

Example:

# Build objects in the p2 directory from source
# in the p1 directory

{p1}.c{p2}.obj:
    icc /c /Fo$@  $<

p2\file.obj: p1\file.c

When using paths or target/dependency statements and curly brace paths on inference rules, all paths must be carefully matched. When a target/dependency statement dependent path does not match the curly brace path on the inference dependent extension, it is deemed a mismatch. The following example combines inference rules, paths and explicit rules to demonstrate correct application of the rule concepts.

Example:

{p1}.c{p2}.obj:                 #  Valid .SUFFIXES: extensions
    $CC) $(CFLAGS) /Fo$@ $<     #  First inference rule

{p3}.c{p4}.obj:                 #  Valid .SUFFIXES: extensions
    $(CC) $(CPPFLAGS) /Fo$@ $<  #  Second inference rule

{p1}.c{p4}.obj:                 #  Valid .SUFFIXES: extensions
    $(CC) $(CPPFLAGS) /Fo$@ $<  #  Third inference rule

p2\dep.obj : p1\dep.c           #  Target / dependency statement
    @echo Bogus explicit rule   #  Explicit rule

p4\dep.obj : p1\dep.c           #  Target / dependency statement
                                #  with no explicit rule

The application of the inference rules for the target/dependency with no explicit rule is as follows:

The third inference rule is the rule that applies to the second target/dependency statement. The target will be updated in the p4 directory from the dependent in the p1 directory, if required.


[Back] [Next]