This chapter describes the programs you need
to configure a kernel, build it, and successfully
boot it. It's a smart idea to consult the file
Documentation/Changes to verify the specific
version number you should have of each
tool described in this chapter. This chapter was based on the 2.6.18
kernel, and describes the versions of tools that work with that
kernel.
If you are using a different kernel, please verify that you
have the required versions as specified in this file, or things
might not work properly and it can be very hard to determine what went
wrong.
Tools to build the kernel
Most Linux distributions offer an installation option to install a
range of Kernel Hacking packages. If your distribution
offers this option, it is easiest to install this instead of
trying to track down all of the individual programs that are needed for
this task.
Only three packages that are needed in order to
successfully build a kernel: a compiler, a linker, and a make
utility. This section describes the contents of each package.
The Linux kernel is written in the C programming language, with a small
amount of assembly language in some places. To build the kernel, the GCC C compiler must be
used. Most Linux distributions have a package entitiled
gcc that should be installed. If you wish to download
the compiler and build it yourself, you can find it at
https://gcc.gnu.org.
As of the 2.6.18 kernel release, the 3.2 version of GCC is the oldest that can
properly build a working kernel. Be warned that getting
the most recent GCC version is not always a good idea. Some of the newest GCC
releases don't build the kernel properly, so unless you wish to
help debug compiler bugs, it is not recommended that you try them out.
To determine which version of gcc you have on your system, run the following command:
$
gcc --version
The C compiler, gcc, does not do all of the compiling on
its own. It needs an additional set of tools known as
binutils to do the linking and assembling of source
files. The binutils package also contains useful
utilities that can manipulate object files in lots of useful ways,
such as to view the contents of a library.
binutils can usually be found in a distribution package
called (not surprisingly) binutils. If you wish to download
and install the package yourself, you can find it at
https://www.gnu.org/software/binutils.
As of the 2.6.18 kernel release, the 2.12 release of
binutils is the oldest that can
successfully link the kernel.
To determine which version of binutils you have on your system, run the following command:
$
ld -v
make is a tool that walks the kernel source tree to
determine which files need to be compiled, and then calls the compiler and
other build tools to do the work in building the kernel. The kernel
requires the GNU version of make, which can usually be found in a package
called make for your distribution.
If you wish to download and install make youself,
you can find it at
https://www.gnu.org/software/make.
As of the 2.6.18 kernel release, the 3.79.1 release of make is the oldest that can
properly build the kernel. It is recommended that you install
the latest stable version of make, because newer versions are known
to work faster at processing the build files.
To determine which version of make you have on your system, run the following command:
$
make --version