views:

135

answers:

2

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.

A: 
Beta
Not quite what I want. I would like to be able to make make spit out a list of targets for an arbitrary makefile that I may have. I am trying to write an argument completion function for my shell and I can't rely on the makefiles having any sensible help.
BitShifter
+1  A: 

Can you parse the output from make -pn (i.e. make --print-data-base --dry-run)? It prints out all the variables, rules, implicit rules and which commands will be run in laborious detail.

Jack Kelly
This answer looks much nicer than the other.
Matt Joiner
I agree that this is much nicer. Still more work than I hoped, but I'm going to mark it as the answer since nothing else seems to be reasonable and GNU make doesn't have a convenient flag for what I want.
BitShifter