help-make
[Top][All Lists]
Advanced

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

Re: Problem using parallel build


From: Johan Borkhuis
Subject: Re: Problem using parallel build
Date: Wed, 17 Nov 2010 20:48:04 +0100
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.4) Gecko/20100608 Thunderbird/3.1

 Paul,

Thank you for your quick reply.

On 17-11-2010 18:34, Paul Smith wrote:
> On Wed, 2010-11-17 at 15:31 +0100, Johan Borkhuis wrote:
>> I am trying to create a project containing 3 directories. These
>> directories generate one archive and two applications. The archive should
>> be built when using make all, make static or when the archive does not
>> exist; the other should be built when using make all or make directory.
>>
>> I use the following makefile:
>>
>> all: static lib test
>>
>> exe: $(TARGET_LIB)
>>      $(MAKE) -C $(TARGET_EXE_DIR)
>>
>> static $(TARGET_STATIC_LIB):
>>      $(MAKE) -C $(TARGET_STATIC_DIR)
>>
>> test: $(TARGET_LIB)
>>      $(MAKE) -C $(TARGET_TEST_DIR)
> Obviously this is not the complete makefile.  What is the value of the
> variable TARGET_LIB?  Without that information we cannot make any
> progress towards helping you because we cannot see the dependency
> relationships.

Sorry about leaving this information out. $(TARGET_LIB) is the path to
the static library, which is identical to $(TARGET_STATIC_LIB). This
library is generated by the Makefile in $(TARGET_STATIC_DIR).
I see that this is a vital part that was missing from the
makefile-snippet above and made it impossible to see what this piece of
Makefile does.

My idea was that, by using the above rules, the makefile in
$(TARGET_STATIC_DIR) would be called when the "static" target is used
(directly or through all) or by using the dependency on $(TARGET_LIB)
(or $(TARGET_STATIC_LIB)). This works when using no jobs.

When using jobs (-j2) the library is build twice. I expect that this is
because of the static target and because of the prerequisite of the
other two rules. When the library is not available when make is started
(for example in a clean build tree) the prerequisite is not true,
causing the library to be built again, in parallel to the static target.

When using the static target as a prerequisite for the other rules
(instead of $(TARGET_LIB)) the system works as I expected for a complete
clean build, however in that case the static rule is also executed when
only building test or exe, which I would like to avoid.

Again, sorry for that vital omission in the first message.

Kind regards,
    Johan Borkhuis




reply via email to

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