help-make
[Top][All Lists]
Advanced

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

Re: Why rules depends on the same target behave differently if the comma


From: Paul Smith
Subject: Re: Why rules depends on the same target behave differently if the commands are different?
Date: Mon, 26 Apr 2010 10:59:19 -0400

On Mon, 2010-04-26 at 09:51 -0500, Peng Yu wrote:
> On Mon, Apr 26, 2010 at 6:40 AM, Paul Smith <address@hidden> wrote:
> > On Sun, 2010-04-25 at 15:13 -0500, Peng Yu wrote:
> >
> >> /tmp/double_targets_same_command$ make
> >> a
> >> echo 'a' > a; sleep 1; echo 'b' > b
> >
> > Here one command (the one for building "a") also builds "b", so when
> > make goes to see if "b" is out of date or not, it finds that "b" is
> > up-to-date (it was just built) and so there's nothing to be done for
> > "b", and make stops.
> 
> I see if I use '-j2' option both command will be executed.

That's because make sees that "b" is not up-to-date before the rule for
"a" has a chance to change it.  This is actually not deterministic; it's
remotely possible you will get different behavior depending on how
things are scheduled by the operating system (well, with a "sleep" it's
not really possible but for a "normal" command it could be, if the
command runs quickly).

> Is there is a way to parallelly run some rules but serially run others rules?

The only way to control parallelism is to disable it completely for the
entire instance of make, or else to manage it through prerequisite
declarations.  For example you can do something like:

        all: a b

        a b: command.out

        command.out: command.sh
                echo 'a' > a; sleep 1; echo 'b' > b
                @touch $@

-- 
-------------------------------------------------------------------------------
 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]