Gentoo : Autoconfigure number of CPU in make.conf


Ever wanted a script that just adapts make.conf to number of cpu cores.
Well, here’s my script, surely improvable but maybe useful.

It will count the number of cpu nodes.
Then make.conf gets backuped and edited accordingly.

We have 8 cpu cores, so anything like:

  • MAKEOPTS=”-j2
  • MAKEOPTS=”-j2 -l1
  • MAKEOPTS=”${MAKEOPTS} -j5 -l3.85
  • EMERGE_DEFAULT_OPTS=”${EMERGE_DEFAULT_OPTS} -j4 –load-average=3.75

becomes this:

  • MAKEOPTS=”-j9
  • MAKEOPTS=”-j9 -l7.95
  • MAKEOPTS=”${MAKEOPTS} -j9 -l7.95
  • EMERGE_DEFAULT_OPTS=”${EMERGE_DEFAULT_OPTS} -j8 –load-average=7.85
 #!/bin/bash die() { echo "$1" 1>&2 exit 1 } # check if running as root check_sudo() { if [[ $EUID -ne 0 ]]; then echo "This script must be run as root" 1>&2 exit 1 fi } # outputs number of CPU coress (with hyperthreading) count_cpu() { grep -c processor /proc/cpuinfo || die "Error getting number of cpu" } # get location of make.conf…

View original post 125 more words


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s