[Top][All Lists]

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

Re: How to get the current make target

From: Yakov Lerner
Subject: Re: How to get the current make target
Date: Wed, 10 Sep 2003 10:55:09 +0200
User-agent: Mozilla/5.0 (X11; U; SunOS sun4u; en-US; rv:1.0.1) Gecko/20020920 Netscape/7.0

Yanghui Bian wrote:
Generally I could get the make target from "makecmdgoals" provided by
GNU make.
But sometimes people will invoke make like below:
make target1 target2 target3
I assume make process the target1 first then the next target just like I
invoke it as:
Make target1; make target2; make target3; In the first case, is there any way to get the target which is under processing?

Yyou can have a workaround if your set of toplevel targets if limited.

Here is how:

(1) for each of toplevel targets, change ":" to "::" in their rules

(2) at the beginning of makefile, add these lines for each toplevel target:

    target1:: TARGET=target1
    target2:: TARGET=target2
    target3:: TARGET=target3

(3) Caution: *don't* write these lines as

    target1: TARGET=$@   # No. Won't work
    target1: TARGET:=$@  # No. Won't work

No, the 'TARGET=$@' won't work for you. Only 'TARGET=target1' will work,
with target literally repeated:

    target1:: TARGET=target1

(3) Use $(TARGET) as current toplevel target execued

Jacob Lerner

reply via email to

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