help-make
[Top][All Lists]
Advanced

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

Re: Problem using parallel build


From: Paul Smith
Subject: Re: Problem using parallel build
Date: Wed, 17 Nov 2010 12:34:28 -0500

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.

> This works for a non-parallel build. When using -j2 and
> $(TARGET_STATIC_LIB) does not exist the static / $(TARGET_STATIC_LIB) rule
> is executed twice.

You are incorrect on how make interprets this rule:

        static $(TARGET_STATIC_LIB):
                $(MAKE) -C $(TARGET_STATIC_DIR)

You are thinking (I believe) that this means that one invocation of the
rule will build both targets.  That's not what it means.  It means that
both targets (completely separately) can be built using that same rule.
In other words the above is exactly identical (as far as make is
concerned) to writing this:

        static:
                $(MAKE) -C $(TARGET_STATIC_DIR)
        $(TARGET_STATIC_LIB):
                $(MAKE) -C $(TARGET_STATIC_DIR)

Depending on the value of TARGET_LIB this may help you understand what
make is doing.




reply via email to

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