2020-11-20 03:54:37 +00:00
|
|
|
# $NetBSD: forloop.mk,v 1.7 2020/11/03 17:37:57 rillig Exp $
|
2012-06-25 22:20:51 +00:00
|
|
|
|
|
|
|
all: for-loop
|
|
|
|
|
2020-11-07 19:39:21 +00:00
|
|
|
LIST= one "two and three" four "five"
|
2012-06-25 22:20:51 +00:00
|
|
|
|
|
|
|
.if make(for-fail)
|
|
|
|
for-fail:
|
|
|
|
|
2020-11-07 19:39:21 +00:00
|
|
|
XTRA_LIST= xtra
|
2012-06-25 22:20:51 +00:00
|
|
|
.else
|
|
|
|
|
2020-11-07 19:39:21 +00:00
|
|
|
. for x in ${LIST}
|
2020-11-20 03:54:37 +00:00
|
|
|
. info x=$x
|
2020-11-07 19:39:21 +00:00
|
|
|
. endfor
|
2012-06-25 22:20:51 +00:00
|
|
|
|
2020-11-07 19:39:21 +00:00
|
|
|
CFL= -I/this -I"This or that" -Ithat "-DTHIS=\"this and that\""
|
2012-06-25 22:20:51 +00:00
|
|
|
cfl=
|
2020-11-07 19:39:21 +00:00
|
|
|
. for x in ${CFL}
|
2020-11-20 03:54:37 +00:00
|
|
|
. info x=$x
|
2020-11-07 19:39:21 +00:00
|
|
|
. if empty(cfl)
|
|
|
|
cfl= $x
|
|
|
|
. else
|
|
|
|
cfl+= $x
|
|
|
|
. endif
|
|
|
|
. endfor
|
2020-11-20 03:54:37 +00:00
|
|
|
. info cfl=${cfl}
|
2020-11-07 19:39:21 +00:00
|
|
|
|
|
|
|
. if ${cfl} != ${CFL}
|
2020-11-20 03:54:37 +00:00
|
|
|
. error ${.newline}${cfl} != ${.newline}${CFL}
|
2020-11-07 19:39:21 +00:00
|
|
|
. endif
|
|
|
|
|
|
|
|
. for a b in ${EMPTY}
|
2020-11-20 03:54:37 +00:00
|
|
|
. info a=$a b=$b
|
2020-11-07 19:39:21 +00:00
|
|
|
. endfor
|
2020-05-20 19:34:48 +00:00
|
|
|
|
|
|
|
# Since at least 1993, iteration stops at the first newline.
|
|
|
|
# Back then, the .newline variable didn't exist, therefore it was unlikely
|
2020-09-05 16:11:04 +00:00
|
|
|
# that a newline ever occurred.
|
2020-11-07 19:39:21 +00:00
|
|
|
. for var in a${.newline}b${.newline}c
|
2020-11-20 03:54:37 +00:00
|
|
|
. info newline-item=(${var})
|
2020-11-07 19:39:21 +00:00
|
|
|
. endfor
|
2020-05-20 19:34:48 +00:00
|
|
|
|
|
|
|
.endif # for-fail
|
2012-06-25 22:20:51 +00:00
|
|
|
|
|
|
|
.for a b in ${LIST} ${LIST:tu} ${XTRA_LIST}
|
2020-11-20 03:54:37 +00:00
|
|
|
. info a=$a b=$b
|
2012-06-25 22:20:51 +00:00
|
|
|
.endfor
|
|
|
|
|
|
|
|
for-loop:
|
|
|
|
@echo We expect an error next:
|
|
|
|
@(cd ${.CURDIR} && ${.MAKE} -f ${MAKEFILE} for-fail) && \
|
|
|
|
{ echo "Oops that should have failed!"; exit 1; } || echo OK
|