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: Paul Smith
Subject: Re: How to refer to the first target?
Date: Thu, 26 Nov 2009 00:01:44 -0500

On Wed, 2009-11-25 at 19:59 -0600, Peng Yu wrote:
> 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

You seem to be under the impression that this rule means that make will
invoke your command.sh one time only, and believe that it generates two
different files.

That's not what this means.

The rule you've written above is _identical_ to, just shorthand for,
writing this:

        a: command.sh
                ./command.sh
        b: command.sh
                ./command.sh

So, in this case, there is only one target file each time command.sh is
invoked, and the name of that target will be stored in address@hidden  So the 
first
time command.sh is invoked, $@ will be set to "a" and the second time it
will be set to "b".

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.mad-scientist.net
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist





reply via email to

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