How to list prerequisites externally in GNU Make

gnu-makemake

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

Best 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.

Related Question