1#                                                                    -*-perl-*-
2
3$description = "Test make -B (always remake) option.\n";
4
5$details = "\
6Construct a simple makefile that builds a target.
7Invoke make once, so it builds everything.  Invoke it again and verify
8that nothing is built.  Then invoke it with -B and verify that everything
9is built again.";
10
11&touch('bar.x');
12
13run_make_test('
14.SUFFIXES:
15
16.PHONY: all
17all: foo
18
19foo: bar.x
20	@echo cp $< $@
21	@echo "" > $@
22',
23              '', 'cp bar.x foo');
24
25run_make_test(undef, '', "#MAKE#: Nothing to be done for `all'.");
26run_make_test(undef, '-B', 'cp bar.x foo');
27
28# Put the timestamp for foo into the future; it should still be remade.
29
30utouch(1000, 'foo');
31run_make_test(undef, '', "#MAKE#: Nothing to be done for `all'.");
32run_make_test(undef, '-B', 'cp bar.x foo');
33
34# Clean up
35
36rmfiles('bar.x', 'foo');
37
38# Test -B with the re-exec feature: we don't want to re-exec forever
39# Savannah bug # 7566
40
41run_make_test('
42all: ; @:
43$(info MAKE_RESTARTS=$(MAKE_RESTARTS))
44include foo.x
45foo.x: ; @touch $@
46',
47              '-B', 'MAKE_RESTARTS=
48#MAKEFILE#:4: foo.x: No such file or directory
49MAKE_RESTARTS=1');
50
51rmfiles('foo.x');
52
53# Test -B with the re-exec feature: we DO want -B in the "normal" part of the
54# makefile.
55
56&touch('blah.x');
57
58run_make_test('
59all: blah.x ; @echo $@
60$(info MAKE_RESTARTS=$(MAKE_RESTARTS))
61include foo.x
62foo.x: ; @touch $@
63blah.x: ; @echo $@
64',
65              '-B', 'MAKE_RESTARTS=
66#MAKEFILE#:4: foo.x: No such file or directory
67MAKE_RESTARTS=1
68blah.x
69all');
70
71rmfiles('foo.x', 'blah.x');
72
731;
74