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