1# -*-perl-*- 2$description = "Test order-only prerequisites."; 3 4$details = "\ 5Create makefiles with various combinations of normal and order-only 6prerequisites and ensure they behave properly. Test the \$| variable."; 7 8# TEST #0 -- Basics 9 10run_make_test(' 11%r: | baz ; @echo $< $^ $| 12bar: foo 13foo:;@: 14baz:;@:', 15 '', "foo foo baz\n"); 16 17# TEST #1 -- First try: the order-only prereqs need to be built. 18 19run_make_test(q! 20foo: bar | baz 21 @echo '$$^ = $^' 22 @echo '$$| = $|' 23 touch $@ 24 25.PHONY: baz 26 27bar baz: 28 touch $@!, 29 '', "touch bar\ntouch baz\n\$^ = bar\n\$| = baz\ntouch foo\n"); 30 31 32# TEST #2 -- now we do it again: baz is PHONY but foo should _NOT_ be updated 33 34run_make_test(undef, '', "touch baz\n"); 35 36unlink(qw(foo bar baz)); 37 38# TEST #3 -- Make sure the order-only prereq was promoted to normal. 39 40run_make_test(q! 41foo: bar | baz 42 @echo '$$^ = $^' 43 @echo '$$| = $|' 44 touch $@ 45 46foo: baz 47 48.PHONY: baz 49 50bar baz: 51 touch $@!, 52 '', "touch bar\ntouch baz\n\$^ = bar baz\n\$| = \ntouch foo\n"); 53 54 55# TEST #4 -- now we do it again 56 57run_make_test(undef, '', "touch baz\n\$^ = bar baz\n\$| = \ntouch foo\n"); 58 59unlink(qw(foo bar baz)); 60 61# Test empty normal prereqs 62 63# TEST #5 -- make sure the parser was correct. 64 65run_make_test(q! 66foo:| baz 67 @echo '$$^ = $^' 68 @echo '$$| = $|' 69 touch $@ 70 71.PHONY: baz 72 73baz: 74 touch $@!, 75 '', "touch baz\n\$^ = \n\$| = baz\ntouch foo\n"); 76 77# TEST #6 -- now we do it again: this time foo won't be built 78 79run_make_test(undef, '', "touch baz\n"); 80 81unlink(qw(foo baz)); 82 83# Test order-only in pattern rules 84 85# TEST #7 -- make sure the parser was correct. 86 87run_make_test(q! 88%.w : %.x | baz 89 @echo '$$^ = $^' 90 @echo '$$| = $|' 91 touch $@ 92 93all: foo.w 94 95.PHONY: baz 96foo.x baz: 97 touch $@!, 98 '', 99 "touch foo.x\ntouch baz\n\$^ = foo.x\n\$| = baz\ntouch foo.w\n"); 100 101# TEST #8 -- now we do it again: this time foo.w won't be built 102 103run_make_test(undef, '', "touch baz\n"); 104 105unlink(qw(foo.w foo.x baz)); 106 107# TEST #9 -- make sure that $< is set correctly in the face of order-only 108# prerequisites in pattern rules. 109 110run_make_test(' 111%r: | baz ; @echo $< $^ $| 112bar: foo 113foo:;@: 114baz:;@:', 115 '', "foo foo baz\n"); 116 117 1181; 119