Here's the info from MSDN about calling nmake
recursively:
Use recursion macros to call NMAKE recursively. Recursive sessions inherit command-line and environment-variable macros and Tools.ini information. They do not inherit makefile-defined inference rules or .SUFFIXES and .PRECIOUS specifications. To pass macros to a recursive NMAKE session, either set an environment variable with SET before the recursive call, define a macro in the command for the recursive call, or define a macro in Tools.ini.
So, you could make a.mak
look like:
# ---- a.mak ----
some_variable = value
all:
nmake -f b.mak some_variable=$(some_variable)
#--- END ---
Also, note that using the set
sommand to put the variable in the environment will work as well, but nmake
automatically capitalizes environment variable names (even for weird ones like "windir
" which is lowercase in the system for some reason), and is case-sensitive, so to use the environment variable, you must use the variable in uppercase.
From MSDN:
inherited names are converted to uppercase. Inheritance occurs before preprocessing
So, here's what your b.mak
should look like if you're going to pass the variable using the environment instead of explicitly on the command line:
#--- b.mak ---
all:
@echo some_variable is: $(SOME_VARIABLE)
#--- end ---
Because of this, it's probably not a bad idea to standardize on an all-caps naming convention for nmake macro names.