diff --git a/doc/make.texi b/doc/make.texi
index 733c0b9..386d545 100644
--- a/doc/make.texi
+++ b/doc/make.texi
@@ -8888,6 +8888,15 @@ the makefiles. This option enables messages while rebuilding makefiles,
too. Note that the @samp{all} option does enable this option. This
option also enables @samp{basic} messages.
+@item p (@i{print})
+Prints the entire recipe to be executed, even for recipes that are
+normally silent (due to @code{.SILENT} or @samp{@@}). Also prints
+the makefile name and line number where the recipe was defined.
+
+@item w (@i{why})
+Explains why each target must be remade by printing the value of the
+automatic variable $?.
+
@item n (@i{none})
Disable all debugging currently enabled. If additional debugging
flags are encountered after this they will still take effect.
@@ -9123,7 +9132,7 @@ Show tracing information for @code{make} execution. Prints the entire
recipe to be executed, even for recipes that are normally silent (due
to @code{.SILENT} or @samp{@@}). Also prints the makefile name and
line number where the recipe was defined, and information on why the
-target is being rebuilt.
+target is being rebuilt. Equivalent to @code{--debug=print,why}.
@item -v
@cindex @code{-v}
diff --git a/src/debug.h b/src/debug.h
index 514b7e8..4db34b9 100644
--- a/src/debug.h
+++ b/src/debug.h
@@ -19,6 +19,8 @@ this program. If not, see . */
#define DB_VERBOSE (0x002)
#define DB_JOBS (0x004)
#define DB_IMPLICIT (0x008)
+#define DB_PRINT (0x010)
+#define DB_WHY (0x020)
#define DB_MAKEFILES (0x100)
#define DB_ALL (0xfff)
diff --git a/src/job.c b/src/job.c
index ae1f18b..bb982e2 100644
--- a/src/job.c
+++ b/src/job.c
@@ -29,7 +29,7 @@ this program. If not, see . */
/* Default shell to use. */
#ifdef WINDOWS32
# ifdef HAVE_STRINGS_H
-# include /* for strcasecmp, strncasecmp */
+# include /* for strcasecmp, strncasecmp */
# endif
# include
@@ -1340,7 +1340,7 @@ start_job_command (struct child *child)
#endif
/* Print the command if appropriate. */
- if (just_print_flag || trace_flag
+ if (just_print_flag || ISDB (DB_PRINT) || trace_flag
|| (!(flags & COMMANDS_SILENT) && !run_silent))
OS (message, 0, "%s", p);
@@ -1883,7 +1883,7 @@ new_job (struct file *file)
/* Trace the build.
Use message here so that changes to working directories are logged. */
- if (trace_flag)
+ if (ISDB (DB_WHY) || trace_flag)
{
char *newer = allocated_variable_expand_for_file ("$?", c->file);
const char *nm;
@@ -1897,12 +1897,9 @@ new_job (struct file *file)
nm = n;
}
- if (newer[0] == '\0')
- OSS (message, 0,
- _("%s: target '%s' does not exist"), nm, c->file->name);
- else
- OSSS (message, 0,
- _("%s: update target '%s' due to: %s"), nm, c->file->name, newer);
+ OSSS (message, 0,
+ _("%s: update target '%s' due to: %s"), nm, c->file->name,
+ newer[0] == '\0' ? _("does not exist") : newer);
free (newer);
}
diff --git a/src/main.c b/src/main.c
index 78a27d7..908ddd3 100644
--- a/src/main.c
+++ b/src/main.c
@@ -746,9 +746,15 @@ decode_debug_flags (void)
case 'n':
db_level = 0;
break;
+ case 'p':
+ db_level |= DB_PRINT;
+ break;
case 'v':
db_level |= DB_BASIC | DB_VERBOSE;
break;
+ case 'w':
+ db_level |= DB_WHY;
+ break;
default:
OS (fatal, NILF,
_("unknown debug level specification '%s'"), p);