2002-07-08 21:05:02 +08:00
|
|
|
# -*-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.";
|
|
|
|
|
2005-10-24 21:01:39 +08:00
|
|
|
# TEST #0 -- Basics
|
2002-07-08 21:05:02 +08:00
|
|
|
|
2005-10-24 21:01:39 +08:00
|
|
|
run_make_test('
|
|
|
|
%r: | baz ; @echo $< $^ $|
|
|
|
|
bar: foo
|
|
|
|
foo:;@:
|
|
|
|
baz:;@:',
|
|
|
|
'', "foo foo baz\n");
|
|
|
|
|
|
|
|
# TEST #1 -- First try: the order-only prereqs need to be built.
|
|
|
|
|
|
|
|
run_make_test(q!
|
2002-07-08 21:05:02 +08:00
|
|
|
foo: bar | baz
|
|
|
|
@echo '$$^ = $^'
|
|
|
|
@echo '$$| = $|'
|
|
|
|
touch $@
|
|
|
|
|
|
|
|
.PHONY: baz
|
|
|
|
|
|
|
|
bar baz:
|
2005-10-24 21:01:39 +08:00
|
|
|
touch $@!,
|
|
|
|
'', "touch bar\ntouch baz\n\$^ = bar\n\$| = baz\ntouch foo\n");
|
2002-07-08 21:05:02 +08:00
|
|
|
|
|
|
|
|
|
|
|
# TEST #2 -- now we do it again: baz is PHONY but foo should _NOT_ be updated
|
|
|
|
|
2005-10-24 21:01:39 +08:00
|
|
|
run_make_test(undef, '', "touch baz\n");
|
2002-07-08 21:05:02 +08:00
|
|
|
|
|
|
|
unlink(qw(foo bar baz));
|
|
|
|
|
2005-10-24 21:01:39 +08:00
|
|
|
# TEST #3 -- Make sure the order-only prereq was promoted to normal.
|
2002-07-08 21:05:02 +08:00
|
|
|
|
2005-10-24 21:01:39 +08:00
|
|
|
run_make_test(q!
|
2002-07-08 21:05:02 +08:00
|
|
|
foo: bar | baz
|
|
|
|
@echo '$$^ = $^'
|
|
|
|
@echo '$$| = $|'
|
|
|
|
touch $@
|
|
|
|
|
|
|
|
foo: baz
|
|
|
|
|
|
|
|
.PHONY: baz
|
|
|
|
|
|
|
|
bar baz:
|
2005-10-24 21:01:39 +08:00
|
|
|
touch $@!,
|
|
|
|
'', "touch bar\ntouch baz\n\$^ = bar baz\n\$| = \ntouch foo\n");
|
2002-07-08 21:05:02 +08:00
|
|
|
|
|
|
|
|
2002-07-09 14:35:56 +08:00
|
|
|
# TEST #4 -- now we do it again
|
2002-07-08 21:05:02 +08:00
|
|
|
|
2005-10-24 21:01:39 +08:00
|
|
|
run_make_test(undef, '', "touch baz\n\$^ = bar baz\n\$| = \ntouch foo\n");
|
2002-07-08 21:05:02 +08:00
|
|
|
|
|
|
|
unlink(qw(foo bar baz));
|
|
|
|
|
2002-07-09 14:35:56 +08:00
|
|
|
# Test empty normal prereqs
|
|
|
|
|
2005-10-24 21:01:39 +08:00
|
|
|
# TEST #5 -- make sure the parser was correct.
|
2002-07-09 14:35:56 +08:00
|
|
|
|
2005-10-24 21:01:39 +08:00
|
|
|
run_make_test(q!
|
2002-07-09 14:35:56 +08:00
|
|
|
foo:| baz
|
|
|
|
@echo '$$^ = $^'
|
|
|
|
@echo '$$| = $|'
|
|
|
|
touch $@
|
|
|
|
|
|
|
|
.PHONY: baz
|
|
|
|
|
|
|
|
baz:
|
2005-10-24 21:01:39 +08:00
|
|
|
touch $@!,
|
|
|
|
'', "touch baz\n\$^ = \n\$| = baz\ntouch foo\n");
|
2002-07-09 14:35:56 +08:00
|
|
|
|
|
|
|
# TEST #6 -- now we do it again: this time foo won't be built
|
|
|
|
|
2005-10-24 21:01:39 +08:00
|
|
|
run_make_test(undef, '', "touch baz\n");
|
2002-07-09 14:35:56 +08:00
|
|
|
|
|
|
|
unlink(qw(foo baz));
|
|
|
|
|
2004-01-08 03:36:39 +08:00
|
|
|
# Test order-only in pattern rules
|
|
|
|
|
2005-10-24 21:01:39 +08:00
|
|
|
# TEST #7 -- make sure the parser was correct.
|
2004-01-08 03:36:39 +08:00
|
|
|
|
2005-10-24 21:01:39 +08:00
|
|
|
run_make_test(q!
|
2004-01-08 03:36:39 +08:00
|
|
|
%.w : %.x | baz
|
|
|
|
@echo '$$^ = $^'
|
|
|
|
@echo '$$| = $|'
|
|
|
|
touch $@
|
|
|
|
|
|
|
|
all: foo.w
|
|
|
|
|
|
|
|
.PHONY: baz
|
|
|
|
foo.x baz:
|
2005-10-24 21:01:39 +08:00
|
|
|
touch $@!,
|
|
|
|
'',
|
|
|
|
"touch foo.x\ntouch baz\n\$^ = foo.x\n\$| = baz\ntouch foo.w\n");
|
2004-01-08 03:36:39 +08:00
|
|
|
|
|
|
|
# TEST #8 -- now we do it again: this time foo.w won't be built
|
|
|
|
|
2005-10-24 21:01:39 +08:00
|
|
|
run_make_test(undef, '', "touch baz\n");
|
2004-01-08 03:36:39 +08:00
|
|
|
|
|
|
|
unlink(qw(foo.w foo.x baz));
|
|
|
|
|
2004-05-17 03:16:52 +08:00
|
|
|
# TEST #9 -- 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:;@:
|
2005-10-24 21:01:39 +08:00
|
|
|
baz:;@:',
|
|
|
|
'', "foo foo baz\n");
|
2004-05-17 03:16:52 +08:00
|
|
|
|
|
|
|
|
2002-07-08 21:05:02 +08:00
|
|
|
1;
|