Updating Backup Files with NMAKE & ALL Target-Dependency (76739)



The information in this article applies to:

  • Microsoft NMAKE Utility for MS-DOS 1.01
  • Microsoft NMAKE Utility for MS-DOS 1.11
  • Microsoft NMAKE Utility for MS-DOS 1.12
  • Microsoft NMAKE Utility for MS-DOS 1.13
  • Microsoft NMAKE Utility for MS-DOS 1.2
  • Microsoft NMAKE Utility for MS-DOS 1.3
  • Microsoft NMAKE Utility for MS-DOS 1.4
  • Microsoft NMAKE Utility for OS/2 1.11
  • Microsoft NMAKE Utility for OS/2 1.12
  • Microsoft NMAKE Utility for OS/2 1.13
  • Microsoft NMAKE Utility for OS/2 1.21
  • Microsoft NMAKE Utility for Windows NT

This article was previously published under Q76739

SUMMARY

The text below demonstrates using NMAKE and the ALL target-dependency (an NMAKE keyword) to copy or backup files that are out-of-date with respect to the previous copy or archive.

MORE INFORMATION

The steps below create a .MAK file that copies the AUTOEXEC.BAT and CONFIG.SYS files to a directory named C:\BACKUP:

  1. Use a text editor to create COPY.MAK that contains the following text:
          ALL: c:\backup\autoexec.bat c:\backup\config.sys
    
          c:\backup\autoexec.bat: c:\autoexec.bat
             copy c:\autoexec.bat c:\backup\autoexec.bat
          c:\backup\config.sys: c:\config.sys
             copy c:\config.sys c:\backup\config.sys
    NOTE: The .MAK file above copies the AUTOEXEC.BAT files from the source directory (C:\) to the target directory (C:\BACKUP). The files are copied only if the files in the source directory have an older time/date stamp than the files in the target directory.
  2. Create the C:\BACKUP directory if it does not already exist. To do so, type the following at the MS-DOS command prompt:

    mkdir c:\backup

  3. To backup any changes you made to your AUTOEXEC.BAT or CONFIG.SYS files, type the following at the MS-DOS command prompt:

    nmake /f copy.mak

NMAKE processes only one dependency per makefile. If the makefile did not include the ALL target-dependency (an NMAKE keyword), only the first file would be copied and the second copy command would be ignored completely. The ALL target creates a dependency that depends on the completion of every task in the makefile. Without this statement, two dependencies are declared, only one of which would be processed.

Page 645 of the "Microsoft Basic 7.0: Programmer's Guide" for versions 7.0 and 7.1 presents a similar example. However, this example lacks the ALL target-dependency and does not work correctly as presented.

Modification Type:MajorLast Reviewed:12/1/2003
Keywords:KB76739 kbAudDeveloper