Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List goals/targets in GNU make that contain variables in their definition

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.

like image 1000
BitShifter Avatar asked Jun 17 '10 16:06

BitShifter


People also ask

What are typical targets in a makefile?

By default, the goal is the first target in the makefile (not counting targets that start with a period). Therefore, makefiles are usually written so that the first target is for compiling the entire program or programs they describe.

Which of these is a reference to a make variable in GNU make?

Basics of Variable References To substitute a variable's value, write a dollar sign followed by the name of the variable in parentheses or braces: either `$(foo)' or `${foo}' is a valid reference to the variable foo .


1 Answers

make -qp | awk -F':' '/^[a-zA-Z0-9][^$#\/\t=]*:([^=]|$)/ {split($1,A,/ /);for(i in A)print A[i]}'      

Taken from the make arg completion, which works like a charm.

like image 146
todd hodes Avatar answered Sep 28 '22 02:09

todd hodes