help-make
[Top][All Lists]
Advanced

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

Re: Does (normal) prerequisite order matter?


From: Brendan Heading
Subject: Re: Does (normal) prerequisite order matter?
Date: Sat, 19 Nov 2005 10:51:55 +0000
User-agent: Mozilla Thunderbird 1.0.6 (Windows/20050716)

Matt England wrote:

...will the rule (if any) for prereq1 complete (and not just start) before the rule for prereq2 starts? This is an important behavior for my Makefiles, and thus far it seems to be behaving this way (but I have more testing to do); I'm using GNU make 3.80 (on cygwin, mingw, and Redhat systems).

The behaviour you have described will continue to work with gmake on any platform as far as I know - provided you do not use parallel make (-jx). But what you are suggesting is that there is a dependency you are not telling make about - a dependency between the prereqs.

When I am writing makefiles I always ensure that there are no dependencies between the prereqs; if there are then I explicitly define them in the makefile. It's like a programmer ensuring their C code is re-entrant - not only is it good practice but it allows you to easily use multiprocessor machines effectively.

I'd strongly recommend you consider reworking your makefiles such that the dependencies are explicitly defined.

I don't yet see this explained clearly in any of the any of the manual (at http://www.gnu.org/software/make/manual/html_chapter/make_toc.html ), and I have read most of the manual, including the parts on rule-writing.

The manual definitely says that the prereqs are always processed left-to-right for non-parallel builds.

As an aside, I tried understanding order-only prerequisites, but they don't seem to address what I seek above:
http://www.gnu.org/software/make/manual/html_chapter/make_4.html#SEC29
http://kolpackov.net/pipermail/notes/2004-January/000001.html

I'd suggest avoiding using any of make's more advanced syntax, and instead look into your prerequisites and understand why they are interdependent. Then you can do something like

target: prereq1 prereq2

prereq2:prereq1
        <do prereq2>
prereq1:
        <do prereq1>

With the above syntax, we are explicitly telling make to order the prereq processing in a certain way even if there are parallel builds.





reply via email to

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