How to get the invoking target of makefile?

Solution 1:

The variable MAKECMDGOALS contains the list of targets that were specified on the command line, no matter how many (it's empty if there were none).

Solution 2:

Maybe you need $@?

See http://www.gnu.org/software/make/manual/make.html#Automatic-Variables for more details.