summaryrefslogtreecommitdiff
path: root/remake.c
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2009-06-10 02:21:09 +0000
committerPaul Smith <psmith@gnu.org>2009-06-10 02:21:09 +0000
commitc8840352acf40443a70ea3748130cee055154492 (patch)
tree1e0ab35d58e13f763e42aa1171112ce0daf080f6 /remake.c
parentd4ee0012925815e069dd9996241703a7e9bd0338 (diff)
downloadgunmake-c8840352acf40443a70ea3748130cee055154492.tar.gz
- Fix Savannah bug #19108
- Fix Savannah bug #17752 - Test suite: * When tests fail keep a "run" file containing the command invoked. * Support for the Valgrind "memcheck" and "massif" tools.
Diffstat (limited to 'remake.c')
-rw-r--r--remake.c150
1 files changed, 81 insertions, 69 deletions
diff --git a/remake.c b/remake.c
index 0d940d6..513cb56 100644
--- a/remake.c
+++ b/remake.c
@@ -370,10 +370,11 @@ complain (const struct file *file)
static int
update_file_1 (struct file *file, unsigned int depth)
{
- register FILE_TIMESTAMP this_mtime;
+ FILE_TIMESTAMP this_mtime;
int noexist, must_make, deps_changed;
int dep_status = 0;
- register struct dep *d, *lastd;
+ struct dep *d, *ad;
+ struct dep amake;
int running = 0;
DBF (DB_VERBOSE, _("Considering target file `%s'.\n"));
@@ -464,83 +465,94 @@ update_file_1 (struct file *file, unsigned int depth)
file->cmds = default_file->cmds;
}
- /* Update all non-intermediate files we depend on, if necessary,
- and see whether any of them is more recent than this file. */
+ /* Update all non-intermediate files we depend on, if necessary, and see
+ whether any of them is more recent than this file. We need to walk our
+ deps, AND the deps of any also_make targets to ensure everything happens
+ in the correct order. */
- lastd = 0;
- d = file->deps;
- while (d != 0)
+ amake.file = file;
+ amake.next = file->also_make;
+ ad = &amake;
+ while (ad)
{
- FILE_TIMESTAMP mtime;
- int maybe_make;
- int dontcare = 0;
+ struct dep *lastd = 0;
- check_renamed (d->file);
+ /* Find the deps we're scanning */
+ d = ad->file->deps;
+ ad = ad->next;
- mtime = file_mtime (d->file);
- check_renamed (d->file);
+ while (d)
+ {
+ FILE_TIMESTAMP mtime;
+ int maybe_make;
+ int dontcare = 0;
- if (is_updating (d->file))
- {
- error (NILF, _("Circular %s <- %s dependency dropped."),
- file->name, d->file->name);
- /* We cannot free D here because our the caller will still have
- a reference to it when we were called recursively via
- check_dep below. */
- if (lastd == 0)
- file->deps = d->next;
- else
- lastd->next = d->next;
- d = d->next;
- continue;
- }
+ check_renamed (d->file);
- d->file->parent = file;
- maybe_make = must_make;
+ mtime = file_mtime (d->file);
+ check_renamed (d->file);
- /* Inherit dontcare flag from our parent. */
- if (rebuilding_makefiles)
- {
- dontcare = d->file->dontcare;
- d->file->dontcare = file->dontcare;
- }
+ if (is_updating (d->file))
+ {
+ error (NILF, _("Circular %s <- %s dependency dropped."),
+ file->name, d->file->name);
+ /* We cannot free D here because our the caller will still have
+ a reference to it when we were called recursively via
+ check_dep below. */
+ if (lastd == 0)
+ file->deps = d->next;
+ else
+ lastd->next = d->next;
+ d = d->next;
+ continue;
+ }
+ d->file->parent = file;
+ maybe_make = must_make;
- dep_status |= check_dep (d->file, depth, this_mtime, &maybe_make);
+ /* Inherit dontcare flag from our parent. */
+ if (rebuilding_makefiles)
+ {
+ dontcare = d->file->dontcare;
+ d->file->dontcare = file->dontcare;
+ }
- /* Restore original dontcare flag. */
- if (rebuilding_makefiles)
- d->file->dontcare = dontcare;
+ dep_status |= check_dep (d->file, depth, this_mtime, &maybe_make);
- if (! d->ignore_mtime)
- must_make = maybe_make;
+ /* Restore original dontcare flag. */
+ if (rebuilding_makefiles)
+ d->file->dontcare = dontcare;
- check_renamed (d->file);
+ if (! d->ignore_mtime)
+ must_make = maybe_make;
- {
- register struct file *f = d->file;
- if (f->double_colon)
- f = f->double_colon;
- do
- {
- running |= (f->command_state == cs_running
- || f->command_state == cs_deps_running);
- f = f->prev;
- }
- while (f != 0);
- }
+ check_renamed (d->file);
+
+ {
+ register struct file *f = d->file;
+ if (f->double_colon)
+ f = f->double_colon;
+ do
+ {
+ running |= (f->command_state == cs_running
+ || f->command_state == cs_deps_running);
+ f = f->prev;
+ }
+ while (f != 0);
+ }
- if (dep_status != 0 && !keep_going_flag)
- break;
+ if (dep_status != 0 && !keep_going_flag)
+ break;
- if (!running)
- /* The prereq is considered changed if the timestamp has changed while
- it was built, OR it doesn't exist. */
- d->changed = ((file_mtime (d->file) != mtime)
- || (mtime == NONEXISTENT_MTIME));
+ if (!running)
+ /* The prereq is considered changed if the timestamp has changed while
+ it was built, OR it doesn't exist. */
+ d->changed = ((file_mtime (d->file) != mtime)
+ || (mtime == NONEXISTENT_MTIME));
- lastd = d;
- d = d->next;
+ lastd = d;
+ d = d->next;
+ }
}
/* Now we know whether this target needs updating.
@@ -981,7 +993,7 @@ check_dep (struct file *file, unsigned int depth,
/* Otherwise, update all non-intermediate files we depend on, if
necessary, and see whether any of them is more recent than the
file on whose behalf we are checking. */
- struct dep *lastd;
+ struct dep *ld;
int deps_running = 0;
/* If this target is not running, set it's state so that we check it
@@ -990,7 +1002,7 @@ check_dep (struct file *file, unsigned int depth,
if (file->command_state != cs_running)
set_command_state (file, cs_not_started);
- lastd = 0;
+ ld = 0;
d = file->deps;
while (d != 0)
{
@@ -1000,7 +1012,7 @@ check_dep (struct file *file, unsigned int depth,
{
error (NILF, _("Circular %s <- %s dependency dropped."),
file->name, d->file->name);
- if (lastd == 0)
+ if (ld == 0)
{
file->deps = d->next;
free_dep (d);
@@ -1008,9 +1020,9 @@ check_dep (struct file *file, unsigned int depth,
}
else
{
- lastd->next = d->next;
+ ld->next = d->next;
free_dep (d);
- d = lastd->next;
+ d = ld->next;
}
continue;
}
@@ -1029,7 +1041,7 @@ check_dep (struct file *file, unsigned int depth,
|| d->file->command_state == cs_deps_running)
deps_running = 1;
- lastd = d;
+ ld = d;
d = d->next;
}