Example Demonstrates Using Paths in NMAKELast reviewed: January 24, 1995Article ID: Q60340 |
The information in this article applies to:
SUMMARYThe text below includes an NMAKE makefile that uses paths in macros, inference rules, and target dependencies (descriptor blocks).
MORE INFORMATIONThe makefile compares the modification dates of the header (.H) and source code (.C) files with the object (.OBJ) files and the dates of the object files with the executable (.EXE) file. If any of the dependent files changed more recently than the target file changed, NMAKE executes the specified commands. The dates of the header and source code files in the WORK directory are compared to the dates of the object files in the LIB directory. If any of the source files changed since its associated object file was created, NMAKE calls the compiler to create the object file and copies it from the current directory to the LIB directory. Then NMAKE compares the dates of the object files in the LIB directory with the date of the executable file in the current directory. If any of the object files changed since the executable file was created, NMAKE calls LINK to rebuild the executable file. The following makefile example uses several predefined macro modifiers. For more information on the macro modifiers, please refer to the macro section of the NMAKE documentation provided with your compiler. If none of the object files exist, NMAKE executes the following commands when it runs this makefile:
cl /c c:\work\test1.c copy test1.obj c:\lib\test1.obj 1 file(s) copied erase test1.obj cl /c c:\work\test2.c copy test2.obj c:\lib\test2.obj 1 file(s) copied erase test2.obj cl /c c:\work\test3.c copy test3.obj c:\lib\test3.obj 1 file(s) copied erase test3.obj link c:\lib\test1 c:\lib\test2 c:\lib\test3; Sample Makefile# macros objdir = c:\lib wrkdir = c:\work list = $(objdir)\test1.obj $(objdir)\test2.obj $(objdir)\test3.obj # inference rules # compile # $< represents the dependent file. # $(*F) represents the targets base name. # $(*R) represents the targets base name and directory. {$(wrkdir)}.c{$(objdir)}.obj: cl /c $< copy $(*F).obj $(*R).obj erase $(*F).obj# link # $(**R) represents all the dependents including directories. {$(objdir)}.obj{}.exe: link $(**R);# target-dependencies # $$(@B) represents the base name of the current target. test1.exe : $(list) $(objdir)\*.obj : $(wrkdir)\$$(@B).c $(wrkdir)\test1.h $(wrkdir)\test2.h
|
Additional reference words: kbinf kbinf 1.10 1.20 1.30 1.40 1.50
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |