how to: make -j x // where x is automatically determined
alias, bash, makefile
Solution
`make` does not look up the number of cores by itself if you just use `make -j` -- instead, it parallelizes to the max. However, you should be able to determine the number of cores by
grep -c "^processor" /proc/cpuinfo
or (as per Azor-Ahai's comment, if available on your system)
nproc
Hence:
make -j $(nproc)
See "How How to obtain the number of CPUs/cores in Linux from the command line?" for more details. Also, see GNU make: should the number of jobs equal the number of CPU cores in a system?
Problem
After reading answer to this question: Make "make" default to "make -j 8" I am wondering if there is way to make the -j option automatically use the correct number of compile threads? So I say `make`. And the `make` command itself uses 6 or 4 or 8 threads depending on the hardware?