VirtualBox

source: kBuild/trunk/src/kmk/tests/scripts/features/targetvars

Last change on this file was 3140, checked in by bird, 7 years ago

kmk: Merged in changes from GNU make 4.2.1 (2e55f5e4abdc0e38c1d64be703b446695e70b3b6 / https://git.savannah.gnu.org/git/make.git).

  • Property svn:eol-style set to LF
File size: 5.7 KB
Line 
1# -*-perl-*-
2$description = "Test target-specific variable settings.";
3
4$details = "\
5Create a makefile containing various flavors of target-specific variable
6values, override and non-override, and using various variable expansion
7rules, semicolon interference, etc.";
8
9run_make_test('
10SHELL = /bin/sh
11export FOO = foo
12export BAR = bar
13one: override FOO = one
14one two: ; @echo $(FOO) $(BAR)
15two: BAR = two
16three: ; BAR=1000
17 @echo $(FOO) $(BAR)
18# Some things that shouldn not be target vars
19funk : override
20funk : override adelic
21adelic override : ; echo $@
22# Test per-target recursive variables
23four:FOO=x
24four:VAR$(FOO)=ok
25four: ; @echo "$(FOO) $(VAR$(FOO)) $(VAR) $(VARx)"
26five:FOO=x
27five six : VAR$(FOO)=good
28five six: ;@echo "$(FOO) $(VAR$(FOO)) $(VAR) $(VARx) $(VARfoo)"
29# Test per-target variable inheritance
30seven: eight
31seven eight: ; @echo $@: $(FOO) $(BAR)
32seven: BAR = seven
33seven: FOO = seven
34eight: BAR = eight
35# Test the export keyword with per-target variables
36nine: ; @echo $(FOO) $(BAR) $$FOO $$BAR
37nine: FOO = wallace
38nine-a: export BAZ = baz
39nine-a: ; @echo $$BAZ
40# Test = escaping
41EQ = =
42ten: one$(EQ)two
43ten: one $(EQ) two
44ten one$(EQ)two $(EQ):;@echo $@
45.PHONY: one two three four five six seven eight nine ten $(EQ) one$(EQ)two
46# Test target-specific vars with pattern/suffix rules
47QVAR = qvar
48RVAR = =
49%.q : ; @echo $(QVAR) $(RVAR)
50foo.q : RVAR += rvar
51# Target-specific vars with multiple LHS pattern rules
52%.r %.s %.t: ; @echo $(QVAR) $(RVAR) $(SVAR) $(TVAR)
53foo.r : RVAR += rvar
54foo.t : TVAR := $(QVAR)
55',
56 "one two three", "one bar\nfoo two\nBAR=1000\nfoo bar\n");
57
58# TEST #2
59
60run_make_test(undef, "one two FOO=1 BAR=2", "one 2\n1 2\n");
61
62# TEST #3
63
64run_make_test(undef, "four", "x ok ok\n");
65
66# TEST #4
67
68run_make_test(undef, "seven", "eight: seven eight\nseven: seven seven\n");
69
70# TEST #5
71
72run_make_test(undef, "nine", "wallace bar wallace bar\n");
73
74# TEST #5-a
75
76run_make_test(undef, "nine-a", "baz\n");
77
78# TEST #6
79
80run_make_test(undef, "ten", "one=two\none bar\n=\nfoo two\nten\n");
81
82# TEST #6
83
84run_make_test(undef, "foo.q bar.q", "qvar = rvar\nqvar =\n");
85
86# TEST #7
87
88run_make_test(undef, "foo.t bar.s", "qvar = qvar\nqvar =\n");
89
90
91# TEST #8
92# For PR/1378: Target-specific vars don't inherit correctly
93
94run_make_test('
95foo: FOO = foo
96bar: BAR = bar
97foo: bar
98bar: baz
99baz: ; @echo $(FOO) $(BAR)
100', "", "foo bar\n");
101
102# TEST #9
103# For PR/1380: Using += assignment in target-specific variables sometimes fails
104# Also PR/1831
105
106run_make_test('
107.PHONY: all one
108all: FOO += baz
109all: one; @echo $(FOO)
110
111FOO = bar
112
113one: FOO += biz
114one: FOO += boz
115one: ; @echo $(FOO)
116',
117 '', "bar baz biz boz\nbar baz\n");
118
119# Test #10
120
121run_make_test(undef, 'one', "bar biz boz\n");
122
123# Test #11
124# PR/1709: Test semicolons in target-specific variable values
125
126run_make_test('
127foo : FOO = ; ok
128foo : ; @echo "$(FOO)"
129',
130 '', "; ok\n");
131
132# Test #12
133# PR/2020: More hassles with += target-specific vars. I _really_ think
134# I nailed it this time :-/.
135
136run_make_test('
137.PHONY: a
138
139BLAH := foo
140COMMAND = echo $(BLAH)
141
142a: ; @$(COMMAND)
143
144a: BLAH := bar
145a: COMMAND += snafu $(BLAH)
146',
147 '', "bar snafu bar\n");
148
149# Test #13
150# Test double-colon rules with target-specific variable values
151
152run_make_test('
153W = bad
154X = bad
155foo: W = ok
156foo:: ; @echo $(W) $(X) $(Y) $(Z)
157foo:: ; @echo $(W) $(X) $(Y) $(Z)
158foo: X = ok
159
160Y = foo
161bar: foo
162bar: Y = bar
163
164Z = nopat
165ifdef PATTERN
166 fo% : Z = pat
167endif
168',
169 'foo', "ok ok foo nopat\nok ok foo nopat\n");
170
171# Test #14
172# Test double-colon rules with target-specific variable values and
173# inheritance
174
175run_make_test(undef, 'bar', "ok ok bar nopat\nok ok bar nopat\n");
176
177# Test #15
178# Test double-colon rules with pattern-specific variable values
179
180run_make_test(undef, 'foo PATTERN=yes', "ok ok foo pat\nok ok foo pat\n");
181
182# Test #16
183# Test target-specific variables with very long command line
184# (> make default buffer length)
185
186run_make_test('
187base_metals_fmd_reports.sun5 base_metals_fmd_reports CreateRealPositions CreateMarginFunds deals_changed_since : BUILD_OBJ=$(shell if [ -f "build_information.generate" ]; then echo "$(OBJ_DIR)/build_information.o"; else echo "no build information"; fi )
188
189deals_changed_since: ; @echo $(BUILD_OBJ)
190',
191 '', "no build information\n");
192
193# TEST #17
194
195# Test a merge of set_lists for files, where one list is much longer
196# than the other. See Savannah bug #15757.
197
198mkdir('t1', 0777);
199touch('t1/rules.mk');
200
201run_make_test('
202VPATH = t1
203include rules.mk
204.PHONY: all
205all: foo.x
206foo.x : rules.mk ; @echo MYVAR=$(MYVAR) FOOVAR=$(FOOVAR) ALLVAR=$(ALLVAR)
207all: ALLVAR = xxx
208foo.x: FOOVAR = bar
209rules.mk : MYVAR = foo
210.INTERMEDIATE: foo.x rules.mk
211',
212 '-I t1', 'MYVAR= FOOVAR=bar ALLVAR=xxx');
213
214rmfiles('t1/rules.mk');
215rmdir('t1');
216
217# TEST #18
218
219# Test appending to a simple variable containing a "$": avoid a
220# double-expansion. See Savannah bug #15913.
221
222run_make_test('
223VAR := $$FOO
224foo: VAR += BAR
225foo: ; @echo '."'".'$(VAR)'."'".'
226',
227 '', '$FOO BAR');
228
229# TEST #19: Override with append variables
230
231run_make_test('
232a: override FOO += f1
233a: FOO += f2
234a: ; @echo "$(FOO)"
235',
236 '', "f1\n");
237
238run_make_test(undef, 'FOO=C', "C f1\n");
239
240# TEST #19: Conditional variables with command-line settings
241
242run_make_test('
243a: FOO ?= f1
244a: ; @echo "$(FOO)"
245',
246 '', "f1\n");
247
248run_make_test(undef, 'FOO=C', "C\n");
249
250# TEST #20: Check for continuation after semicolons
251
252run_make_test(q!
253a: A = 'hello;\
254world'
255a: ; @echo $(A)
256!,
257 '', "hello; world\n");
258
259# TEST #19: Test define/endef variables as target-specific vars
260
261# run_make_test('
262# define b
263# @echo global
264# endef
265# a: define b
266# @echo local
267# endef
268
269# a: ; $(b)
270# ',
271# '', "local\n");
272
2731;
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette