3 $description = "Test automatic variable setting.";
10 $dir =~ s,.*/([^/]+)$,../$1,;
12 open(MAKEFILE, "> $makefile");
13 print MAKEFILE "dir = $dir\n";
14 print MAKEFILE <<'EOF';
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)'
26 $(dir)/bar.y baz.z : ; touch $@
30 # TEST #1 -- simple test
33 # Touch these into the past
34 &utouch(-10, qw(foo.x baz.z));
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
45 &compare_output($answer, &get_logfile(1));
47 unlink(qw(foo.x bar.y baz.z));
49 # TEST #2 -- test the SysV emulation of $$@ etc.
52 $makefile2 = &get_tmpfile;
54 open(MAKEFILE, "> $makefile2");
55 print MAKEFILE "dir = $dir\n";
56 print MAKEFILE <<'EOF';
58 .DEFAULT: ; @echo '$@'
60 $(dir)/foo $(dir)/bar: $@.x $$@.x $$$@.x $$$$@.x $$(@D).x $$(@F).x
62 $(dir)/x.z $(dir)/y.z: $(dir)/%.z : $@.% $$@.% $$$@.% $$$$@.% $$(@D).% $$(@F).%
64 $(dir)/biz: $$(@).x $${@}.x $${@D}.x $${@F}.x
69 &run_make_with_options($makefile2, "$dir/foo $dir/bar", &get_logfile);
70 $answer = ".x\n$dir/foo.x\n\$.x\n\$@.x\n$dir.x\nfoo.x\n$dir/bar.x\nbar.x\n";
71 &compare_output($answer, &get_logfile(1));
73 &run_make_with_options($makefile2, "$dir/x.z $dir/y.z", &get_logfile);
74 $answer = ".x\n$dir/x.z.x\n\$.x\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";
75 &compare_output($answer, &get_logfile(1));
77 &run_make_with_options($makefile2, "$dir/biz", &get_logfile);
78 $answer = "$dir/biz.x\n$dir.x\nbiz.x\n";
79 &compare_output($answer, &get_logfile(1));