Subject: Kernel cross-compiling howto
To: None <netbsd-docs@netbsd.org, tech-kern@netbsd.org>
From: Florian Stoehr <netbsd@wolfnode.de>
List: netbsd-docs
Date: 12/24/2004 15:57:16
Hi,

since I shot myself in the foot cross-compiling a kernel yesterday and had 
to figure things out (I found no documentation except VERY old mailing 
list entries), I wrote a litte howto. As far as I see, this one worked.

Maybe someone can proof the steps here and add it to the Kernel FAQ on the 
website?

Hehe ... my Xmas-present to NeBSD ;-)

-Florian

Now the howto:



In order to cross-compile the kernel, a toolchain for the
destination architecture is needed first.

We assume NetBSD source is in /usr/src.
We will build a kernel for sgimips on a i386 in this howto,
so replace "sgimips" with your platform of choice.

We store the toolchain in the /usr/TOOLS directory.

First create the toolchain directories:

mkdir /usr/TOOLS

Now build the toolchain:

cd /usr/src
./build.sh -T ../TOOLS -m sgimips tools

A new kernel config file "MYKERNEL" for sgimips was
created in the /usr/src/sys/arch/sgimips/conf directory.

Configure the new kernel:

cd /usr/src/sys/arch/sgimips/conf
/usr/TOOLS/bin/nbconfig MYKERNEL

Now "make depend" the kernel:

cd ../compile
/usr/TOOLS/bin/nbmake-sgimips depend

Finally, let's make the kernel:

/usr/TOOLS/bin/nbmake-sgimips

One thing to remember: If you want to keep toolchains for
several architectures (toolchain-SGIMIPS, toolchain-SPARC, ...),
note that if you RENAME the toolchain directory OR MOVE THE
DIRECTORY, you have to adjust the "bin/nbmake-<platform>"
script.

Make sure you call "nbmake-<platform>", not just "nbmake".