Note. This answer relates to make
version 3.82 and earlier. For a better answer from version 4.2 see Dima Pasechnik's answer.
You cannot determine which -j option was provided to create. Information about the number of jobs is not available in the usual way from make or its subprocesses in accordance with the following quote:
The top make and all its sub-make processes use the channel to communicate with each other to ensure that no more than N jobs are launched in all make files.
(taken from a file named NEWS in the make 3.82 source tree)
The top make process acts as a job server, passing tokens to sub-make processes through the pipe. It seems your goal is to do your own parallel processing and still respect the specified maximum number of simultaneous jobs specified in make
. To achieve this, you will somehow have to embed yourself in the message through this channel. However, this is an unnamed channel, and as far as I can see, there is no way for your own process to join the server-server mechanism.
By the way, the βpre-processed version of flagsβ that you mentioned contains the expression --jobserver-fds=3,4
, which is used to transfer information about the channel endpoints between make processes. This reveals a bit of what is happening under the hood ...
source share