1 # $NetBSD: var-op-append.mk,v 1.8 2021/02/03 08:40:47 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 # Before var.c 1.793 from 2021-02-03, the variable name of a newly created
36 # variable was expanded two times in a row, which was unexpected but
37 # irrelevant in practice since variable names containing dollars lead to
38 # strange side effects in several other places as well.
40 VAR.${:U\$\$\$\$\$\$\$\$}+= dollars
42 .if ${VAR.${:U\$\$\$\$\$\$\$\$}} != "dollars"