2021-06-25 18:16:24 +00:00
|
|
|
# $NetBSD: varparse-dynamic.mk,v 1.5 2021/02/22 20:38:55 rillig Exp $
|
2020-09-05 16:11:04 +00:00
|
|
|
|
|
|
|
# Before 2020-07-27, there was an off-by-one error in Var_Parse that skipped
|
|
|
|
# the last character in the variable name.
|
|
|
|
# To trigger the bug, the variable must not be defined.
|
|
|
|
.if ${.TARGET} # exact match, may be undefined
|
|
|
|
.endif
|
|
|
|
.if ${.TARGEX} # 1 character difference, must be defined
|
|
|
|
.endif
|
|
|
|
.if ${.TARGXX} # 2 characters difference, must be defined
|
|
|
|
.endif
|
|
|
|
|
2020-11-07 19:39:21 +00:00
|
|
|
# When a dynamic variable (such as .TARGET) is evaluated in the global
|
2021-02-11 01:51:11 +00:00
|
|
|
# scope, it is not yet ready to be expanded. Therefore the complete
|
2020-11-07 19:39:21 +00:00
|
|
|
# expression is returned as the variable value, hoping that it can be
|
|
|
|
# resolved at a later point.
|
|
|
|
#
|
2021-06-25 18:16:24 +00:00
|
|
|
# This test covers the code in Var_Parse that deals with DEF_UNDEF but not
|
|
|
|
# DEF_DEFINED for dynamic variables.
|
2020-11-07 19:39:21 +00:00
|
|
|
.if ${.TARGET:S,^,,} != "\${.TARGET:S,^,,}"
|
|
|
|
. error
|
|
|
|
.endif
|
|
|
|
|
2021-02-11 01:51:11 +00:00
|
|
|
# If a dynamic variable is expanded in a non-local scope, the expression
|
2021-01-14 01:24:34 +00:00
|
|
|
# based on this variable is not expanded. But there may be nested variable
|
|
|
|
# expressions in the modifiers, and these are kept unexpanded as well.
|
|
|
|
.if ${.TARGET:M${:Ufallback}} != "\${.TARGET:M\${:Ufallback}}"
|
|
|
|
. error
|
|
|
|
.endif
|
|
|
|
.if ${.TARGET:M${UNDEF}} != "\${.TARGET:M\${UNDEF}}"
|
|
|
|
. error
|
|
|
|
.endif
|
|
|
|
|
2020-09-05 16:11:04 +00:00
|
|
|
all:
|
|
|
|
@:
|