Makefile-将作业参数传递给子Makefile [英] Makefile - Pass jobs param to sub makefiles

查看:596
本文介绍了Makefile-将作业参数传递给子Makefile的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个makefile,可以调用多个其他makefile.

I have a makefile which calls multiple other makefiles.

我想将-j参数传递给其他makefile调用.

I'd like to pass the -j param along to the other makefile calls.

类似(make -j8)的东西

Something like (make -j8):

 all:
     make -f libpng_linux.mk -j$(J)

其中$(J)是-j8中的值8.我绝对发誓我之前已经做过,但是我找不到我的例子.

Where $(J) is the value 8 from -j8. I absolutely swear I've done this before but I cannot locate my example.

$(MAKEFLAGS)似乎包含--jobserver-fds = 3,4 -j而不管是-j2还是-j8

$(MAKEFLAGS) seems to contain --jobserver-fds=3,4 -j regardless of what -j2 or -j8

可能的解决方案:

很快就会将其发布为答案.

Will post this as an answer soon.

一种似乎不用担心的解决方案.调用主makefile时包含-j8.进行的子调用应如下所示:

It appears one solution to not worry about it. Include -j8 when you call the main makefile. The sub calls to make should look like this:

 all:
      +make -f libpng_linux.mk -j$(J)

请注意make前面的"+"号.在尝试并行构建时,我注意到make抛出警告:make [1]:警告:jobserver不可用:使用-j1.在父级制作规则中添加"+".

Notice the "+" in front of make. I noticed make tossing a warning when I tried parallel builds: make[1]: warning: jobserver unavailable: using -j1. Add `+' to parent make rule.

推荐答案

Only certain flags go into $(MAKEFLAGS). -j isn't included because the sub-makes communicate with each other to ensure the appropriate number of jobs are occuring

此外,您应该使用$(MAKE)而不是make,因为$(MAKE)将始终评估为正确的可执行文件名称(可能不是make).

Also, you should use $(MAKE) instead of make, since $(MAKE) will always evaluate to the correct executable name (which might not be make).

这篇关于Makefile-将作业参数传递给子Makefile的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆