Seeker
Seeker

Reputation: 39

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?

Upvotes: 1

Views: 368

Answers (2)

MadScientist
MadScientist

Reputation: 100781

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.

Upvotes: 4

D. Joe
D. Joe

Reputation: 43

This might be tedious but you could go to each makefile and echo the makefile's location and filename. Then you can go on to print when a variable was defined as the makefile runs. Here is another post that goes more into detail with printing variables.

How to print out a variable in makefile

Upvotes: 1

Related Questions