There is a method of choosing a command block to be executed based on which dependents cause the target to be updated. If an object library contains both compiled files and assembled files, you might want to generate the objects and update the library in different ways depending on which file types were updated. NMAKE32 supports this with dependent specific rules. These rules are similar to regular rules, but are identified by using two colons (::) between the target and the dependents, and the target is usually specified in more than one description block. The following description blocks are permissible:

X :: a
   command block

X :: b
   command block

The following example shows how dependent specific rules can be utilized.

object.lib :: a.asm
 $(AS) a.asm;
 $(LIB) object -+a.obj;

object.lib :: b.c
 $(CC) $(CFLAGS) b.c
 $(LIB) object -+b.obj;

The two description blocks both update the library named object.lib, however, the first command block is only executed if a.asm is newer than object.lib, and the second command block is only executed if b.c is newer than object.lib.

Whenever there is a target that appears in more than one description block, and the target/dependency separator is a single colon (:), the two description blocks are merged by concatenating the command blocks and the dependents.


[Back] [Next]