INF: NMAKE Macros Do Not Become Part of the Environment

ID Number: Q75327

1.10 1.11 1.12 1.13 | 1.10 1.11 1.12 1.13

MS-DOS | OS/2

Summary:

When using the Microsoft NMAKE utility versions 1.1, 1.11, 1.12, and

1.13, macros defined in a makefile do not get assigned to the

environment for use by processes invoked by NMAKE. This should not be

confused with the concept that NMAKE macros reassign corresponding

environment variables.

For example, in the first sample makefile below a macro named CL is

assigned. If an environment variable named CL exists, the CL macro

assignment will temporarily reassign the CL environment variable and

in this case, the compiler will see the /c option and compile only. If

a CL environment variable does not exist, the CL macro is just another

macro and the /c option will not be seen when the compiler is invoked

because there is no CL variable in the environment.

More Information:

To assign an environment variable inside a makefile that does not

already exist before execution of the makefile, use the DOS or OS/2

SET command. The second sample makefile below demonstrates how you can

set the CL environment variable if it is not already in the inherited

environment.

NOTE: If NMK.COM is being used instead of NMAKE, the SET command must

be used to reassign any environment variables. NMK.COM

will not permit the environment to be overridden with macro

assignments. For more information, query on the following words:

NMK.COM and environment and macros

Sample Makefile #1

------------------

# If the following items are done, the compiler and linker will be

# invoked:

#

# 1. Do not assign CL to anything before executing this makefile.

# 2. Create a file TEST.C.

#

# If the CL variable is assigned to the environment before

# running the makefile and then execute the makefile, the "/c" option

# is seen by the compiler and the linker is not executed.

#

CL=/c

ALL:

cl test.c

Sample Makefile #2

------------------

# This is a modified makefile from sample 1. CL is set by using the

# SET command.

INCLUDE=d:\include

ALL:

set cl=/c

cl test.c