help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Variable with name of current target (from command line)?


From: Michael Weise
Subject: Variable with name of current target (from command line)?
Date: Thu, 10 Oct 2013 12:15:13 +0200

Hi,

I'm looking for a way to put the name of the target given from the
command line into a variable.

Currently I'm using target specific variables, like this:

----
doc: TARGET = doc
clean: TARGET = clean

.PHONY: doc clean targetname
doc: targetname
        @echo doing some work   

clean: targetname
        @echo cleaning up

targetname:
        @echo Working on target: $(TARGET)
----

This is fine for two targets, but what if I have 20 or 50 targets?

Putting 50 lines like this
----
$targetname: TARGET = $targetname
----
feels really stupid.

Is there a more erlegant solution, e.g. a variable that stores the
current target name?

Regards
Michael Weise



reply via email to

[Prev in Thread] Current Thread [Next in Thread]