Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

How can I query prerequisites of a target from a GNU Make makefile?

E.g. if the targets specified like this:

fred: wilma barney betty

I want to print prerequisites of fred like this:

$ make some_action fred
wilma barney betty
share|improve this question
    
This doesn't answer your question, but have you considered alternative to GNU Make. I use SCons, which is good for small programs at least. With larger ones it supposedly has performance problems. If you know Python, then that is an even better reason to use it, since SCons build recipes are written in Python. –  Faheem Mitha Sep 26 '11 at 15:21
add comment

1 Answer

Maybe a dry run is what you are looking for?

make --dry-run fred

The man page gives us this about the dry run:

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

So it will not give you a direct list, but a indirect list since you know that he would like to execute what he depends on.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.