Search code examples
linuxmultithreadingmakefile

Set number of threads used by make permanently


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?


Solution

  • 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.