1 1.5 rillig # $NetBSD: opt-debug-var.mk,v 1.5 2025/01/11 21:21:33 rillig Exp $ 2 1.1 rillig # 3 1.1 rillig # Tests for the -dv command line option, which adds debug logging about 4 1.1 rillig # variable assignment and evaluation. 5 1.1 rillig 6 1.2 rillig .MAKEFLAGS: -dv 7 1.1 rillig 8 1.2 rillig # expect: Global: ASSIGNED = value 9 1.2 rillig ASSIGNED= value 10 1.2 rillig 11 1.2 rillig # TODO: Explain why the empty assignment "Global: SUBST = " is needed. 12 1.4 rillig # expect: Global: SUBST = # (empty) 13 1.2 rillig # expect: Global: SUBST = value 14 1.2 rillig SUBST:= value 15 1.2 rillig 16 1.2 rillig .if defined(ASSIGNED) 17 1.2 rillig .endif 18 1.2 rillig 19 1.3 rillig # The usual form of expressions is ${VAR}. The form $(VAR) is used 20 1.2 rillig # less often as it can be visually confused with the shell construct for 21 1.2 rillig # capturing the output of a subshell, which looks the same. 22 1.2 rillig # 23 1.2 rillig # In conditions, a call to the function 'empty' is syntactically similar to 24 1.2 rillig # the form $(VAR), only that the initial '$' is the 'y' of 'empty'. 25 1.2 rillig # 26 1.2 rillig # expect: Var_Parse: y(ASSIGNED) (eval) 27 1.2 rillig .if !empty(ASSIGNED) 28 1.2 rillig .endif 29 1.2 rillig 30 1.4 rillig 31 1.4 rillig # An expression for a variable with a single-character ordinary name. 32 1.5 rillig # expect: Var_Parse: $U (eval-defined-loud) 33 1.5 rillig # expect+1: Variable "U" is undefined 34 1.4 rillig .if $U 35 1.4 rillig .endif 36 1.4 rillig 37 1.4 rillig # An expression for a target-specific variable with a single-character name. 38 1.5 rillig # expect: Var_Parse: $< (eval-defined-loud) 39 1.5 rillig # expect+1: Variable "<" is undefined 40 1.4 rillig .if $< 41 1.4 rillig .endif 42 1.4 rillig 43 1.4 rillig 44 1.2 rillig .MAKEFLAGS: -d0 45