你可以用内联文件做你想做的事。
# ---- piotr1.mak ----
all :
nmake -nologo -f piotr2.mak MYVAR=BBB
#--- END ---
# ---- piotr2.mak ----
AAA_SETTING=17
BBB_SETTING=24
AVAR=$(MYVAR)_SETTING
all:
# create and invoke a temporary cmd file
@<<myecho.cmd
@echo off
setlocal
REM insert nMAKE macros into environment of the command
set AAA_SETTING=$(AAA_SETTING)
set BBB_SETTING=$(BBB_SETTING)
REM now echo the value of whichever env var is named by the
REM nmake macro, AVAR.
echo %$(AVAR)%
endlocal
<<
#--- END ---
当我运行时,nmake -f piotr1.mak
我得到期望值回显到控制台:24。