By default, the kernel build system default kernel is compiled locally, that is, the compiled kernel is running on the same architecture as the host system. If you are compiling the kernel for another schema, that is, cross compilation, we need to set two variables: Arch and Cross_compile. which
Arch indicates the target architecture, that is, what platform the compiled kernel runs on, such as x86, ARM, or MIPS.
cross_compile Specifies the prefix of the cross compiler to use. For our cross tool chain, the prefix is i686-none-linux-gnu-.
In the top-level makefile, we can see that the compiler, linker, and so on in the tool chain are prefixed by $ (cross_compile):
Linux-3.7.4/makefile:
As = $ (cross_compile) as
LD = $ (cross_compile) LD
CC = $ (cross_compile) gcc
CPP = $ (CC)-E
AR = $ (cross_compile) AR
NM = $ (cross_compile) NM
Strip = $ (cross_compile) strip
Objcopy = $ (cross_compile) objcopy
Objdump = $ (cross_compile) objdump
You can define these two variables in a variety of ways, such as by defining Arch, cross_compile in an environment variable, or by assigning values to these two variables by naming behavior each time you execute make, such as:
Make arch=i386 cross_compile=i686-none-linux-gnu-
You can also change the top layer makefile directly. This method is more convenient, but be careful to avoid damaging makefile files. In this book we use the following script in the top-level makefile:
Linux-3.7.4/makefile:
ARCH? = $ (Subarch)
Cross_compile? = $ (config_cross_compile: "%" =%)
Change to:
Linux-3.7.4/makefile:
ARCH? = i386
Cross_compile? = i686-none-linux-gnu-