3 $description = "Test the behaviour of the .SECONDARY target.";
6 Test the behavior of the .SECONDARY special target.
7 Create a makefile where a file would not normally be considered
8 intermediate, then specify it as .SECONDARY. Build and note that it's
9 not automatically deleted. Delete the file. Rebuild to ensure that
10 it's not created if it doesn't exist but doesn't need to be built.
11 Change the original and ensure that the secondary file and the ultimate
12 target are both rebuilt, and that the secondary file is not deleted.
14 Try this with implicit rules and explicit rules: both should work.\n";
16 open(MAKEFILE,"> $makefile");
18 print MAKEFILE <<'EOF';
29 foo.c: foo.e ; cp $< $@
36 &utouch(-20, 'foo.f');
38 &run_make_with_options($makefile,'foo.d',&get_logfile);
39 $answer = "cp foo.f foo.e\ncp foo.e foo.d\n";
40 &compare_output($answer, &get_logfile(1));
46 &run_make_with_options($makefile,'foo.d',&get_logfile);
47 $answer = "$make_name: `foo.d' is up to date.\n";
48 &compare_output($answer, &get_logfile(1));
52 &utouch(-10, 'foo.d');
55 &run_make_with_options($makefile,'foo.d',&get_logfile);
56 $answer = "cp foo.f foo.e\ncp foo.e foo.d\n";
57 &compare_output($answer, &get_logfile(1));
61 &run_make_with_options($makefile,'foo.c',&get_logfile);
62 $answer = "cp foo.e foo.c\n";
63 &compare_output($answer, &get_logfile(1));
69 &run_make_with_options($makefile,'foo.c',&get_logfile);
70 $answer = "$make_name: `foo.c' is up to date.\n";
71 &compare_output($answer, &get_logfile(1));
75 &utouch(-10, 'foo.c');
78 &run_make_with_options($makefile,'foo.c',&get_logfile);
79 $answer = "cp foo.f foo.e\ncp foo.e foo.c\n";
80 &compare_output($answer, &get_logfile(1));
82 unlink('foo.f', 'foo.e', 'foo.d', 'foo.c');
84 # TEST #7 -- test the "global" .SECONDARY, with no targets.
86 $makefile2 = &get_tmpfile;
88 open(MAKEFILE, "> $makefile2");
90 print MAKEFILE <<'EOF';
96 final intermediate source:
102 &utouch(-10, 'source');
105 &run_make_with_options($makefile2, '', &get_logfile);
106 $answer = "$make_name: `final' is up to date.\n";
107 &compare_output($answer, &get_logfile(1));
109 unlink('source', 'final', 'intermediate');
112 # TEST #8 -- test the "global" .SECONDARY, with .PHONY.
118 version2: version ; @echo GOOD
124 # TEST #9 -- Savannah bug #15919
125 # The original fix for this bug caused a new bug, shown here.
140 unlink(qw(1.a 2.a 1.c 2.c));
142 # TEST #10 -- Savannah bug #15919
145 .SECONDARY : test.1 test.2 test.3
149 %.4 : %.int %.3 ; touch $@
151 %.int : %.3 %.2 ; touch $@
153 %.3 : | %.2 ; touch $@
157 %.1 : %.0 ; touch $@', '-rR -j 2',
165 # After a touch of test.0 it should give the same output, except we don't need
166 # to rebuild test.3 (order-only)
169 run_make_test(undef, '-rR -j 2',
176 # With both test.0 and test.3 updated it should still build everything except
179 touch('test.0', 'test.3');
180 run_make_test(undef, '-rR -j 2',
187 unlink(qw(test.0 test.1 test.2 test.3 test.4));
189 # This tells the test driver that the perl test script executed properly.