var-scope-local-legacy.mk revision 1.3 1 1.3 rillig # $NetBSD: var-scope-local-legacy.mk,v 1.3 2023/12/17 14:07:22 rillig Exp $
2 1.1 rillig #
3 1.1 rillig # Tests for legacy target-local variables, such as ${<F} or ${@D}.
4 1.1 rillig
5 1.3 rillig
6 1.3 rillig # In the global or command line scopes, the legacy forms are not recognized,
7 1.3 rillig # as the target-specific variables are not available either. The expressions
8 1.3 rillig # are retained so that they can be resolved later, in the target scope.
9 1.3 rillig .if "${@D}" != "\${@D}"
10 1.3 rillig . error
11 1.3 rillig .endif
12 1.3 rillig
13 1.3 rillig # It's possible to define variables of the legacy name in the global or
14 1.3 rillig # command line scope, and they override the target-local variables, leading to
15 1.3 rillig # unnecessary confusion.
16 1.3 rillig @D= global-value
17 1.3 rillig .if "${@D}" != "global-value"
18 1.3 rillig . error
19 1.3 rillig .endif
20 1.3 rillig
21 1.3 rillig
22 1.2 rillig all: .PHONY
23 1.2 rillig # Only variables of length 2 can be legacy, this one cannot.
24 1.2 rillig : LEN4=${LEN4:Uundef}_
25 1.2 rillig # The second character of the name must be 'D' or 'F'.
26 1.2 rillig : XY=${XY:Uundef}_
27 1.2 rillig # The first character must name one of the 7 predefined local
28 1.2 rillig # variables, 'A' is not such a character.
29 1.2 rillig : AF=${AF:Uundef}_
30 1.2 rillig # The variable '.MEMBER' is undefined, therefore '%D' and '%F' are
31 1.2 rillig # undefined as well.
32 1.2 rillig : %D=${%D:Uundef}_ %F=${%F:Uundef}_
33 1.3 rillig # The directory name of the target is shadowed by the global variable,
34 1.3 rillig # it would be '.' otherwise. The basename is 'all'.
35 1.2 rillig : @D=${@D:Uundef}_ @F=${@F:Uundef}_
36