Home | History | Annotate | Line # | Download | only in unit-tests
dep-var.mk revision 1.2
      1 # $NetBSD: dep-var.mk,v 1.2 2020/09/03 19:10:56 rillig Exp $
      2 #
      3 # Tests for variable references in dependency declarations.
      4 #
      5 # Uh oh, this feels so strange that probably nobody uses it. But it seems to
      6 # be the only way to reach the lower half of SuffExpandChildren.
      7 
      8 # XXX: The -dv log says:
      9 #	Var_Parse: ${UNDEF1} with VARE_UNDEFERR|VARE_WANTRES
     10 # but no error message is generated for this line.
     11 # The variable expression ${UNDEF1} simply expands to an empty string.
     12 all: ${UNDEF1}
     13 
     14 # Using a double dollar in order to circumvent immediate variable expansion
     15 # feels like unintended behavior.  At least the manual page says nothing at
     16 # all about defined or undefined variables in dependency lines.
     17 #
     18 # At the point where the expression ${DEF2} is expanded, the variable DEF2
     19 # is defined, so everything's fine.
     20 all: $${DEF2} a-$${DEF2}-b
     21 
     22 # This variable is not defined at all.
     23 # XXX: The -dv log says:
     24 #	Var_Parse: ${UNDEF3} with VARE_UNDEFERR|VARE_WANTRES
     25 # but no error message is generated for this line, just like for UNDEF1.
     26 # The variable expression ${UNDEF3} simply expands to an empty string.
     27 all: $${UNDEF3}
     28 
     29 UNDEF1=	undef1
     30 DEF2=	def2
     31 
     32 undef1 def2 a-def2-b:
     33 	@echo ${.TARGET}
     34