From: Paul Smith Date: Sat, 17 Dec 2022 19:01:02 +0000 (-0500) Subject: * src/job.c (new_job): [SV 63510] Trace phony prerequisite rebuilds X-Git-Tag: 4.4.0.90~35 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c0023150f176a91526d88b45eb02334add9059e1;p=thirdparty%2Fmake.git * src/job.c (new_job): [SV 63510] Trace phony prerequisite rebuilds --- diff --git a/src/job.c b/src/job.c index b78f279c..876898c8 100644 --- a/src/job.c +++ b/src/job.c @@ -1893,7 +1893,6 @@ new_job (struct file *file) Use message here so that changes to working directories are logged. */ if (ISDB (DB_WHY)) { - char *newer = allocated_variable_expand_for_file ("$?", c->file); const char *nm; if (! cmds->fileinfo.filenm) @@ -1905,11 +1904,51 @@ new_job (struct file *file) nm = n; } - OSSS (message, 0, - _("%s: update target '%s' due to: %s"), nm, c->file->name, - newer[0] == '\0' ? _("target does not exist") : newer); - - free (newer); + if (c->file->phony) + OSS (message, 0, _("%s: update target '%s' due to: target is .PHONY"), + nm, c->file->name); + else if (c->file->last_mtime == NONEXISTENT_MTIME) + OSS (message, 0, + _("%s: update target '%s' due to: target does not exist"), + nm, c->file->name); + else + { + char *newer = allocated_variable_expand_for_file ("$?", c->file); + if (newer[0] != '\0') + { + OSSS (message, 0, _("%s: update target '%s' due to: %s"), + nm, c->file->name, newer); + free (newer); + } + else + { + /* One or more files didn't exist, and didn't get created. */ + size_t len = 0; + struct dep *d; + + for (d = c->file->deps; d != NULL; d = d->next) + if (d->file->last_mtime == NONEXISTENT_MTIME) + len += strlen (d->file->name) + 1; + + if (!len) + OSS (message, 0, + _("%s: update target '%s' due to: unknown reasons"), + nm, c->file->name); + else + { + char *cp = newer = alloca (len); + for (d = c->file->deps; d != NULL; d = d->next) + if (d->file->last_mtime == NONEXISTENT_MTIME) + { + if (cp > newer) + *(cp++) = ' '; + cp = stpcpy (cp, d->file->name); + } + OSSS (message, 0, _("%s: update target '%s' due to: %s"), + nm, c->file->name, newer); + } + } + } } /* The job is now primed. Start it running.