- Rework secondary expansion so we only defer it if there's a possibility
[make.git] / tests / scripts / features / statipattrules
blob3f363defb1f0749a722c0adca8a07483ef5ab68d
1 #                                                                    -*-perl-*-
2 $description = "Test handling of static pattern rules.";
4 $details = "\
5 The makefile created in this test has three targets.  The
6 filter command is used to get those target names ending in
7 .o and statically creates a compile command with the target
8 name and the target name with .c.  It also does the same thing
9 for another target filtered with .elc and creates a command
10 to emacs a .el file";
12 &touch('bar.c', 'lose.c');
14 #   TEST #0
15 #   -------
17 run_make_test('
18 files = foo.elc bar.o lose.o
20 $(filter %.o,$(files)): %.o: %.c ; @echo CC -c $(CFLAGS) $< -o $@
22 $(filter %.elc,$(files)): %.elc: %.el ; @echo emacs $<
24               '',
25               'CC -c bar.c -o bar.o');
27 #  TEST #1
28 #  -------
30 run_make_test(undef, 'lose.o', 'CC -c lose.c -o lose.o');
33 #   TEST #2
34 #   -------
35 &touch("foo.el");
37 run_make_test(undef, 'foo.elc', 'emacs foo.el');
39 # Clean up after the first tests.
40 unlink('foo.el', 'bar.c', 'lose.c');
43 # TEST #3 -- PR/1670: don't core dump on invalid static pattern rules
44 # -------
46 run_make_test('
47 .DEFAULT: ; @echo $@
48 foo: foo%: % %.x % % % y.% % ; @echo $@
50               '', ".x\ny.\nfoo");
53 # TEST #4 -- bug #12180: core dump on a stat pattern rule with an empty
54 #                        prerequisite list.
55 run_make_test('
56 foo.x bar.x: %.x : ; @echo $@
59               '', 'foo.x');
62 # TEST #5 -- bug #13881: double colon static pattern rule does not
63 #                        substitute %.
64 run_make_test('
65 foo.bar:: %.bar: %.baz
66 foo.baz: ;@:
68               '', '');
71 # TEST #6: make sure the second stem does not overwrite the first
72 #          perprerequisite's stem (Savannah bug #16053).
74 run_make_test('
75 all.foo.bar: %.foo.bar: %.one
77 all.foo.bar: %.bar: %.two
79 all.foo.bar:
80         @echo $*
81         @echo $^
83 .DEFAULT:;@:
85 '',
86 'all.foo
87 all.one all.foo.two');
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).
94 run_make_test('
95 .SECONDEXPANSION:
97 all.foo.bar: %.foo.bar: %.one $$*-one
99 all.foo.bar: %.bar: %.two $$*-two
101 all.foo.bar:
102         @echo $*
103         @echo $^
105 .DEFAULT:;@:
108 'all.foo
109 all.one all-one all.foo.two all.foo-two');