help-make
[Top][All Lists]
Advanced

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

Does GNU Make allow get number of running jobs?


From: Oleksandr Gavenko
Subject: Does GNU Make allow get number of running jobs?
Date: Sat, 29 Jan 2011 00:22:49 +0200
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.2.12) Gecko/20101027 Thunderbird/3.1.6

Cygwin make does not support jobserver.
Cygwin is our main build platform.

In some project we have 2 build with almost same sources.
So decide move common logic to 'Malefile.common',
different logic to 'Makefile.1' and 'Makefile.2' and write
'Makefile' for easy run build because 'Makefile' save us from
typing '-f Makefile.1' or '-f Makefile.2' and more.

'Makefile' used standard pattern for this case
(but a little extended):

  TARGETS := $(MAKECMDGOALS)
  ifeq '' '$(TARGETS)'
    TARGETS := all
  endif

  $(TARGETS):
      [ -z '$(filter %-2,$@)' ] && \
          make -f Makefile.1 $(patsubst %-1,%,$@) || :
      [ -z '$(filter %-1,$@)' ] && \
          make -f Makefile.2 $(patsubst %-2,%,$@) || :

How work first command: if target name is 'dist-2' then
we don't call Makefile.1, because of '-2' suffix,
if target name is 'dist-1' or 'dist' we call
'Makefile.1' with 'dist' target.

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)!

I try check if there are any variable store '-j 4' info from output of

  $ make -p  -j 111 dist

but there no entry of '-j' or '111' was found.

If I can get number after -j option I can rewrite commands to
support parallel build:

  ...
  make -j $(JOBS)  -f Makefile.1 $(patsubst %-1,%,$@) || :
  ...

Does GNU Make allow get number of running jobs?

--
Best regards!




reply via email to

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