On Fri, 2022-01-28 at 01:09 +0100, Alejandro Colomar (man-pages) wrote: > I'd like make to warn about this. It took me a while to debug > a Makefile bug, which I thought was not happening, since make should > have warned me. Isn't this supposed to trigger the warning?
In previous versions of GNU make, the value of MAKEFLAGS set inside a makefile is only re-parsed once before all makefiles are read (from the environment) and again after all makefiles are read. So, changes to this variable within the makefile don't take effect until after all makefiles are parsed. In your situation the variable in question is part of a prerequisite list and that's expanded while parsing the makefile, so the option is not set yet and you don't get warnings. Undefined variables used in a recipe WOULD be warned about since recipes are expanded after all makefiles are parsed. To make this option do what you want you must pass it in either via the command line: $ make --warn-undefined-variables or the environment: $ MAKEFLAGS=--warn-undefined-variables make or: $ GNUMAKEFLAG=--warn-undefined-variables make In the next release of GNU make, this has been changed; from the NEWS file: * If the MAKEFLAGS variable is modified in a makefile, it will be re-parsed immediately rather than after all makefiles have been read. Note that although all options are parsed immediately, some special effects won't appear until after all makefiles are read.