Reputation: 2315
For a project spread over several sub-directories we use GNU make for the builds. Developers can use the -j <number>
flag to parallelize the build tasks, and choose a number that suits the hardware of their machines.
However, the Makefiles of a third-party library that we use are not safe to parallelize - they apparently rely on implicit order of targets instead of explicit dependency rules between all dependent targets.
Since I have no desire to fix third-party Makefiles, we currently invoke their Makefiles with an explicit -j 1
parameter to restrict the number of jobs to 1 for building that library. The rule looks like this:
third_party_lib:
$(MAKE) -j 1 -C $@
This works as desired, however, make emits a warning for this:
make[1]: warning: -jN forced in submake: disabling jobserver mode.
which leads me to ask here if there is a better way to restrict the number of parallel jobs in one sub-make.
Upvotes: 2
Views: 1759
Reputation: 100856
You can add the .NOTPARALLEL:
special target to the makefiles which should not be parallelized.
If you don't want to modify those makefiles you can use the --eval
option on the command line (note --eval
was added in GNU make 3.82):
third_party_lib:
$(MAKE) --eval .NOTPARALLEL: -C $@
Upvotes: 4