help-make
[Top][All Lists]
Advanced

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

RE: please clarify the manual on foreach function?


From: Paul Smith
Subject: RE: please clarify the manual on foreach function?
Date: Fri, 18 Feb 2011 18:36:07 -0500

On Fri, 2011-02-18 at 14:40 -0800, Mark Galeck (CW) wrote:
> >Well, I think you misunderstand what -j does.  All it does is allow
> >make to have multiple jobs (that is, sub-programs) active at the same
> >time.
> 
> OK, thank you Paul for your answers.  I "think" I understand what is
> meant by multiple-jobs: multiple targets updated.  
> 
> But my particular problem was during the "first pass" of make, where
> no targets are updated yet.  During that time, I invoke "foreach" and
> from your first answer, it follows that it concatenates in order.  Are
> you also saying, that the first pass of make, is always serial,
> period?  

All the processing make does is always serial, period.

Without -j, make works by first reading and parsing all the makefiles,
then it figures out what the first shell command it needs to run is.
That is a "job" in make parlance.  Note a given target might require
multiple shell commands (jobs) to complete, if it has multiple logical
recipe lines (and ONESHELL) is not set.

Once make knows that, it starts a shell process to run that job.  So
make can continue running (although it's still, internally, serial)
while that process (and hence the job) is running in parallel with make,
because the operating system allows them to run at the same time (just
like a server process can run at the same time as the rest of the
system).  Without -j, make will not start the next job until the first
job (process) completes.  So make will wait (sleeping) until that
happens, then when it happens make will start the next job.

With -j, make still reads and parses the makefile serially and runs the
first job (shell command) in another process.  However, in this case
when make finds the second job (shell command) that it could run instead
of waiting for the first to complete it starts the second one right
away.  And so on and so on.

So, internally to make (and that includes reading makefiles, evaluating
variables and functions, etc.) make always runs serially and never does
two different things at once.  But, make might start more than one
program (shell/compiler/whatever) and they might be running at the same
time.

Hopefully this makes sense.




reply via email to

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