]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/bmake/unit-tests/var-op-expand.mk
Merge bmake-20201117
[FreeBSD/FreeBSD.git] / contrib / bmake / unit-tests / var-op-expand.mk
1 # $NetBSD: var-op-expand.mk,v 1.4 2020/11/08 14:00:52 rillig Exp $
2 #
3 # Tests for the := variable assignment operator, which expands its
4 # right-hand side.
5
6 # TODO: Implementation
7
8 # XXX: edge case: When a variable name refers to an undefined variable, the
9 # behavior differs between the '=' and the ':=' assignment operators.
10 # This bug exists since var.c 1.42 from 2000-05-11.
11 #
12 # The '=' operator expands the undefined variable to an empty string, thus
13 # assigning to VAR_ASSIGN_.  In the name of variables to be set, it should
14 # really be forbidden to refer to undefined variables.
15 #
16 # The ':=' operator expands the variable name twice.  In one of these
17 # expansions, the undefined variable expression is preserved (controlled by
18 # preserveUndefined in VarAssign_EvalSubst), in the other expansion it expands
19 # to an empty string.  This way, 2 variables are created using a single
20 # variable assignment.  It's magic. :-/
21 .MAKEFLAGS: -dv
22 VAR_ASSIGN_${UNDEF}=    undef value
23 VAR_SUBST_${UNDEF}:=    undef value
24 .MAKEFLAGS: -d0
25
26 all:
27         @:;