Sample Header Ad - 728x90

How to make MAKEFLAGS=--warn-undefined-variables apply to current Makefile?

5 votes
1 answer
290 views
Yes I read [Communicating Options to a Sub-'make'](https://www.gnu.org/software/make/manual/html_node/Options_002fRecursion.html) but I want to set an option for this make, not a sub-make, and set it within the Makefile, not via the command line.
$ cat Makefile
MAKEFLAGS = --warn-undefined-variables
zz: $(yy); xx
$ make -n # see, it didn't work!:
xx
$ make -n --warn-undefined-variables #need to do instead.
Makefile:2: warning: undefined variable 'yy'
xx
$ make --version
GNU Make 4.3
[Others](https://help-make.gnu.narkive.com/SzNl26tG/is-there-a-way-to-set-warn-undefined-variables-in-the-makefile) had the same problem too.
Asked by Dan Jacobson (560 rep)
Oct 12, 2024, 06:54 AM
Last activity: Oct 12, 2024, 07:21 AM