| # -*-perl-*- | |
| $description = "Test order-only prerequisites."; | |
| $details = "\ | |
| Create makefiles with various combinations of normal and order-only | |
| prerequisites and ensure they behave properly. Test the \$| variable."; | |
| # Basics | |
| run_make_test(' | |
| %r: | baz ; @echo $< $^ $| | |
| bar: foo | |
| foo:;@: | |
| baz:;@:', | |
| '', "foo foo baz\n"); | |
| # First try: the order-only prereqs need to be built. | |
| run_make_test(q! | |
| foo: bar | baz | |
| #TAB#@echo '$$^ = $^' | |
| #TAB#@echo '$$| = $|' | |
| #TAB#touch $@ | |
| .PHONY: baz | |
| bar baz: | |
| #TAB#touch $@!, | |
| '', "touch bar\ntouch baz\n\$^ = bar\n\$| = baz\ntouch foo\n"); | |
| # now we do it again: baz is PHONY but foo should _NOT_ be updated | |
| run_make_test(undef, '', "touch baz\n"); | |
| unlink(qw(foo bar baz)); | |
| # Make sure the order-only prereq was promoted to normal. | |
| run_make_test(q! | |
| foo: bar | baz | |
| #TAB#@echo '$$^ = $^' | |
| #TAB#@echo '$$| = $|' | |
| #TAB#touch $@ | |
| foo: baz | |
| .PHONY: baz | |
| bar baz: | |
| #TAB#touch $@!, | |
| '', "touch bar\ntouch baz\n\$^ = bar baz\n\$| = \ntouch foo\n"); | |
| # now we do it again | |
| run_make_test(undef, '', "touch baz\n\$^ = bar baz\n\$| = \ntouch foo\n"); | |
| unlink(qw(foo bar baz)); | |
| # Test empty normal prereqs | |
| # make sure the parser was correct. | |
| run_make_test(q! | |
| foo:| baz | |
| #TAB#@echo '$$^ = $^' | |
| #TAB#@echo '$$| = $|' | |
| #TAB#touch $@ | |
| .PHONY: baz | |
| baz: | |
| #TAB#touch $@!, | |
| '', "touch baz\n\$^ = \n\$| = baz\ntouch foo\n"); | |
| # now we do it again: this time foo won't be built | |
| run_make_test(undef, '', "touch baz\n"); | |
| unlink(qw(foo baz)); | |
| # Test order-only in pattern rules | |
| # make sure the parser was correct. | |
| run_make_test(q! | |
| %.w : %.x | baz | |
| #TAB#@echo '$$^ = $^' | |
| #TAB#@echo '$$| = $|' | |
| #TAB#touch $@ | |
| all: foo.w | |
| .PHONY: baz | |
| foo.x baz: | |
| #TAB#touch $@!, | |
| '', | |
| "touch foo.x\ntouch baz\n\$^ = foo.x\n\$| = baz\ntouch foo.w\n"); | |
| # now we do it again: this time foo.w won't be built | |
| run_make_test(undef, '', "touch baz\n"); | |
| unlink(qw(foo.w foo.x baz)); | |
| # make sure that $< is set correctly in the face of order-only | |
| # prerequisites in pattern rules. | |
| run_make_test(' | |
| %r: | baz ; @echo $< $^ $| | |
| bar: foo | |
| foo:;@: | |
| baz:;@:', | |
| '', "foo foo baz\n"); | |
| 1; |