1*d5e0a182SSimon J. Gerraty# $NetBSD: var-scope-local-legacy.mk,v 1.3 2023/12/17 14:07:22 rillig Exp $
29f45a3c8SSimon J. Gerraty#
39f45a3c8SSimon J. Gerraty# Tests for legacy target-local variables, such as ${<F} or ${@D}.
49f45a3c8SSimon J. Gerraty
5*d5e0a182SSimon J. Gerraty
6*d5e0a182SSimon J. Gerraty# In the global or command line scopes, the legacy forms are not recognized,
7*d5e0a182SSimon J. Gerraty# as the target-specific variables are not available either.  The expressions
8*d5e0a182SSimon J. Gerraty# are retained so that they can be resolved later, in the target scope.
9*d5e0a182SSimon J. Gerraty.if "${@D}" != "\${@D}"
10*d5e0a182SSimon J. Gerraty.  error
11*d5e0a182SSimon J. Gerraty.endif
12*d5e0a182SSimon J. Gerraty
13*d5e0a182SSimon J. Gerraty# It's possible to define variables of the legacy name in the global or
14*d5e0a182SSimon J. Gerraty# command line scope, and they override the target-local variables, leading to
15*d5e0a182SSimon J. Gerraty# unnecessary confusion.
16*d5e0a182SSimon J. Gerraty@D=	global-value
17*d5e0a182SSimon J. Gerraty.if "${@D}" != "global-value"
18*d5e0a182SSimon J. Gerraty.  error
19*d5e0a182SSimon J. Gerraty.endif
20*d5e0a182SSimon J. Gerraty
21*d5e0a182SSimon J. Gerraty
224fde40d9SSimon J. Gerratyall: .PHONY
234fde40d9SSimon J. Gerraty	# Only variables of length 2 can be legacy, this one cannot.
244fde40d9SSimon J. Gerraty	: LEN4=${LEN4:Uundef}_
254fde40d9SSimon J. Gerraty	# The second character of the name must be 'D' or 'F'.
264fde40d9SSimon J. Gerraty	: XY=${XY:Uundef}_
274fde40d9SSimon J. Gerraty	# The first character must name one of the 7 predefined local
284fde40d9SSimon J. Gerraty	# variables, 'A' is not such a character.
294fde40d9SSimon J. Gerraty	: AF=${AF:Uundef}_
304fde40d9SSimon J. Gerraty	# The variable '.MEMBER' is undefined, therefore '%D' and '%F' are
314fde40d9SSimon J. Gerraty	# undefined as well.
324fde40d9SSimon J. Gerraty	: %D=${%D:Uundef}_ %F=${%F:Uundef}_
33*d5e0a182SSimon J. Gerraty	# The directory name of the target is shadowed by the global variable,
34*d5e0a182SSimon J. Gerraty	# it would be '.' otherwise.  The basename is 'all'.
354fde40d9SSimon J. Gerraty	: @D=${@D:Uundef}_ @F=${@F:Uundef}_
36