Using this flag make treats warnings as errors and stops if it encounters one. It is most useful in combination with --warn-undefined-variables to detect undefined variables and avoid unconditional execution of partial commands.
Signed-off-by: Richard Weinberger <rich...@nod.at> --- main.c | 9 +++++++++ makeint.h | 2 +- misc.c | 6 ++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index 0a2774c..57575d0 100644 --- a/main.c +++ b/main.c @@ -370,6 +370,8 @@ static const char *const usage[] = Consider FILE to be infinitely new.\n"), N_("\ --warn-undefined-variables Warn when an undefined variable is referenced.\n"), + N_("\ + --strict-mode Treat warnings as error.\n"), NULL }; @@ -425,6 +427,8 @@ static const struct command_switch switches[] = { CHAR_MAX+5, flag, &warn_undefined_variables_flag, 1, 1, 0, 0, 0, "warn-undefined-variables" }, { CHAR_MAX+6, string, &eval_strings, 1, 0, 0, 0, 0, "eval" }, + { CHAR_MAX+7, flag, &strict_mode_flag, 1, 1, 0, 0, 0, + "strict-mode" }, { 0, 0, 0, 0, 0, 0, 0, 0, 0 } }; @@ -513,6 +517,11 @@ int not_parallel; warning at the end of the run. */ int clock_skew_detected; + +/* Treat warnings as errors. */ + +int strict_mode_flag; + /* Mask of signals that are being caught with fatal_error_signal. */ diff --git a/makeint.h b/makeint.h index 6f2ee67..6fb62d0 100644 --- a/makeint.h +++ b/makeint.h @@ -536,7 +536,7 @@ extern int env_overrides, no_builtin_rules_flag, no_builtin_variables_flag; extern int print_version_flag, print_directory_flag, check_symlink_flag; extern int warn_undefined_variables_flag, trace_flag, posix_pedantic; extern int not_parallel, second_expansion, clock_skew_detected; -extern int rebuilding_makefiles, one_shell; +extern int rebuilding_makefiles, one_shell, strict_mode_flag; /* can we run commands via 'sh -c xxx' or must we use batch files? */ extern int batch_mode_shell; diff --git a/misc.c b/misc.c index 37fa1e1..043b5e8 100644 --- a/misc.c +++ b/misc.c @@ -280,6 +280,12 @@ error (flocp, fmt, va_alist) VA_PRINTF (stderr, fmt, args); VA_END (args); + if (strict_mode_flag) + { + fputs (_(". Stop.\n"), stderr); + die (2); + } + putc ('\n', stderr); fflush (stderr); } -- 1.8.1.4 _______________________________________________ Bug-make mailing list Bug-make@gnu.org https://lists.gnu.org/mailman/listinfo/bug-make