Tool for debugging makefiles

前端 未结 6 1188
有刺的猬
有刺的猬 2020-12-12 13:08

I have a large legacy codebase with very complicated makefiles, with lots of variables. Sometimes I need to change them, and I find that it\'s very difficult to figure out

相关标签:
6条回答
  • 2020-12-12 13:21

    Have you been looking at the output from running make -n and make -np, and the biggie make -nd?

    Are you using a fairly recent version of gmake?

    Have you looked at the free chapter on Debugging Makefiles available on O'Reilly's site for their excellent book "Managing Projects with GNU Make" (Amazon Link).

    0 讨论(0)
  • 2020-12-12 13:27

    From the man page on make 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.  
    
    0 讨论(0)
  • 2020-12-12 13:27
    remake --debugger all

    More info https://vimeo.com/97397484

    https://github.com/rocky/remake/wiki/Installing

    0 讨论(0)
  • 2020-12-12 13:34

    There is a GNU make debugger project at http://gmd.sf.net which looks quite useful. The main feature supported by gmd is breakpointing, which may be more useful than stepping. To use this, you download gmd from http://gmd.sf.net and gmsl from http://gmsl.sf.net, and do an 'include gmd' in your makefile.

    0 讨论(0)
  • 2020-12-12 13:39

    I'm not aware of any specific flag that does exactly what you want, but

    --print-data-base
    sounds like it might be useful.

    0 讨论(0)
  • 2020-12-12 13:44

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

    From the homepage:

    remake is a patched and modernized version of GNU make utility that adds improved error reporting, the ability to trace execution in a comprehensible way, and a debugger.

    It has gdb-like interface and is supported by mdb-mode in (x)emacs which means breakponts, watches etc. And there's DDD if you don't like (x)emacs

    0 讨论(0)
提交回复
热议问题