1 # $NetBSD: cond-token-var.mk,v 1.5 2020/11/15 14:58:14 rillig Exp $
3 # Tests for variable expressions in .if conditions.
5 # Note the fine distinction between a variable and a variable expression.
6 # A variable has a name and a value. To access the value, one writes a
7 # variable expression of the form ${VAR}. This is a simple variable
8 # expression. Variable expressions can get more complicated by adding
9 # variable modifiers such as in ${VAR:Mpattern}.
11 # XXX: Strictly speaking, variable modifiers should be called expression
12 # modifiers instead since they only modify the expression, not the variable.
13 # Well, except for the assignment modifiers, these do indeed change the value
18 # A defined variable may appear on either side of the comparison.
25 # A variable that appears on the left-hand side must be defined.
26 # The following line thus generates a parse error.
27 .if ${UNDEF} == ${DEF}
31 # A variable that appears on the right-hand side must be defined.
32 # The following line thus generates a parse error.
33 .if ${DEF} == ${UNDEF}
37 # A defined variable may appear as an expression of its own.
41 # An undefined variable on its own generates a parse error.
45 # The :U modifier turns an undefined expression into a defined expression.
46 # Since the expression is defined now, it doesn't generate any parse error.