- Enhance .POSIX to set -e when invoking shells, as demanded by a
[make.git] / tests / scripts / options / dash-B
blobe36842e339c8b01d9bac1356ad1b2c9008a8f037
1 #                                                                    -*-perl-*-
3 $description = "Test make -B (always remake) option.\n";
5 $details = "\
6 Construct a simple makefile that builds a target.
7 Invoke make once, so it builds everything.  Invoke it again and verify
8 that nothing is built.  Then invoke it with -B and verify that everything
9 is built again.";
11 &touch('bar.x');
13 run_make_test('
14 .SUFFIXES:
16 .PHONY: all
17 all: foo
19 foo: bar.x
20         @echo cp $< $@
21         @echo "" > $@
23               '', 'cp bar.x foo');
25 run_make_test(undef, '', "#MAKE#: Nothing to be done for `all'.");
26 run_make_test(undef, '-B', 'cp bar.x foo');
28 # Put the timestamp for foo into the future; it should still be remade.
30 utouch(1000, 'foo');
31 run_make_test(undef, '', "#MAKE#: Nothing to be done for `all'.");
32 run_make_test(undef, '-B', 'cp bar.x foo');
34 # Clean up
36 rmfiles('bar.x', 'foo');
38 # Test -B with the re-exec feature: we don't want to re-exec forever
39 # Savannah bug # 7566
41 run_make_test('
42 all: ; @:
43 $(info MAKE_RESTARTS=$(MAKE_RESTARTS))
44 include foo.x
45 foo.x: ; @touch $@
47               '-B', 'MAKE_RESTARTS=
48 #MAKEFILE#:4: foo.x: No such file or directory
49 MAKE_RESTARTS=1');
51 rmfiles('foo.x');
53 # Test -B with the re-exec feature: we DO want -B in the "normal" part of the
54 # makefile.
56 &touch('blah.x');
58 run_make_test('
59 all: blah.x ; @echo $@
60 $(info MAKE_RESTARTS=$(MAKE_RESTARTS))
61 include foo.x
62 foo.x: ; @touch $@
63 blah.x: ; @echo $@
65               '-B', 'MAKE_RESTARTS=
66 #MAKEFILE#:4: foo.x: No such file or directory
67 MAKE_RESTARTS=1
68 blah.x
69 all');
71 rmfiles('foo.x', 'blah.x');
73 # Test that $? is set properly with -B; all prerequisites will be newer!
75 utouch(-10, 'x.b');
76 touch('x.a');
78 run_make_test(q!
79 x.a: x.b ; @echo $?
81               '-B', "x.b\n");
83 unlink(qw(x.a x.b));