{
struct file *f = (struct file*)item;
struct dep *prereqs = NULL;
+ struct dep *d;
/* If we're not doing second expansion then reset updating. */
if (!second_expansion)
/* If .EXTRA_PREREQS is set, add them as ignored by automatic variables. */
if (f->variables)
- prereqs = expand_extra_prereqs (lookup_variable_in_set (STRING_SIZE_TUPLE(".EXTRA_PREREQS"), f->variables->set));
-
+ {
+ prereqs = expand_extra_prereqs (lookup_variable_in_set (
+ STRING_SIZE_TUPLE(".EXTRA_PREREQS"), f->variables->set));
+ if (second_expansion)
+ for (d = prereqs; d; d = d->next)
+ {
+ if (!d->name)
+ d->name = xstrdup (d->file->name);
+ d->need_2nd_expansion = 1;
+ }
+ }
else if (f->is_target)
prereqs = copy_dep_chain (arg);
if (prereqs)
{
- struct dep *d;
for (d = prereqs; d; d = d->next)
if (streq (f->name, dep_name (d)))
/* Skip circular dependencies. */
const char *d = dep_name (dep);
size_t l = strlen (d);
+ if (second_expansion)
+ {
+ if (!dep->name)
+ dep->name = xstrdup (dep->file->name);
+ dep->need_2nd_expansion = 1;
+ }
if (dep->need_2nd_expansion)
/* When pattern_search allocates a buffer, allow 5 bytes per each % to
substitute each % with $(*F) while avoiding realloc. */
',
'all', "tack\ntick\ntack tick\n");
+# SV 65006. Second expansion of global .EXTRA_PREQREQS.
+run_make_test('
+.SECONDEXPANSION:
+extradep:=tick tack
+.EXTRA_PREREQS=$$(extradep)
+%.x:; @echo $@
+',
+ 'hello.x', "hello.x\n");
+
unlink('tick', 'tack');
+# SV 65006. Second expansion of a target-specific .EXTRA_PREQREQS.
+run_make_test('
+.SECONDEXPANSION:
+all: hello.x;
+extradep=tick tack
+hello.x: .EXTRA_PREREQS=$$(extradep)
+%.x:; @echo $@
+tick tack:; @echo $@
+',
+ '', "tick\ntack\nhello.x\n");
+
+# SV 65006. Second expansion of a target-specific .EXTRA_PREQREQS.
+# The value of .EXTRA_PREQREQS contains automatic variables.
+run_make_test('
+.SECONDEXPANSION:
+all: hello.x world.x
+hello.x world.x: .EXTRA_PREREQS=$$@.d
+%.x:; @echo $@
+%.d:; @echo $@
+',
+ '', "hello.x.d\nhello.x\nworld.x.d\nworld.x\n");
+
+
+
# This tells the test driver that the perl test script executed properly.
1;