Search code examples
c++cmakefilebuildcompilation

Is there a way to get the name of the makefile where a make variable was defined?


For debugging purposes, when there are many make file inclusions, it's useful to print the full path of the makefile where a particular variable in the current makefile was first defined. Is there a way to do that?


Solution

  • Just run make -p. Make will print its internal database including all targets and variables that were seen along with the filename and linenumber where they were set.