Building with -j
Note: X meaning number of processors
make -jX
Example of a machine with 32 cores
make -j32
Below scripts to automate the build process
numprocs=$(lscpu | grep -i 'CPU(s):' | head -n 1 | awk '{print $2}')
cat < makefile
MAKE=make -j `expr ${numprocs} + ${numprocs}`
include Makefile
CFLAGS:=\$(CFLAGS) -pipe
CXXFLAGS:=\$(CXXFLAGS) -pipe
Alternative script
numprocs=$(/usr/bin/getconf _NPROCESSORS_ONLN)
cat < makefile
MAKE=make -j `expr ${numprocs} + ${numprocs}`
include Makefile
CFLAGS:=\$(CFLAGS) -pipe
CXXFLAGS:=\$(CXXFLAGS) -pipe