Backtrace for GNU make

Is there any way to get GNU to print backtrace for the purposes that led to the execution of the command when it fails? I regularly deal with very confusing makefiles when dealing with portability problems of creating software on the new system, and it seems like it should be an extremely simple task to do this, which will help a lot in debugging, but I cannot find a way to request It. I would like to see something like:

gcc: error: ... make[2]: error: gcc ... make[2]: error building target bar make[2]: error building dependency bar for target foo make[1]: error: make -C subdir make[1]: error building target subdir make[1]: error building dependency subdir for target all ... 

shows the entire dependency path for how the failed command completed.

Is there any way to do this?

+6
c makefile gnu-make
source share
3 answers

Use a remake . This is a fixed version of GNU Make, which adds improved error reporting, the ability to track execution in an understandable way, and a debugger.

+4
source share

make -p and make -d provide interesting information, but not quite what you are asking for. See create a help page .

+3
source share

Yes, remake can give you backtrace. Here is a run to use the Makeake Makefile:

  remake --debugger makefile
     GNU Make 4.1 + dbg0.91
     Built for x86_64-unknown-linux-gnu
     Copyright (C) 1988-2014 Free Software Foundation, Inc.
     Copyright (C) 2015 Rocky Bernstein.
     License GPLv3 +: GNU GPL version 3 or later 
     This is free software: you are free to change and redistribute it.
     There is NO WARRANTY, to the extent permitted by law.
     Reading makefiles ...
     Updating makefiles ....
     -> (/ src / github / remake / Makefile: 608)
     Makefile: Makefile.in config.status
     remake <0> bt
     => # 0 Makefile at / src / github / remake / Makefile: 608
     remake <1> s
     -> (/ src / github / remake / Makefile: 594)
     Makefile.in: 
     remake <2> bt
     => # 0 Makefile.in at / src / github / remake / Makefile: 594
       # 1 Makefile at / src / github / remake / Makefile: 608
     remake <3> s
     -> (/ src / github / remake / Makefile: 618)
     config.status: configure
     remake <4> bt
     => # 0 config.status at / src / github / remake / Makefile: 618
       # 1 Makefile at / src / github / remake / Makefile: 608
     remake <5> s
     -> (/ src / github / remake / Makefile: 621)
     configure: 
     remake <6> bt
     = & lt # 0 configure at / src / github / remake / Makefile: 621
       # 1 config.status at / src / github / remake / Makefile: 618
       # 2 Makefile at / src / github / remake / Makefile: 608
     remake <7> 

You can also set a breakpoint on a specific target ( break ), go there ( continue ) and backtrace that. And by mistake, you get a return line from where you were when you crashed.

+1
source share

All Articles