Anonymous User
  Thursday, 24 January 2019
  0 Replies
  1.6K Visits
1
Votes
Undo
  Subscribe
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
Rate this post:
There are no replies made for this post yet.