forloop.mk revision 302408
1# $Id: forloop.mk,v 1.1.1.1 2014/08/30 18:57:18 sjg Exp $ 2 3all: for-loop 4 5LIST = one "two and three" four "five" 6 7.if make(for-fail) 8for-fail: 9 10XTRA_LIST = xtra 11.else 12 13.for x in ${LIST} 14X!= echo 'x=$x' >&2; echo 15.endfor 16 17CFL = -I/this -I"This or that" -Ithat "-DTHIS=\"this and that\"" 18cfl= 19.for x in ${CFL} 20X!= echo 'x=$x' >&2; echo 21.if empty(cfl) 22cfl= $x 23.else 24cfl+= $x 25.endif 26.endfor 27X!= echo 'cfl=${cfl}' >&2; echo 28 29.if ${cfl} != ${CFL} 30.error ${.newline}'${cfl}' != ${.newline}'${CFL}' 31.endif 32 33.for a b in ${EMPTY} 34X!= echo 'a=$a b=$b' >&2; echo 35.endfor 36.endif 37 38.for a b in ${LIST} ${LIST:tu} ${XTRA_LIST} 39X!= echo 'a=$a b=$b' >&2; echo 40.endfor 41 42for-loop: 43 @echo We expect an error next: 44 @(cd ${.CURDIR} && ${.MAKE} -f ${MAKEFILE} for-fail) && \ 45 { echo "Oops that should have failed!"; exit 1; } || echo OK 46