If you are ready to add a dependency for each goal, you can make warnings in the form of errors.
Here is the make file with an error in it ("SRCS" instead of "SRC"):
MAKEFLAGS += --warn-undefined-variables
ifndef MAKECMDGOALS
MAKECMDGOALS = all
endif
SRC=hello.c
all: compile
no-make-warnings:
! make -n $(MAKECMDGOALS) 2>&1 >/dev/null | grep warning
compile: no-make-warnings
gcc -o hello $(SRCS)
When I started it, I see the following:
$ make
! make -n all 2>&1 >/dev/null | grep warning
Makefile:17: warning: undefined variable `SRCS'
make: *** [no-make-warnings] Error 1
You just need each goal that you want to test depends on the goal no-make-warnings.
If someone knows how to do this automatically, log in.