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