Debug your makefile

make -d | egrep --color -i '(considering|older|newer|remake)'
Say your dependencies specified in your Makefile (or dates on your source files) is causing 'make' to skip some source-files (that it should not) or on the other other end, if it is causing make to always build some source-files regardless of dates of target, then above command is handy to find out what 'make' thinks of your date v/s target date-wise or what dependencies are in make's view-point. The egrep part removes the extra noise, that you might want to avoid.
Sample Output
$ make -d | egrep --color -i '(considering|older|newer|remake)'
 Considering target file `Makefile'.
 No need to remake target `Makefile'.
Considering target file `hffcmprss'.
  Considering target file `hffcmprss.o'.
    Considering target file `common/common_types.h'.
    No need to remake target `common/common_types.h'.
    Considering target file `gnrcheap/gnrcheap.o'.
      Considering target file `gnrcheap/gnrcheap.c'.
      No need to remake target `gnrcheap/gnrcheap.c'.
      Considering target file `gnrcheap/gnrcheap.h'.
      No need to remake target `gnrcheap/gnrcheap.h'.
     Prerequisite `gnrcheap/gnrcheap.c' is older than target `gnrcheap/gnrcheap.o'.
     Prerequisite `gnrcheap/gnrcheap.h' is older than target `gnrcheap/gnrcheap.o'.
     Prerequisite `Makefile' is older than target `gnrcheap/gnrcheap.o'.
    No need to remake target `gnrcheap/gnrcheap.o'.
    Considering target file `gnrcqueue/gnrcqueue.o'.
      Considering target file `gnrcqueue/gnrcqueue.c'.
      No need to remake target `gnrcqueue/gnrcqueue.c'.
      Considering target file `gnrcqueue/gnrcqueue.h'.
      No need to remake target `gnrcqueue/gnrcqueue.h'.
     Prerequisite `gnrcqueue/gnrcqueue.c' is older than target `gnrcqueue/gnrcqueue.o'.
     Prerequisite `gnrcqueue/gnrcqueue.h' is older than target `gnrcqueue/gnrcqueue.o'.
     Prerequisite `Makefile' is older than target `gnrcqueue/gnrcqueue.o'.
    No need to remake target `gnrcqueue/gnrcqueue.o'.
    Considering target file `gnrclist/gnrclist.o'.
      Considering target file `gnrclist/gnrclist.c'.
      No need to remake target `gnrclist/gnrclist.c'.
      Considering target file `gnrclist/gnrclist.h'.
      No need to remake target `gnrclist/gnrclist.h'.
     Prerequisite `gnrclist/gnrclist.c' is older than target `gnrclist/gnrclist.o'.
     Prerequisite `gnrclist/gnrclist.h' is older than target `gnrclist/gnrclist.o'.
     Prerequisite `Makefile' is older than target `gnrclist/gnrclist.o'.
    No need to remake target `gnrclist/gnrclist.o'.
    Considering target file `gnrctree/gnrctree.o'.
      Considering target file `gnrctree/gnrctree.c'.
      No need to remake target `gnrctree/gnrctree.c'.
      Considering target file `gnrctree/gnrctree.h'.
      No need to remake target `gnrctree/gnrctree.h'.
     Prerequisite `gnrctree/gnrctree.c' is newer than target `gnrctree/gnrctree.o'.
     Prerequisite `gnrctree/gnrctree.h' is older than target `gnrctree/gnrctree.o'.
     Prerequisite `Makefile' is older than target `gnrctree/gnrctree.o'.
    Must remake target `gnrctree/gnrctree.o'.
gnrctree/gnrctree.c: In function ?gnrctree_bfs?:
gnrctree/gnrctree.c:99: warning: suggest parentheses around assignment used as truth value
    Considering target file `hfftypes.h'.
    No need to remake target `hfftypes.h'.
    Considering target file `hffcmprss.h'.
    No need to remake target `hffcmprss.h'.
    Considering target file `hffcmprss.c'.
    No need to remake target `hffcmprss.c'.
   Prerequisite `common/common_types.h' is older than target `hffcmprss.o'.
   Prerequisite `gnrcheap/gnrcheap.o' is older than target `hffcmprss.o'.
   Prerequisite `gnrcqueue/gnrcqueue.o' is older than target `hffcmprss.o'.
   Prerequisite `gnrclist/gnrclist.o' is older than target `hffcmprss.o'.
   Prerequisite `gnrctree/gnrctree.o' is newer than target `hffcmprss.o'.
   Prerequisite `hfftypes.h' is older than target `hffcmprss.o'.
   Prerequisite `hffcmprss.h' is newer than target `hffcmprss.o'.
   Prerequisite `hffcmprss.c' is older than target `hffcmprss.o'.
   Prerequisite `Makefile' is older than target `hffcmprss.o'.
  Must remake target `hffcmprss.o'.
 Prerequisite `hffcmprss.o' is newer than target `hffcmprss'.
 Prerequisite `Makefile' is older than target `hffcmprss'.
Must remake target `hffcmprss'.

1
By: b_t
2011-06-03 01:55:08

What Others Think

Brilliant. Simple and effective. If you want to look at all of make's output, you can add "|$" to the end of the grep clause. This will syntax-highlight the words and leave the rest of the text intact. make -d | egrep --color -i '(considering|older|newer|remake|$)'
flatcap · 384 weeks and 6 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: