Escape variable expansion in Makefile


Is there a way to escape the expansion of variables in OpenWrt Makefiles? With normal Makefiles one would use the symbol twice (e.g. $${TEST_VARIABLE}) in bash the variable would be put in quotes (e.g. '${TEST_VARIABLE}'), however both options not work and if you want to use envsubst you can't pass the variables which you want to be substituted as a string, since they get immediately expanded.

I'm interested in knowing this too.
Can you move the testvariable to your source code's makefile instead, and perhaps use in your openwrt makefile? Not sure what you want to achieve.



I'm trying to capture the entry from the menucon fig which gets stored in the .config file as the TEST_VARIABLE. When the Makefile of the application obtains this TEST_VARIABLE it is used from envsubst to substitute a variable with the same name in a different bash script. However if I want to specify which variables should be substituted I have to pass the names of the variables as a string starting with a dollar sign, however the openwrt Makefile expands it instead of treating it as a string. Hope this makes sense :slightly_smiling_face:

1 Like

Found the solution to the problem. In order to have the dollar sign in a string one can type four dollar signs as a prefix. So an example would be '$$$${TEST_VARIABLE}' which will not expand the TEST_VARIABLE and would give a string in the form of '${TEST_VARIABLE}', what actually my goal was.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.