1 # $NetBSD: cond-late.mk,v 1.1 2020/04/29 23:15:21 rillig Exp $
3 # Using the :? modifier, variable expressions can contain conditional
4 # expressions that are evaluated late. Any variables appearing in these
5 # conditions are expanded before parsing the condition. This is
6 # different from many other places.
8 # Because of this, variables that are used in these lazy conditions
9 # should not contain double-quotes, or the parser will probably fail.
11 # They should also not contain operators like == or <, since these are
12 # actually interpreted as these operators. This is demonstrated below.
14 # If the order of evaluation were to change to first parse the condition
15 # and then expand the variables, the output would change from the
16 # current "yes no" to "yes yes", since both variables are non-empty.
18 COND.true= "yes" == "yes"
19 COND.false= "yes" != "yes"
22 @echo ${ ${COND.true} :?yes:no}
23 @echo ${ ${COND.false} :?yes:no}