KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q48862: Incrementally Updating Libraries with NMAKE

Article: Q48862
Product(s): See article
Version(s): 1.00 1.01 1.10 1.11 1.12 | 1.11 1.12
Operating System(s): MS-DOS | OS/2
Keyword(s): ENDUSER | | mspl13_basic
Last Modified: 25-FEB-1991

The repetition modifier "!" (without the quotation marks) provided in
NMAKE allows libraries to be maintained and incrementally updated very
easily. By using this modifier with the special macro for dependents
out-of-date with the target (for example, "$?"), the library update
becomes an automated part of modifying a project.

The following NMAKE makefile keeps FOO.LIB up-to-date based on the
four object files listed in the OBJS macro. These object files can be
based on C or assembly source files. The list of source-file types can
be extended by adding the appropriate inference rules to the
description file.

Sample NMAKE Makefile
---------------------

    #
    # List of object files to be kept in library
    #
    OBJS = foo1.obj foo2.obj foo3.obj foo4.obj

    .c.obj:
        cl /c $?

    .asm.obj:
        masm $?;

    foo.lib : $(OBJS)
        !lib foo.lib -+ $?;

The command for the library dependency line uses a predefined macro
and a special NMAKE directive. Placing "$?" on the end of the LIB line
expands to the list of all dependents that are out-of-date with the
target. This list combined with "!" causes the LIB line to be executed
once for each member in the list.

If FOO1.OBJ and FOO3.OBJ are out-of-date with respect to FOO.LIB, "$?"
evaluates to "FOO1.OBJ FOO3.OBJ". With "!", the following commands are
executed:

   lib foo.lib -+ foo1.OBJ;
   lib foo.lib -+ foo3.OBJ;

THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Copyright Microsoft Corporation 1986-2002.