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