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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
|
# -*-perl-*-
$description = "Test second expansion in static pattern rules.";
$details = "";
# Test #1: automatic variables.
#
run_make_test(q!
.SECONDEXPANSION:
.DEFAULT: ; @echo '$@'
foo.a foo.b: foo.%: bar.% baz.%
foo.a foo.b: foo.%: biz.% | buz.%
foo.a foo.b: foo.%: $$@.1 \
$$<.2 \
$$(addsuffix .3,$$^) \
$$(addsuffix .4,$$+) \
$$|.5 \
$$*.6
!,
'', 'bar.a
baz.a
biz.a
buz.a
foo.a.1
bar.a.2
bar.a.3
baz.a.3
biz.a.3
bar.a.4
baz.a.4
biz.a.4
buz.a.5
a.6
');
# Test #2: target/pattern -specific variables.
#
run_make_test(q!
.SECONDEXPANSION:
.DEFAULT: ; @echo '$@'
foo.x foo.y: foo.%: $$(%_a) $$($$*_b)
foo.x: x_a := bar
%.x: x_b := baz
!,
'', "bar\nbaz\n");
# Test #3: order of prerequisites.
#
run_make_test(q!
.SECONDEXPANSION:
.DEFAULT: ; @echo '$@'
all: foo.a bar.a baz.a
# Subtest #1
foo.a foo.b: foo.%: foo.%.1; @:
foo.a foo.b: foo.%: foo.%.2
foo.a foo.b: foo.%: foo.%.3
# Subtest #2
bar.a bar.b: bar.%: bar.%.2
bar.a bar.b: bar.%: bar.%.1; @:
bar.a bar.b: bar.%: bar.%.3
# Subtest #3
baz.a baz.b: baz.%: baz.%.1
baz.a baz.b: baz.%: baz.%.2
baz.a baz.b: ; @:
!,
'', 'foo.a.1
foo.a.2
foo.a.3
bar.a.1
bar.a.2
bar.a.3
baz.a.1
baz.a.2
');
# Test #4: Make sure stem triple-expansion does not happen.
#
run_make_test(q!
.SECONDEXPANSION:
foo$$bar: f%r: % $$*.1 ; @echo '$*'
oo$$ba oo$$ba.1: ; @echo '$@'
!,
'', 'oo$ba
oo$ba.1
oo$ba
');
# sv 62324.
# Integrity self check.
run_make_test(q!
.SECONDEXPANSION:
all: bye.x
bye.x: %.x: $$(firstword %.1;
!, '', "#MAKEFILE#:4: *** unterminated call to function 'firstword': missing ')'. Stop.", 512);
#unlink('hello.tsk', 'bye.tsk', 'hello.o', 'hello.q', 'bye.o');
# sv 62706.
# Test that makes avoids second expanding prerequisites of the targets which
# are not built.
# Here, hello.tsk is built and its prerequisites are second expanded.
# bye.tsk is not built and its prerequisites are not second expanded.
# Static pattern rules.
run_make_test(q!
.SECONDEXPANSION:
hello.tsk: %.tsk: %.o $$(info second expansion of $$@ prereqs); $(info $@ from $<)
bye.tsk: %.tsk: %.o $$(info second expansion of $$@ prereqs); $(info $@ from $<)
hello.o: $$(info second expansion of $$@ prereqs); $(info $@)
bye.o: $$(info second expansion of $$@ prereqs); $(info $@)
!, 'hello.tsk',
"second expansion of hello.tsk prereqs
second expansion of hello.o prereqs
hello.o
hello.tsk from hello.o
#MAKE#: 'hello.tsk' is up to date.\n");
# sv 62706.
# Order only prereqs.
run_make_test(q!
.SECONDEXPANSION:
hello.tsk: %.tsk:| %.o $$(info second expansion of $$@ prereqs); $(info $@ from $|)
bye.tsk: %.tsk:| %.o $$(info second expansion of $$@ prereqs); $(info $@ from $|)
hello.o:| $$(info second expansion of $$@ prereqs); $(info $@)
bye.o:| $$(info second expansion of $$@ prereqs); $(info $@)
!, 'hello.tsk',
"second expansion of hello.tsk prereqs
second expansion of hello.o prereqs
hello.o
hello.tsk from hello.o
#MAKE#: 'hello.tsk' is up to date.\n");
# sv 62706.
# Double colon. 1 rule per target.
run_make_test(q!
.SECONDEXPANSION:
hello.tsk:: %.tsk: %.o $$(info second expansion of $$@ prereqs); $(info $@ from $<)
bye.tsk:: %.tsk: %.o $$(info second expansion of $$@ prereqs); $(info $@ from $<)
hello.o:: $$(info second expansion of $$@ prereqs); $(info $@)
bye.o:: $$(info second expansion of $$@ prereqs); $(info $@)
!, 'hello.tsk',
"second expansion of hello.tsk prereqs
second expansion of hello.o prereqs
hello.o
hello.tsk from hello.o
#MAKE#: 'hello.tsk' is up to date.\n");
# sv 62706.
# Double colon. 2 rules per target.
run_make_test(q!
.SECONDEXPANSION:
hello.tsk:: %.tsk: %.o $$(info 1 second expansion of $$@ prereqs); $(info 1 $@ from $<)
hello.tsk:: %.tsk: %.o $$(info 2 second expansion of $$@ prereqs); $(info 2 $@ from $<)
bye.tsk:: %.tsk: %.o $$(info 1 second expansion of $$@ prereqs); $(info 1 $@ from $<)
bye.tsk:: %.tsk: %.o $$(info 2 second expansion of $$@ prereqs); $(info 2 $@ from $<)
hello.o:: $$(info 1 second expansion of $$@ prereqs); $(info 1 $@)
hello.o:: $$(info 2 second expansion of $$@ prereqs); $(info 2 $@)
bye.o:: $$(info 1 second expansion of $$@ prereqs); $(info 1 $@)
bye.o:: $$(info 2 second expansion of $$@ prereqs); $(info 2 $@)
!, 'hello.tsk',
"1 second expansion of hello.tsk prereqs
1 second expansion of hello.o prereqs
1 hello.o
2 second expansion of hello.o prereqs
2 hello.o
1 hello.tsk from hello.o
2 second expansion of hello.tsk prereqs
2 hello.tsk from hello.o
#MAKE#: 'hello.tsk' is up to date.\n");
# sv 62706.
# Test that the prerequisites of 'hello.tsk' are second expanded once.
run_make_test(q!
.SECONDEXPANSION:
all: hello.tsk hello.q
hello.tsk: %.tsk: %.o $$(info second expansion of $$@ prereqs); $(info $@ from $^)
hello.o: $$(info second expansion of $$@ prereqs); $(info $@)
hello.q: %.q: %.tsk $$(info second expansion of $$@ prereqs); $(info $@ from $^)
!, '',
"second expansion of hello.tsk prereqs
second expansion of hello.o prereqs
hello.o
hello.tsk from hello.o
second expansion of hello.q prereqs
hello.q from hello.tsk
#MAKE#: Nothing to be done for 'all'.\n");
unlink('hello.1');
# sv 62706.
# No side effects from second expansion of unrelated rules.
run_make_test(q!
.SECONDEXPANSION:
all: hello.tsk
hello.tsk: %.tsk: %.o; exit 1
hello.o:;
bye.tsk: %.tsk: $$(shell touch hello.1);
!, '',
"exit 1
#MAKE#: *** [#MAKEFILE#:4: hello.tsk] Error 1\n", 512);
# sv 62706.
# Second expansion of intermediate prerequisites.
# The rule to build hello.x is static pattern.
# .SECONDARY marks hello.x as intermediate.
# Test that $$(deps) is secondary expanded.
run_make_test(q!
deps:=hello.h
.SECONDEXPANSION:
.SECONDARY: hello.x
all: hello.x
hello.x: %.x: $$(deps); $(info $@)
hello.h:; $(info $@)
!, '', "hello.h\nhello.x\n#MAKE#: Nothing to be done for 'all'.\n");
# This tells the test driver that the perl test script executed properly.
1;
|