Using NMAKE and ALL Target-Dependency to Update Backup Files

ID Number: Q76739

1.00 1.01 1.10 1.11 1.12 1.13 | 1.10 1.11 1.12 1.13

MS-DOS | OS/2

Summary:

This article demonstrates how to use NMAKE and the ALL target-

dependency (an NMAKE keyword) to cause files to be copied or backed up

when they are out of date with respect to the backed up files.

This information applies to NMAKE versions 1.0, 1.01, 1.1, 1.11, 1.12,

and 1.13. This information also applies to Microsoft BASIC PDS

(Professional Development System) versions 7.0 (which includes NMAKE

version 1.1) and 7.1 (which includes NMAKE version 1.11) for MS-DOS

and MS OS/2.

More Information:

Below is an example of the steps necessary to create a .MAK file that

will cause the AUTOEXEC.BAT and CONFIG.SYS files to be copied to a

directory called C:\BACKUP\:

1. Using any text editor, enter 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 above .MAK file will copy the selected files AUTOEXEC.BAT

and CONFIG.SYS from the source directory (C:\) to the target directory

(C:\BACKUP\). These files will be copied only if the files contained

in the source directory have a different time/date stamp than the

files contained in the target directory.

2. Save the above file as a text file with the name COPY.MAK.

3. From the DOS command line, type

mkdir c:\backup

to create the directory C:\BACKUP\ if it does not already exist.

4. Type the following from the DOS command line:

nmake copy.mak

NMAKE will only process one dependency per .MAK file. Without the use

of the ALL target-dependency (a keyword recognized by NMAKE), only the

first file will get copied, and the second copy command will be

completely ignored. By adding the ALL target to the .MAK file, you

create a single dependency that is dependent on the completion of all

tasks. Without this statement, you have two separate dependencies

declared. In this case, NMAKE will never process the second

dependency.

This is an example similar to the one documented on page 645 of the

"Microsoft Basic 7.0: Programmer's Guide" (for version 7.0 and 7.1).

Note that the example is missing the ALL target-dependency, and

therefore will not work correctly as it is written. Query on the

following words for more information on this problem:

NMAKE and docerr and PDS