哪些操作系统支持将 -j 选项传递给子品牌?

Which operating systems support passing -j options to sub-makes?

来自 gnu make 的手册页:

The ‘-j’ option is a special case (see Parallel Execution). If you set it to some numeric value ‘N’ and your operating system supports it (most any UNIX system will; others typically won’t), the parent make and all the sub-makes will communicate to ensure that there are only ‘N’ jobs running at the same time between them all. Note that any job that is marked recursive (see Instead of Executing Recipes) doesn’t count against the total jobs (otherwise we could get ‘N’ sub-makes running and have no slots left over for any real work!)

If your operating system doesn’t support the above communication, then ‘-j 1’ is always put into MAKEFLAGS instead of the value you specified. This is because if the ‘-j’ option were passed down to sub-makes, you would get many more jobs running in parallel than you asked for. If you give ‘-j’ with no numeric argument, meaning to run as many jobs as possible in parallel, this is passed down, since multiple infinities are no more than one.

哪些常见操作系统支持或不支持此行为? 你怎么知道你的 os 是否支持它?

要判断您的 make 是否支持此功能,运行 来自 shell 提示符的此命令:

echo 'all:;@echo $(filter jobserver,$(.FEATURES))' | make -f-

如果它打印'jobserver',那么你有支持。如果它什么都不打印,则说明您没有得到支持。或者,如果您的 OS 不支持 echo 或管道,请创建一个包含以下内容的小 makefile:

all:;@echo $(filter jobserver,$(.FEATURES))

然后 运行 make 使用该 makefile。