help-make
[Top][All Lists]
Advanced

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

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


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

On Thu, 10 Oct 2013 07:41:18 -0400
Paul Smith <address@hidden> wrote:

> On Thu, 2013-10-10 at 12:15 +0200, Michael Weise wrote:
> > Is there a more erlegant solution, e.g. a variable that stores the
> > current target name?
> 
> Please look up "Automatic Variables" in the GNU make manual.

I've looked up "Automatic Variables" and other parts of the manual,
used google, etc.

> You want the $@ variable.

No, I dont.


Please have a look at my Makefile ...:
----
doc: TARGET = doc
clean: TARGET = clean

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

clean: targetname
        @echo cleaning up

targetname:
        @echo What I want is: $(TARGET), not $@
----

... and the output:

----
$ make doc
What I want is: doc, not targetname
doing some work

$ make clean
What I want is: clean, not targetname
cleaning up
----

I want the name of the "main" target from the command line, not the
one of some prerequisite.

Regards
Michael



reply via email to

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