From dac7b49de4b935db71d7b4257c6354f16fe41cfa Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Tue, 17 Sep 2002 21:52:45 +0000 Subject: Fix bug #940 (from the Savannah bug tracker): make sure that target- specific variables work correctly in conjunction with double-colon targets. --- variable.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'variable.c') diff --git a/variable.c b/variable.c index 27a38e2..308ad75 100644 --- a/variable.c +++ b/variable.c @@ -372,9 +372,12 @@ lookup_variable_in_set (name, length, set) /* Initialize FILE's variable set list. If FILE already has a variable set list, the topmost variable set is left intact, but the the rest of the - chain is replaced with FILE->parent's setlist. If we're READing a - makefile, don't do the pattern variable search now, since the pattern - variable might not have been defined yet. */ + chain is replaced with FILE->parent's setlist. If FILE is a double-colon + rule, then we will use the "root" double-colon target's variable set as the + parent of FILE's variable set. + + If we're READing a makefile, don't do the pattern variable search now, + since the pattern variable might not have been defined yet. */ void initialize_file_variables (file, reading) @@ -389,10 +392,21 @@ initialize_file_variables (file, reading) xmalloc (sizeof (struct variable_set_list)); l->set = (struct variable_set *) xmalloc (sizeof (struct variable_set)); hash_init (&l->set->table, PERFILE_VARIABLE_BUCKETS, - variable_hash_1, variable_hash_2, variable_hash_cmp); + variable_hash_1, variable_hash_2, variable_hash_cmp); file->variables = l; } + /* If this is a double-colon, then our "parent" is the "root" target for + this double-colon rule. Since that rule has the same name, parent, + etc. we can just use its variables as the "next" for ours. */ + + if (file->double_colon && file->double_colon != file) + { + initialize_file_variables (file->double_colon, reading); + l->next = file->double_colon->variables; + return; + } + if (file->parent == 0) l->next = &global_setlist; else -- cgit v1.2.3