I would like to have make option "-j2" as the default.
Can I modify Makefile for that?
Asked
Active
Viewed 661 times
2

Jonathan Leffler
- 730,956
- 141
- 904
- 1,278

Łukasz Lew
- 48,526
- 41
- 139
- 208
2 Answers
1
As mentioned previously one can set the environment variable MAKEFLAGS
. But this apparently works even inside a makefile (at least with GNU make). If you add a line
MAKEFLAGS=-j 2
at the top of the makefile this should give you the desired results. I have not tested this thoroughly and maybe it does only work with recursive invocations, but that could be easily worked around with a wrapper target.
I have used this to prevent make from printing the "Entering directory"/"Leaving directory" messages in recursive executions by setting MAKEFLAGS=-s
.

stefanct
- 2,503
- 1
- 28
- 32
1
Looking at the GNU Make manual (3.82), there is nothing I can see that allows that.
You might be able to set environment variable MAKEFLAGS (to either '-j 2
' or perhaps 'j 2
'), but otherwise, it appears you cannot.

Jonathan Leffler
- 730,956
- 141
- 904
- 1,278
-
I agree, see also here: http://stackoverflow.com/questions/2151605/make-make-default-to-make-j-8 – Jan Rüegg Feb 23 '12 at 12:42