vardebug.mk revision 1.16 1 # $NetBSD: vardebug.mk,v 1.16 2025/01/11 21:21:33 rillig Exp $
2 #
3 # Demonstrates the debugging output for var.c.
4
5 .MAKEFLAGS: -dv FROM_CMDLINE=
6
7 # expect: Global: VAR = added
8 VAR= added # VarAdd
9 # expect: Global: VAR = overwritten
10 VAR= overwritten # Var_Set
11 # expect: Global: delete VAR
12 .undef VAR
13 # expect: Global: ignoring delete 'VAR' as it is not found
14 .undef VAR
15
16 # The variable with the empty name cannot be set at all.
17 # expect: Global: ignoring ' = empty name' as the variable name '${:U}' expands to empty
18 ${:U}= empty name # Var_Set
19 # expect: Global: ignoring ' += empty name' as the variable name '${:U}' expands to empty
20 ${:U}+= empty name # Var_Append
21
22 FROM_CMDLINE= overwritten # Var_Set (ignored)
23
24 # expect: Global: VAR = 1
25 VAR= 1
26 # expect: Global: VAR = 1 2
27 VAR+= 2
28 # expect: Global: VAR = 1 2 3
29 VAR+= 3
30
31 # expect: Pattern for ':M' is "[2]"
32 # expect: Result of ${VAR:M[2]} is "2"
33 .if ${VAR:M[2]} # ModifyWord_Match
34 .endif
35 # expect: Pattern for ':N' is "[2]"
36 # expect: Result of ${VAR:N[2]} is "1 3"
37 .if ${VAR:N[2]} # ModifyWord_NoMatch
38 .endif
39
40 .if ${VAR:S,2,two,} # ParseModifierPart
41 .endif
42
43 # expect: Result of ${VAR:Q} is "1\ 2\ 3"
44 .if ${VAR:Q} # VarQuote
45 .endif
46
47 .if ${VAR:tu:tl:Q} # ApplyModifiers
48 .endif
49
50 # ApplyModifiers, "Got ..."
51 # expect: Result of ${:Mvalu[e]} is "value" (eval, defined)
52 .if ${:Uvalue:${:UM*e}:Mvalu[e]}
53 .endif
54
55 # expect: Global: delete VAR
56 .undef ${:UVAR} # Var_Delete
57
58 # When ApplyModifiers results in an error, this appears in the debug log
59 # as "is error", without surrounding quotes.
60 # expect: Result of ${:unknown} is error (eval, defined)
61 # expect+1: Unknown modifier "unknown"
62 .if ${:Uvariable:unknown}
63 .endif
64
65 # expect+1: Variable "UNDEFINED" is undefined
66 .if ${UNDEFINED}
67 .endif
68
69 # By default, .SHELL is not defined and thus can be set. As soon as it is
70 # accessed, it is initialized in the command line scope (during VarFind),
71 # where it is set to read-only. Assigning to it is ignored.
72 # expect: Command: ignoring '.SHELL = overwritten' as it is read-only
73 .MAKEFLAGS: .SHELL=overwritten
74
75 DYN = ${:U$@} $@ ${@}
76 # expect: Global: DYN = $(.TARGET) $(.TARGET) ${@}
77 DYN := ${DYN}
78
79 .MAKEFLAGS: -d0
80