First install the relevant kernel sources. You can use a package from the
Gentoo portage tree or fetch your own from
You should install the kernel into the sysroot so that if you want to
cross-compile packages which include kernel modules, the process will be
transparent. Otherwise, the actual place where you build the kernel does
not matter. Some people build all their kernels in
There are two fundamental variables that the kernel uses to select the target
architecture. Normally these values are guessed based on your build
environment, but of course that environment here does not match our target
embedded system, so we'll need to override them. The variables in question
are
The
Hopefully the
There is an additional variable,
There are really two ways you can setup the system. You can modify the toplevel Makefile or you can override the relevant variables on the command line. How you do it is largely a matter of taste, so we'll cover both. Pick one of the following.
# This is what the vanilla Makefile looks like ARCH ?= $(SUBARCH) CROSS_COMPILE ?=# Set the ARCH and CROSS_COMPILE default values ARCH ?= arm CROSS_COMPILE ?= arm-unknown-linux-gnu-
# make ARCH=arm CROSS_COMPILE=arm-unknown-linux-gnu- ....
You can use a little helper script if you need to hop between different kernel
trees at the sametime. We'll call this script
#!/bin/sh
exec make ARCH="arm" CROSS_COMPILE="arm-unknown-linux-gnu-" INSTALL_MOD_PATH="${SYSROOT}" "$@"
So now when you want to build a kernel or do anything else, you just execute
At this point, configuring and compiling the kernel is like any other kernel, so we won't go into depth as there are plenty of HOWTOs and guides out there which can treat the subject in much greater detail.
# cd "${SYSROOT}/usr/src/linux"
# xkmake menuconfig
# xkmake