2021-03-14 20:14:15 +03:00
|
|
|
# $NetBSD: varmod-remember.mk,v 1.5 2021/03/14 17:14:15 rillig Exp $
|
2020-08-16 15:07:50 +03:00
|
|
|
#
|
2020-08-16 17:25:16 +03:00
|
|
|
# Tests for the :_ modifier, which saves the current variable value
|
|
|
|
# in the _ variable or another, to be used later again.
|
2020-08-16 15:07:50 +03:00
|
|
|
|
2021-03-14 20:07:11 +03:00
|
|
|
.if ${1 2 3:L:_:@var@${_}@} != "1 2 3 1 2 3 1 2 3"
|
|
|
|
. error
|
|
|
|
.endif
|
|
|
|
|
2020-08-23 18:18:43 +03:00
|
|
|
# In the parameterized form, having the variable name on the right side of
|
|
|
|
# the = assignment operator is confusing. In almost all other situations
|
|
|
|
# the variable name is on the left-hand side of the = operator. Luckily
|
|
|
|
# this modifier is only rarely needed.
|
2021-03-14 20:07:11 +03:00
|
|
|
.if ${1 2 3:L:@var@${var:_=SAVED:}@} != "1 2 3"
|
|
|
|
. error
|
|
|
|
.elif ${SAVED} != "3"
|
|
|
|
. error
|
|
|
|
.endif
|
|
|
|
|
2021-03-14 20:14:15 +03:00
|
|
|
# The ':_' modifier takes a variable name as optional argument. This variable
|
|
|
|
# name can refer to other variables, though this was rather an implementation
|
|
|
|
# oversight than an intended feature. The variable name stops at the first
|
|
|
|
# '}' or ')' and thus cannot use the usual form ${VARNAME} of long variable
|
|
|
|
# names.
|
|
|
|
S= INDIRECT_VARNAME
|
|
|
|
.if ${value:L:@var@${var:_=$S}@} != "value"
|
|
|
|
. error
|
|
|
|
.elif ${INDIRECT_VARNAME} != "value"
|
|
|
|
. error
|
|
|
|
.endif
|
|
|
|
|
2020-08-16 15:07:50 +03:00
|
|
|
all:
|