2 $description = "Test target-specific variable settings.";
5 Create a makefile containing various flavors of target-specific variable
6 values, override and non-override, and using various variable expansion
7 rules, semicolon interference, etc.";
13 one: override FOO = one
14 one two: ; @echo $(FOO) $(BAR)
18 # Some things that shouldn not be target vars
20 funk : override adelic
21 adelic override : ; echo $@
22 # Test per-target recursive variables
25 four: ; @echo "$(FOO) $(VAR$(FOO)) $(VAR) $(VARx)"
27 five six : VAR$(FOO)=good
28 five six: ;@echo "$(FOO) $(VAR$(FOO)) $(VAR) $(VARx) $(VARfoo)"
29 # Test per-target variable inheritance
31 seven eight: ; @echo $@: $(FOO) $(BAR)
35 # Test the export keyword with per-target variables
36 nine: ; @echo $(FOO) $(BAR) $$FOO $$BAR
38 nine-a: export BAZ = baz
44 ten 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
49 %.q : ; @echo $(QVAR) $(RVAR)
51 # Target-specific vars with multiple LHS pattern rules
52 %.r %.s %.t: ; @echo $(QVAR) $(RVAR) $(SVAR) $(TVAR)
54 foo.t : TVAR := $(QVAR)
56 "one two three", "one bar\nfoo two\nBAR=1000\nfoo bar\n");
60 run_make_test(undef, "one two FOO=1 BAR=2", "one 2\n1 2\n");
64 run_make_test(undef, "four", "x ok ok\n");
68 run_make_test(undef, "seven", "eight: seven eight\nseven: seven seven\n");
72 run_make_test(undef, "nine", "wallace bar wallace bar\n");
76 run_make_test(undef, "nine-a", "baz\n");
80 run_make_test(undef, "ten", "one=two\none bar\n=\nfoo two\nten\n");
84 run_make_test(undef, "foo.q bar.q", "qvar = rvar\nqvar =\n");
88 run_make_test(undef, "foo.t bar.s", "qvar = qvar\nqvar =\n");
92 # For PR/1378: Target-specific vars don't inherit correctly
99 baz: ; @echo $(FOO) $(BAR)
103 # For PR/1380: Using += assignment in target-specific variables sometimes fails
109 all: one; @echo $(FOO)
117 '', "bar baz biz boz\nbar baz\n");
121 run_make_test(undef, 'one', "bar biz boz\n");
124 # PR/1709: Test semicolons in target-specific variable values
128 foo : ; @echo "$(FOO)"
133 # PR/2020: More hassles with += target-specific vars. I _really_ think
134 # I nailed it this time :-/.
140 COMMAND = echo $(BLAH)
145 a: COMMAND += snafu $(BLAH)
147 '', "bar snafu bar\n");
150 # Test double-colon rules with target-specific variable values
156 foo:: ; @echo $(W) $(X) $(Y) $(Z)
157 foo:: ; @echo $(W) $(X) $(Y) $(Z)
169 'foo', "ok ok foo nopat\nok ok foo nopat\n");
172 # Test double-colon rules with target-specific variable values and
175 run_make_test(undef, 'bar', "ok ok bar nopat\nok ok bar nopat\n");
178 # Test double-colon rules with pattern-specific variable values
180 run_make_test(undef, 'foo PATTERN=yes', "ok ok foo pat\nok ok foo pat\n");
183 # Test target-specific variables with very long command line
184 # (> make default buffer length)
187 base_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 )
189 deals_changed_since: ; @echo $(BUILD_OBJ)
191 '', "no build information\n");
195 # Test a merge of set_lists for files, where one list is much longer
196 # than the other. See Savannah bug #15757.
199 touch('t1/rules.mk');
206 foo.x : rules.mk ; @echo MYVAR=$(MYVAR) FOOVAR=$(FOOVAR) ALLVAR=$(ALLVAR)
209 rules.mk : MYVAR = foo
210 .INTERMEDIATE: foo.x rules.mk
212 '-I t1', 'MYVAR= FOOVAR=bar ALLVAR=xxx');
214 rmfiles('t1/rules.mk');
219 # Test appending to a simple variable containing a "$": avoid a
220 # double-expansion. See Savannah bug #15913.
225 foo: ; @echo '."'".'$(VAR)'."'".'
229 # TEST #19: Override with append variables
232 a: override FOO += f1
238 run_make_test(undef, 'FOO=C', "C f1\n");
240 # TEST #20: Check for continuation after semicolons
247 '', "hello; world\n");
249 # TEST #19: Test define/endef variables as target-specific vars