1 # $NetBSD: var-op-append.mk,v 1.7 2020/10/30 20:36:33 rillig Exp $
3 # Tests for the += variable assignment operator, which appends to a variable,
4 # creating it if necessary.
6 # Appending to an undefined variable is possible.
7 # The variable is created, and no extra space is added before the value.
13 # Appending to an existing variable adds a single space and the value.
15 .if ${VAR} != "one two"
19 # Appending an empty string nevertheless adds a single space.
21 .if ${VAR} != "one two "
25 # Variable names may contain '+', and this character is also part of the
26 # '+=' assignment operator. As far as possible, the '+' is interpreted as
27 # part of the assignment operator.
31 .if ${C+} != "value" || defined(C++)
35 # Try out how often the variable name is expanded when appending to a
36 # nonexistent variable.
37 # As of 2020-10-30, that's two times.
38 # XXX: That's one time too often.
39 # See Var_Append, the call to Var_Set.
41 VAR.${:U\$\$\$\$\$\$\$\$}+= dollars
43 .if ${VAR.${:U\$\$\$\$}} != "dollars"