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