1 1.5 rillig # $NetBSD: deptgt-end.mk,v 1.5 2020/09/23 03:06:38 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.1 rillig all: 22 1.4 rillig : $@ '$${VAR}' 23 1.4 rillig ... 24 1.4 rillig : $@ '$${VAR}' deferred 25 1.4 rillig # Oops: The deferred command must not be expanded twice. 26 1.4 rillig # The Var_Subst in Compat_RunCommand looks suspicious. 27 1.5 rillig # The Var_Subst in JobSaveCommand looks suspicious. 28 1.4 rillig 29 1.4 rillig # The deferred commands are run in the order '.END .BEGIN all'. 30 1.4 rillig # This may be unexpected at first since the natural order would be 31 1.4 rillig # '.BEGIN all .END', but it is implemented correctly. 32 1.4 rillig # 33 1.4 rillig # At the point where the commands of a node with deferred commands are run, 34 1.4 rillig # the deferred commands are appended to the commands of the .END node. 35 1.4 rillig # This happens in Compat_RunCommand, and to prevent an endless loop, the 36 1.4 rillig # deferred commands of the .END node itself are not appended to itself. 37 1.4 rillig # Instead, the deferred commands of the .END node are run as if they were 38 1.4 rillig # immediate commands. 39