A makefile contains a list of targets (i.e., source files, object files, and executables), dependents (i.e., the files that a target depends on), and commands (i.e., what needs to be done if the target does not exist, if the target has an earlier time stamp than a dependent, or if the target is actually a "pseudotarget" without an associated file).
nmake [- option...] [macro...] [target]... [@ command-file]...
A | Build all evaluated targets. |
B | Build if times stamps are equal. |
C | Suppress output messages. |
fmakefile | Use the given makefile. |
N | Display commands but do not execute them. |
Multiple targets can be specified in the same dependency line; separate them using spaces or tabs.
Note: If the target is a single letter, separate it from the colon (i.e., the : character) using a space (so it is not confused with a drive letter).
Multiple dependents can be specified in the same dependency line; seperate them using spaces or tabs.
Of course, a dependent can also be a target elsewhere in the makefile. The namke command will update dependents that are targets first. However, some care needs to be taken when creating makefiles.
Note: To split a "long" line, use the backslash (i.e., the \ character) after a dependent.
test.exe: test.obj module1.obj link test.obj module1.obj test.obj: test.cpp module1.h cl -c test.cpp module1.obj: module1.cpp module1.h cl -c module1.cpp
The first description block says that the target test.exe depends on two files, test.obj and module1.obj. If test.exe has an earlier time stamp than either of these files, test.exe should be rebuilt using the link command.
The second description block says that test.obj depends on test.cpp and module1.h, and that it can be created with the cl command.
The third description block says that module1.obj depends on module1.cpp and module1.h, and that it can be created with the cl command.
Assuming that this makefile is named makefile, the application test.exe can be built with the following command:
While you are still learning to use the nmake command you should not make use of these predefined rules.
Copyright 2019