return strcmp (dep_name (dx), dep_name (dy));
}
-/* Set FILE's automatic variables up. */
+/* Set FILE's automatic variables up.
+ * Use STEM to set $*.
+ * If STEM is 0, then set FILE->STEM and $* to the target name with any
+ * suffix in the .SUFFIXES list stripped off. */
void
-set_file_variables (struct file *file)
+set_file_variables (struct file *file, const char *stem)
{
struct dep *d;
const char *at, *percent, *star, *less;
}
/* $* is the stem from an implicit or static pattern rule. */
- if (file->stem == 0)
+ if (stem == 0)
{
/* In Unix make, $* is set to the target name with
any suffix in the .SUFFIXES list stripped off for
size_t slen = strlen (dep_name (d));
if (len > slen && strneq (dep_name (d), name + (len - slen), slen))
{
- file->stem = strcache_add_len (name, len - slen);
+ file->stem = stem = strcache_add_len (name, len - slen);
break;
}
}
if (d == 0)
- file->stem = "";
+ file->stem = stem = "";
}
- star = file->stem;
+ star = stem;
/* $< is the first not order-only dependency. */
less = "";
initialize_file_variables (file, 0);
- set_file_variables (file);
+ set_file_variables (file, file->stem);
/* If this is a loaded dynamic object, unload it before remaking.
Some systems don't support overwriting a loaded object. */
void print_commands (const struct commands *cmds);
void delete_child_targets (struct child *child);
void chop_commands (struct commands *cmds);
-void set_file_variables (struct file *file);
+void set_file_variables (struct file *file, const char *stem);
{
struct dep *d;
struct dep **dp;
- const char *file_stem = f->stem;
const char *fstem;
int initialized = 0;
initialized = 1;
}
- if (d->stem != 0)
- f->stem = d->stem;
-
- set_file_variables (f);
+ set_file_variables (f, d->stem ? d->stem : f->stem);
p = variable_expand_for_file (d->name, f);
/* Free the un-expanded name. */
free ((char*)d->name);
- if (d->stem != 0)
- f->stem = file_stem;
-
/* Parse the prerequisites and enter them into the file database. */
new = split_prereqs (p);
if (rule->deps == 0)
break;
- /* Temporary assign STEM to file->stem (needed to set file
- variables below). */
- file->stem = stem_str;
-
/* Mark this rule as in use so a recursive pattern_search won't try
to use it. */
rule->in_use = 1;
if (!file_vars_initialized)
{
initialize_file_variables (file, 0);
- set_file_variables (file);
+ set_file_variables (file, stem_str);
file_vars_initialized = 1;
}
/* Update the stem value in $* for this rule. */
else if (!file_variables_set)
{
define_variable_for_file (
- "*", 1, file->stem, o_automatic, 0, file);
+ "*", 1, stem_str, o_automatic, 0, file);
file_variables_set = 1;
}
break;
}
- /* Reset the stem in FILE. */
-
- file->stem = 0;
-
/* This rule is no longer 'in use' for recursive searches. */
rule->in_use = 0;
#MAKE#: Nothing to be done for 'all'.\n");
+# sv 62324.
+# Integrity self check.
+run_make_test(q!
+.SECONDEXPANSION:
+all: bye.x
+bye.x: $$(firstword bye.1;
+!, '', "#MAKEFILE#:4: *** unterminated call to function 'firstword': missing ')'. Stop.", 512);
1;
"@=2.x,<=,^=,+=,|=,?=,*=2
#MAKE#: Nothing to be done for 'all'.\n");
+# sv 62324.
+# Integrity self check.
+run_make_test(q!
+.SECONDEXPANSION:
+all: bye.x
+%.x: $$(firstword %.1;
+!, '', "#MAKE#: *** unterminated call to function 'firstword': missing ')'. Stop.", 512);
# This tells the test driver that the perl test script executed properly.
1;
oo$ba
');
+# sv 62324.
+# Integrity self check.
+run_make_test(q!
+.SECONDEXPANSION:
+all: bye.x
+bye.x: %.x: $$(firstword %.1;
+!, '', "#MAKEFILE#:4: *** unterminated call to function 'firstword': missing ')'. Stop.", 512);
# This tells the test driver that the perl test script executed properly.
1;
'',
'mbr');
+# Same as above with second expansion.
+#
+run_make_test('
+.SECONDEXPANSION:
+.SUFFIXES: .b .src
+
+p:=mbr.src
+mbr.b: $$p
+ @echo $*
+
+mbr.src: ; @:',
+ '',
+ 'mbr');
+
+# Test that $* is set to empty string for unknown suffixes.
+
+run_make_test('
+mbr.b: mbr.src
+ @echo star=$*
+
+mbr.src: ; @:',
+ '',
+ "star=\n");
+
# TEST #3 -- test for Savannah bug #8154
# Make sure that nonexistent prerequisites are listed in $?, since they are
# considered reasons for the target to be rebuilt.