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