VirtualBox

source: kBuild/trunk/src/kmk/tests/scripts/features/se_implicit

Last change on this file was 3140, checked in by bird, 7 years ago

kmk: Merged in changes from GNU make 4.2.1 (2e55f5e4abdc0e38c1d64be703b446695e70b3b6 / https://git.savannah.gnu.org/git/make.git).

  • Property svn:eol-style set to LF
File size: 3.6 KB
Line 
1# -*-perl-*-
2$description = "Test second expansion in ordinary rules.";
3
4$details = "";
5
6use Cwd;
7
8$dir = cwd;
9$dir =~ s,.*/([^/]+)$,../$1,;
10
11
12# Test #1: automatic variables.
13#
14run_make_test(q!
15.SECONDEXPANSION:
16.DEFAULT: ; @echo '$@'
17
18foo.a: bar baz
19
20foo.a: biz | buz
21
22foo.%: 1.$$@ \
23 2.$$< \
24 $$(addprefix 3.,$$^) \
25 $$(addprefix 4.,$$+) \
26 5.$$| \
27 6.$$*
28 @:
29
301.foo.a \
312.bar \
323.bar \
333.baz \
343.biz \
354.bar \
364.baz \
374.biz \
385.buz \
396.a:
40 @echo '$@'
41
42!,
43'-j1',
44'1.foo.a
452.bar
463.bar
473.baz
483.biz
494.bar
504.baz
514.biz
525.buz
536.a
54bar
55baz
56biz
57buz
58');
59
60
61# Test #2: target/pattern -specific variables.
62#
63run_make_test(q!
64.SECONDEXPANSION:
65foo.x:
66
67foo.%: $$(%_a) $$(%_b) bar
68 @:
69
70foo.x: x_a := bar
71
72%.x: x_b := baz
73
74bar baz: ; @echo '$@'
75!,
76 '', "bar\nbaz\n");
77
78
79# Test #3: order of prerequisites.
80#
81run_make_test(q!
82.SECONDEXPANSION:
83.DEFAULT: ; @echo '$@'
84
85all: foo bar baz
86
87
88# Subtest #1
89#
90%oo: %oo.1; @:
91
92foo: foo.2
93
94foo: foo.3
95
96foo.1: ; @echo '$@'
97
98
99# Subtest #2
100#
101bar: bar.2
102
103%ar: %ar.1; @:
104
105bar: bar.3
106
107bar.1: ; @echo '$@'
108
109
110# Subtest #3
111#
112baz: baz.1
113
114baz: baz.2
115
116%az: ; @:
117!,
118 '-j1',
119'foo.1
120foo.2
121foo.3
122bar.1
123bar.2
124bar.3
125baz.1
126baz.2
127');
128
129
130# Test #4: stem splitting logic.
131#
132run_make_test(q!
133.SECONDEXPANSION:
134$(dir)/tmp/bar.o:
135
136$(dir)/tmp/foo/bar.c: ; @echo '$@'
137$(dir)/tmp/bar/bar.c: ; @echo '$@'
138foo.h: ; @echo '$@'
139
140%.o: $$(addsuffix /%.c,foo bar) foo.h
141 @echo '$@: {$<} $^'
142!,
143 "dir=$dir", "$dir/tmp/foo/bar.c
144$dir/tmp/bar/bar.c
145foo.h
146$dir/tmp/bar.o: {$dir/tmp/foo/bar.c} $dir/tmp/foo/bar.c $dir/tmp/bar/bar.c foo.h
147");
148
149
150# Test #5: stem splitting logic and order-only prerequisites.
151#
152run_make_test(q!
153.SECONDEXPANSION:
154$(dir)/tmp/foo.o: $(dir)/tmp/foo.c
155$(dir)/tmp/foo.c: ; @echo '$@'
156bar.h: ; @echo '$@'
157
158%.o: %.c|bar.h
159 @echo '$@: {$<} {$|} $^'
160
161!,
162 "dir=$dir", "$dir/tmp/foo.c
163bar.h
164$dir/tmp/foo.o: {$dir/tmp/foo.c} {bar.h} $dir/tmp/foo.c
165");
166
167
168# Test #6: lack of implicit prerequisites.
169#
170run_make_test(q!
171.SECONDEXPANSION:
172foo.o: foo.c
173foo.c: ; @echo '$@'
174
175%.o:
176 @echo '$@: {$<} $^'
177!,
178 '', "foo.c\nfoo.o: {foo.c} foo.c\n");
179
180
181# Test #7: Test stem from the middle of the name.
182#
183run_make_test(q!
184.SECONDEXPANSION:
185foobarbaz:
186
187foo%baz: % $$*.1
188 @echo '$*'
189
190bar bar.1:
191 @echo '$@'
192!,
193 '', "bar\nbar.1\nbar\n");
194
195
196# Test #8: Make sure stem triple-expansion does not happen.
197#
198run_make_test(q!
199.SECONDEXPANSION:
200foo$$bar:
201
202f%r: % $$*.1
203 @echo '$*'
204
205oo$$ba oo$$ba.1:
206 @echo '$@'
207!,
208 '', 'oo$ba
209oo$ba.1
210oo$ba
211');
212
213# Test #9: Check the value of $^
214run_make_test(q!
215.SECONDEXPANSION:
216
217%.so: | $$(extra) ; @echo $^
218
219foo.so: extra := foo.o
220foo.so:
221foo.o:
222!,
223 '', "\n");
224
225# Test #10: Test second expansion with second expansion prerequisites
226# Ensures pattern_search() recurses with SE prereqs.
227touch('a');
228run_make_test(q!
229.SECONDEXPANSION:
230sim_base_rgg := just_a_name
231sim_base_src := a
232sim_base_f := a a a
233sim_%.f: $${sim_$$*_f}
234 echo $@
235sim_%.src: $${sim_$$*_src}
236 echo $@
237sim_%: \
238 $$(if $$(sim_$$*_src),sim_%.src) \
239 $$(if $$(sim_$$*_f),sim_%.f) \
240 $$(if $$(sim_$$*_rgg),$$(sim_$$*_rgg).s)
241 echo $@
242!,
243 '-s sim_base', "#MAKE#: *** No rule to make target 'sim_base'. Stop.", 512);
244
245unlink('a');
246
247# Ensure that order-only tokens embedded in second expansions are parsed
248run_make_test(q!
249.SECONDEXPANSION:
250PREREQS=p1|p2
251P2=p2
252all : foo bar
253f%o: $$(PREREQS) ; @echo '$@' from '$^' and '$|'
254b%r: p1|$$(P2) ; @echo '$@' from '$^' and '$|'
255p% : ; : $@
256!,
257 "", ": p1\n: p2\nfoo from p1 and p2\nbar from p1 and p2\n");
258
259# This tells the test driver that the perl test script executed properly.
2601;
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette