1 1.7 rillig # $NetBSD: varname.mk,v 1.7 2020/11/02 22:44:29 rillig Exp $ 2 1.1 rillig # 3 1.2 rillig # Tests for special variables, such as .MAKE or .PARSEDIR. 4 1.5 rillig # And for variable names in general. 5 1.1 rillig 6 1.5 rillig .MAKEFLAGS: -dv 7 1.5 rillig 8 1.5 rillig # In variable names, braces are allowed, but they must be balanced. 9 1.5 rillig # Parentheses and braces may be mixed. 10 1.5 rillig VAR{{{}}}= 3 braces 11 1.5 rillig .if "${VAR{{{}}}}" != "3 braces" 12 1.5 rillig . error 13 1.5 rillig .endif 14 1.5 rillig 15 1.5 rillig # In variable expressions, the parser works differently. It doesn't treat 16 1.5 rillig # braces and parentheses equally, therefore the first closing brace already 17 1.5 rillig # marks the end of the variable name. 18 1.5 rillig VARNAME= VAR((( 19 1.5 rillig ${VARNAME}= 3 open parentheses 20 1.5 rillig .if "${VAR(((}}}}" != "3 open parentheses}}}" 21 1.5 rillig . error 22 1.5 rillig .endif 23 1.5 rillig 24 1.5 rillig # In the above test, the variable name is constructed indirectly. Neither 25 1.5 rillig # of the following expressions produces the intended effect. 26 1.7 rillig # 27 1.7 rillig # This is not a variable assignment since the parentheses and braces are not 28 1.7 rillig # balanced. At the end of the line, there are still 3 levels open, which 29 1.7 rillig # means the variable name is not finished. 30 1.6 rillig ${:UVAR(((}= try1 31 1.6 rillig ${:UVAR\(\(\(}= try2 32 1.6 rillig ${:UVAR\(\(\(}= try3 33 1.5 rillig 34 1.5 rillig .MAKEFLAGS: -d0 35 1.1 rillig 36 1.1 rillig all: 37