1# $NetBSD: cond-late.mk,v 1.2 2020/07/25 20:37:46 rillig Exp $ 2# 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. 7# 8# Because of this, variables that are used in these lazy conditions 9# should not contain double-quotes, or the parser will probably fail. 10# 11# They should also not contain operators like == or <, since these are 12# actually interpreted as these operators. This is demonstrated below. 13# 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. 17 18all: cond-literal 19 20COND.true= "yes" == "yes" 21COND.false= "yes" != "yes" 22 23cond-literal: 24 @echo ${ ${COND.true} :?yes:no} 25 @echo ${ ${COND.false} :?yes:no} 26 27VAR+= ${${UNDEF} != "no":?:} 28.if empty(VAR:Mpattern) 29.endif 30