Debian Codegraph @

tests/scripts/features/suffixrules

raw
1 # -*-perl-*-
2
3 $description = "Test suffix rules.";
4
5 $details = "";
6
7 # TEST #0: Clear all suffixes
8
9 touch('foo.c');
10
11 run_make_test(q!
12 .SUFFIXES:
13 all: foo.o ; @echo $@ $<
14 !,
15 '', "#MAKE#: *** No rule to make target 'foo.o', needed by 'all'. Stop.\n", 512);
16
17 unlink('foo.c');
18
19 # Test #1: Add a simple suffix rule
20
21 touch('foo.baz');
22
23 run_make_test(q!
24 .SUFFIXES: .biz .baz
25
26 .baz.biz: ; @echo make $@
27 !,
28 'foo.biz', "make foo.biz\n");
29
30 unlink('foo.baz');
31
32 # Test #2: Make sure the defaults still work
33
34 touch('foo.c');
35
36 run_make_test(undef, 'foo.o COMPILE.c=@echo OUTPUT_OPTION=', "foo.c\n");
37
38 unlink('foo.c');
39
40 # Test #3: Replacing all suffixes
41
42 touch('foo.baz');
43
44 run_make_test(q!
45 .SUFFIXES:
46 .SUFFIXES: .biz .baz
47
48 .baz.biz: ; @echo make $@
49 !,
50 'foo.biz', "make foo.biz\n");
51
52 unlink('foo.baz');
53
54 # SV 40657: Test #4: "Suffix rules" with deps are normal rules
55
56 my $prewarn = 'warning: ignoring prerequisites on suffix rule definition';
57
58 touch('foo.bar');
59
60 run_make_test(q!
61 .SUFFIXES:
62 .SUFFIXES: .biz .baz
63
64 $X.POSIX:
65
66 .baz.biz: foo.bar ; @echo make $@ from $<
67 !,
68 'X=1 .baz.biz', "#MAKEFILE#:7: $prewarn\nmake .baz.biz from foo.bar\n");
69
70 # SV 40657: Test #5: In POSIX mode we don't get a warning
71
72 run_make_test(undef, 'X= .baz.biz', "make .baz.biz from foo.bar\n");
73
74 unlink('foo.bar');
75
76 # SV 40657: Test #6: In POSIX mode, no pattern rules should be created
77
78 utouch(-20, 'foo.baz');
79
80 run_make_test(undef,
81 'X= foo.biz', "#MAKE#: *** No rule to make target 'foo.biz'. Stop.\n", 512);
82
83 # SV 40657: Test #7: In Non-POSIX mode, a pattern rule is created
84
85 run_make_test(undef,
86 'X=1 foo.biz', "#MAKEFILE#:7: $prewarn\nmake foo.biz from foo.baz\n");
87
88 # SV 40657: Test #8: ... but any prerequisites are ignored
89
90 utouch(-10, 'foo.biz');
91 touch('foo.bar');
92
93 run_make_test(undef,
94 'X=1 foo.biz', "#MAKEFILE#:7: $prewarn\n#MAKE#: 'foo.biz' is up to date.\n");
95
96 unlink('foo.baz', 'foo.biz', 'foo.bar');
97
98
99 touch('hello.c');
100 unlink('hello.o');
101
102 # sv 63821.
103 # Default suffix rule .c.o.
104
105 run_make_test('all: hello.o', 'COMPILE.c=@echo OUTPUT_OPTION=', 'hello.c');
106
107 # User defined rules beat built-in rules.
108
109 run_make_test(q!
110 all: hello.o
111 .c.o:; $(info $@ user defined .c.o rule)
112 !, '', "hello.o user defined .c.o rule\n#MAKE#: Nothing to be done for 'all'.\n");
113
114 # sv 63821.
115 # The same as above, but suffixes are cleared.
116
117 run_make_test(q!
118 all: hello.o
119 .SUFFIXES:
120 .c.o:; $(info $@ user defined .c.o rule)
121 !, '', "#MAKE#: *** No rule to make target 'hello.o', needed by 'all'. Stop.\n", 512);
122
123 # sv 63821.
124 # Suffixes are cleared and defined in the makefile.
125
126 run_make_test(q!
127 all: hello.o
128 .SUFFIXES:
129 .SUFFIXES: .c .o
130 .c.o:; $(info $@ user defined .c.o rule)
131 !, '', "hello.o user defined .c.o rule\n#MAKE#: Nothing to be done for 'all'.\n");
132
133 # sv 63821.
134 # When built-in rules are disabled, but certain suffixes are added to
135 # .SUFFIXES, make should exit with the 'No rule...' error message.
136
137 run_make_test(q!
138 .SUFFIXES: .c .o
139 all: hello.o
140 !, '-r', "#MAKE#: *** No rule to make target 'hello.o', needed by 'all'. Stop.\n", 512);
141
142 # sv 63821.
143 # Same as above, but this time built-in rules are disabled inside the makefile.
144
145 run_make_test(q!
146 MAKEFLAGS += -r
147 .SUFFIXES: .c .o
148 all: hello.o
149 !, '', "#MAKE#: *** No rule to make target 'hello.o', needed by 'all'. Stop.\n", 512);
150
151 # sv 63821.
152 # Same as above, but this time there is a rule.
153
154 run_make_test(q!
155 all: hello.o
156 MAKEFLAGS += -r
157 .SUFFIXES: .c .o
158 .c.o:; $(info $@ user defined .c.o rule)
159 !, '', "hello.o user defined .c.o rule\n#MAKE#: Nothing to be done for 'all'.\n");
160
161 unlink('hello.c', 'hello.o');
162
163 # Complete
164 1;