2

I would like to have make option "-j2" as the default.
Can I modify Makefile for that?

Jonathan Leffler
  • 698,132
  • 130
  • 858
  • 1,229
Łukasz Lew
  • 45,986
  • 40
  • 137
  • 203

2 Answers2

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,208
  • 1
  • 26
  • 29
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
  • 698,132
  • 130
  • 858
  • 1,229