3 $description = "Test define/endef variable assignments.";
7 # TEST 0: old-style basic define/endef
17 '', "hi\necho there\nthere\n");
19 # TEST 1: Various new-style define/endef
27 endef # this is the end
44 define cond ?= # this is a conditional
60 '', "echo hi\nhi\nthere\nfoo\nfoo\na\nb\nfirst\n");
62 # TEST 1a: Various new-style define/endef, with no spaces
70 endef # this is the end
91 define cond?= # this is a conditional
108 '', "echo hi\nhi\nthere\nfoo\nfoo\nfoo\$bar\na\nb\nfirst\n");
110 # TEST 2: define in true section of conditional (containing conditional)
117 define $(subst e,e,$(NAME)) =
129 # TEST 3: define in false section of conditional (containing conditional)
131 run_make_test(undef, '', "foo\n");
133 # TEST 4: nested define (supported?)
144 outer: ; @echo $(inner)
148 # TEST 5: NEGATIVE: Missing variable name
157 '', "#MAKEFILE#:3: *** empty variable name. Stop.\n", 512);
159 # TEST 6: NEGATIVE: extra text after define
163 define NAME = $(NAME)
168 '', "#MAKEFILE#:3: extraneous text after 'define' directive\nok\n");
170 # TEST 7: NEGATIVE: extra text after endef
179 '', "#MAKEFILE#:5: extraneous text after 'endef' directive\nok\n");
181 # TEST 8: NEGATIVE: missing endef
190 '', "#MAKEFILE#:4: *** missing 'endef', unterminated 'define'. Stop.\n", 512);
192 # -------------------------
193 # Make sure that prefix characters apply properly to define/endef values.
195 # There's a bit of oddness here if you try to use a variable to hold the
196 # prefix character for a define. Even though something like this:
204 # (where V=@) can be seen by the user to be obviously different than this:
212 # and the user thinks it should behave the same as when the "@" is literal
213 # instead of in a variable, that can't happen because by the time make
214 # expands the variables for the command line and sees it begins with a "@" it
215 # can't know anymore whether the prefix character came before the variable
216 # reference or was included in the first line of the variable reference.
233 run_make_test(undef, 'V1=@ V2=@', 'hello
252 run_make_test(undef, 'V2=@', 'echo hello
259 run_make_test(undef, 'V1=@ V2=@', 'hello
264 # Test the basics; a "@" internally to the variable applies to only one line.
265 # A "@" before the variable applies to the entire variable.
287 # Ensure that define can be a target when not appearing in a variable
288 # definition context. See SV 59870
293 $(define) : ;@echo $@