Gentoo reads /etc/portage/make.conf before package calculations, so a global setting in that file can change many future builds. Editing the file with a backup and a Portage parser check keeps system-wide defaults controlled before emerge uses them.
make.conf stores shell-like KEY=“value” assignments for Portage. User settings normally belong in /etc/portage/make.conf, which overrides the older /etc/make.conf path, while the selected profile still supplies baseline defaults below it.
Use make.conf for defaults that should apply broadly, such as MAKEOPTS, GENTOO_MIRRORS, FEATURES, and compiler flags already placed there by the stage. Package-specific USE flags belong under /etc/portage/package.use instead, and CHOST should not be changed casually because it describes the system's toolchain target.
Related: How to set Gentoo USE flags
Related: How to build Gentoo binary packages
Related: How to update a Gentoo world set
Steps to edit Gentoo make.conf:
- Check whether make.conf is a file or a directory.
$ ls -ld /etc/portage/make.conf -rw-r--r-- 1 root root 543 Jun 8 02:57 /etc/portage/make.conf
If /etc/portage/make.conf is a directory, edit a file inside that directory instead. Portage reads the files there in lexical filename order as one combined make.conf.
- Review the current Portage make configuration.
$ cat /etc/portage/make.conf # These settings were set by the catalyst build script that automatically # built this stage. # Please consult /usr/share/portage/config/make.conf.example for a more # detailed example. COMMON_FLAGS="-O2 -pipe" CFLAGS="${COMMON_FLAGS}" CXXFLAGS="${COMMON_FLAGS}" FCFLAGS="${COMMON_FLAGS}" FFLAGS="${COMMON_FLAGS}" # WARNING: Changing your CHOST is not something that should be done lightly. # Please consult https://wiki.gentoo.org/wiki/Changing_the_CHOST_variable before changing. CHOST="aarch64-unknown-linux-gnu" ##### snipped ##### - Back up the current make.conf path.
$ sudo cp -a /etc/portage/make.conf /etc/portage/make.conf.before-edit
- Open make.conf in a root-owned editor.
$ sudoedit /etc/portage/make.conf
- Add or update the global Portage setting.
- /etc/portage/make.conf
MAKEOPTS="-j4 -l4"
MAKEOPTS controls parallel make jobs and load limits for packages that use make. Current Portage can choose defaults when it is unset, so set an explicit value only when the system needs a lower or different build limit.
- Confirm that Portage parses the saved value.
$ portageq envvar MAKEOPTS -j4 -l4
Use the variable name changed in make.conf when checking a different setting, such as portageq envvar FEATURES or portageq envvar GENTOO_MIRRORS.
- Preview the next package calculation before accepting a build that uses the edited configuration.
$ sudo emerge --pretend --verbose --update --deep --newuse @world
If emerge reports blockers, unexpected rebuilds, or invalid configuration output after the edit, restore the backup or correct make.conf before merging packages.
Mohd Shakir Zakaria is a cloud architect with deep roots in software development and open-source advocacy. Certified in AWS, Red Hat, VMware, ITIL, and Linux, he specializes in designing and managing robust cloud and on-premises infrastructures.