1999-09-14 02:03:19 +00:00
|
|
|
#! -*-perl-*-
|
|
|
|
|
|
|
|
$description = "Test the behaviour of the .SECONDARY target.";
|
|
|
|
|
|
|
|
$details = "\
|
|
|
|
Test the behavior of the .SECONDARY special target.
|
|
|
|
Create a makefile where a file would not normally be considered
|
|
|
|
intermediate, then specify it as .SECONDARY. Build and note that it's
|
|
|
|
not automatically deleted. Delete the file. 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 secondary file and the ultimate
|
|
|
|
target are both rebuilt, and that the secondary file is not deleted.
|
|
|
|
|
|
|
|
Try this with implicit rules and explicit rules: both should work.\n";
|
|
|
|
|
|
|
|
open(MAKEFILE,"> $makefile");
|
|
|
|
|
|
|
|
print MAKEFILE <<'EOF';
|
|
|
|
|
|
|
|
.SECONDARY: foo.e
|
|
|
|
|
|
|
|
# Implicit rule test
|
|
|
|
%.d : %.e ; cp $< $@
|
|
|
|
%.e : %.f ; cp $< $@
|
|
|
|
|
|
|
|
foo.d: foo.e
|
|
|
|
|
|
|
|
# Explicit rule test
|
|
|
|
foo.c: foo.e ; cp $< $@
|
|
|
|
EOF
|
|
|
|
|
|
|
|
close(MAKEFILE);
|
|
|
|
|
|
|
|
# TEST #1
|
|
|
|
|
2002-09-04 07:26:19 +00:00
|
|
|
&utouch(-20, 'foo.f');
|
1999-09-14 02:03:19 +00:00
|
|
|
|
|
|
|
&run_make_with_options($makefile,'foo.d',&get_logfile);
|
|
|
|
$answer = "cp foo.f foo.e\ncp foo.e foo.d\n";
|
|
|
|
&compare_output($answer, &get_logfile(1));
|
|
|
|
|
|
|
|
# TEST #2
|
|
|
|
|
|
|
|
unlink('foo.e');
|
|
|
|
|
|
|
|
&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 #3
|
|
|
|
|
2002-09-04 07:26:19 +00:00
|
|
|
&utouch(-10, 'foo.d');
|
1999-09-14 02:03:19 +00:00
|
|
|
&touch('foo.f');
|
|
|
|
|
|
|
|
&run_make_with_options($makefile,'foo.d',&get_logfile);
|
|
|
|
$answer = "cp foo.f foo.e\ncp foo.e foo.d\n";
|
|
|
|
&compare_output($answer, &get_logfile(1));
|
|
|
|
|
|
|
|
# TEST #4
|
|
|
|
|
|
|
|
&run_make_with_options($makefile,'foo.c',&get_logfile);
|
|
|
|
$answer = "cp foo.e foo.c\n";
|
|
|
|
&compare_output($answer, &get_logfile(1));
|
|
|
|
|
|
|
|
# TEST #5
|
|
|
|
|
|
|
|
unlink('foo.e');
|
|
|
|
|
|
|
|
&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 #6
|
|
|
|
|
2002-09-04 07:26:19 +00:00
|
|
|
&utouch(-10, 'foo.c');
|
1999-09-14 02:03:19 +00:00
|
|
|
&touch('foo.f');
|
|
|
|
|
|
|
|
&run_make_with_options($makefile,'foo.c',&get_logfile);
|
|
|
|
$answer = "cp foo.f foo.e\ncp foo.e foo.c\n";
|
|
|
|
&compare_output($answer, &get_logfile(1));
|
|
|
|
|
|
|
|
unlink('foo.f', 'foo.e', 'foo.d', 'foo.c');
|
|
|
|
|
2003-03-28 06:31:44 +00:00
|
|
|
# TEST #7 -- test the "global" .SECONDARY, with no targets.
|
|
|
|
|
|
|
|
$makefile2 = &get_tmpfile;
|
|
|
|
|
|
|
|
open(MAKEFILE, "> $makefile2");
|
|
|
|
|
|
|
|
print MAKEFILE <<'EOF';
|
|
|
|
.SECONDARY:
|
|
|
|
|
|
|
|
final: intermediate
|
|
|
|
intermediate: source
|
|
|
|
|
|
|
|
final intermediate source:
|
|
|
|
echo $< > $@
|
|
|
|
EOF
|
|
|
|
|
|
|
|
close(MAKEFILE);
|
|
|
|
|
|
|
|
&utouch(-10, 'source');
|
|
|
|
touch('final');
|
|
|
|
|
|
|
|
&run_make_with_options($makefile2, '', &get_logfile);
|
|
|
|
$answer = "$make_name: `final' is up to date.\n";
|
|
|
|
&compare_output($answer, &get_logfile(1));
|
|
|
|
|
|
|
|
unlink('source', 'final', 'intermediate');
|
|
|
|
|
2005-04-08 12:51:20 +00:00
|
|
|
|
|
|
|
# TEST #8 -- test the "global" .SECONDARY, with .PHONY.
|
|
|
|
|
|
|
|
touch('version2');
|
|
|
|
run_make_test('
|
|
|
|
.PHONY: version
|
|
|
|
.SECONDARY:
|
|
|
|
version2: version ; @echo GOOD
|
|
|
|
all: version2',
|
|
|
|
'all', 'GOOD');
|
|
|
|
|
|
|
|
unlink('version2');
|
|
|
|
|
1999-09-14 02:03:19 +00:00
|
|
|
# This tells the test driver that the perl test script executed properly.
|
|
|
|
1;
|