- Enhance .POSIX to set -e when invoking shells, as demanded by a
[make.git] / tests / scripts / features / se_explicit
blob79e0a36f982f000beb7f171446fb850e3b986a93
1 #                                                                    -*-perl-*-
2 $description = "Test second expansion in ordinary rules.";
4 $details = "";
6 # TEST #0: Test handing of '$' in prerequisites with and without second
7 # expansion.
9 run_make_test(q!
10 ifdef SE
11   .SECONDEXPANSION:
12 endif
13 foo$$bar: bar$$baz bar$$biz ; @echo '$@ : $^'
14 PRE = one two
15 bar$$baz: $$(PRE)
16 baraz: $$(PRE)
17 PRE = three four
18 .DEFAULT: ; @echo '$@'
20               '',
21               "\$\nbar\$biz\nfoo\$bar : bar\$baz bar\$biz");
23 run_make_test(undef, 'SE=1', "three\nfour\nbariz\nfoo\$bar : baraz bariz");
25 # TEST #1: automatic variables.
27 run_make_test(q!
28 .SECONDEXPANSION:
29 .DEFAULT: ; @echo '$@'
31 foo: bar baz
33 foo: biz | buz
35 foo: $$@.1 \
36      $$<.2 \
37      $$(addsuffix .3,$$^) \
38      $$(addsuffix .4,$$+) \
39      $$|.5 \
40      $$*.6
43 '',
44 'bar
45 baz
46 biz
47 buz
48 foo.1
49 bar.2
50 bar.3
51 baz.3
52 biz.3
53 bar.4
54 baz.4
55 biz.4
56 buz.5
58 ');
61 # Test #2: target/pattern -specific variables.
63 run_make_test(q!
64 .SECONDEXPANSION:
65 .DEFAULT: ; @echo '$@'
67 foo.x: $$a $$b
69 foo.x: a := bar
71 %.x: b := baz
73 '',
74 'bar
75 baz
76 ');
79 # Test #3: order of prerequisites.
81 run_make_test(q!
82 .SECONDEXPANSION:
83 .DEFAULT: ; @echo '$@'
85 all: foo bar baz
87 # Subtest #1
88 foo: foo.1; @:
89 foo: foo.2
90 foo: foo.3
92 # Subtest #2
93 bar: bar.2
94 bar: bar.1; @:
95 bar: bar.3
97 # Subtest #3
98 baz: baz.1
99 baz: baz.2
100 baz: ; @:
103 'foo.1
104 foo.2
105 foo.3
106 bar.1
107 bar.2
108 bar.3
109 baz.1
110 baz.2
113 # TEST #4: eval in a context where there is no reading_file
114 run_make_test(q!
115 .SECONDEXPANSION:
116 all : $$(eval $$(info test))
118             '', "test\n#MAKE#: Nothing to be done for `all'.\n");
120 # TEST #5: (NEGATIVE) catch eval in a prereq list trying to create new
121 # target/prereq relationships.
123 run_make_test(q!
124 .SECONDEXPANSION:
125 proj1.exe : proj1.o $$(eval $$(test))
126 define test
127 proj1.o : proj1.c
128 proj1.c: proj1.h
129 endef
131               '', "#MAKE#: *** prerequisites cannot be defined in recipes.  Stop.\n", 512);
134 # Automatic $$+ variable expansion issue.  Savannah bug #25780
135 run_make_test(q!
136 all : foo foo
137 .SECONDEXPANSION:
138 all : $$+ ; @echo '$+'
139 foo : ;
141                   '', "foo foo foo foo\n");
144 # Automatic $$+ variable expansion issue.  Savannah bug #25780
145 run_make_test(q!
146 all : bar bar
147 bar : ;
148 q%x : ;
149 .SECONDEXPANSION:
150 a%l: q1x $$+ q2x ; @echo '$+'
152                   '', "q1x bar bar q2x bar bar\n");
155 # This tells the test driver that the perl test script executed properly.