1#                                                                    -*-perl-*-
2$description = "Test handling of static pattern rules.";
3
4$details = "\
5The makefile created in this test has three targets.  The
6filter command is used to get those target names ending in
7.o and statically creates a compile command with the target
8name and the target name with .c.  It also does the same thing
9for another target filtered with .elc and creates a command
10to emacs a .el file";
11
12&touch('bar.c', 'lose.c');
13
14#   TEST #0
15#   -------
16
17run_make_test('
18files = foo.elc bar.o lose.o
19
20$(filter %.o,$(files)): %.o: %.c ; @echo CC -c $(CFLAGS) $< -o $@
21
22$(filter %.elc,$(files)): %.elc: %.el ; @echo emacs $<
23',
24              '',
25              'CC -c bar.c -o bar.o');
26
27#  TEST #1
28#  -------
29
30run_make_test(undef, 'lose.o', 'CC -c lose.c -o lose.o');
31
32
33#   TEST #2
34#   -------
35&touch("foo.el");
36
37run_make_test(undef, 'foo.elc', 'emacs foo.el');
38
39# Clean up after the first tests.
40unlink('foo.el', 'bar.c', 'lose.c');
41
42
43# TEST #3 -- PR/1670: don't core dump on invalid static pattern rules
44# -------
45
46run_make_test('
47.DEFAULT: ; @echo $@
48foo: foo%: % %.x % % % y.% % ; @echo $@
49',
50              '', ".x\ny.\nfoo");
51
52
53# TEST #4 -- bug #12180: core dump on a stat pattern rule with an empty
54#                        prerequisite list.
55run_make_test('
56foo.x bar.x: %.x : ; @echo $@
57
58',
59              '', 'foo.x');
60
61
62# TEST #5 -- bug #13881: double colon static pattern rule does not
63#                        substitute %.
64run_make_test('
65foo.bar:: %.bar: %.baz
66foo.baz: ;@:
67',
68              '', '');
69
70
71# TEST #6: make sure the second stem does not overwrite the first
72#          perprerequisite's stem (Savannah bug #16053).
73#
74run_make_test('
75all.foo.bar: %.foo.bar: %.one
76
77all.foo.bar: %.bar: %.two
78
79all.foo.bar:
80	@echo $*
81	@echo $^
82
83.DEFAULT:;@:
84',
85'',
86'all.foo
87all.one all.foo.two');
88
89
90# TEST #7: make sure the second stem does not overwrite the first
91#          perprerequisite's stem when second expansion is enabled
92#          (Savannah bug #16053).
93#
94run_make_test('
95.SECONDEXPANSION:
96
97all.foo.bar: %.foo.bar: %.one $$*-one
98
99all.foo.bar: %.bar: %.two $$*-two
100
101all.foo.bar:
102	@echo $*
103	@echo $^
104
105.DEFAULT:;@:
106',
107'',
108'all.foo
109all.one all-one all.foo.two all.foo-two');
110
1111;
112