Debian Codegraph @

tests/scripts/variables/MAKEFLAGS

raw
1 # -*-perl-*-
2
3 $description = "Test proper behavior of MAKEFLAGS";
4
5 $details = "DETAILS";
6
7 # Normal flags aren't prefixed with "-"
8 run_make_test(q!
9 all: ; @echo /$(MAKEFLAGS)/
10 !,
11 '-e -r -R', '/erR/');
12
13 # Long arguments mean everything is prefixed with "-"
14 run_make_test(q!
15 all: ; @echo /$(MAKEFLAGS)/
16 !,
17 '--no-print-directory -e -r -R --trace', "#MAKEFILE#:2: update target 'all' due to: target does not exist
18 echo /erR --trace --no-print-directory/
19 /erR --trace --no-print-directory/");
20
21
22 # Recursive invocations of make should accumulate MAKEFLAGS values.
23 # Savannah bug #2216
24 run_make_test(q!
25 MSG = Fails
26 .RECIPEPREFIX = >
27 all:
28 > @echo '$@: MAKEFLAGS=$(MAKEFLAGS)'
29 > @MSG=Works $(MAKE) -e -f #MAKEFILE# jump
30 jump:
31 > @echo '$@ $(MSG): MAKEFLAGS=$(MAKEFLAGS)'
32 > @$(MAKE) -f #MAKEFILE# print
33 print:
34 > @echo '$@ $(MSG): MAKEFLAGS=$(MAKEFLAGS)'
35 .PHONY: all jump print
36 !,
37 '--no-print-directory',
38 'all: MAKEFLAGS= --no-print-directory
39 jump Works: MAKEFLAGS=e --no-print-directory
40 print Works: MAKEFLAGS=e --no-print-directory');
41
42 # Ensure MAKEFLAGS updates are handled immediately rather than later
43
44 mkdir('foo', 0777);
45 mkdir('bar', 0777);
46
47 run_make_test(q!
48 $(info MAKEFLAGS=$(MAKEFLAGS))
49 $(info INCLUDE_DIRS=$(.INCLUDE_DIRS))
50 MAKEFLAGS += -Ibar
51 $(info MAKEFLAGS=$(MAKEFLAGS))
52 $(info INCLUDE_DIRS=$(.INCLUDE_DIRS))
53 .PHONY: all
54 all: ; @echo 'MAKEFLAGS=$(MAKEFLAGS)' "\$$MAKEFLAGS=$$MAKEFLAGS"
55 !,
56 '-I- -Ifoo', 'MAKEFLAGS= -I- -Ifoo
57 INCLUDE_DIRS=foo
58 MAKEFLAGS= -I- -Ifoo -Ibar
59 INCLUDE_DIRS=foo bar
60 MAKEFLAGS= -I- -Ifoo -Ibar $MAKEFLAGS= -I- -Ifoo -Ibar');
61
62 rmdir('foo');
63 rmdir('bar');
64
65 # Test that command line switches are all present in MAKEFLAGS.
66 # sv 62514.
67 my @opts;
68 my @flavors;
69
70 # Simple flags.
71 @opts = ('i', 'k', 'n', 'q', 'r', 's', 'w', 'd');
72 exists $FEATURES{'check-symlink'} and push @opts, 'L';
73 @flavors = ('=', ':=', ':::=', '+=-');
74
75 for my $fl (@flavors) {
76 for my $opt (@opts) {
77 run_make_test("
78 MAKEFLAGS${fl}B
79 all:; \$(info makeflags='\$(MAKEFLAGS)')
80 ", "-$opt", "/makeflags='B$opt'/");
81 }
82 }
83
84 # Strawberry Perl's exec()--or something!--appears to replace all /tmp with the
85 # user's %TEMP% value so we can't use that for -I testing. Make a directory.
86
87 mkdir('localtmp', 0777);
88
89 # Switches which carry arguments.
90 @opts = (' -Ilocaltmp', ' -Onone', ' --debug=b', ' -l2.5');
91 for my $fl (@flavors) {
92 for my $opt (@opts) {
93 run_make_test("
94 MAKEFLAGS${fl}B
95 all:; \$(info makeflags='\$(MAKEFLAGS)')
96 ", "$opt", "/makeflags='B$opt'/");
97 }
98 }
99
100 # Long options which take no arguments.
101 # sv 62514.
102 @opts = (' --no-print-directory', ' --warn-undefined-variables', ' --trace');
103 for my $fl (@flavors) {
104 for my $opt (@opts) {
105 run_make_test("
106 MAKEFLAGS${fl}B
107 all:; \$(info makeflags='\$(MAKEFLAGS)')
108 ", "$opt", "/makeflags='B$opt'/");
109 }
110 }
111
112 # Test that make filters out duplicates.
113 # Each option is specified in the makefile, env and on the command line.
114 @opts = (' -Ilocaltmp', ' -Onone', ' --debug=b', ' -l2.5');
115 for my $fl (@flavors) {
116 for my $opt (@opts) {
117 $ENV{'MAKEFLAGS'} = $opt;
118 run_make_test("
119 MAKEFLAGS${fl}B $opt
120 all:; \$(info makeflags='\$(MAKEFLAGS)')
121 ", "$opt", "/makeflags='B$opt'/");
122 }
123 }
124
125 # Test that make filters out duplicates.
126 # Each option is specified in the makefile, env and on the command line.
127 # decode_switches reallocates when the number of parameters in sl->list exceeds 5.
128 # This test exercises the realloc branch.
129 for my $fl (@flavors) {
130 $ENV{'MAKEFLAGS'} = '-I1 -Onone --debug=b -l2.5 -I2 -I3 -I4 -I5 -I6 -I2 -I2';
131 run_make_test("
132 MAKEFLAGS${fl}B -I1 -Onone --debug=b -l2.5 -I2 -I3 -I4 -I5 -I6 -I2 -I2
133 all:; \$(info makeflags='\$(MAKEFLAGS)')
134 ",
135 '-I1 -Onone --debug=b -l2.5 -I2 -I3 -I4 -I5 -I6',
136 "/makeflags='B -I1 -I2 -I3 -I4 -I5 -I6 -l2.5 -Onone --debug=b'/");
137 }
138
139 # A mix of multiple flags from env, the makefile and command line.
140 # Skip -L since it's not available everywhere
141 for my $fl (@flavors) {
142 $ENV{'MAKEFLAGS'} = 'ikB --no-print-directory --warn-undefined-variables --trace';
143 run_make_test("
144 MAKEFLAGS${fl}iknqrswd -Ilocaltmp -Ilocaltmp -Onone -Onone -l2.5 -l2.5
145 all:; \$(info makeflags='\$(MAKEFLAGS)')
146 ",
147 '-Onone -l2.5 -l2.5 -Onone -Ilocaltmp -iknqrswd -i -n -s -k -Ilocaltmp',
148 "/makeflags='Bdiknqrsw -Ilocaltmp -l2.5 -Onone --trace --warn-undefined-variables'/");
149 }
150
151 # Verify MAKEFLAGS are all available to shell function at parse time.
152 for my $fl (@flavors) {
153 my $answer = 'Biknqrs -Ilocaltmp -l2.5 -Onone --no-print-directory --warn-undefined-variables';
154 $ENV{'MAKEFLAGS'} = 'ikB --no-print-directory --warn-undefined-variables';
155 run_make_test("
156 MAKEFLAGS${fl}iknqrsw -Ilocaltmp -Ilocaltmp -Onone -Onone -l2.5 -l2.5 --no-print-directory
157 \$(info at parse time '\$(MAKEFLAGS)')
158 XX := \$(shell echo \"\$\$MAKEFLAGS\")
159 all:; \$(info at build time makeflags='\$(XX)')
160 ",
161 '-Onone -l2.5 -l2.5 -Onone -Ilocaltmp -iknqrs -i -n -s -k -Ilocaltmp',
162 "at parse time '$answer'
163 at build time makeflags='$answer'");
164 }
165
166 # Verify MAKEFLAGS and command line definitions are all available to shell function at parse time.
167 for my $fl (@flavors) {
168 $ENV{'MAKEFLAGS'} = 'ikB --no-print-directory --warn-undefined-variables';
169 my $answer = 'Biknqrs -Ilocaltmp -l2.5 -Onone --no-print-directory --warn-undefined-variables -- hello=world';
170 run_make_test("
171 MAKEFLAGS${fl}iknqrsw -Ilocaltmp -Ilocaltmp -Onone -Onone -l2.5 -l2.5 --no-print-directory
172 \$(info at parse time '\$(MAKEFLAGS)')
173 XX := \$(shell echo \"\$\$MAKEFLAGS\")
174 all:; \$(info at build time makeflags='\$(XX)')
175 ",
176 '-Onone -l2.5 -l2.5 -Onone -Ilocaltmp -iknqrs -i -n -s -k -Ilocaltmp hello=world',
177 "at parse time '$answer'
178 at build time makeflags='$answer'");
179 }
180
181 # Verify that command line arguments are included in MAKEFLAGS
182 run_make_test(q!
183 all: ; @echo $(MAKEFLAGS)
184 !,
185 '-e FOO=bar -r -R', 'erR -- FOO=bar');
186
187 # Long arguments mean everything is prefixed with "-"
188 run_make_test(q!
189 all: ; @echo /$(MAKEFLAGS)/
190 !,
191 '--no-print-directory -e -r -R --trace FOO=bar',
192 "#MAKEFILE#:2: update target 'all' due to: target does not exist
193 echo /erR --trace --no-print-directory -- FOO=bar/
194 /erR --trace --no-print-directory -- FOO=bar/");
195
196
197 # sv 63347.
198 # Verify that command line arguments are included in MAKEFLAGS
199 # when makefiles are parsed.
200 my $answer = 'erR -- hello:=world FOO=bar';
201 run_make_test(q!
202 $(info $(MAKEFLAGS))
203 all:; $(info $(MAKEFLAGS))
204 !, '-e FOO=bar -r -R hello:=world',
205 "$answer
206 $answer
207 #MAKE#: 'all' is up to date.\n");
208
209 # sv 63347.
210 # Same as above, with makefile setting the value of the same variables as
211 # defined on the cli.
212 $answer = 'erR -- hello:=world FOO=bar';
213 run_make_test(q!
214 $(info $(MAKEFLAGS))
215 FOO=moon
216 hello:=moon
217 $(info $(MAKEFLAGS))
218 all:; $(info $(MAKEFLAGS))
219 !, '-e FOO=bar -r -R hello:=world',
220 "$answer
221 $answer
222 $answer
223 #MAKE#: 'all' is up to date.\n");
224
225 # sv 63347.
226 # Same as above, with makefile overriding the value of cli definition.
227 $answer = 'erR -- hello:=world FOO=bar';
228 run_make_test(q!
229 $(info $(MAKEFLAGS))
230 override FOO=moon
231 override hello:=moon
232 export hello
233 $(info $(MAKEFLAGS))
234 all:; $(info $(MAKEFLAGS))
235 !, '-e FOO=bar -r -R hello:=world',
236 "$answer
237 $answer
238 $answer
239 #MAKE#: 'all' is up to date.\n");
240
241 # Same as above, and makefile overrides the value of cli definition.
242 # resets MAKEOVERRIDES.
243 $answer = 'rR -- hello:=world FOO=bar';
244 run_make_test(q!
245 $(info $(MAKEFLAGS))
246 override FOO=moon
247 override hello:=moon
248 export hello
249 $(info $(MAKEFLAGS))
250 MAKEOVERRIDES=
251 $(info $(MAKEFLAGS))
252 all:; $(info $(MAKEFLAGS))
253 !, 'FOO=bar -r -R hello:=world',
254 "$answer
255 $answer
256 rR -- \nrR
257 #MAKE#: 'all' is up to date.\n");
258
259 # sv 63347.
260 # MAKEFLAGS set is env and makefile sets MAKEFLAGS and there is a command
261 # line definition.
262 $answer = ' -- bye=moon hello=world';
263 $ENV{'MAKEFLAGS'} = 'hello=world';
264 run_make_test(q!
265 $(info $(MAKEFLAGS))
266 all:; $(info $(MAKEFLAGS))
267 !, 'bye=moon',
268 " -- bye=moon hello=world
269 -- bye=moon hello=world
270 #MAKE#: 'all' is up to date.\n");
271
272 # sv 63347.
273 # Conditional assignment and MAKEFLAGS.
274 $answer = 'B -- bye=moon hello=world';
275 $ENV{'MAKEFLAGS'} = 'hello=world';
276 run_make_test(q!
277 $(info $(MAKEFLAGS))
278 MAKEFLAGS?=-k
279 $(info $(MAKEFLAGS))
280 all:; $(info $(MAKEFLAGS))
281 !, '-B bye=moon',
282 "$answer
283 $answer
284 $answer
285 #MAKE#: 'all' is up to date.\n");
286
287 # sv 63347.
288 # MAKEFLAGS set is env and makefile sets MAKEFLAGS and there is a command
289 # line definition.
290 for my $fl (@flavors) {
291 my $answer = ' -- bye=moon hello=world';
292 $ENV{'MAKEFLAGS'} = 'hello=world';
293 run_make_test("
294 \$(info \$(MAKEFLAGS))
295 MAKEFLAGS${fl}R
296 \$(info \$(MAKEFLAGS))
297 all:; \$(info \$(MAKEFLAGS))
298 ", 'bye=moon',
299 "$answer
300 R$answer
301 rR$answer
302 #MAKE#: 'all' is up to date.\n");
303 }
304
305 # sv 63347.
306 # Test changes introduced by makefiles to MAKEFLAGS.
307 for my $fl (@flavors) {
308 my $answer = 'rR --no-print-directory -- hello:=world FOO=bar';
309 run_make_test(q!
310 MAKEFLAGS+=--no-print-directory
311 $(info $(MAKEFLAGS))
312 MAKEFLAGS+=-k
313 $(info $(MAKEFLAGS))
314 all:; $(info $(MAKEFLAGS))
315 !, 'FOO=bar -r -R hello:=world',
316 "$answer
317 k$answer
318 k$answer
319 #MAKE#: 'all' is up to date.\n");
320 }
321
322 # sv 63347.
323 # Test changes introduced by makefiles to MAKEFLAGS.
324 # Same as above, but with -e.
325 for my $fl (@flavors) {
326 my $answer = 'erR -- hello:=world FOO=bar';
327 run_make_test(q!
328 MAKEFLAGS+=--no-print-directory
329 $(info $(MAKEFLAGS))
330 MAKEFLAGS+=-k
331 $(info $(MAKEFLAGS))
332 all:; $(info $(MAKEFLAGS))
333 !, '-e FOO=bar -r -R hello:=world',
334 "$answer
335 $answer
336 $answer
337 #MAKE#: 'all' is up to date.\n");
338 }
339
340 mkdir('bye', 0777);
341
342 create_file('bye/makefile',
343 'hello=moon
344 all:; $(info $(hello))');
345
346 # sv 63347.
347 # Test that a cli definition takes precedence over a definition set in
348 # submake.
349 run_make_test(q!
350 v:=$(shell $(MAKE) -C bye --no-print-directory)
351 all: ; $(info $(v))
352 !, 'hello=world', "world #MAKE#[1]: 'all' is up to date.\n#MAKE#: 'all' is up to date.");
353
354 # Same as above with the shell assignment operator.
355 run_make_test(q!
356 v \!= $(MAKE) -C bye --no-print-directory
357 all: ; $(info $(v))
358 !, 'hello=world', "world #MAKE#[1]: 'all' is up to date.\n#MAKE#: 'all' is up to date.");
359
360 unlink('bye/makefile');
361 rmdir('bye');
362
363 # sv 63347
364 # Invalid command line variable definition.
365 run_make_test(q!
366 all:; $(info $(hello))
367 !, 'hello=\'$(world\'', "#MAKEFILE#:2: *** unterminated variable reference. Stop.\n", 512);
368
369 # sv 63347
370 # An unused invalid command line variable definition is ignored.
371 run_make_test(q!
372 all:; $(info good)
373 !, 'hello=\'$(world\'', "good\n#MAKE#: 'all' is up to date.\n");
374
375
376
377 # sv 63537
378 # Certain switches can be flipped on and off.
379 # -k/-S, -w/--no-print-directory and -s/--no-silent.
380 # Test the following aspects of behavior of these switches
381 # 1. A switch can be enabled or disabled in makefile.
382 # 2. A switch can be enabled or disabled in env.
383 # 3. A switch can be enabled or disabled on the command line.
384 # 4. Command line beats makefile.
385 # 5. Env beats makefile.
386 # 6. Command line beats env.
387 # 7. MAKEFLAGS contains each specified switch at parse and build time.
388 # 8. If contradicting switches are specified in multiple origins, MAKEFLAGS
389 # contains the winning switch at parse and build time.
390 # 9. MAKEFLAGS does not contain the beaten switch.
391
392 @flavors = ('=', ':=', ':::=', '+=');
393
394 # sv 63537
395 # -w vs --no-print-directory
396
397 # -w on the command line.
398 run_make_test(q!
399 $(info $(MAKEFLAGS))
400 all:; $(info $(MAKEFLAGS))
401 !, '-w',
402 "#MAKE#: Entering directory '#PWD#'
403 w
404 w
405 #MAKE#: 'all' is up to date.
406 #MAKE#: Leaving directory '#PWD#'\n");
407
408 # -w in the env.
409 $ENV{'MAKEFLAGS'} = '-w';
410 run_make_test(q!
411 $(info $(MAKEFLAGS))
412 all:; $(info $(MAKEFLAGS))
413 !, '',
414 "#MAKE#: Entering directory '#PWD#'
415 w
416 w
417 #MAKE#: 'all' is up to date.
418 #MAKE#: Leaving directory '#PWD#'\n");
419
420 # -w in env, --no-print-directory on the command line.
421 $ENV{'MAKEFLAGS'} = '-w';
422 run_make_test(q!
423 $(info $(MAKEFLAGS))
424 all:; $(info $(MAKEFLAGS))
425 !, '--no-print-directory',
426 " --no-print-directory
427 --no-print-directory
428 #MAKE#: 'all' is up to date.\n");
429
430 # --no-print-directory in env, -w on the command line.
431 $ENV{'MAKEFLAGS'} = '--no-print-directory';
432 run_make_test(q!
433 $(info $(MAKEFLAGS))
434 all:; $(info $(MAKEFLAGS))
435 !, '-w',
436 "#MAKE#: Entering directory '#PWD#'
437 w
438 w
439 #MAKE#: 'all' is up to date.
440 #MAKE#: Leaving directory '#PWD#'\n");
441
442 delete $ENV{'MAKEFLAGS'};
443
444 # -w in makefile.
445 for my $fl (@flavors) {
446 run_make_test("
447 MAKEFLAGS${fl}-w
448 \$(info \$(MAKEFLAGS))
449 all:; \$(info \$(MAKEFLAGS))
450 ", '',
451 "#MAKE#: Entering directory '#PWD#'
452 w
453 w
454 #MAKE#: 'all' is up to date.
455 #MAKE#: Leaving directory '#PWD#'\n");
456 }
457
458 # sv 63537
459 # -w in makefile, --no-print-directory on the command line.
460 for my $fl (@flavors) {
461 run_make_test("
462 MAKEFLAGS${fl}-w
463 \$(info \$(MAKEFLAGS))
464 all:; \$(info \$(MAKEFLAGS))
465 ", '--no-print-directory',
466 " --no-print-directory
467 --no-print-directory
468 #MAKE#: 'all' is up to date.\n");
469 }
470
471 mkdir('lib2', 0777);
472 create_file('lib2/makefile', 'all:; $(info $(MAKEFLAGS))');
473
474 # sv 63537
475 # Default, no -w or --no-print-directory is specified.
476 run_make_test(q!
477 all:; $(MAKE) -C lib2
478 !, '',
479 "#MAKEPATH# -C lib2
480 #MAKE#[1]: Entering directory '#PWD#/lib2'
481
482 #MAKE#[1]: 'all' is up to date.
483 #MAKE#[1]: Leaving directory '#PWD#/lib2'\n");
484
485 # sv 63537
486 # --no-print-directory in makefile, -w on the command line.
487 for my $fl (@flavors) {
488 run_make_test("
489 MAKEFLAGS${fl}--no-print-directory
490 \$(info \$(MAKEFLAGS))
491 all:
492 \t \$(info \$(MAKEFLAGS))
493 \t \$(MAKE) -C lib2
494 ", '-w',
495 "#MAKE#: Entering directory '#PWD#'
496 w
497 w
498 #MAKEPATH# -C lib2
499 #MAKE#[1]: Entering directory '#PWD#/lib2'
500 w
501 #MAKE#[1]: 'all' is up to date.
502 #MAKE#[1]: Leaving directory '#PWD#/lib2'
503 #MAKE#: Leaving directory '#PWD#'\n");
504 }
505
506 # sv 63537
507 # --no-print-directory in makefile, -w in the env.
508 for my $fl (@flavors) {
509 $ENV{'MAKEFLAGS'} = '-w';
510 run_make_test("
511 MAKEFLAGS${fl}--no-print-directory
512 \$(info \$(MAKEFLAGS))
513 all:
514 \t \$(info \$(MAKEFLAGS))
515 \t \$(MAKE) -C lib2
516 ", '',
517 "#MAKE#: Entering directory '#PWD#'
518 w
519 w
520 #MAKEPATH# -C lib2
521 #MAKE#[1]: Entering directory '#PWD#/lib2'
522 w
523 #MAKE#[1]: 'all' is up to date.
524 #MAKE#[1]: Leaving directory '#PWD#/lib2'
525 #MAKE#: Leaving directory '#PWD#'\n");
526 }
527
528 unlink('lib2/makefile');
529 rmdir('lib2');
530
531 # sv 63537
532 # -k vs -S.
533
534
535 # -S in env.
536 $ENV{'MAKEFLAGS'} = '-S';
537 run_make_test(q!
538 .RECIPEPREFIX := >
539 $(info $(MAKEFLAGS))
540 all: one two
541 one:
542 > $(info $(MAKEFLAGS))
543 > #HELPER# -q fail 1
544 two:; $(info $@)
545 !, '',
546 "S
547 S
548 #HELPER# -q fail 1
549 #MAKE#: *** [#MAKEFILE#:7: one] Error 1", 512);
550
551 # -S in env, -k on the command line.
552 $ENV{'MAKEFLAGS'} = '-S';
553 run_make_test(q!
554 .RECIPEPREFIX := >
555 $(info $(MAKEFLAGS))
556 all: one two
557 one:
558 > $(info $(MAKEFLAGS))
559 > #HELPER# -q fail 1
560 two:; $(info $@)
561 !, '-k',
562 "k
563 k
564 #HELPER# -q fail 1
565 #MAKE#: *** [#MAKEFILE#:7: one] Error 1
566 two
567 #MAKE#: Target 'all' not remade because of errors.", 512);
568
569 # -k in env.
570 $ENV{'MAKEFLAGS'} = '-k';
571 run_make_test(q!
572 .RECIPEPREFIX := >
573 $(info $(MAKEFLAGS))
574 all: one two
575 one:
576 > $(info $(MAKEFLAGS))
577 > #HELPER# -q fail 1
578 two:; $(info $@)
579 !, '',
580 "k
581 k
582 #HELPER# -q fail 1
583 #MAKE#: *** [#MAKEFILE#:7: one] Error 1
584 two
585 #MAKE#: Target 'all' not remade because of errors.", 512);
586
587 # -k in env, -S on the command line.
588 $ENV{'MAKEFLAGS'} = '-k';
589 run_make_test(q!
590 .RECIPEPREFIX := >
591 $(info $(MAKEFLAGS))
592 all: one two
593 one:
594 > $(info $(MAKEFLAGS))
595 > #HELPER# -q fail 1
596 two:; $(info $@)
597 !, '-S',
598 "S
599 S
600 #HELPER# -q fail 1
601 #MAKE#: *** [#MAKEFILE#:7: one] Error 1", 512);
602
603 delete $ENV{'MAKEFLAGS'};
604
605 # -k in makefile.
606 for my $fl (@flavors) {
607 run_make_test("
608 MAKEFLAGS${fl}-k
609 \$(info \$(MAKEFLAGS))
610 all: one two
611 one:
612 \t \$(info \$(MAKEFLAGS))
613 \t #HELPER# -q fail 1
614 two:; \$(info \$@)
615 ", '',
616 "k
617 k
618 #HELPER# -q fail 1
619 #MAKE#: *** [#MAKEFILE#:7: one] Error 1
620 two
621 #MAKE#: Target 'all' not remade because of errors.", 512);
622 }
623
624 # sv 63537
625 # -k in makefile and -S on the command line.
626 for my $fl (@flavors) {
627 run_make_test("
628 MAKEFLAGS${fl}-k
629 \$(info \$(MAKEFLAGS))
630 all: one two
631 one:
632 \t \$(info \$(MAKEFLAGS))
633 \t #HELPER# -q fail 1
634 two:; \$(info \$@)
635 ", '-S',
636 "S
637 S
638 #HELPER# -q fail 1
639 #MAKE#: *** [#MAKEFILE#:7: one] Error 1", 512);
640 }
641
642 # sv 63537
643 # -k in makefile and -S in the env.
644 for my $fl (@flavors) {
645 $ENV{'MAKEFLAGS'} = '-S';
646 run_make_test("
647 MAKEFLAGS${fl}-k
648 \$(info \$(MAKEFLAGS))
649 all: one two
650 one:
651 \t \$(info \$(MAKEFLAGS))
652 \t #HELPER# -q fail 1
653 two:; \$(info \$@)
654 ", '',
655 "S
656 S
657 #HELPER# -q fail 1
658 #MAKE#: *** [#MAKEFILE#:7: one] Error 1", 512);
659 }
660
661 delete $ENV{'MAKEFLAGS'};
662
663 # sv 63537
664 # -S in makefile.
665 for my $fl (@flavors) {
666 run_make_test("
667 MAKEFLAGS${fl}-S
668 \$(info \$(MAKEFLAGS))
669 all: one two
670 one:
671 \t \$(info \$(MAKEFLAGS))
672 \t #HELPER# -q fail 1
673 two:; \$(info \$@)
674 ", '',
675 "S
676 S
677 #HELPER# -q fail 1
678 #MAKE#: *** [#MAKEFILE#:7: one] Error 1", 512);
679 }
680
681 # -S in makefile and -k on the command line.
682 for my $fl (@flavors) {
683 run_make_test("
684 MAKEFLAGS${fl}-S
685 \$(info \$(MAKEFLAGS))
686 all: one two
687 one:
688 \t \$(info \$(MAKEFLAGS))
689 \t #HELPER# -q fail 1
690 two:; \$(info \$@)
691 ", '-k',
692 "k
693 k
694 #HELPER# -q fail 1
695 #MAKE#: *** [#MAKEFILE#:7: one] Error 1
696 two
697 #MAKE#: Target 'all' not remade because of errors.", 512);
698 }
699
700 # sv 63537
701 # -S in makefile and -k in the env.
702 for my $fl (@flavors) {
703 $ENV{'MAKEFLAGS'} = '-k';
704 run_make_test("
705 MAKEFLAGS${fl}-S
706 \$(info \$(MAKEFLAGS))
707 all: one two
708 one:
709 \t \$(info \$(MAKEFLAGS))
710 \t #HELPER# -q fail 1
711 two:; \$(info \$@)
712 ", '',
713 "k
714 k
715 #HELPER# -q fail 1
716 #MAKE#: *** [#MAKEFILE#:7: one] Error 1
717 two
718 #MAKE#: Target 'all' not remade because of errors.", 512);
719 }
720
721
722 # sv 63537
723 # -s vs --no-silent.
724
725 # -s in env.
726 $ENV{'MAKEFLAGS'} = '-s';
727 run_make_test(q!
728 $(info $(MAKEFLAGS))
729 all:; $(info $(MAKEFLAGS))
730 !, '', "s\ns");
731
732 # -s in env, --no-silent on the command line.
733 $ENV{'MAKEFLAGS'} = '-s';
734 run_make_test(q!
735 $(info $(MAKEFLAGS))
736 all:; $(info $(MAKEFLAGS))
737 !, '--no-silent',
738 " --no-silent
739 --no-silent
740 #MAKE#: 'all' is up to date.\n");
741
742 # --no-silent in env.
743 $ENV{'MAKEFLAGS'} = '--no-silent';
744 run_make_test(q!
745 $(info $(MAKEFLAGS))
746 all:; $(info $(MAKEFLAGS))
747 !, '',
748 " --no-silent
749 --no-silent
750 #MAKE#: 'all' is up to date.\n");
751
752 # --no-silent in env, -s on the command line.
753 $ENV{'MAKEFLAGS'} = '--no-silent';
754 run_make_test(q!
755 $(info $(MAKEFLAGS))
756 all:; $(info $(MAKEFLAGS))
757 !, '-s', "s\ns");
758
759 delete $ENV{'MAKEFLAGS'};
760
761 # -s in the makefile.
762 for my $fl (@flavors) {
763 run_make_test("
764 MAKEFLAGS${fl}-s
765 \$(info \$(MAKEFLAGS))
766 all:; \$(info \$(MAKEFLAGS))
767 ", '', "s\ns");
768 }
769
770 # sv 63537
771 # -s in makefile and --no-silent on the command line.
772 for my $fl (@flavors) {
773 run_make_test("
774 MAKEFLAGS${fl}-s
775 \$(info \$(MAKEFLAGS))
776 all:; \$(info \$(MAKEFLAGS))
777 ", '--no-silent',
778 " --no-silent
779 --no-silent
780 #MAKE#: 'all' is up to date.\n");
781 }
782
783 # sv 63537
784 # -s in makefile and --no-silent in the env.
785 for my $fl (@flavors) {
786 $ENV{'MAKEFLAGS'} = '--no-silent';
787 run_make_test("
788 MAKEFLAGS${fl}-s
789 \$(info \$(MAKEFLAGS))
790 all:; \$(info \$(MAKEFLAGS))
791 ", '',
792 " --no-silent
793 --no-silent
794 #MAKE#: 'all' is up to date.\n");
795 }
796
797 delete $ENV{'MAKEFLAGS'};
798
799 # sv 63537
800 # --no-silent in makefile.
801 for my $fl (@flavors) {
802 run_make_test("
803 MAKEFLAGS${fl}--no-silent
804 \$(info \$(MAKEFLAGS))
805 all:; \$(info \$(MAKEFLAGS))
806 ", '',
807 " --no-silent
808 --no-silent
809 #MAKE#: 'all' is up to date.\n");
810 }
811
812 # sv 63537
813 # --no-silent in makefile and -s on the command line.
814 for my $fl (@flavors) {
815 run_make_test("
816 MAKEFLAGS${fl}--no-silent
817 \$(info \$(MAKEFLAGS))
818 all:; \$(info \$(MAKEFLAGS))
819 ", '-s', "s\ns");
820 }
821
822 # sv 63537
823 # --no-silent in makefile and -s in the env.
824 for my $fl (@flavors) {
825 $ENV{'MAKEFLAGS'} = '-s';
826 run_make_test("
827 MAKEFLAGS${fl}--no-silent
828 \$(info \$(MAKEFLAGS))
829 all:; \$(info \$(MAKEFLAGS))
830 ", '', "s\ns");
831 }
832
833 delete $ENV{'MAKEFLAGS'};
834
835 # sv 63537
836 # Multiple --debug switches from various origins are all combined.
837 # Because run_make_test regex matching facility does not allow to match against
838 # multiple lines, run the test twice. During the first run match the output of
839 # --debug=b, during the second run match the output of --debug=-j.
840 #
841 # --debug=b in makefile.
842 for my $fl (@flavors) {
843 run_make_test("
844 MAKEFLAGS${fl}--debug=b
845 hello:; touch \$@
846 .PHONY: hello
847 ", '', "/Updating makefiles/");
848 }
849
850 # --debug=b in makefile, --debug=j on the command line.
851 # Test for --debug=j output.
852 for my $fl (@flavors) {
853 run_make_test("
854 MAKEFLAGS${fl}--debug=b
855 hello:; touch \$@
856 .PHONY: hello
857 ", '--debug=j', "/Putting child/");
858 }
859
860 # --debug=b in makefile, --debug=j on the command line.
861 # Test for --debug=b output.
862 for my $fl (@flavors) {
863 run_make_test("
864 MAKEFLAGS${fl}--debug=b
865 hello:; touch \$@
866 .PHONY: hello
867 ", '--debug=j', "/Updating makefiles/");
868 }
869
870 # --debug=j in makefile, --debug=b on the command line.
871 # Test that MAKEFLAGS contains --debug=b.
872 run_make_test(q!
873 MAKEFLAGS=--debug=j
874 $(info makeflags=$(MAKEFLAGS))
875 hello:; touch $@
876 .PHONY: hello
877 !, '--debug=b', "/makeflags= --debug=b/");
878
879 # --debug=b in makefile, --debug=j in the env.
880 # Test for --debug=j output.
881 for my $fl (@flavors) {
882 $ENV{'MAKEFLAGS'} = '--debug=j';
883 run_make_test("
884 MAKEFLAGS${fl}--debug=b
885 hello:; touch \$@
886 .PHONY: hello
887 ", '', "/Putting child/");
888 }
889
890 # --debug=b in makefile, --debug=j in the env.
891 # Test for --debug=b output.
892 for my $fl (@flavors) {
893 $ENV{'MAKEFLAGS'} = '--debug=j';
894 run_make_test("
895 MAKEFLAGS${fl}--debug=b
896 hello:; touch \$@
897 .PHONY: hello
898 ", '', "/Updating makefiles/");
899 }
900
901 unlink('hello');
902
903 rmdir('localtmp');
904
905 # This tells the test driver that the perl test script executed properly.
906 1;