1 # $Id: varmisc.mk,v 1.9 2017/02/01 18:44:54 sjg Exp $
3 # Miscellaneous variable tests.
5 all: unmatched_var_paren D_true U_true D_false U_false Q_lhs Q_rhs NQ_none \
9 @echo ${foo::=foo-text}
11 True = ${echo true >&2:L:sh}TRUE
12 False= ${echo false >&2:L:sh}FALSE
18 @echo :U skipped when var set
19 @echo ${VSET:U${False}}
22 @echo :D skipped if var undef
23 @echo ${UNDEF:D${False}}
26 @echo :U expanded when var undef
27 @echo ${UNDEF:U${True}}
30 @echo :D expanded when var set
31 @echo ${VSET:D${True}}
34 @echo :? only lhs when value true
35 @echo ${1:L:?${True}:${False}}
38 @echo :? only rhs when value false
39 @echo ${0:L:?${True}:${False}}
42 @echo do not evaluate or expand :? if discarding
43 @echo ${VSET:U${1:L:?${True}:${False}}}
47 # slightly contorted syntax to use utc via variable
49 @echo ${year=%Y month=%m day=%d:L:gmtime=1459494000}
50 @echo date=${%Y%m%d:L:${gmtime=${April1}:L}}
52 # big jumps to handle 3 digits per step
53 M_cmpv.units = 1 1000 1000000
54 M_cmpv = S,., ,g:_:range:@i@+ $${_:[-$$i]} \* $${M_cmpv.units:[$$i]}@:S,^,expr 0 ,1:sh
57 cmpv.only = target specific vars
60 @echo Version=${Version} == ${Version:${M_cmpv}}
61 @echo Literal=3.4.5 == ${3.4.5:L:${M_cmpv}}
62 @echo We have ${${.TARGET:T}.only}