If you can change the variables to be recursively expanded, you can use the following trick:
DOCKER_IMAGE_VERSION = latest$(warning DOCKER_IMAGE_VERSION accessed)
etc, and then grep the output to see where it's accessed. Notice that this does not work for immediate expanded variables (as the warning appears at the assignment rather than at the reference). Also notice that this will only print when the variable is expanded, so for example, if it is referenced inside of a recipe for a target that is never run, it will not output a log. Also, it will not output a log if it is in an ifdef
'd location in the makefile, or as part of a logical function ($(or...)
,$(if ...)
, where the parameter is short circuited.
But, while it can miss references, what this trick is good for is if you have a makefile, where you want to assume a variable is no longer used, you can do:
SOME_VAR = $(error use of deprecated variable)