On Mon, 2023-10-16 at 15:00 +0000, R. Diez wrote: > I would like to have a flag like "--error-undefined-variables" > instead, which would be the equivalent to Bash' option "set -o > nounset". This way, such programming errors cannot go undetected any > more.
This has already been implemented in Git and will be available in the next release of GNU Make. >From the NEWS file for the next release: * New feature: Makefile warning reporting control A new option "--warn" controls reporting of warnings for makefiles. Actions can be set to "ignore", "warn", or "error". Two new warnings are reported: assigning to invalid variable names, and referencing invalid variable names (both set to "warn" by default), in addition to the existing warning for undefined variables (defaults to "ignore"). "--warn-undefined-variables" is deprecated, and is translated to "--warn=undefined-vars" internally. * New feature: Control warnings with the .WARNINGS variable In addition to --warn from the command line, which takes effect for make invoked recursively, warnings can be controlled only for the current instance of make using the .WARNINGS variable. The man page says: --warn[=ARG[,ARG]] Control warning reporting for makefiles. This option can appear multiple times. In case of conflicts, later settings override earlier settings. ARG can be an action; one of ignore, warn, or error to set the default action for all warnings, or it can be a specific warning: invalid-var (assigning to an invalid variable name), invalid-ref (referencing an invalid variable name), or un‐ defined-var (referencing an undefined variable). The behavior of each warning can be set by adding :action after the warning name. If an action is not specified the default is warn. If no ARG is provided the action for all warnings is warn. If no --warn option is provided the default action for invalid-var and invalid-ref is warn and the default action for undefined-var is ignore. --warn-undefined-variables A deprecated alternative for --warn=undefined-var. The user manual has more detail.