Section 2.1. Tools to Build the Kernel


2.1. 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.

2.1.1. Compiler

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 http://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 

2.1.2. Linker

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 http://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 

2.1.3. make

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 http://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 



Linux Kernel in a Nutshell
Linux Kernel in a Nutshell (In a Nutshell (OReilly))
ISBN: 0596100795
EAN: 2147483647
Year: 2004
Pages: 113

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net