Targets are the files that will be created or updated in the description file. Targets are file names that start in column one of a description file and are followed by a colon (:). Dependents are the filenames that follow after the colon. These are the files that are examined to determine if the target should be updated. Specification of the target(s) and dependent(s) will be frequently referenced as the target/dependency statement. The target/dependency statement must start in the first column of the description file by definition. The target/dependency statement has the following format:

targets...  :  [{path}]dependents...
or
{path1;path2;...}targets  :  {path1;path2;...}dependents

Example:

program.obj : program.c program.h

Note: Target/Dependency statements may not contain an equal sign (=). Only macro definitions may contain an equal sign.

The optional curly brace paths preceding the filenames are alternative paths that can be used if the file is not located in the current directory. When specifying multiple paths they must be separated by semicolons (;). Whenever one of the dependents has a timestamp equal to or newer (depending on the use of the -= option) than the target, the target will be updated. All dependents are also checked for being out of date with respect to their dependents. Missing files are always considered to be out of date. The target build process can be specified in a command block following the target/dependency statement. If there is no command block in the description block, then the build process will be inferred from either rules predefined in NMAKE32, or rules that have been given in the description file, the TOOLS.INI file, the BUILTINS.MAK file, or the file specified by the -b option on the command line (see Inference Rules).

NMAKE32 builds the first target that is specified in the description file if it is out of date. Often a pseudotarget will be used to list all the targets that the developer wants to build from the description file.

Example:

all : hello.obj bye.obj

hello.obj : hello.c hello.h
   icc /fohello.obj /c hello.c

target1.obj : target1.c
   icc /fotarget1.obj /c target1.c

bye.obj : bye.c bye.h
   icc /fobye.obj /c bye.c

target2.obj : target2.c
   icc /fotarget2.obj /c target2.c

In the preceding example, of the four targets listed (five, including the pseudotarget all), only hello.obj and bye.obj will be checked for updating. The first target NMAKE32 encounters is all, and it has two dependents, hello.obj and bye.obj.

If we deleted the target/dependency statement that defines all and its dependents, the only target checked for updating would be hello.obj, because it would be the first target in the description file.

Targets can also be specified during NMAKE32 invocation from the command line. When targets are specified during invocation, they become the targets to be updated, those targets and their dependents will be checked for updating. The command line targets supersede targets defined in the description file. If a command line target does not correspond to a target in the description file, NMAKE32 will attempt to infer a command using either a default inference rule, or an inference rule defined in the makefile.

A target specified in the description file without dependencies is always out of date. When specified for updating, it's command block will always execute.


[Back] [Next]