调试Makefile的工具


73

我有一个大型的旧版代码库,其中包含非常复杂的makefile和许多变量。有时我需要更改它们,但发现很难弄清为什么更改未按我期望的方式工作。我想找到的是一个基本上可以对“ make”过程进行逐步调试的工具,我可以在其中给它一个目录,然后我可以在不同位置查看不同变量的值。处理。尽管可能会丢失某些内容,但所有要使的调试标志似乎都没有显示我想要的内容。有人知道这样做的方法吗?

Answers:


70

您是否一直在查看runningmake -nmake -npbiggie的输出make -nd

您是否使用的是最新版本gmake

您是否看过O'Reilly网站上免费的关于调试Makefile的章节,其中包含其出色的著作“使用GNU Make管理项目”(Amazon Link)。


34

我确定重拍是您想要的。

从首页:

remake是GNU make实用程序的修补程序和现代化版本,它增加了改进的错误报告,以可理解的方式跟踪执行的能力以及调试器。

它具有类似gdb的界面,并由(x)emacs中的mdb-mode支持,这意味着断点,手表等。如果您不喜欢(x)emacs,则还有 DDD


2
如果可以的话,我会加+100。当使用翻拍(“ brew install remake”进行安装)时,我不得不调试的问题就简单地消失了。不知道问题出在哪里,但是谁在乎呢?:)
ishahak 2015年

20

在手册页上的make命令行选项中:

-n, --just-print, --dry-run, --recon  
Print the commands that would be executed, but do not execute them.  

-d  Print debugging information in addition to normal processing.  
The debugging information says  
which files are being considered for remaking,  
which file-times are being compared and with what results,  
which files actually need  to  be  remade,  
which implicit  rules are considered and which are applied---  
everything interesting about how make decides what to do.  

--debug[=FLAGS] Print debugging information in addition to normal processing.  
If the FLAGS are omitted, then the behaviour is the same as if -d was specified.  
FLAGS may be:  
'a' for all debugging output same as using -d,  
'b' for basic debugging,  
'v' for more verbose basic debugging,  
'i' for showing implicit rules,  
'j' for details on invocation of commands, and  
'm' for debugging while remaking makefiles.  

5

我不知道有什么特定标志可以完全满足您的要求,但是

--print-data-base
听起来可能很有用。



By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.