Home | History | Annotate | Line # | Download | only in unit-tests
deptgt-end.mk revision 1.5
      1 # $NetBSD: deptgt-end.mk,v 1.5 2020/09/23 03:06:38 rillig Exp $
      2 #
      3 # Tests for the special target .END in dependency declarations,
      4 # which is run after making the desired targets.
      5 
      6 VAR=	Should not be expanded.
      7 
      8 .BEGIN:
      9 	: $@ '$${VAR}'
     10 	...
     11 	: $@ '$${VAR}' deferred
     12 # Oops: The deferred command must not be expanded twice.
     13 # The Var_Subst in Compat_RunCommand looks suspicious.
     14 # The Var_Subst in JobSaveCommand looks suspicious.
     15 
     16 .END:
     17 	: $@ '$${VAR}'
     18 	...
     19 	: $@ '$${VAR}' deferred
     20 
     21 all:
     22 	: $@ '$${VAR}'
     23 	...
     24 	: $@ '$${VAR}' deferred
     25 # Oops: The deferred command must not be expanded twice.
     26 # The Var_Subst in Compat_RunCommand looks suspicious.
     27 # The Var_Subst in JobSaveCommand looks suspicious.
     28 
     29 # The deferred commands are run in the order '.END .BEGIN all'.
     30 # This may be unexpected at first since the natural order would be
     31 # '.BEGIN all .END', but it is implemented correctly.
     32 #
     33 # At the point where the commands of a node with deferred commands are run,
     34 # the deferred commands are appended to the commands of the .END node.
     35 # This happens in Compat_RunCommand, and to prevent an endless loop, the
     36 # deferred commands of the .END node itself are not appended to itself.
     37 # Instead, the deferred commands of the .END node are run as if they were
     38 # immediate commands.
     39