There are two things I'd like to note. First, I noticed that cross-compiling seems a major issue for me. Don't know why that is.
Second, I need to remember Warner Losh's post on cross compiling FreeBSD. Essentialy, the procedure is:
$ export TARGET=powerpc $ export TARGET_ARCH=powerpc $ make kernel-toolchain $ make buildkernelAddendum: Unfortunately, this procedure works only on architectures already supported by FreeBSD and its build system. Therefore, it doesn't work for me. So here's the full story on how I got FreeBSD to at least compile.
Building the Toolchain
Building the toolchain is pretty straight forward. I've already written about how to build a cross compiler. On FreeBSD however, four things are different.- The target is powerpc64-unknown-freebsd. I don't know if powerpc64-unknown-elf would have worked, too.
- The target is new, so a patch to the binutils sources is required.
- The GNU MP Bignum Library (GMP) is required. I used version GMP 4.2.1 and installed it in $PREFIX
- Finally, the MPFT Library needs to be built. I used version MPFT 2.3.0 and installed it in $PREFIX
$ export LD_LIBRARY_PATH=$PREFIX/lib
Building the Kernel
The basic procedure of building a kernel is outlined in the FreeBSD Developer's Handbook. Provided that the cross compiler has been installed in $PREFIX, these steps are required:$ export MACHINE=powerpc64 $ export MACHINE_ARCH=powerpc64 $ export CC=${PREFIX}/${TARGET_PREFIX}-gcc $ export NM=${PREFIX}/${TARGET_PREFIX}-nm $ export LD=${PREFIX}/${TARGET_PREFIX}-ld $ export SYSTEM_LD=${LD} $ export OBJCOPY=${PREFIX}/${TARGET_PREFIX}-objcopy $ cd /usr/src/sys/powerpc64/conf $ config KERNCONF $ cd ../compile/KERNCONF $ make cleandepend && make depend $ make kernelOh, of course this doesn't work with the stock FreeBSD sources. Instead, my FreeBSD 64-Bit PowerPC Mercurial repository needs to be used. Note that for convenience reasons, that tree includes a crossenv script which, when sourced, sets up the required environment variables.