2

I know for Makefile debugging, people use (I do too) $(info ... ) or $(warn ...) print to see Makefile variable and flow. and I also know Makefile goes through mulitple pass according to the dependency as the variables get re-evaluated. But none the less I occasionally wish there were some kind of Makefile debugger or print option like we debug bash script. (in bash script, with set -x we can print the commands with variables expanded.) Isn't there such a method in Makefile? (I know how to suppress the recipe by placing @mark, but I want to see all the lines being processed and re-evaluated).
I found remake (http://bashdb.sourceforge.net/remake/) but the documentation is weak, and I don't know it's usable.
ADD : David Z showed me How do I force make/GCC to show me the commands? but that solution only expands the recipe part and not the other variable expansion parts.

Chan Kim
  • 5,177
  • 12
  • 57
  • 112
  • Does this answer your question? [How do I force make/GCC to show me the commands?](https://stackoverflow.com/questions/5820303/how-do-i-force-make-gcc-to-show-me-the-commands) – David Z Dec 15 '20 at 06:50
  • @DavidZ thanks for the info. I checked it but it shows only the recipe part, and not the variable expansion(export AA=$(TOP_DIR)...). but it helps though not as much I wanted. – Chan Kim Dec 15 '20 at 07:12
  • You can expand the variables using `info`, e.g. `$(info $$SOURCES is [${SOURCES}])` to dump the content of the `SOURCES` variable. It requires an individual call for each variable, but for debugging it is helpful. – David C. Rankin Dec 15 '20 at 07:30
  • @DavidC.Rankin yes that's what sometimes do(like today). but I want to see the expansion without modifying numerous Makefiles. – Chan Kim Dec 15 '20 at 12:12
  • The direct and short answer to your question is no, there is not something like you request. The closest there is is using the `-p` option to print make's database. That will include the results of all variable assignments, and it will show you the filename/linenumber in the makefile where the variable was assigned. So it gives you the results but not in any particular order, as the makefile is parsed. – MadScientist Dec 15 '20 at 14:14
  • 1
    @MadScientist yeap. that looks to be too much information. I tried --debug=... with various flags like a,j,v,y,.. they all didn't show the Makefile line-by-line flow and expansion. I don't know why the developers didn't add that option to make. – Chan Kim Dec 15 '20 at 14:23

0 Answers0