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