I have a fairly large makefile that creates a number of targets on the fly by computing names from variables. (eg foo$(VAR) : $(PREREQS)). Is there any way that gnu make can be convinced to spit out a list of targets after it has expanded these variables?
I'd like to be able to get the targets for an aribitrary makefile. I'm trying to write a completion function for my shell.
Edit: FYI the debian bash completion git repository in another answer now incorporates an enhanced version of this script tailored to bash completion use cases.
This is a much more complete script than the debian bash completion script because it provides results for generated rules which is what the question asks for and the top voted answer (debian bash completion script at the debian git server) doesn't go far enough.
This is not the original script that I linked to but it is much simpler and is a touch faster.
There is a very nice solution with some sed and egrep magic here: https://gist.github.com/pvdb/777954
This is the code for alias based on Todd Hodes solution