dir.mk revision 1.9 1 # $NetBSD: dir.mk,v 1.9 2021/01/23 10:48:49 rillig Exp $
2 #
3 # Tests for dir.c.
4
5 .MAKEFLAGS: -m / # hide /usr/share/mk from the debug log
6
7 # Dependency lines may use braces for expansion.
8 # See DirExpandCurly for the implementation.
9 all: {one,two,three}
10
11 # XXX: The above dependency line is parsed as a single node named
12 # "{one,two,three}". There are no individual targets "one", "two", "three"
13 # yet. The node exists but is not a target since it never appeared
14 # on the left-hand side of a dependency operator. However, it is listed
15 # in .ALLTARGETS (which lists all nodes, not only targets).
16 .if target(one)
17 . error
18 .endif
19 .if target({one,two,three})
20 . error
21 .endif
22 .if ${.ALLTARGETS:M{one,two,three}} != "{one,two,three}"
23 . error
24 .endif
25
26 one:
27 : 1
28 two:
29 : 2
30 three:
31 : 3
32
33 # The braces may start in the middle of a word.
34 all: f{our,ive}
35
36 four:
37 : 4
38 five:
39 : 5
40 six:
41 : 6
42
43 # Nested braces work as expected since 2020-07-31 19:06 UTC.
44 # They had been broken at least since 2003-01-01, probably even longer.
45 all: {{thi,fou}r,fif}teen
46
47 thirteen:
48 : 13
49 fourteen:
50 : 14
51 fifteen:
52 : 15
53
54 # There may be multiple brace groups side by side.
55 all: {pre-,}{patch,configure}
56
57 pre-patch patch pre-configure configure:
58 : $@
59
60 # Empty pieces are allowed in the braces.
61 all: {fetch,extract}{,-post}
62
63 fetch fetch-post extract extract-post:
64 : $@
65
66 # The expansions may have duplicates.
67 # When the source of the dependency line is expanded later, each of the
68 # expanded words will be the same.
69 all: dup-{1,1,1,1,1,1,1}
70
71 dup-1:
72 : $@
73
74 # Other than in Bash, the braces are also expanded if there is no comma.
75 all: {{{{{{{{{{single-word}}}}}}}}}}
76
77 single-word:
78 : $@
79
80 # Demonstrate debug logging for filename expansion, especially curly braces.
81 .MAKEFLAGS: -dd
82 # The below line does not call SearchPath_Expand yet.
83 # It is expanded only when necessary, that is, when the 'debug' target is
84 # indeed made.
85 debug: {{thi,fou}r,fif}twen
86 # Therefore, keep the debug logging active.
87
88 .PHONY: one two three four five six
89 .PHONY: thirteen fourteen fifteen
90 .PHONY: single-word
91 .PHONY: pre-patch patch pre-configure configure
92 .PHONY: fetch fetch-post extract extract-post
93 .PHONY: dup-1 single-word
94 .PHONY: all
95