Tool for debugging makefiles

I have a large legacy code base with very complex makefiles with lots of variables. Sometimes I need to change them, and I find it very difficult to understand why the change does not work the way I expect. What I would like to find is a tool that basically performs end-to-end debugging of the β€œmake” process, where I would give it a directory, and I could see the value of different variables at different points to process. None of the debug flags seem to show me what I want, although it is possible that I am missing something. Does anyone know a way to do this?

+45
debugging makefile
Sep 10 '08 at 17:16
source share
5 answers

Have you looked at the results of make -n and make -np , and biggie make -nd ?

Are you using a fairly recent version of gmake ?

Have you looked at the free chapter on Debugging Makefiles on O'Reilly for the excellent book "Project Management with GNU Make" ( Amazon Link ).

+47
Sep 10 '08 at 17:22
source share

I'm sure remake is what you are looking for.

On the home page:

The remake is a revised and updated version of the GNU make utility, which adds improved error reporting, the ability to track execution in an understandable form, and a debugger.

It has a gdb-like interface and is supported by mdb-mode in (x) emacs, which means breakponts, clocks, etc. And there DDD if you do not like (x) emacs

+20
Nov 24 '08 at 9:45
source share

On the man page in command line options:

 -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. 
+6
Mar 20 '13 at 11:33
source share

I don’t know of any specific flag that does exactly what you want, but

  --print-data-base 
sounds like it might be helpful.
+3
Sep 10 '08 at 17:28
source share

There is a GNU make debugger project from http://gmd.sf.net that looks very useful. The main function supported by gmd is a breakpoint, which can be more useful than stepping. To use this, you download gmd from http://gmd.sf.net and gmsl from http://gmsl.sf.net , and execute 'include gmd' in your makefile.

0
Aug 14 '14 at 15:22
source share



All Articles