1#                                                                    -*-perl-*-
2$description = "Test second expansion in ordinary rules.";
3
4$details = "";
5
6# TEST #0: Test handing of '$' in prerequisites with and without second
7# expansion.
8
9run_make_test(q!
10ifdef SE
11  .SECONDEXPANSION:
12endif
13foo$$bar: bar$$baz bar$$biz ; @echo '$@ : $^'
14PRE = one two
15bar$$baz: $$(PRE)
16baraz: $$(PRE)
17PRE = three four
18.DEFAULT: ; @echo '$@'
19!,
20              '',
21              "\$\nbar\$biz\nfoo\$bar : bar\$baz bar\$biz");
22
23run_make_test(undef, 'SE=1', "three\nfour\nbariz\nfoo\$bar : baraz bariz");
24
25# TEST #1: automatic variables.
26#
27run_make_test('
28.SECONDEXPANSION:
29.DEFAULT: ; @echo $@
30
31foo: bar baz
32
33foo: biz | buz
34
35foo: $$@.1 \
36     $$<.2 \
37     $$(addsuffix .3,$$^) \
38     $$(addsuffix .4,$$+) \
39     $$|.5 \
40     $$*.6
41
42',
43'',
44'bar
45baz
46biz
47buz
48foo.1
49bar.2
50bar.3
51baz.3
52biz.3
53bar.4
54baz.4
55biz.4
56buz.5
57.6
58');
59
60
61# Test #2: target/pattern -specific variables.
62#
63run_make_test('
64.SECONDEXPANSION:
65.DEFAULT: ; @echo $@
66
67foo.x: $$a $$b
68
69foo.x: a := bar
70
71%.x: b := baz
72
73',
74'',
75'bar
76baz
77');
78
79
80# Test #3: order of prerequisites.
81#
82run_make_test('
83.SECONDEXPANSION:
84.DEFAULT: ; @echo $@
85
86all: foo bar baz
87
88# Subtest #1
89#
90foo: foo.1; @:
91
92foo: foo.2
93
94foo: foo.3
95
96
97# Subtest #2
98#
99bar: bar.2
100
101bar: bar.1; @:
102
103bar: bar.3
104
105
106# Subtest #3
107#
108baz: baz.1
109
110baz: baz.2
111
112baz: ; @:
113
114',
115'',
116'foo.1
117foo.2
118foo.3
119bar.1
120bar.2
121bar.3
122baz.1
123baz.2
124');
125
126# This tells the test driver that the perl test script executed properly.
1271;
128