How can I forward macros between nmake invocations?
Let’s say we have
--- a.mak ---
some_variable = value
all:
nmake -f b.mak
--- END ---
--- b.mak ---
all:
@echo some_variable = WHAT TO PUT HERE TO GET VALUE OF some_variable?
--- END ---
I was trying different things like using set and setx commands but value of variable set in parent makefile is not visible in makefiles being invoked from within it.
Here’s the info from MSDN about calling
nmakerecursively:So, you could make
a.maklook like:Also, note that using the
setsommand to put the variable in the environment will work as well, butnmakeautomatically 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:
So, here’s what your
b.makshould look like if you’re going to pass the variable using the environment instead of explicitly on the command line:Because of this, it’s probably not a bad idea to standardize on an all-caps naming convention for nmake macro names.