Kernel Hacking Lesson #2: Configure Your Kernel

The Linux kernel comes with several configuration tools. Each one is
run by typing make <something>config in the top-level kernel source
directory. (All make commands need to be run
from the top-level kernel directory.)

make config

This is the barebones configuration tool. It will ask each and every
configuration question in order. The Linux kernel has a LOT of
configuration questions. Don't use it unless you are a masochist.

make oldconfig

This will take the config file named .config and only ask the
configuration questions which are not already answered in that file.
This is most often used when upgrading to a more recent version of the
kernel.

make menuconfig

This is the kernel hacker mainstay. This command pops up a text-based
menu-style configurator using the ncurses library. You can descend
into the menus that interest you and change only the configuration
options you care about.

make xconfig, make gconfig

If you're running Xwindows, these are prettier, clickable versions of
menuconfig. They tends to work less often than menuconfig since
they are more sensitive to buggy configuration input files than
menuconfig (and because more people use menuconfig). xconfig uses the
qt libraries, and gconfig uses the gtk libraries.

Each of the configuration programs produces these end products:

A file named .config in the top-level directory containing all your
configuration choices.

A file named autoconf.h in the include/linux/ directory
defining (or not defining) the CONFIG_*
symbols so that the C preprocessor knows whether or not they are
turned on.

If you have a working .config file for your machine, just copy it into
your kernel source directory and run make oldconfig. You should
double check the configuration with make menuconfig. If you don't
already have a .config file, you can create one by visiting each
submenu and turning on or off the options you need. menuconfig and
xconfig have a "Help" option that shows you the Configure.help entry
for that option, which may help you decide whether or not it should be
turned on. RedHat and other distributions often include sample .config
files with their distribution specific kernel source in a subdirectory
named configs in the top-level source directory. If you are compiling for
PowerPC, you have a variety of default configs to choose from in
arch/ppc/configs. make defconfig will copy the default ppc config
file to .config. If you know another source of default
configuration files, let us know.

Tips for configuring a kernel:

Always turn on "Prompt for development... drivers".

From kernel 2.6.8, you can add your own string (such as your
initials) at "Local version - append to kernel release" to personalize your
kernel version string (for older kernel versions, you have to edit the
EXTRAVERSION line in the Makefile).