Gentoo is not an ordinary Linux distro, Gentoo Linux is a meta-distribution. Everything is compiled from source in Gentoo, allowing for almost unlimited customization and optimization. The very heart of this is /etc/make.conf.
This is a quick guide to help Gentoo newcomers to get off on the right foot.
Below is an example for amd64, we will have a brief look at every entry. Adjust it for i686 using common sense.
------
This is your architecture, comes preset with stage3 tarball. If CHOST in your tarball is not what you want you've downloaded incorrect stage3 tarball.Code:CHOST="x86_64-pc-linux-gnu"
Changing CHOST after Gentoo is installed is possible in some cases, but this is not something you want to do.
------
For 64-bit Intel architecture
For 32-bit Intel architectureCode:CFLAGS="-march=native -O2 -pipe"
CXXFLAGS="${CFLAGS}"
Make sure your -march is set to native. This allows GCC to take advantage of your CPU features.Code:CFLAGS="-march=native -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"
NB! Do not use -march=native with distcc!
BTW, GCC versions older than 4.2 do not support -march=native, not a problem with Gentoo.
Do not set LDFLAGS unless you know what you are doing. If you do include ${LDFLAGS}, otherwise you will override defaults instead of adding to them.
------
General consensus is you should set it to the number of your CPU's plus one for maximum compilation performance. Note, you also need more RAM if you increase the number of make instances. With four CPU's and -j5 you'll need at least 2 GB.Code:MAKEOPTS="-j3"
You can decrease it to leave more resources for user tasks.
------
There are default features already set for you, adding ccache will speed up compilation.Code:FEATURES="ccache"
------
Set it to whatever suits you.Code:LINGUAS="en_US en"
------
There are some variables which need to be set, otherwise you will get too many drivers, or, in some cases, none. See below.
------
That's all most people need nowadays.Code:INPUT_DEVICES="evdev"
------
Set it according to your hardware, only the driver(s) you set will be installed. If this variable is unset all possible video drivers will be pulled in, that's not what we want, it's Gentoo, remember?Code:VIDEO_CARDS="nvidia vesa"
------
Setting it to "~amd64" will switch you to testing version of packages (including system packages), use at your own risk.Code:ACCEPT_KEYWORDS="amd64"
------
USE flags give you the flexibility, although they do not have the power Gentoo newcomers often expect.Code:USE="foo0 foo1 foo2"
Default USE flags are set by your chosen profile, use eselect profile list to see all profiles available to you, eselect profile set n to set your choice (n is the number of profile).
A good default set for a given package is also often set in the ebuild. Flags from mplayer ebuild as an example, flags with + are enabled by default:
As a result of all this there is no dire need to set your own USE flags at all. Furthermore, you can change your mind any time and edit your USE flags, just follow up with emerge -avN world to apply the changes.Code:"3dnow 3dnowext +a52 aalib +alsa altivec +ass bidi bindist bl bs2b
+cddb +cdio cdparanoia cpudetection custom-cpuopts debug dga +dirac directfb
doc +dts +dv dvb +dvd +dvdnav dxr3 +enca +encode esd +faac +faad fbcon ftp
gif ggi -gmplayer +iconv ipv6 jack joystick jpeg jpeg2k kernel_linux ladspa
libcaca lirc +live lzo mad md5sum +mmx mmxext mng +mp3 nas +network nut
openal amr +opengl +osdmenu oss png pnm pulseaudio pvr +quicktime radio
+rar +real +rtc samba +shm +schroedinger sdl +speex sse sse2 ssse3 svga tga
+theora +tremor +truetype +toolame +twolame +unicode v4l v4l2 vdpau vidix
+vorbis win32codecs +X +x264 xanim xinerama +xscreensaver +xv +xvid xvmc
zoran"
Anyhow, if the feature you need is not enabled by default or you feel there are some features enabled you do not need go ahead and start setting them in make.conf.
USE flags have three states:
1. When enabled by user they enable given feature for all packages that support it. (USE="foo")
2. When disabled by user it will be disabled for all packages which have this feature as optional. (USE="-foo")
3. When not set by user defaults from profile and ebuild for given package are used.
Also, you should understand if a feature is not optional it will be enabled regardless what USE flags are set.
For instance, if an application relies on GTK toolkit it will be pulled in even if user sets USE="-gtk".
------
Notes
1. When using distcc (FEATURES="distcc" is set) you cannot use -march=native. Use correct -m options for your CPU in both master and helper boxes. To determine correct options do
In my box it will repond withCode:gcc -### -march=native -E /usr/include/stdlib.h 2>&1 | grep "/usr/libexec/gcc/.*cc1"
so my -m options would be "-march=core2 -mcx16 -msahf".Code:"/usr/libexec/gcc/x86_64-pc-linux-gnu/4.4.4/cc1" "-E" "-quiet"
"/usr/include/stdlib.h" "-D_FORTIFY_SOURCE=2" "-march=core2" "-mcx16"
"-msahf" "--param" "l1-cache-size=32" "--param" "l1-cache-line-size=64"
"--param" "l2-cache-size=4096" "-mtune=core2"
2. Every time you emerge something I suggest using emerge -av. This gives you the opportunity to verify correct features and options are set before you install.
For instance, if you see something like this:
you will certainly want to enable at least one of them by adding CAMERAS="mychoice" to the make.conf.Code:$ emerge -pv libgphoto2
These are the packages that would be merged, in order:
Calculating dependencies... done!
[ebuild N ] media-libs/libgphoto2-2.4.9 USE="exif -bonjour -doc -examples
-hal -nls" CAMERAS="-adc65 -agfa_cl20 -aox -ax203 -barbie -canon -casio_qv
-clicksmart310 -digigr8 -digita -dimagev -dimera3500 -directory -enigma13 -fuji
-gsmart300 -hp215 -iclick -jamcam -jd11 -jl2005a -kodak_dc120 -kodak_dc210
-kodak_dc240 -kodak_dc3200 -kodak_ez200 -konica -konica_qm150 -largan
-lg_gsm -mars -mustek -panasonic_coolshot -panasonic_dc1000
-panasonic_dc1580 -panasonic_l859 -pccam300 -pccam600 -polaroid_pdc320
-polaroid_pdc640 -polaroid_pdc700 -ptp2 -ricoh -ricoh_g3 -samsung -sierra
-sipix_blink -sipix_blink2 -sipix_web2 -smal -sonix -sony_dscf1 -sony_dscf55
-soundvision -spca50x -sq905 -st2205 -stv0674 -stv0680 -sx330z -template
-topfield -toshiba_pdrm11" 5,511 kB
Total: 1 package (1 new), Size of downloads: 5,511 kB
3. I'd recommend emerging a USE flag editor, I'm using ufed myself.
4. See /usr/share/portage/config/make.conf.example for more.
5. In cases when system-wide enabling of a given USE flag is not desirable it can be set in /etc/portage/package.use per package. For instance, you have -gtk in your make.conf because you use KDE desktop and you want to avoid building GTK support into packages which support it. But there is an application which does not support QT so you have to choose whether to build it CLI only or with GUI by enabling gtk USE flag for it.
6. You can see your settings in effect by looking at emerge --info output.
Happy compiling! ;)

