Examples

TRIG.LIB : SIN.OBJ COS.OBJ ARCTAN.OBJ
  !LIB TRIG.LIB -+$?;

In the example above, the macro $? represents the names of all dependent files that are out-of-date with respect to the target file. The exclamation point ( ! ) preceding the LIB command causes NMAKE to execute the LIB command once for each dependent file in the list. As a result of this description, the LIB command is executed up to three times, each time replacing a module with a newer version.

DIR=C:\INCLUDE
$(DIR)\GLOBALS.H : GLOBALS.H
 COPY GLOBALS.H $@
$(DIR)\TYPES.H : TYPES.H
 COPY TYPES.H $@
$(DIR)\MACROS.H : MACROS.H
 COPY MACROS.H $@

The example above shows how to update a group of include files. Each of the files GLOBALS.H, TYPES.H, and MACROS.H in the directory C:\INCLUDE depends on its counterpart in the current directory. If one of the include files is out-of-date, NMAKE replaces it with the file of the same name from the current directory.

The following description file, which uses the special macro $$@, is equivalent:

DIR=C:\INCLUDE
$(DIR)\GLOBALS.H $(DIR)\TYPES.H $(DIR)\MACROS.H : $$(@F)
!COPY $? $@

The special macro $$(@F) signifies the file name (without the path) of the current target.

When NMAKE evaluates the description block, it evaluates the three targets, one at a time, with respect to their dependents. Thus, NMAKE first checks whether C:\INCLUDE\GLOBALS.H is out-of-date compared with GLOBALS.H in the current directory. If so, it executes the command to copy the dependent file GLOBALS.H to the target. NMAKE repeats the procedure for the other two targets.

Note that on the command line, the macro $? refers to the dependent for this target. The macro $@ specifies the full file specification of the target file.


[Back: Special Macros]
[Next: File-Specification Parts]