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