vardebug.mk revision 1.8       1 # $NetBSD: vardebug.mk,v 1.8 2023/06/01 20:56:35 rillig Exp $
      2 #
      3 # Demonstrates the debugging output for var.c.
      4 
      5 .MAKEFLAGS: -dv FROM_CMDLINE=
      6 
      7 VAR=		added		# VarAdd
      8 VAR=		overwritten	# Var_Set
      9 .undef VAR			# Var_Delete (found)
     10 .undef VAR			# Var_Delete (not found)
     11 
     12 # The variable with the empty name cannot be set at all.
     13 ${:U}=		empty name	# Var_Set
     14 ${:U}+=		empty name	# Var_Append
     15 
     16 FROM_CMDLINE=	overwritten	# Var_Set (ignored)
     17 
     18 VAR=		1
     19 VAR+=		2
     20 VAR+=		3
     21 
     22 .if ${VAR:M[2]}			# ModifyWord_Match
     23 .endif
     24 .if ${VAR:N[2]}			# ModifyWord_NoMatch (no debug output)
     25 .endif
     26 
     27 .if ${VAR:S,2,two,}		# ParseModifierPart
     28 .endif
     29 
     30 .if ${VAR:Q}			# VarQuote
     31 .endif
     32 
     33 .if ${VAR:tu:tl:Q}		# ApplyModifiers
     34 .endif
     35 
     36 # ApplyModifiers, "Got ..."
     37 .if ${:Uvalue:${:UM*e}:Mvalu[e]}
     38 .endif
     39 
     40 .undef ${:UVAR}			# Var_Delete
     41 
     42 # When ApplyModifiers results in an error, this appears in the debug log
     43 # as "is error", without surrounding quotes.
     44 # expect+2: Malformed conditional (${:Uvariable:unknown})
     45 # expect+1: Unknown modifier "unknown"
     46 .if ${:Uvariable:unknown}
     47 .endif
     48 
     49 # XXX: The error message is "Malformed conditional", which is wrong.
     50 # The condition is syntactically fine, it just contains an undefined variable.
     51 #
     52 # There is a specialized error message for "Undefined variable", but as of
     53 # 2020-08-08, that is not covered by any unit tests.  It might even be
     54 # unreachable.
     55 # expect+1: Malformed conditional (${UNDEFINED})
     56 .if ${UNDEFINED}
     57 .endif
     58 
     59 # By default, .SHELL is not defined and thus can be set.  As soon as it is
     60 # accessed, it is initialized in the command line scope (during VarFind),
     61 # where it is set to read-only.  Assigning to it is ignored.
     62 .MAKEFLAGS: .SHELL=overwritten
     63 
     64 .MAKEFLAGS: -d0
     65 
     66 all:
     67 	@:
     68