1 # $NetBSD: cond-late.mk,v 1.3 2020/11/15 14:07:53 rillig Exp $
3 # Using the :? modifier, variable expressions can contain conditional
4 # expressions that are evaluated late, at expansion time.
6 # Any variables appearing in these
7 # conditions are expanded before parsing the condition. This is
8 # different from many other places.
10 # Because of this, variables that are used in these lazy conditions
11 # should not contain double-quotes, or the parser will probably fail.
13 # They should also not contain operators like == or <, since these are
14 # actually interpreted as these operators. This is demonstrated below.
19 COND.true= "yes" == "yes"
20 COND.false= "yes" != "yes"
22 # If the order of evaluation were to change to first parse the condition
23 # and then expand the variables, the output would change from the
24 # current "yes no" to "yes yes", since both variables are non-empty.
26 @echo ${ ${COND.true} :?yes:no}
27 @echo ${ ${COND.false} :?yes:no}
29 VAR+= ${${UNDEF} != "no":?:}
30 .if empty(VAR:Mpattern)