1 | # -*-mode: perl-*-
|
---|
2 |
|
---|
3 | $description = "Test GNU make's auto-reinvocation feature.";
|
---|
4 |
|
---|
5 | $details = "\
|
---|
6 | If the makefile or one it includes can be rebuilt then it is, and make
|
---|
7 | is reinvoked. We create a rule to rebuild the makefile from a temp
|
---|
8 | file, then touch the temp file to make it newer than the makefile.";
|
---|
9 |
|
---|
10 | $makefile2 = &get_tmpfile;
|
---|
11 | $makefile_orig = &get_tmpfile;
|
---|
12 |
|
---|
13 | open(MAKEFILE,"> $makefile");
|
---|
14 |
|
---|
15 | print MAKEFILE <<EOM;
|
---|
16 |
|
---|
17 | all: ; \@echo 'running rules.'
|
---|
18 |
|
---|
19 | $makefile $makefile2: $makefile_orig
|
---|
20 | \@echo 'rebuilding \$\@.'
|
---|
21 | \@echo >> \$\@
|
---|
22 |
|
---|
23 | include $makefile2
|
---|
24 |
|
---|
25 | EOM
|
---|
26 |
|
---|
27 | close(MAKEFILE);
|
---|
28 |
|
---|
29 | &utouch(-10, $makefile, $makefile2);
|
---|
30 | &touch($makefile_orig);
|
---|
31 |
|
---|
32 | &run_make_with_options($makefile, "", &get_logfile, 0);
|
---|
33 |
|
---|
34 | # Create the answer to what should be produced by this Makefile
|
---|
35 |
|
---|
36 | $answer = "rebuilding $makefile2.\nrebuilding $makefile.\nrunning rules.\n";
|
---|
37 |
|
---|
38 | &compare_output($answer,&get_logfile(1))
|
---|
39 | && unlink "$makefile_orig";
|
---|
40 |
|
---|
41 | # In this test we create an included file that's out-of-date, but then
|
---|
42 | # the rule doesn't update it. Make shouldn't re-exec.
|
---|
43 |
|
---|
44 | $makefile3 = &get_tmpfile;
|
---|
45 |
|
---|
46 | open(MAKEFILE, "> $makefile3");
|
---|
47 | print MAKEFILE <<'EOM';
|
---|
48 | SHELL = /bin/sh
|
---|
49 |
|
---|
50 | all: ; @echo hello
|
---|
51 |
|
---|
52 | a : b ; echo >> $@
|
---|
53 |
|
---|
54 | b : c ; [ -f $@ ] || echo >> $@
|
---|
55 |
|
---|
56 | c: ; echo >> $@
|
---|
57 |
|
---|
58 | include $(F)
|
---|
59 | EOM
|
---|
60 |
|
---|
61 | close(MAKEFILE);
|
---|
62 |
|
---|
63 | &utouch(-20, 'b','a');
|
---|
64 | #&utouch(-10, 'a');
|
---|
65 | &touch('c');
|
---|
66 |
|
---|
67 | # First try with the file that's not updated "once removed" from the
|
---|
68 | # file we're including.
|
---|
69 |
|
---|
70 | &run_make_with_options($makefile3, "F=a", &get_logfile, 0);
|
---|
71 |
|
---|
72 | $answer = "[ -f b ] || echo >> b\nhello\n";
|
---|
73 | &compare_output($answer,&get_logfile(1));
|
---|
74 |
|
---|
75 | # Now try with the file we're not updating being the actual file we're
|
---|
76 | # including: this and the previous one test different parts of the code.
|
---|
77 |
|
---|
78 | &run_make_with_options($makefile3, "F=b", &get_logfile, 0);
|
---|
79 |
|
---|
80 | $answer = "[ -f b ] || echo >> b\nhello\n";
|
---|
81 | &compare_output($answer,&get_logfile(1));
|
---|
82 |
|
---|
83 | unlink('a','b','c');
|
---|
84 |
|
---|
85 | # This tells the test driver that the perl test script executed properly.
|
---|
86 | 1;
|
---|