1 1.6 rillig # $NetBSD: var-op-append.mk,v 1.6 2020/10/24 08:50:17 rillig Exp $ 2 1.1 rillig # 3 1.2 rillig # Tests for the += variable assignment operator, which appends to a variable, 4 1.2 rillig # creating it if necessary. 5 1.1 rillig 6 1.5 rillig # Appending to an undefined variable is possible. 7 1.5 rillig # The variable is created, and no extra space is added before the value. 8 1.5 rillig VAR+= one 9 1.5 rillig .if ${VAR} != "one" 10 1.5 rillig . error 11 1.5 rillig .endif 12 1.5 rillig 13 1.5 rillig # Appending to an existing variable adds a single space and the value. 14 1.5 rillig VAR+= two 15 1.5 rillig .if ${VAR} != "one two" 16 1.5 rillig . error 17 1.5 rillig .endif 18 1.5 rillig 19 1.5 rillig # Appending an empty string nevertheless adds a single space. 20 1.5 rillig VAR+= # empty 21 1.5 rillig .if ${VAR} != "one two " 22 1.5 rillig . error 23 1.5 rillig .endif 24 1.5 rillig 25 1.5 rillig # Variable names may contain '+', and this character is also part of the 26 1.5 rillig # '+=' assignment operator. As far as possible, the '+' is interpreted as 27 1.5 rillig # part of the assignment operator. 28 1.5 rillig # 29 1.5 rillig # See Parse_DoVar 30 1.6 rillig C++= value 31 1.5 rillig .if ${C+} != "value" || defined(C++) 32 1.5 rillig . error 33 1.5 rillig .endif 34 1.1 rillig 35 1.1 rillig all: 36 1.1 rillig @:; 37