Convert all "`'" quotes to "''" per new GNU Coding Standard guidelines.
[make.git] / tests / scripts / targets / INTERMEDIATE
blob2b3021b2352cfd53a6b92cf17a64ea8d9dee15e6
1 #                                                                    -*-perl-*-
3 $description = "Test the behaviour of the .INTERMEDIATE target.";
5 $details = "\
6 Test the behavior of the .INTERMEDIATE special target.
7 Create a makefile where a file would not normally be considered
8 intermediate, then specify it as .INTERMEDIATE.  Build and ensure it's
9 deleted properly.  Rebuild to ensure that it's not created if it doesn't
10 exist but doesn't need to be built.  Change the original and ensure
11 that the intermediate file and the ultimate target are both rebuilt, and
12 that the intermediate file is again deleted.
14 Try this with implicit rules and explicit rules: both should work.\n";
16 open(MAKEFILE,"> $makefile");
18 print MAKEFILE <<'EOF';
20 .INTERMEDIATE: foo.e bar.e
22 # Implicit rule test
23 %.d : %.e ; cp $< $@
24 %.e : %.f ; cp $< $@
26 foo.d: foo.e
28 # Explicit rule test
29 foo.c: foo.e bar.e; cat $^ > $@
30 EOF
32 close(MAKEFILE);
34 # TEST #0
36 &utouch(-20, 'foo.f', 'bar.f');
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));
42 # TEST #1
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));
48 # TEST #2
50 &utouch(-10, 'foo.d');
51 &touch('foo.f');
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));
57 # TEST #3
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));
63 # TEST #4
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));
69 # TEST #5
71 &utouch(-10, 'foo.c');
72 &touch('foo.f');
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));
78 # TEST #6 -- added for PR/1669: don't remove files mentioned on the cmd line.
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));
84 unlink('foo.f', 'foo.e', 'foo.d', 'foo.c', 'bar.f', 'bar.e', 'bar.d', 'bar.c');
86 # TEST #7 -- added for PR/1423
88 $makefile2 = &get_tmpfile;
90 open(MAKEFILE, "> $makefile2");
92 print MAKEFILE <<'EOF';
93 all: foo
94 foo.a: ; touch $@
95 %: %.a ; touch $@
96 .INTERMEDIATE: foo.a
97 EOF
99 close(MAKEFILE);
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));
105 unlink('foo');
107 # This tells the test driver that the perl test script executed properly.