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
|
# -*-perl-*-
$description = "Test the behaviour of the .INTERMEDIATE target.";
$details = "\
Test the behavior of the .INTERMEDIATE special target.
Create a makefile where a file would not normally be considered
intermediate, then specify it as .INTERMEDIATE. Build and ensure it's
deleted properly. Rebuild to ensure that it's not created if it doesn't
exist but doesn't need to be built. Change the original and ensure
that the intermediate file and the ultimate target are both rebuilt, and
that the intermediate file is again deleted.
Try this with implicit rules and explicit rules: both should work.\n";
open(MAKEFILE,"> $makefile");
print MAKEFILE <<'EOF';
.INTERMEDIATE: foo.e bar.e
# Implicit rule test
%.d : %.e ; cp $< $@
%.e : %.f ; cp $< $@
foo.d: foo.e
# Explicit rule test
foo.c: foo.e bar.e; cat $^ > $@
EOF
close(MAKEFILE);
# TEST #0
&touch('foo.f');
&touch('bar.f');
&run_make_with_options($makefile,'foo.d',&get_logfile);
$answer = "cp foo.f foo.e\ncp foo.e foo.d\nrm foo.e\n";
&compare_output($answer, &get_logfile(1));
# TEST #1
&run_make_with_options($makefile,'foo.d',&get_logfile);
$answer = "$make_name: `foo.d' is up to date.\n";
&compare_output($answer, &get_logfile(1));
# TEST #2
# Sleep 2 seconds for DOS/Windows FAT volumes which have 2-second
# granularity of file times.
sleep(2);
&touch('foo.f');
&run_make_with_options($makefile,'foo.d',&get_logfile);
$answer = "cp foo.f foo.e\ncp foo.e foo.d\nrm foo.e\n";
&compare_output($answer, &get_logfile(1));
# TEST #3
&run_make_with_options($makefile,'foo.c',&get_logfile);
$answer = "cp foo.f foo.e\ncp bar.f bar.e\ncat foo.e bar.e > foo.c\nrm foo.e bar.e\n";
&compare_output($answer, &get_logfile(1));
# TEST #4
&run_make_with_options($makefile,'foo.c',&get_logfile);
$answer = "$make_name: `foo.c' is up to date.\n";
&compare_output($answer, &get_logfile(1));
# TEST #5
# Sleep 2 seconds for DOS/Windows FAT volumes which have 2-second
# granularity of file times.
sleep(2);
&touch('foo.f');
&run_make_with_options($makefile,'foo.c',&get_logfile);
$answer = "cp foo.f foo.e\ncp bar.f bar.e\ncat foo.e bar.e > foo.c\nrm foo.e bar.e\n";
&compare_output($answer, &get_logfile(1));
unlink('foo.f', 'foo.e', 'foo.d', 'foo.c', 'bar.f', 'bar.e', 'bar.d', 'bar.c');
# This tells the test driver that the perl test script executed properly.
1;
|