summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2020-12-05 16:25:12 -0500
committerPaul Smith <psmith@gnu.org>2020-12-05 16:25:12 -0500
commit7044e0c93ca3d52e3e947764e538a0d1f5f2f16a (patch)
tree8e7a8994da16a16f8469f0257f05226538e827e5
parent94d90776914f4086e2402a0a6a9dfa3d1a9a7d0c (diff)
downloadmake-git-7044e0c93ca3d52e3e947764e538a0d1f5f2f16a.tar.gz
[SV 59169] Add --debug=why and --debug=print options
Add debug options to print recipes even if they would otherwise be silent, and to print the reason that a target was considered out of date. Modify --trace to simply be a shorthand for --debug=print,why. * NEWS: Announce changes. * doc/make.texi (Summary of Options): Document the new options. * doc/make.1: Ditto. * src/debug.h: Add new flags DB_PRINT and DB_WHY. * src/makeint.h: Remove the trace_flag variable. * src/job.c (start_job_command): Check debug flags not trace_flag. (new_job): Ditto. * src/main.c (trace_flag): Make a static variable for switches. (decode_debug_flags): Set DB_PRINT and DB_WHY if trace_flag is set. * tests/scripts/variables/GNUMAKEFLAGS: Update known-good messages. * tests/scripts/variables/MAKEFLAGS: Ditto.
-rw-r--r--NEWS8
-rw-r--r--doc/make.129
-rw-r--r--doc/make.texi16
-rw-r--r--src/debug.h2
-rw-r--r--src/job.c15
-rw-r--r--src/main.c17
-rw-r--r--src/makeint.h2
-rw-r--r--tests/scripts/variables/GNUMAKEFLAGS2
-rw-r--r--tests/scripts/variables/MAKEFLAGS17
9 files changed, 67 insertions, 41 deletions
diff --git a/NEWS b/NEWS
index 0e3ca536..6802a7ce 100644
--- a/NEWS
+++ b/NEWS
@@ -34,6 +34,14 @@ https://sv.gnu.org/bugs/index.php?group=make&report_id=111&fix_release_id=109&se
https://www.gnu.org/software/gnulib/manual/html_node/C99-features-assumed.html
The configure script should verify the compiler has these features.
+* New debug option "print" will show the recipe to be run, even when silent
+ mode is set.
+
+* New debug option "why" will show why a target is rebuilt (which
+ prerequisites caused the target to be considered out of date).
+
+* The existing --trace option is made equivalent to --debug=print,why
+
* Target-specific variables can now be marked "unexport".
* Exporting / unexporting target-specific variables is handled correctly, so
diff --git a/doc/make.1 b/doc/make.1
index dbd023fa..1ec661ea 100644
--- a/doc/make.1
+++ b/doc/make.1
@@ -130,21 +130,28 @@ are omitted, then the behavior is the same as if
.B \-d
was specified.
.I FLAGS
-may be
-.I a
+may be any or all of the following names, comma- or space-separated. Only the
+first character is significant: the rest may be omitted:
+.I all
for all debugging output (same as using
.BR \-d ),
-.I b
+.I basic
for basic debugging,
-.I v
+.I verbose
for more verbose basic debugging,
-.I i
-for showing implicit rules,
-.I j
-for details on invocation of commands, and
-.I m
-for debugging while remaking makefiles. Use
-.I n
+.I implicit
+for showing implicit rule search operations,
+.I jobs
+for details on invocation of commands,
+.I makefile
+for debugging while remaking makefiles,
+.I print
+shows all recipes that are run even if they are silent, and
+.I why
+shows the reason
+.BR make
+decided to rebuild each target. Use
+.I none
to disable all previous debugging flags.
.TP 0.5i
\fB\-e\fR, \fB\-\-environment\-overrides\fR
diff --git a/doc/make.texi b/doc/make.texi
index 45b51002..85bd66e0 100644
--- a/doc/make.texi
+++ b/doc/make.texi
@@ -8892,6 +8892,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 recipe to be executed, even when the recipe is 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 showing which prerequisites
+are more up to date than the target.
+
@item n (@i{none})
Disable all debugging currently enabled. If additional debugging
flags are encountered after this they will still take effect.
@@ -9123,11 +9132,8 @@ recipes were done, in order to fool future invocations of
@item --trace
@cindex @code{--trace}
-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.
+Show tracing information for @code{make} execution. This is shorthand
+for @code{--debug=print,why}.
@item -v
@cindex @code{-v}
diff --git a/src/debug.h b/src/debug.h
index 514b7e8e..4db34b9d 100644
--- a/src/debug.h
+++ b/src/debug.h
@@ -19,6 +19,8 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
#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 28ddacff..d6e28d3a 100644
--- a/src/job.c
+++ b/src/job.c
@@ -29,7 +29,7 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
/* Default shell to use. */
#ifdef WINDOWS32
# ifdef HAVE_STRINGS_H
-# include <strings.h> /* for strcasecmp, strncasecmp */
+# include <strings.h> /* for strcasecmp, strncasecmp */
# endif
# include <windows.h>
@@ -1341,7 +1341,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)
|| (!(flags & COMMANDS_SILENT) && !run_silent))
OS (message, 0, "%s", p);
@@ -1884,7 +1884,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))
{
char *newer = allocated_variable_expand_for_file ("$?", c->file);
const char *nm;
@@ -1898,12 +1898,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' ? _("target does not exist") : newer);
free (newer);
}
diff --git a/src/main.c b/src/main.c
index 64e25291..2c202588 100644
--- a/src/main.c
+++ b/src/main.c
@@ -413,6 +413,10 @@ static const char *const usage[] =
NULL
};
+/* Nonzero if the "--trace" option was given. */
+
+static int trace_flag = 0;
+
/* The table of command switches.
Order matters here: this is the order MAKEFLAGS will be constructed.
So be sure all simple flags (single char, no argument) come first. */
@@ -553,10 +557,6 @@ int one_shell;
int output_sync = OUTPUT_SYNC_NONE;
-/* Nonzero if the "--trace" option was given. */
-
-int trace_flag = 0;
-
/* Nonzero if we have seen the '.NOTPARALLEL' target.
This turns off parallel builds for this invocation of make. */
@@ -724,6 +724,9 @@ decode_debug_flags (void)
if (debug_flag)
db_level = DB_ALL;
+ if (trace_flag)
+ db_level = DB_PRINT | DB_WHY;
+
if (db_flags)
for (pp=db_flags->list; *pp; ++pp)
{
@@ -751,9 +754,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);
diff --git a/src/makeint.h b/src/makeint.h
index 70ee2b6d..015bf5c2 100644
--- a/src/makeint.h
+++ b/src/makeint.h
@@ -686,7 +686,7 @@ extern int just_print_flag, run_silent, ignore_errors_flag, keep_going_flag;
extern int print_data_base_flag, question_flag, touch_flag, always_make_flag;
extern int env_overrides, no_builtin_rules_flag, no_builtin_variables_flag;
extern int print_version_flag, print_directory, check_symlink_flag;
-extern int warn_undefined_variables_flag, trace_flag, posix_pedantic;
+extern int warn_undefined_variables_flag, posix_pedantic;
extern int not_parallel, second_expansion, clock_skew_detected;
extern int rebuilding_makefiles, one_shell, output_sync, verify_flag;
extern unsigned long command_count;
diff --git a/tests/scripts/variables/GNUMAKEFLAGS b/tests/scripts/variables/GNUMAKEFLAGS
index 063c256d..30bccf68 100644
--- a/tests/scripts/variables/GNUMAKEFLAGS
+++ b/tests/scripts/variables/GNUMAKEFLAGS
@@ -19,7 +19,7 @@ $ENV{'GNUMAKEFLAGS'} = '--no-print-directory -e -r -R --trace';
run_make_test(q!
all: ; @echo $(MAKEFLAGS)
!,
- '', "#MAKEFILE#:2: target 'all' does not exist
+ '', "#MAKEFILE#:2: update target 'all' due to: target does not exist
echo erR --trace --no-print-directory
erR --trace --no-print-directory");
diff --git a/tests/scripts/variables/MAKEFLAGS b/tests/scripts/variables/MAKEFLAGS
index 0fac74a3..752bdc30 100644
--- a/tests/scripts/variables/MAKEFLAGS
+++ b/tests/scripts/variables/MAKEFLAGS
@@ -14,7 +14,7 @@ all: ; @echo $(MAKEFLAGS)
run_make_test(q!
all: ; @echo $(MAKEFLAGS)
!,
- '--no-print-directory -e -r -R --trace', "#MAKEFILE#:2: target 'all' does not exist
+ '--no-print-directory -e -r -R --trace', "#MAKEFILE#:2: update target 'all' due to: target does not exist
echo erR --trace --no-print-directory
erR --trace --no-print-directory");
@@ -23,14 +23,15 @@ erR --trace --no-print-directory");
# Savannah bug #2216
run_make_test(q!
MSG = Fails
+.RECIPEPREFIX = >
all:
- @echo '$@: MAKEFLAGS=$(MAKEFLAGS)'
- @MSG=Works $(MAKE) -e -f #MAKEFILE# jump
+> @echo '$@: MAKEFLAGS=$(MAKEFLAGS)'
+> @MSG=Works $(MAKE) -e -f #MAKEFILE# jump
jump:
- @echo '$@ $(MSG): MAKEFLAGS=$(MAKEFLAGS)'
- @$(MAKE) -f #MAKEFILE# print
+> @echo '$@ $(MSG): MAKEFLAGS=$(MAKEFLAGS)'
+> @$(MAKE) -f #MAKEFILE# print
print:
- @echo '$@ $(MSG): MAKEFLAGS=$(MAKEFLAGS)'
+> @echo '$@ $(MSG): MAKEFLAGS=$(MAKEFLAGS)'
.PHONY: all jump print
!,
'--no-print-directory',
@@ -39,7 +40,3 @@ jump Works: MAKEFLAGS=e --no-print-directory
print Works: MAKEFLAGS=e --no-print-directory');
1;
-
-### Local Variables:
-### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action))
-### End: