1 | # -*-perl-*-
|
---|
2 |
|
---|
3 | $description = "Test pattern rules.";
|
---|
4 |
|
---|
5 | $details = "";
|
---|
6 |
|
---|
7 | use Cwd;
|
---|
8 |
|
---|
9 | $dir = cwd;
|
---|
10 | $dir =~ s,.*/([^/]+)$,../$1,;
|
---|
11 |
|
---|
12 |
|
---|
13 | # TEST #0: Make sure that multiple patterns where the same target
|
---|
14 | # can be built are searched even if the first one fails
|
---|
15 | # to match properly.
|
---|
16 | #
|
---|
17 |
|
---|
18 | run_make_test(q!
|
---|
19 | .PHONY: all
|
---|
20 |
|
---|
21 | all: case.1 case.2 case.3
|
---|
22 |
|
---|
23 | # We can't have this, due to "Implicit Rule Search Algorithm" step 5c
|
---|
24 | #xxx: void
|
---|
25 |
|
---|
26 | # 1 - existing file
|
---|
27 | %.1: void
|
---|
28 | @exit 1
|
---|
29 | %.1: #MAKEFILE#
|
---|
30 | @exit 0
|
---|
31 |
|
---|
32 | # 2 - phony
|
---|
33 | %.2: void
|
---|
34 | @exit 1
|
---|
35 | %.2: 2.phony
|
---|
36 | @exit 0
|
---|
37 | .PHONY: 2.phony
|
---|
38 |
|
---|
39 | # 3 - implicit-phony
|
---|
40 | %.3: void
|
---|
41 | @exit 1
|
---|
42 | %.3: 3.implicit-phony
|
---|
43 | @exit 0
|
---|
44 |
|
---|
45 | 3.implicit-phony:
|
---|
46 | !, '', '');
|
---|
47 |
|
---|
48 | # TEST #1: make sure files that are built via implicit rules are marked
|
---|
49 | # as targets (Savannah bug #12202).
|
---|
50 | #
|
---|
51 | run_make_test('
|
---|
52 | TARGETS := foo foo.out
|
---|
53 |
|
---|
54 | .PHONY: all foo.in
|
---|
55 |
|
---|
56 | all: $(TARGETS)
|
---|
57 |
|
---|
58 | %: %.in
|
---|
59 | @echo $@
|
---|
60 |
|
---|
61 | %.out: %
|
---|
62 | @echo $@
|
---|
63 |
|
---|
64 | foo.in: ; @:
|
---|
65 |
|
---|
66 | ',
|
---|
67 | '',
|
---|
68 | 'foo
|
---|
69 | foo.out');
|
---|
70 |
|
---|
71 |
|
---|
72 | # TEST #2: make sure intermediate files that also happened to be
|
---|
73 | # prerequisites are not removed (Savannah bug #12267).
|
---|
74 | #
|
---|
75 | run_make_test('
|
---|
76 | $(dir)/foo.o:
|
---|
77 |
|
---|
78 | $(dir)/foo.y:
|
---|
79 | @echo $@
|
---|
80 |
|
---|
81 | %.c: %.y
|
---|
82 | touch $@
|
---|
83 |
|
---|
84 | %.o: %.c
|
---|
85 | @echo $@
|
---|
86 |
|
---|
87 | .PHONY: install
|
---|
88 | install: $(dir)/foo.c
|
---|
89 |
|
---|
90 | ',
|
---|
91 | "dir=$dir",
|
---|
92 | "$dir/foo.y
|
---|
93 | touch $dir/foo.c
|
---|
94 | $dir/foo.o");
|
---|
95 |
|
---|
96 | unlink("$dir/foo.c");
|
---|
97 |
|
---|
98 |
|
---|
99 | # TEST #3: make sure precious flag is set properly for targets
|
---|
100 | # that are built via implicit rules (Savannah bug #13218).
|
---|
101 | #
|
---|
102 | run_make_test('
|
---|
103 | .DELETE_ON_ERROR:
|
---|
104 |
|
---|
105 | .PRECIOUS: %.bar
|
---|
106 |
|
---|
107 | %.bar:; @touch $@ && exit 1
|
---|
108 |
|
---|
109 | $(dir)/foo.bar:
|
---|
110 |
|
---|
111 | ',
|
---|
112 | "dir=$dir",
|
---|
113 | "#MAKE#: *** [#MAKEFILE#:6: $dir/foo.bar] Error 1",
|
---|
114 | 512);
|
---|
115 |
|
---|
116 | unlink("$dir/foo.bar");
|
---|
117 |
|
---|
118 |
|
---|
119 | # TEST #4: make sure targets of a matched implicit pattern rule are
|
---|
120 | # never considered intermediate (Savannah bug #13022).
|
---|
121 | #
|
---|
122 | run_make_test('
|
---|
123 | .PHONY: all
|
---|
124 | all: foo.c foo.o
|
---|
125 |
|
---|
126 | %.h %.c: %.in
|
---|
127 | touch $*.h
|
---|
128 | touch $*.c
|
---|
129 |
|
---|
130 | %.o: %.c %.h
|
---|
131 | echo $+ >$@
|
---|
132 |
|
---|
133 | %.o: %.c
|
---|
134 | @echo wrong rule
|
---|
135 |
|
---|
136 | foo.in:
|
---|
137 | touch $@
|
---|
138 |
|
---|
139 | ',
|
---|
140 | '',
|
---|
141 | 'touch foo.in
|
---|
142 | touch foo.h
|
---|
143 | touch foo.c
|
---|
144 | echo foo.c foo.h >foo.o');
|
---|
145 |
|
---|
146 | unlink('foo.in', 'foo.h', 'foo.c', 'foo.o');
|
---|
147 |
|
---|
148 | # TEST #5: make sure both prefix and suffix patterns work with multiple
|
---|
149 | # target patterns (Savannah bug #26593).
|
---|
150 | #
|
---|
151 | run_make_test('
|
---|
152 | all: foo.s1 foo.s2 p1.foo p2.foo
|
---|
153 |
|
---|
154 | p1.% p2.%: %.orig
|
---|
155 | @echo $@
|
---|
156 | %.s1 %.s2: %.orig
|
---|
157 | @echo $@
|
---|
158 |
|
---|
159 | .PHONY: foo.orig
|
---|
160 | ',
|
---|
161 | '', "foo.s1\np1.foo\n");
|
---|
162 |
|
---|
163 | # TEST 6: Make sure that non-target files are still eligible to be created
|
---|
164 | # as part of implicit rule chaining. Savannah bug #17752.
|
---|
165 |
|
---|
166 | run_make_test(q!
|
---|
167 | BIN = xyz
|
---|
168 | COPY = $(BIN).cp
|
---|
169 | SRC = $(BIN).c
|
---|
170 | allbroken: $(COPY) $(BIN) ; @echo ok
|
---|
171 | $(SRC): ; @echo 'main(){}' > $@
|
---|
172 | %.cp: % ; @cp $< $@
|
---|
173 | % : %.c ; @cp $< $@
|
---|
174 | clean: ; @rm -rf $(SRC) $(COPY) $(BIN)
|
---|
175 | !,
|
---|
176 | '', "ok\n");
|
---|
177 |
|
---|
178 | unlink(qw(xyz xyz.cp xyz.c));
|
---|
179 |
|
---|
180 | # TEST 7: Make sure that all prereqs of all "also_make" targets get created
|
---|
181 | # before any of the things that depend on any of them. Savannah bug #19108.
|
---|
182 |
|
---|
183 | run_make_test(q!
|
---|
184 | final: x ; @echo $@
|
---|
185 | x: x.t1 x.t2 ; @echo $@
|
---|
186 | x.t2: dep
|
---|
187 | dep: ; @echo $@
|
---|
188 | %.t1 %.t2: ; @echo $*.t1 ; echo $*.t2
|
---|
189 | !,
|
---|
190 | '', "dep\nx.t1\nx.t2\nx\nfinal\n");
|
---|
191 |
|
---|
192 |
|
---|
193 | # TEST 8: Verify we can remove pattern rules. Savannah bug #18622.
|
---|
194 |
|
---|
195 | my @f = (qw(foo.w foo.ch));
|
---|
196 | touch(@f);
|
---|
197 |
|
---|
198 | run_make_test(q!
|
---|
199 | CWEAVE := :
|
---|
200 |
|
---|
201 | # Disable builtin rules
|
---|
202 | %.tex : %.w
|
---|
203 | %.tex : %.w %.ch
|
---|
204 | !,
|
---|
205 | 'foo.tex',
|
---|
206 | "#MAKE#: *** No rule to make target 'foo.tex'. Stop.", 512);
|
---|
207 |
|
---|
208 | unlink(@f);
|
---|
209 |
|
---|
210 | # TEST #9: Test shortest stem selection in pattern rules.
|
---|
211 |
|
---|
212 | run_make_test('
|
---|
213 | %.x: ;@echo one
|
---|
214 | %-mt.x: ;@echo two
|
---|
215 |
|
---|
216 | all: foo.x foo-mt.x
|
---|
217 | ',
|
---|
218 | '',
|
---|
219 | "one\ntwo");
|
---|
220 |
|
---|
221 | 1;
|
---|
222 |
|
---|
223 | # This tells the test driver that the perl test script executed properly.
|
---|
224 | 1;
|
---|
225 |
|
---|
226 | ### Local Variables:
|
---|
227 | ### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action))
|
---|
228 | ### End:
|
---|