KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q64028: Changing Directories in Make Files Not Supported by NMK.COM

Article: Q64028
Product(s): See article
Version(s): 1.11
Operating System(s): MS-DOS
Keyword(s): ENDUSER | buglist1.11 S_QUICKC S_C | mspl13_basic
Last Modified: 31-AUG-1990

Using a command to change directories in a make file will cause
unexpected results with NMK.COM version 1.11. This is a side effect of
a problem with NMAKE.EXE where directory changes within make files are
executed while processing the make file, and the current directory is
not reset upon exit.

NMK spawns NMAKE to do its processing. While NMAKE is processing, if
it sees a change drive/directory command, it must make the change to
finish processing the make file. The problem is that it doesn't reset
the drive when it is through processing. This causes NMK, when control
is returned to it, to spawn the actual commands from the final
drive/directory, rather than where it was originally invoked.

The make file below, if run from Drive D, will demonstrate the
problem. It works properly with NMAKE.EXE but not with NMK.COM.

all: cded.exe

cded.exe: cded.obj
  c:\
  copy cded.obj cded.exe

cded.obj: cded.mak
  copy cded.mak c:\cded.obj

To work around the problem, add a line at the end of each place block
where you change the drive/directory to the original one (if known).
For example, change the above make file to the following:

all: cded.exe

cded.exe: cded.obj
  c:\
  copy cded.obj cded.exe
  d:

cded.obj: cded.mak
  copy cded.mak c:\cded.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.