• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#                                                                    -*-perl-*-
2
3$description = "Test the behaviour of the .INTERMEDIATE target.";
4
5$details = "\
6Test the behavior of the .INTERMEDIATE special target.
7Create a makefile where a file would not normally be considered
8intermediate, then specify it as .INTERMEDIATE.  Build and ensure it's
9deleted properly.  Rebuild to ensure that it's not created if it doesn't
10exist but doesn't need to be built.  Change the original and ensure
11that the intermediate file and the ultimate target are both rebuilt, and
12that the intermediate file is again deleted.
13
14Try this with implicit rules and explicit rules: both should work.\n";
15
16open(MAKEFILE,"> $makefile");
17
18print MAKEFILE <<'EOF';
19
20.INTERMEDIATE: foo.e bar.e
21
22# Implicit rule test
23%.d : %.e ; cp $< $@
24%.e : %.f ; cp $< $@
25
26foo.d: foo.e
27
28# Explicit rule test
29foo.c: foo.e bar.e; cat $^ > $@
30EOF
31
32close(MAKEFILE);
33
34# TEST #0
35
36&utouch(-20, 'foo.f', 'bar.f');
37
38&run_make_with_options($makefile,'foo.d',&get_logfile);
39$answer = "cp foo.f foo.e\ncp foo.e foo.d\nrm foo.e\n";
40&compare_output($answer, &get_logfile(1));
41
42# TEST #1
43
44&run_make_with_options($makefile,'foo.d',&get_logfile);
45$answer = "$make_name: `foo.d' is up to date.\n";
46&compare_output($answer, &get_logfile(1));
47
48# TEST #2
49
50&utouch(-10, 'foo.d');
51&touch('foo.f');
52
53&run_make_with_options($makefile,'foo.d',&get_logfile);
54$answer = "cp foo.f foo.e\ncp foo.e foo.d\nrm foo.e\n";
55&compare_output($answer, &get_logfile(1));
56
57# TEST #3
58
59&run_make_with_options($makefile,'foo.c',&get_logfile);
60$answer = "cp foo.f foo.e\ncp bar.f bar.e\ncat foo.e bar.e > foo.c\nrm bar.e foo.e\n";
61&compare_output($answer, &get_logfile(1));
62
63# TEST #4
64
65&run_make_with_options($makefile,'foo.c',&get_logfile);
66$answer = "$make_name: `foo.c' is up to date.\n";
67&compare_output($answer, &get_logfile(1));
68
69# TEST #5
70
71&utouch(-10, 'foo.c');
72&touch('foo.f');
73
74&run_make_with_options($makefile,'foo.c',&get_logfile);
75$answer = "cp foo.f foo.e\ncp bar.f bar.e\ncat foo.e bar.e > foo.c\nrm bar.e foo.e\n";
76&compare_output($answer, &get_logfile(1));
77
78# TEST #6 -- added for PR/1669: don't remove files mentioned on the cmd line.
79
80&run_make_with_options($makefile,'foo.e',&get_logfile);
81$answer = "cp foo.f foo.e\n";
82&compare_output($answer, &get_logfile(1));
83
84unlink('foo.f', 'foo.e', 'foo.d', 'foo.c', 'bar.f', 'bar.e', 'bar.d', 'bar.c');
85
86# TEST #7 -- added for PR/1423
87
88$makefile2 = &get_tmpfile;
89
90open(MAKEFILE, "> $makefile2");
91
92print MAKEFILE <<'EOF';
93all: foo
94foo.a: ; touch $@
95%: %.a ; touch $@
96.INTERMEDIATE: foo.a
97EOF
98
99close(MAKEFILE);
100
101&run_make_with_options($makefile2, '-R', &get_logfile);
102$answer = "touch foo.a\ntouch foo\nrm foo.a\n";
103&compare_output($answer, &get_logfile(1));
104
105unlink('foo');
106
107# This tells the test driver that the perl test script executed properly.
1081;
109