cond-late.mk revision 1.2
11.2Srillig# $NetBSD: cond-late.mk,v 1.2 2020/07/25 20:37:46 rillig Exp $ 21.1Srillig# 31.1Srillig# Using the :? modifier, variable expressions can contain conditional 41.1Srillig# expressions that are evaluated late. Any variables appearing in these 51.1Srillig# conditions are expanded before parsing the condition. This is 61.1Srillig# different from many other places. 71.1Srillig# 81.1Srillig# Because of this, variables that are used in these lazy conditions 91.1Srillig# should not contain double-quotes, or the parser will probably fail. 101.1Srillig# 111.1Srillig# They should also not contain operators like == or <, since these are 121.1Srillig# actually interpreted as these operators. This is demonstrated below. 131.1Srillig# 141.1Srillig# If the order of evaluation were to change to first parse the condition 151.1Srillig# and then expand the variables, the output would change from the 161.1Srillig# current "yes no" to "yes yes", since both variables are non-empty. 171.1Srillig 181.2Srilligall: cond-literal 191.2Srillig 201.1SrilligCOND.true= "yes" == "yes" 211.1SrilligCOND.false= "yes" != "yes" 221.1Srillig 231.2Srilligcond-literal: 241.1Srillig @echo ${ ${COND.true} :?yes:no} 251.1Srillig @echo ${ ${COND.false} :?yes:no} 261.2Srillig 271.2SrilligVAR+= ${${UNDEF} != "no":?:} 281.2Srillig.if empty(VAR:Mpattern) 291.2Srillig.endif 30