| 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 |
# TEST #0 |
| 17 |
|
| 18 |
&utouch(-20, 'foo.f', 'bar.f'); |
| 19 |
|
| 20 |
run_make_test(q! |
| 21 |
.INTERMEDIATE: foo.e bar.e |
| 22 |
|
| 23 |
# Implicit rule test |
| 24 |
%.d : %.e ; cp $< $@ |
| 25 |
%.e : %.f ; cp $< $@ |
| 26 |
|
| 27 |
foo.d: foo.e |
| 28 |
|
| 29 |
# Explicit rule test |
| 30 |
foo.c: foo.e bar.e; cat $^ > $@ |
| 31 |
!, |
| 32 |
'foo.d', "cp foo.f foo.e\ncp foo.e foo.d\nrm foo.e\n"); |
| 33 |
|
| 34 |
# TEST #1 |
| 35 |
|
| 36 |
run_make_test(undef, 'foo.d', "#MAKE#: 'foo.d' is up to date.\n"); |
| 37 |
|
| 38 |
# TEST #2 |
| 39 |
|
| 40 |
&utouch(-10, 'foo.d'); |
| 41 |
&touch('foo.f'); |
| 42 |
|
| 43 |
run_make_test(undef, 'foo.d', "cp foo.f foo.e\ncp foo.e foo.d\nrm foo.e\n"); |
| 44 |
|
| 45 |
# TEST #3 |
| 46 |
|
| 47 |
run_make_test(undef, 'foo.c', "cp foo.f foo.e\ncp bar.f bar.e\ncat foo.e bar.e > foo.c\nrm foo.e bar.e\n"); |
| 48 |
|
| 49 |
# TEST #4 |
| 50 |
|
| 51 |
run_make_test(undef, 'foo.c', "#MAKE#: 'foo.c' is up to date.\n"); |
| 52 |
|
| 53 |
# TEST #5 |
| 54 |
|
| 55 |
&utouch(-10, 'foo.c'); |
| 56 |
&touch('foo.f'); |
| 57 |
|
| 58 |
run_make_test(undef, 'foo.c', "cp foo.f foo.e\ncp bar.f bar.e\ncat foo.e bar.e > foo.c\nrm foo.e bar.e\n"); |
| 59 |
|
| 60 |
# TEST #6 -- added for PR/1669: don't remove files mentioned on the cmd line. |
| 61 |
|
| 62 |
run_make_test(undef, 'foo.e', "cp foo.f foo.e\n"); |
| 63 |
|
| 64 |
unlink('foo.f', 'foo.e', 'foo.d', 'foo.c', 'bar.f', 'bar.e', 'bar.d', 'bar.c'); |
| 65 |
|
| 66 |
# TEST #7 -- added for PR/1423 |
| 67 |
|
| 68 |
run_make_test(q! |
| 69 |
all: foo |
| 70 |
foo.a: ; touch $@ |
| 71 |
%: %.a ; touch $@ |
| 72 |
.INTERMEDIATE: foo.a |
| 73 |
!, |
| 74 |
'-R', "touch foo.a\ntouch foo\nrm foo.a\n"); |
| 75 |
|
| 76 |
unlink('foo'); |
| 77 |
|
| 78 |
# sv 60188. |
| 79 |
# A file made by an implicit rule, but explicitly mentioned by the user, is |
| 80 |
# still considered intermediate if it's a prereq to .INTERMEDIATE. |
| 81 |
|
| 82 |
touch('hello.z'); |
| 83 |
unlink('test.x'); |
| 84 |
|
| 85 |
run_make_test(q! |
| 86 |
all: hello.z |
| 87 |
%.z: test.x; touch $@ |
| 88 |
%.x: ; |
| 89 |
.INTERMEDIATE: test.x |
| 90 |
!, '', "#MAKE#: Nothing to be done for 'all'.\n"); |
| 91 |
|
| 92 |
unlink('hello.z'); |
| 93 |
|
| 94 |
# A target explicitly listed as a prerequisite of a pattern rule, is still |
| 95 |
# considered mentioned and "ought to exist". |
| 96 |
|
| 97 |
run_make_test(q! |
| 98 |
1.all: 1.q ; touch $@ |
| 99 |
%.q: 1.r ; touch $@ |
| 100 |
%.r: ; touch $@ |
| 101 |
.INTERMEDIATE: 1.r |
| 102 |
!, |
| 103 |
'', "touch 1.r\ntouch 1.q\ntouch 1.all\nrm 1.r\n"); |
| 104 |
|
| 105 |
unlink('1.all', '1.q', '1.r'); |
| 106 |
|
| 107 |
# This tells the test driver that the perl test script executed properly. |
| 108 |
1; |