Printing Variables Values in a Makefile

To print a variable named MY_VAR defined in a Makefile:

$(info $$MY_VAR is [${MY_VAR}])

You can also define a rule

print-%:
	@echo $* = $($*)

and then run make print-MY_VAR.

This comes from this StackOverflow post.

Home | Back to blog

This work is licensed under CC BY-NC 4.0 Creative Commons BY-NC image