| 1 |
# -*-perl-*- |
| 2 |
|
| 3 |
$description = "Test the behaviour of the .INTERMEDIATE target."; |
| 4 |
|
| 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. |
| 13 |
|
| 14 |
Try this with implicit rules and explicit rules: both should work.\n"; |
| 15 |
|
| 16 |
open(MAKEFILE,"> $makefile"); |
| 17 |
|
| 18 |
print MAKEFILE <<'EOF'; |
| 19 |
|
| 20 |
.INTERMEDIATE: foo.e bar.e |
| 21 |
|
| 22 |
# Implicit rule test |
| 23 |
%.d : %.e ; cp $< $@ |
| 24 |
%.e : %.f ; cp $< $@ |
| 25 |
|
| 26 |
foo.d: foo.e |
| 27 |
|
| 28 |
# Explicit rule test |
| 29 |
foo.c: foo.e bar.e; cat $^ > $@ |
| 30 |
EOF |
| 31 |
|
| 32 |
close(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 foo.e bar.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 foo.e bar.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 |
|
| 84 |
unlink('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 |
|
| 90 |
open(MAKEFILE, "> $makefile2"); |
| 91 |
|
| 92 |
print MAKEFILE <<'EOF'; |
| 93 |
all: foo |
| 94 |
foo.a: ; touch $@ |
| 95 |
%: %.a ; touch $@ |
| 96 |
.INTERMEDIATE: foo.a |
| 97 |
EOF |
| 98 |
|
| 99 |
close(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 |
|
| 105 |
unlink('foo'); |
| 106 |
|
| 107 |
# This tells the test driver that the perl test script executed properly. |
| 108 |
1; |