blob: 0162ffa27a072b5047377ff19f730bf8f26aa1bb (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# $NetBSD: forloop.mk,v 1.6 2020/10/24 08:50:17 rillig Exp $
all: for-loop
LIST= one "two and three" four "five"
.if make(for-fail)
for-fail:
XTRA_LIST= xtra
.else
. for x in ${LIST}
X!= echo 'x=$x' >&2; echo
. endfor
CFL= -I/this -I"This or that" -Ithat "-DTHIS=\"this and that\""
cfl=
. for x in ${CFL}
X!= echo 'x=$x' >&2; echo
. if empty(cfl)
cfl= $x
. else
cfl+= $x
. endif
. endfor
X!= echo 'cfl=${cfl}' >&2; echo
. if ${cfl} != ${CFL}
. error ${.newline}'${cfl}' != ${.newline}'${CFL}'
. endif
. for a b in ${EMPTY}
X!= echo 'a=$a b=$b' >&2; echo
. endfor
# Since at least 1993, iteration stops at the first newline.
# Back then, the .newline variable didn't exist, therefore it was unlikely
# that a newline ever occurred.
. for var in a${.newline}b${.newline}c
X!= echo 'newline-item=('${var:Q}')' 1>&2; echo
. endfor
.endif # for-fail
.for a b in ${LIST} ${LIST:tu} ${XTRA_LIST}
X!= echo 'a=$a b=$b' >&2; echo
.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
|