help-make
[Top][All Lists]
Advanced

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

Re: Does GNU Make allow get number of running jobs?


From: Greg Chicares
Subject: Re: Does GNU Make allow get number of running jobs?
Date: Sat, 29 Jan 2011 02:08:06 +0000
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.13) Gecko/20101207 Thunderbird/3.1.7

On 2011-01-28 22:22Z, Oleksandr Gavenko wrote:
> Cygwin make does not support jobserver.

Yes. See this discussion:
  http://lists.gnu.org/archive/html/make-w32/2010-10/msg00009.html
You may benefit from parallelism without the jobserver.

> Cygwin is our main build platform.
[...]
>    $(TARGETS):
>        [ -z '$(filter %-2,$@)' ] && \
>            make -f Makefile.1 $(patsubst %-1,%,$@) || :
>        [ -z '$(filter %-1,$@)' ] && \
>            make -f Makefile.2 $(patsubst %-2,%,$@) || :
[...]
> But sadly if I call
> 
>    $ make -j 4 dist
> 
> and Make does not support jobserver first and second command
> from 'Makefile' running like '-j 1' not '-j 4' (I get this info by
> putting 'export MAKEFLAGS += --debug=j' into Makefile)!

Try using '$(MAKE)' instead of 'make' in your recipe, e.g.
        $(MAKE) -f Makefile.1 $(patsubst %-1,%,$@) || :
Then the submake runs in parallel. In the following test case,
the 'make' line runs one command at a time, but the '$(MAKE)'
line runs four concurrent 'sleep' processes and is faster.

$make --version
GNU Make 3.81
...
This program built for i686-pc-cygwin

$cat >j.make <<\EOF
this_makefile := $(abspath $(lastword $(MAKEFILE_LIST)))

.PHONY: all
all:
        make    -f $(this_makefile) foo
        $(MAKE) -f $(this_makefile) foo

.PHONY: foo
foo:
        echo $@ $(MAKEFLAGS)

foo: foo1 foo2 foo3 foo4

foo1 foo2 foo3 foo4:
        @sleep 3 && echo $@ $(MAKEFLAGS)
EOF

$make -sf j.make -j4



reply via email to

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