cond-late.mk revision 1.3
11.3Srillig# $NetBSD: cond-late.mk,v 1.3 2020/11/15 14:07:53 rillig Exp $ 21.1Srillig# 31.1Srillig# Using the :? modifier, variable expressions can contain conditional 41.3Srillig# expressions that are evaluated late, at expansion time. 51.3Srillig# 61.3Srillig# Any variables appearing in these 71.1Srillig# conditions are expanded before parsing the condition. This is 81.1Srillig# different from many other places. 91.1Srillig# 101.1Srillig# Because of this, variables that are used in these lazy conditions 111.1Srillig# should not contain double-quotes, or the parser will probably fail. 121.1Srillig# 131.1Srillig# They should also not contain operators like == or <, since these are 141.1Srillig# actually interpreted as these operators. This is demonstrated below. 151.1Srillig# 161.1Srillig 171.2Srilligall: cond-literal 181.2Srillig 191.1SrilligCOND.true= "yes" == "yes" 201.1SrilligCOND.false= "yes" != "yes" 211.1Srillig 221.3Srillig# If the order of evaluation were to change to first parse the condition 231.3Srillig# and then expand the variables, the output would change from the 241.3Srillig# current "yes no" to "yes yes", since both variables are non-empty. 251.2Srilligcond-literal: 261.1Srillig @echo ${ ${COND.true} :?yes:no} 271.1Srillig @echo ${ ${COND.false} :?yes:no} 281.2Srillig 291.2SrilligVAR+= ${${UNDEF} != "no":?:} 301.2Srillig.if empty(VAR:Mpattern) 311.2Srillig.endif 32