我怎么知道提供了什么-j选项 [英] How can I tell what -j option was provided to make
问题描述
在球拍的构建系统中,我们有一个构建步骤,该步骤调用可以运行多个并行任务的程序立刻.由于这是从make
调用的,因此最好遵循最初调用make
的-j
选项.
In Racket's build system, we have a build step that invokes a program that can run several parallel tasks at once. Since this is invoked from make
, it would be nice to respect the -j
option that make
was originally invoked with.
但是,据我所知,无法从Makefile
内部获取-j
选项的值,甚至无法作为make
调用的程序中的环境变量.
However, as far as I can tell, there's no way to get the value of the -j
option from inside the Makefile
, or even as an environment variable in the programs that make
invokes.
是否有一种方法可以获取此值,或者是否有调用make
的命令行,或者具有相关信息的类似方法?只能在GNU make中使用此功能是可以的.
Is there a way to get this value, or the command line that make
was invoked with, or something similar that would have the relevant information? It would be ok to have this only work in GNU make.
推荐答案
在make 4.2.1
中,他们最终弄清了MAKEFLAGS
.也就是说,您可以在Makefile中有一个目标
In make 4.2.1
finally they got MAKEFLAGS
right. That is, you can have in your Makefile a target
opts:
@echo $(MAKEFLAGS)
并将其告诉您正确的-j
参数值.
and making it will tell you the value of -j
parameter right.
$ make -j10 opts
-j10 --jobserver-auth=3,4
(在make 4.1
中它仍然坏了).不用说,除了echo
之外,您还可以调用一个脚本来正确解析MAKEFLAGS
(In make 4.1
it is still broken). Needless to say, instead of echo
you can invoke a script doing proper parsing of MAKEFLAGS
这篇关于我怎么知道提供了什么-j选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!