summaryrefslogtreecommitdiff
path: root/tests/scripts/variables/automatic
blob: b80d4782491550cfee31648e99acf19a241e3805 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#                                                                    -*-perl-*-

$description = "Test automatic variable setting.";

$details = "";

use Cwd;

$dir = cwd;
$dir =~ s,.*/([^/]+)$,../$1,;

open(MAKEFILE, "> $makefile");
print MAKEFILE "dir = $dir\n";
print MAKEFILE <<'EOF';
.SUFFIXES:
.SUFFIXES: .x .y .z
$(dir)/foo.x : baz.z $(dir)/bar.y baz.z
	@echo '$$@ = $@, $$(@D) = $(@D), $$(@F) = $(@F)'
	@echo '$$* = $*, $$(*D) = $(*D), $$(*F) = $(*F)'
	@echo '$$< = $<, $$(<D) = $(<D), $$(<F) = $(<F)'
	@echo '$$^ = $^, $$(^D) = $(^D), $$(^F) = $(^F)'
	@echo '$$+ = $+, $$(+D) = $(+D), $$(+F) = $(+F)'
	@echo '$$? = $?, $$(?D) = $(?D), $$(?F) = $(?F)'
	touch $@

$(dir)/bar.y baz.z : ; touch $@
EOF
close(MAKEFILE);

# TEST #1 -- simple test
# -------

&touch(qw(foo.x baz.z));

sleep(1);

&run_make_with_options($makefile, "", &get_logfile);
$answer = "touch $dir/bar.y
\$\@ = $dir/foo.x, \$(\@D) = $dir, \$(\@F) = foo.x
\$* = $dir/foo, \$(*D) = $dir, \$(*F) = foo
\$< = baz.z, \$(<D) = ., \$(<F) = baz.z
\$^ = baz.z $dir/bar.y, \$(^D) = . $dir, \$(^F) = baz.z bar.y
\$+ = baz.z $dir/bar.y baz.z, \$(+D) = . $dir ., \$(+F) = baz.z bar.y baz.z
\$? = $dir/bar.y, \$(?D) = $dir, \$(?F) = bar.y
touch $dir/foo.x\n";
&compare_output($answer, &get_logfile(1));

unlink(qw(foo.x bar.y baz.z));

1;