Nmake - simulating eval function

I want to get the value of a variable named $ (MYVAR) _SOME_SUFFIX in the make.md file. Instead, I get "b.mak (2): fatal error U1001: syntax error: illegal character" $ "in the macro"

# ---- a.mak ---- all : set MYVAR=SOME_PREFIX nmake -f b.mak #--- END --- # ---- b.mak ---- all: @echo $($(MYVAR)_SOME_SUFFIX) #--- END --- 
+1
source share
1 answer

You can do what you want with embedded 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 --- 

when I run nmake -f piotr1.mak , I get the expected value echo'd on the console: 24.

+2
source

Source: https://habr.com/ru/post/1332493/


All Articles