Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GNU make nested calls

Tags:

bash

gnu-make

I need to find a way to avoid sub-calls to make to be done in parallel, and avoid getting the warning: make[1]: warning: -jN forced in submake: disabling jobserver mode.

I do have several make calls that run in parallel because the main make call runs with flag -jNwith N>1 I receive the warning listed above and can see the Makefile and make call causing it. However, I've tried to use several options provided in the gnu/make documentation and still cannot get the warning to go.

a)
+make -C $FOO $@

b)
make MAKEFLAGS= -C $FOO $@

c)
make -j1 -C $FOO $@

d)
.NOTPARALLEL:bar

I need the whole compilation to run without warnings (because they are treated as errors). But the warning described above continues to appear.

like image 723
zerofrancisco Avatar asked Jul 04 '26 21:07

zerofrancisco


1 Answers

The warning is coming from the invoked make, because it's getting certain jobserver-related flags via MAKEFLAGS.

To show this, we can reproduce the error message in a simple invocation of make like this:

make --jobserver-fds=3,4 -j1
make: warning: -jN forced in submake: disabling jobserver mode.
... other errors about those being bad file descriptors ...

Overriding MAKEFLAGS in the make command line isn't doing it, because that is being interpreted by the invoked make, after it has already received the MAKEFLAGS from the parent. But we can intercept the parent's environment variable via the external utility env:

yourtarget: yourprereq
        env MAKEFLAGS= make -j1 -C $FOO $@

With env, we have total control over what environment variables are seen by the nested make.

like image 81
Kaz Avatar answered Jul 10 '26 09:07

Kaz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!