| 1 | # -*-perl-*-
|
|---|
| 2 |
|
|---|
| 3 | $description = "Test automatic variable setting.";
|
|---|
| 4 |
|
|---|
| 5 | $details = "";
|
|---|
| 6 |
|
|---|
| 7 | use Cwd;
|
|---|
| 8 |
|
|---|
| 9 | $dir = cwd;
|
|---|
| 10 | $dir =~ s,.*/([^/]+)$,../$1,;
|
|---|
| 11 |
|
|---|
| 12 | open(MAKEFILE, "> $makefile");
|
|---|
| 13 | print MAKEFILE "dir = $dir\n";
|
|---|
| 14 | print MAKEFILE <<'EOF';
|
|---|
| 15 | .SUFFIXES:
|
|---|
| 16 | .SUFFIXES: .x .y .z
|
|---|
| 17 | $(dir)/foo.x : baz.z $(dir)/bar.y baz.z
|
|---|
| 18 | @echo '$$@ = $@, $$(@D) = $(@D), $$(@F) = $(@F)'
|
|---|
| 19 | @echo '$$* = $*, $$(*D) = $(*D), $$(*F) = $(*F)'
|
|---|
| 20 | @echo '$$< = $<, $$(<D) = $(<D), $$(<F) = $(<F)'
|
|---|
| 21 | @echo '$$^ = $^, $$(^D) = $(^D), $$(^F) = $(^F)'
|
|---|
| 22 | @echo '$$+ = $+, $$(+D) = $(+D), $$(+F) = $(+F)'
|
|---|
| 23 | @echo '$$? = $?, $$(?D) = $(?D), $$(?F) = $(?F)'
|
|---|
| 24 | touch $@
|
|---|
| 25 |
|
|---|
| 26 | $(dir)/bar.y baz.z : ; touch $@
|
|---|
| 27 | EOF
|
|---|
| 28 | close(MAKEFILE);
|
|---|
| 29 |
|
|---|
| 30 | # TEST #0 -- simple test
|
|---|
| 31 | # -------
|
|---|
| 32 |
|
|---|
| 33 | # Touch these into the past
|
|---|
| 34 | &utouch(-10, qw(foo.x baz.z));
|
|---|
| 35 |
|
|---|
| 36 | &run_make_with_options($makefile, "", &get_logfile);
|
|---|
| 37 | $answer = "touch $dir/bar.y
|
|---|
| 38 | \$\@ = $dir/foo.x, \$(\@D) = $dir, \$(\@F) = foo.x
|
|---|
| 39 | \$* = $dir/foo, \$(*D) = $dir, \$(*F) = foo
|
|---|
| 40 | \$< = baz.z, \$(<D) = ., \$(<F) = baz.z
|
|---|
| 41 | \$^ = baz.z $dir/bar.y, \$(^D) = . $dir, \$(^F) = baz.z bar.y
|
|---|
| 42 | \$+ = baz.z $dir/bar.y baz.z, \$(+D) = . $dir ., \$(+F) = baz.z bar.y baz.z
|
|---|
| 43 | \$? = $dir/bar.y, \$(?D) = $dir, \$(?F) = bar.y
|
|---|
| 44 | touch $dir/foo.x\n";
|
|---|
| 45 | &compare_output($answer, &get_logfile(1));
|
|---|
| 46 |
|
|---|
| 47 | unlink(qw(foo.x bar.y baz.z));
|
|---|
| 48 |
|
|---|
| 49 | # TEST #1 -- test the SysV emulation of $$@ etc.
|
|---|
| 50 | # -------
|
|---|
| 51 |
|
|---|
| 52 | $makefile2 = &get_tmpfile;
|
|---|
| 53 |
|
|---|
| 54 | open(MAKEFILE, "> $makefile2");
|
|---|
| 55 | print MAKEFILE "dir = $dir\n";
|
|---|
| 56 | print MAKEFILE <<'EOF';
|
|---|
| 57 | .SECONDEXPANSION:
|
|---|
| 58 | .SUFFIXES:
|
|---|
| 59 | .DEFAULT: ; @echo '$@'
|
|---|
| 60 |
|
|---|
| 61 | $(dir)/foo $(dir)/bar: $@.x $$@.x $$$@.x $$$$@.x $$(@D).x $$(@F).x
|
|---|
| 62 |
|
|---|
| 63 | $(dir)/x.z $(dir)/y.z: $(dir)/%.z : $@.% $$@.% $$$@.% $$$$@.% $$(@D).% $$(@F).%
|
|---|
| 64 |
|
|---|
| 65 | $(dir)/biz: $$(@).x $${@}.x $${@D}.x $${@F}.x
|
|---|
| 66 | EOF
|
|---|
| 67 |
|
|---|
| 68 | close(MAKEFILE);
|
|---|
| 69 |
|
|---|
| 70 | &run_make_with_options($makefile2, "-j1 $dir/foo $dir/bar", &get_logfile);
|
|---|
| 71 | $answer = ".x\n$dir/foo.x\nx\n\$@.x\n$dir.x\nfoo.x\n$dir/bar.x\nbar.x\n";
|
|---|
| 72 | &compare_output($answer, &get_logfile(1));
|
|---|
| 73 |
|
|---|
| 74 | &run_make_with_options($makefile2, "-j1 $dir/x.z $dir/y.z", &get_logfile);
|
|---|
| 75 | $answer = ".x\n$dir/x.z.x\nx\n\$@.x\n$dir.x\nx.z.x\n.y\n$dir/y.z.y\n\y\n\$@.y\n$dir.y\ny.z.y\n";
|
|---|
| 76 | &compare_output($answer, &get_logfile(1));
|
|---|
| 77 |
|
|---|
| 78 | &run_make_with_options($makefile2, "-j1 $dir/biz", &get_logfile);
|
|---|
| 79 | $answer = "$dir/biz.x\n$dir.x\nbiz.x\n";
|
|---|
| 80 | &compare_output($answer, &get_logfile(1));
|
|---|
| 81 |
|
|---|
| 82 | # TEST #2 -- test for Savannah bug #12320.
|
|---|
| 83 | #
|
|---|
| 84 | run_make_test('
|
|---|
| 85 | .SUFFIXES: .b .src
|
|---|
| 86 |
|
|---|
| 87 | mbr.b: mbr.src
|
|---|
| 88 | @echo $*
|
|---|
| 89 |
|
|---|
| 90 | mbr.src: ; @:',
|
|---|
| 91 | '',
|
|---|
| 92 | 'mbr');
|
|---|
| 93 |
|
|---|
| 94 | # TEST #3 -- test for Savannah bug #8154
|
|---|
| 95 | # Make sure that nonexistent prerequisites are listed in $?, since they are
|
|---|
| 96 | # considered reasons for the target to be rebuilt.
|
|---|
| 97 | #
|
|---|
| 98 | # See also Savannah bugs #16002 and #16051.
|
|---|
| 99 |
|
|---|
| 100 | touch('foo');
|
|---|
| 101 |
|
|---|
| 102 | run_make_test('
|
|---|
| 103 | foo: bar ; @echo "\$$? = $?"
|
|---|
| 104 | bar: ;',
|
|---|
| 105 | '',
|
|---|
| 106 | '$? = bar');
|
|---|
| 107 |
|
|---|
| 108 | unlink('foo');
|
|---|
| 109 |
|
|---|
| 110 | # TEST #4: ensure prereq ordering is correct when the commmand target has none
|
|---|
| 111 | # See Savannah bug #21198
|
|---|
| 112 |
|
|---|
| 113 | run_make_test('
|
|---|
| 114 | all : A B
|
|---|
| 115 | all : ; @echo $@ -- $^ -- $<
|
|---|
| 116 | all : C D
|
|---|
| 117 | all : E F
|
|---|
| 118 | A B C D E F G H : ; @:
|
|---|
| 119 | ',
|
|---|
| 120 | '', "all -- A B C D E F -- A\n");
|
|---|
| 121 |
|
|---|
| 122 | 1;
|
|---|