2 $description = "Test second expansion in static pattern rules.";
6 # Test #1: automatic variables.
10 .DEFAULT: ; @echo '$@'
12 foo.a foo.b: foo.%: bar.% baz.%
13 foo.a foo.b: foo.%: biz.% | buz.%
15 foo.a foo.b: foo.%: $$@.1 \
17 $$(addsuffix .3,$$^) \
18 $$(addsuffix .4,$$+) \
39 # Test #2: target/pattern -specific variables.
43 .DEFAULT: ; @echo '$@'
45 foo.x foo.y: foo.%: $$(%_a) $$($$*_b)
54 # Test #3: order of prerequisites.
58 .DEFAULT: ; @echo '$@'
60 all: foo.a bar.a baz.a
63 foo.a foo.b: foo.%: foo.%.1; @:
64 foo.a foo.b: foo.%: foo.%.2
65 foo.a foo.b: foo.%: foo.%.3
69 bar.a bar.b: bar.%: bar.%.2
70 bar.a bar.b: bar.%: bar.%.1; @:
71 bar.a bar.b: bar.%: bar.%.3
75 baz.a baz.b: baz.%: baz.%.1
76 baz.a baz.b: baz.%: baz.%.2
90 # Test #4: Make sure stem triple-expansion does not happen.
94 foo$$bar: f%r: % $$*.1 ; @echo '$*'
96 oo$$ba oo$$ba.1: ; @echo '$@'
104 # Integrity self check.
108 bye.x: %.x: $$(firstword %.1;
109 !, '', "#MAKEFILE#:4: *** unterminated call to function 'firstword': missing ')'. Stop.", 512);
111 #unlink('hello.tsk', 'bye.tsk', 'hello.o', 'hello.q', 'bye.o');
114 # Test that makes avoids second expanding prerequisites of the targets which
116 # Here, hello.tsk is built and its prerequisites are second expanded.
117 # bye.tsk is not built and its prerequisites are not second expanded.
119 # Static pattern rules.
122 hello.tsk: %.tsk: %.o $$(info second expansion of $$@ prereqs); $(info $@ from $<)
123 bye.tsk: %.tsk: %.o $$(info second expansion of $$@ prereqs); $(info $@ from $<)
124 hello.o: $$(info second expansion of $$@ prereqs); $(info $@)
125 bye.o: $$(info second expansion of $$@ prereqs); $(info $@)
127 "second expansion of hello.tsk prereqs
128 second expansion of hello.o prereqs
130 hello.tsk from hello.o
131 #MAKE#: 'hello.tsk' is up to date.\n");
134 # Order only prereqs.
137 hello.tsk: %.tsk:| %.o $$(info second expansion of $$@ prereqs); $(info $@ from $|)
138 bye.tsk: %.tsk:| %.o $$(info second expansion of $$@ prereqs); $(info $@ from $|)
139 hello.o:| $$(info second expansion of $$@ prereqs); $(info $@)
140 bye.o:| $$(info second expansion of $$@ prereqs); $(info $@)
142 "second expansion of hello.tsk prereqs
143 second expansion of hello.o prereqs
145 hello.tsk from hello.o
146 #MAKE#: 'hello.tsk' is up to date.\n");
149 # Double colon. 1 rule per target.
152 hello.tsk:: %.tsk: %.o $$(info second expansion of $$@ prereqs); $(info $@ from $<)
153 bye.tsk:: %.tsk: %.o $$(info second expansion of $$@ prereqs); $(info $@ from $<)
154 hello.o:: $$(info second expansion of $$@ prereqs); $(info $@)
155 bye.o:: $$(info second expansion of $$@ prereqs); $(info $@)
157 "second expansion of hello.tsk prereqs
158 second expansion of hello.o prereqs
160 hello.tsk from hello.o
161 #MAKE#: 'hello.tsk' is up to date.\n");
164 # Double colon. 2 rules per target.
167 hello.tsk:: %.tsk: %.o $$(info 1 second expansion of $$@ prereqs); $(info 1 $@ from $<)
168 hello.tsk:: %.tsk: %.o $$(info 2 second expansion of $$@ prereqs); $(info 2 $@ from $<)
169 bye.tsk:: %.tsk: %.o $$(info 1 second expansion of $$@ prereqs); $(info 1 $@ from $<)
170 bye.tsk:: %.tsk: %.o $$(info 2 second expansion of $$@ prereqs); $(info 2 $@ from $<)
171 hello.o:: $$(info 1 second expansion of $$@ prereqs); $(info 1 $@)
172 hello.o:: $$(info 2 second expansion of $$@ prereqs); $(info 2 $@)
173 bye.o:: $$(info 1 second expansion of $$@ prereqs); $(info 1 $@)
174 bye.o:: $$(info 2 second expansion of $$@ prereqs); $(info 2 $@)
176 "1 second expansion of hello.tsk prereqs
177 1 second expansion of hello.o prereqs
179 2 second expansion of hello.o prereqs
181 1 hello.tsk from hello.o
182 2 second expansion of hello.tsk prereqs
183 2 hello.tsk from hello.o
184 #MAKE#: 'hello.tsk' is up to date.\n");
187 # Test that the prerequisites of 'hello.tsk' are second expanded once.
190 all: hello.tsk hello.q
191 hello.tsk: %.tsk: %.o $$(info second expansion of $$@ prereqs); $(info $@ from $^)
192 hello.o: $$(info second expansion of $$@ prereqs); $(info $@)
193 hello.q: %.q: %.tsk $$(info second expansion of $$@ prereqs); $(info $@ from $^)
195 "second expansion of hello.tsk prereqs
196 second expansion of hello.o prereqs
198 hello.tsk from hello.o
199 second expansion of hello.q prereqs
200 hello.q from hello.tsk
201 #MAKE#: Nothing to be done for 'all'.\n");
206 # No side effects from second expansion of unrelated rules.
210 hello.tsk: %.tsk: %.o; exit 1
212 bye.tsk: %.tsk: $$(shell touch hello.1);
215 #MAKE#: *** [#MAKEFILE#:4: hello.tsk] Error 1\n", 512);
218 # Second expansion of intermediate prerequisites.
219 # The rule to build hello.x is static pattern.
220 # .SECONDARY marks hello.x as intermediate.
221 # Test that $$(deps) is secondary expanded.
227 hello.x: %.x: $$(deps); $(info $@)
229 !, '', "hello.h\nhello.x\n#MAKE#: Nothing to be done for 'all'.\n");
231 # This tells the test driver that the perl test script executed properly.