File-Specification Parts

A full file specification gives the base name of the file, the file name extension, and the path. The path provides the disk drive identifier and the sequence of directories needed to locate the file on the disk.

Example:

The file specification:

     C:\SOURCE\PROG\SORT.OBJ

has the following parts:

┌────────────────────┬────────────────────┬────────────────────┐
│Path Name           │C:\SOURCE\PROG      │everything prior to │
│                    │                    │the last path       │
│                    │                    │separator           │
├────────────────────┼────────────────────┼────────────────────┤
│File Extension      │.OBJ                │everything after and│
│                    │                    │including the last  │
│                    │                    │dot (.)             │
├────────────────────┼────────────────────┼────────────────────┤
│Base File Name      │SORT                │what's left         │
└────────────────────┴────────────────────┴────────────────────┘

NMAKE32 predefines several macros which are useful for writing rules for building targets.

┌────────────┬────────────────────────────────────────────────┐
│Macro       │Value                                           │
├────────────┼────────────────────────────────────────────────┤
│$$          │The '$' character, which does not participate in│
│            │any further macro expansion.                    │
├────────────┼────────────────────────────────────────────────┤
│$*          │The path name and base file name of the current │
│            │target with the extension deleted.              │
├────────────┼────────────────────────────────────────────────┤
│$<          │When used in an explicit rule; the first        │
│            │dependent of the target (regardless of whether  │
│            │the dependent is out of date), if any. When used│
│            │in an inference rule, the file specification of │
│            │the (inferred) dependent which is out of date   │
│            │with respect to the target. For example, in the │
│            │.c.obj: rule, $< would evaluate to the .c file. │
├────────────┼────────────────────────────────────────────────┤
│$@          │The file specification of the current target.   │
├────────────┼────────────────────────────────────────────────┤
│$?          │The file specification of all dependents which  │
│            │are out of date with respect to the target.     │
├────────────┼────────────────────────────────────────────────┤
│$**         │The list of file specifications of all          │
│            │dependents (whether up-to-date or not).         │
├────────────┼────────────────────────────────────────────────┤
│$$@         │The file specification of the target that       │
│            │NMAKE32 is currently evaluating. This is a      │
│            │dynamic dependency parameter, used only in      │
│            │dependent lists.                                │
├────────────┼────────────────────────────────────────────────┤
│$:          │The path name of the current target file        │
│            │specification.                                  │
├────────────┼────────────────────────────────────────────────┤
│$.          │The base file name and extension of the current │
│            │target file specification.                      │
├────────────┼────────────────────────────────────────────────┤
│$&          │The base file name of the current target file   │
│            │specification.                                  │
├────────────┼────────────────────────────────────────────────┤
│$()         │The null string                                 │
└────────────┴────────────────────────────────────────────────┘

Note: The special macros $** and $$@ are the only exceptions to the rule that macro names longer than one character must be enclosed in parentheses.

Example:

Given the following description file excerpt:

     c:\mydir\myprog.obj: $*.c
          @echo Dollar Star is $*
          @echo Dollar Star Star is $**
          @echo Dollar At is $@

The special macro $* on the target dependent line will expand to c:\mydir\myprog, and the following text will be displayed when NMAKE32 is run:

     Dollar Star is c:\mydir\myprog
     Dollar Star Star is c:\mydir\myprog.c
     Dollar At is c:\mydir\myprog.obj

Characters that Modify Built-in Macros

The following macros all resolve to a file specification (or possible several file specifications for $** and $?):

$* $@ $** $< $? $$@

There are four characters (D, F, B, or R), which may be appended to any of these macros to modify the filename returned by the macro. Parts of the full file specification are returned, depending on which character is used.

Appended Character

┌────────────────────────┬────────┬────────┬────────┬────────┐
│File Part Returned      │D       │F       │B       │R       │
├────────────────────────┼────────┼────────┼────────┼────────┤
│File Path               │Yes     │No      │No      │Yes     │
├────────────────────────┼────────┼────────┼────────┼────────┤
│Base File Name          │No      │Yes     │Yes     │Yes     │
├────────────────────────┼────────┼────────┼────────┼────────┤
│File Name Extension     │No      │Yes     │No      │No      │
└────────────────────────┴────────┴────────┴────────┴────────┘

Example:

If the macro $@ has the value

     C:\SOURCE\PROG\SORT.OBJ

then the following values are returned for the modified macro: