2009-04-29 96 views
1

我想要獲取b.mak makefile中名爲$(MYVAR)_SOME_SUFFIX的變量的值。 相反,我得到「b.mak(2):致命錯誤U1001:語法錯誤:非法字符‘$’宏」nmake - 模擬eval函數

# ---- a.mak ---- 
all : 
    set MYVAR=SOME_PREFIX 
    nmake -f b.mak 
#--- END --- 

# ---- b.mak ---- 
all: 
    @echo $($(MYVAR)_SOME_SUFFIX) 
#--- END --- 

回答

2

您可以排序的做你想要什麼inline files

# ---- 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