diff --git a/src/file.c b/src/file.c index 73511d8a..c20fcf8b 100644 --- a/src/file.c +++ b/src/file.c @@ -410,7 +410,7 @@ remove_intermediates (int sig) { if (! doneany) DB (DB_BASIC, (_("Removing intermediate files...\n"))); - if (!silent_flag) + if (!run_silent) { if (! doneany) { @@ -768,7 +768,7 @@ snap_deps (void) if (f != 0 && f->is_target) { if (f->deps == 0) - silent_flag = 1; + run_silent = 1; else for (d = f->deps; d != 0; d = d->next) for (f2 = d->file; f2 != 0; f2 = f2->prev) diff --git a/src/job.c b/src/job.c index dbf85851..54dd284f 100644 --- a/src/job.c +++ b/src/job.c @@ -541,7 +541,7 @@ child_error (struct child *child, const char *nm; size_t l; - if (ignored && silent_flag) + if (ignored && run_silent) return; if (exit_sig && coredump) @@ -1312,7 +1312,7 @@ start_job_command (struct child *child) /* Print the command if appropriate. */ if (just_print_flag || trace_flag - || (!(flags & COMMANDS_SILENT) && !silent_flag)) + || (!(flags & COMMANDS_SILENT) && !run_silent)) OS (message, 0, "%s", p); /* Tell update_goal_chain that a command has been started on behalf of diff --git a/src/main.c b/src/main.c index 13c1521e..e9323fae 100644 --- a/src/main.c +++ b/src/main.c @@ -164,9 +164,13 @@ int verify_flag; /* Nonzero means do not print commands to be executed (-s). */ -int silent_flag; +static int silent_flag; static const int default_silent_flag = 0; +/* Nonzero means either -s was given, or .SILENT-with-no-deps was seen. */ + +int run_silent = 0; + /* Nonzero means just touch the files that would appear to need remaking (-t) */ @@ -3012,6 +3016,9 @@ decode_switches (int argc, const char **argv, int env) /* If there are any options that need to be decoded do it now. */ decode_debug_flags (); decode_output_sync_flags (); + + /* Perform any special switch handling. */ + run_silent = silent_flag; } /* Decode switches from environment variable ENVAR (which is LEN chars long). diff --git a/src/makeint.h b/src/makeint.h index 2b882c9b..dd6e894f 100644 --- a/src/makeint.h +++ b/src/makeint.h @@ -654,7 +654,7 @@ extern const floc **expanding_var; extern unsigned short stopchar_map[]; -extern int just_print_flag, silent_flag, ignore_errors_flag, keep_going_flag; +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_flag, check_symlink_flag; diff --git a/src/remake.c b/src/remake.c index 0f0a6d32..a331a63a 100644 --- a/src/remake.c +++ b/src/remake.c @@ -221,7 +221,7 @@ update_goal_chain (struct goaldep *goaldeps) any commands were actually started for this goal. */ && file->update_status == us_success && !g->changed /* Never give a message under -s or -q. */ - && !silent_flag && !question_flag) + && !run_silent && !question_flag) OS (message, 1, ((file->phony || file->cmds == 0) ? _("Nothing to be done for '%s'.") : _("'%s' is up to date.")), @@ -1144,7 +1144,7 @@ check_dep (struct file *file, unsigned int depth, static enum update_status touch_file (struct file *file) { - if (!silent_flag) + if (!run_silent) OS (message, 0, "touch %s", file->name); /* Print-only (-n) takes precedence over touch (-t). */ diff --git a/tests/scripts/targets/SILENT b/tests/scripts/targets/SILENT index 521930e8..df396a4c 100644 --- a/tests/scripts/targets/SILENT +++ b/tests/scripts/targets/SILENT @@ -1,31 +1,33 @@ # -*-perl-*- -$description = "The following tests the special target .SILENT. By simply\n" - ."mentioning this as a target, it tells make not to print\n" - ."commands before executing them."; +$description = "Test the special target .SILENT."; -$details = "This test is the same as the clean test except that it should\n" - ."not echo its command before deleting the specified file.\n"; +run_make_test(q! +.PHONY: M a b +M: a b +.SILENT : b +a b: ; echo $@ +!, + '', "echo a\na\nb"); -$example = "EXAMPLE_FILE"; +run_make_test(q! +.PHONY: M a b +M: a b +.SILENT: +a b: ; echo $@ +!, + '', "a\nb"); -open(MAKEFILE,"> $makefile"); -print MAKEFILE qq! -.SILENT : clean -clean: ; $CMD_rmfile $example -!; -close(MAKEFILE); +# SV 54740 : don't inherit .SILENT settings in sub-makes +run_make_test(q! +.PHONY: M r a b +r: a b ; @$(MAKE) -f #MAKEFILE# M V=x +a b: ; echo $@ -touch($example); - -$answer = ''; -run_make_with_options($makefile,"clean",&get_logfile,0); -if (-f $example) { - $test_passed = 0; -} -compare_output($answer,&get_logfile(1)); - -# Just in case -unlink($example); +V = +$V.SILENT: +M: a b +!, + '--no-print-directory', "a\nb\necho a\na\necho b\nb"); 1;