help-make
[Top][All Lists]
Advanced

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

Re: How to refer to the first target?


From: Peng Yu
Subject: Re: How to refer to the first target?
Date: Wed, 25 Nov 2009 19:59:32 -0600

On Mon, Nov 23, 2009 at 10:58 PM, Paul Smith <address@hidden> wrote:
> On Mon, 2009-11-23 at 22:13 -0600, Peng Yu wrote:
>> $< refers to the first prerequisite. How to refer to the first target?
>
> Not sure what you mean: generally there is only one target.
>
> If you mean in a pattern rule with multiple target patterns, there is no
> way.  You can construct it with $*, but since, unlike prerequisites, all
> targets have to be defined right there in the rule it's not as important
> to be able to generically refer to the "first" target.

Suppose I have 'command.sh' that generate files 'a' and 'b'.

If either of 'a' or 'b' is older than 'command.sh', I need to run
'command.sh' again. The following Makefile has two targets, right? I
want to refer to the second target 'b' in this Makefile.

$ cat Makefile
all: a b

a b: command.sh
        ./command.sh
$ cat command.sh
echo 'a' > a
echo 'b' > b




reply via email to

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