Always when i want to compile using make command in linux I run it with -j9 to set number of threads to be used. Is there any way to set it permanently in the environment path or .bashrc file or any other way?
Asked
Active
Viewed 2,040 times
2
-
1`alias make='make -j9'` – Jonathan Wakely Dec 12 '16 at 10:27
-
@JonathanWakely: Using an alias is not a good idea IMHO, considering the availability of `MAKEFLAGS`/`GNUMAKEFLAGS`. – einpoklum Jun 23 '20 at 14:06
-
Does this answer your question? [Make "make" default to "make -j 8"](https://stackoverflow.com/questions/2151605/make-make-default-to-make-j-8) – user202729 May 19 '23 at 03:15
1 Answers
8
You can set GNUMAKEFLAGS
environment variable with extra flags to pass to GNU make
, e.g.:
export GNUMAKEFLAGS=-j9
in your shell start-up scripts.
GNUMAKEFLAGS
Other flags parsed by make. You can set this in the environment or a makefile to set make command-line flags. GNU make never sets this variable itself. This variable is only needed if you’d like to set GNU make-specific flags in a POSIX-compliant makefile. This variable will be seen by GNU make and ignored by other make implementations. It’s not needed if you only use GNU make; just use MAKEFLAGS directly.

Maxim Egorushkin
- 131,725
- 17
- 180
- 271
-
3Just a note, `GNUMAKEFLAGS` is only available in GNU make 4.0 and above. `MAKEFLAGS` is always available but note the caveat in the documentation above. – MadScientist Dec 12 '16 at 14:01