O'Reilly logo

Building Embedded Linux Systems by Karim Yaghmour

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Compiling the Kernel

Compiling the kernel involves a number of steps: building the kernel dependencies, building the kernel image, and building the kernel modules. Each step uses a separate make command and is described separately in this section. However, you could also carry out all these steps using a single command line.

Building Dependencies

Most files in the kernel's sources depend on a number of header files. To build the kernel adequately, the kernel's Makefiles need to know about these dependencies. For each subdirectory in the kernel tree, a hidden .depend file is created during the dependencies build. This contains the list of header files that each file in the directory depends on. As with other software that relies on make, only the files that depend on a header that changed since the last build will need to be recompiled when a kernel is rebuilt.

From the kernel source's root directory, the following command builds the kernel's dependencies:

$ make ARCH=arm CROSS_COMPILE=arm-linux- clean dep

As in the configuration of the kernel earlier, we set the ARCH and CROSS_COMPILE variables. As I explained in Chapter 4, CROSS_COMPILE is only required when source code is actually compiled, and could be omitted here. On the other hand, we will need to set at least the ARCH variable for every make command we issue because we are cross-compiling the kernel. Even when issuing make clean or make distclean, we will need to set this variable. Otherwise, the kernel's Makefiles assume ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required