::documentation::cross compilation under mac os x  

Cross Compilation Under Mac OS X

This page describes a method for cross-compiling Linux/mac68k (2.2) and Linux/m68k (2.6 and later) kernels. Versions 2.3, 2.4 and 2.5 are best avoided on Macs.

The method requires Mac OS X 10.3 or later on PowerPC (or on Intel with the Rosetta PowerPC emulator). Also required is the Mac OS X SDK installed from your XCode CD or Mac OS X DVD.

First, obtain the necessary files

These instructions assume that certain files can be found in your Desktop folder. So you'll want to vist the file release page and download the cross compilers tarball, m68k-xcompilers-for-os-x. Also download the Linux/mac68k kernel build patch, linux-2.2.25-darwin-build.diff (unless you are going to compile the Linux/m68k kernel, which instead requires linux-2.6.x-darwin-build.diff).

Install the cross-compilers in /opt

cd ~/Desktop
sudo tar -C / -xjf m68k-xcompilers-for-os-x-0.9a.tar.bz2

Create and mount a disk image

A case sensitive volume is required for building the kernel.

hdiutil create -size 800M -fs HFSX -volname kernel -partitionType Apple_HFS -attach kernel

At this point, the instructions diverge depending on whether you are building Linux/mac68k or Linux/m68k. Keep reading for mac68k, or click here for m68k.

Instructions for Linux/mac68k (Linux 2.2 branch)

Install gawk

Running make menuconfig or oldconfig etc requires GNU awk and will not work with the BSD awk.

curl -O
tar -C /tmp -xjf gawk-3.1.4.tar.bz2
cd /tmp/gawk-3.1.4
./configure --prefix=/opt/gnu
make && sudo make install

Download sources

Grab the kernel sources as per the usual procedure (no password).

cd /Volumes/kernel
cvs login
cvs -z3 co -P -r linux-2_2 linux-mac68k

Patch sources

This patch permits the kernel to build under Darwin, and also creates a kernel configuration suitable for Macs (essentially the Debian one, updated).

cd linux-mac68k
patch -p1 < ~/Desktop/linux-2.2.25-darwin-build.diff

Set PATH variable

For the Linux 2.2 kernels we use gcc 2.95.4 (actually 2.95.3 with Debian's patches).

export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/opt/btc-0.9/gcc-2.95.3-binutils-

The file drivers/char/defkeymap.c was removed from the mac68k CVS and so we have a hacked-up loadkeys just for generating this (though we could instead use the defkeymap.c from the source).

Place gawk, and loadkeys in the PATH ( is from the busybox package, and loadkeys comes from kbd).

export PATH=/opt/gnu/bin:$PATH:/opt/btc-0.9/bin


Next, create the config file.

cp config-debian-like-2.2 .config

Lastly, compile the kernel, either the easy way (which conveniently creates a modules tarball),


or the traditional way.

make oldconfig
make dep && make vmlinux && make modules

Instructions for Linux/m68k ( sources)

Install gettext

As of linux-2.6.12, the kbuild system depends on gettext.

curl -O
tar -C /tmp -xzf gettext-0.14.5.tar.gz
cd /tmp/gettext-0.14.5
./configure --prefix=/opt/gnu
make && sudo make install

Set some variables that help locate gettext.

export HOSTLDFLAGS="-L/opt/gnu/lib -lintl"
export HOST_EXTRACFLAGS="-I /opt/gnu/include"

Download sources

Grab the kernel sources from

cd /Volumes/kernel
tar -xjf ~/Desktop/linux-2.6.22.tar.bz2

Patch sources

This patch permits the kernel to build under Darwin.

cd linux
patch -p1 < ~/Desktop/linux-2.6.18-darwin-build.diff

Set PATH variable

Choose a gcc cross compiler. For compiling kernel version 2.6.15 and later, gcc version 3.2 or later is required. However, FSF gcc 3.3 and 3.4 were installed in an earlier step.

export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/opt/btc-0.9/gcc-3.4.4-binutils-

Put the patched in the PATH and it will create modules.dep.

export PATH=$PATH:/opt/btc-0.9/bin


First configure the kernel,

cp arch/m68k/configs/mac_defconfig .config
make oldconfig

and then build it (add -j3 for building on a dual processor Mac).


Finally, install the modules into /tmp/lib/modules for easy tar'ing.

make INSTALL_MOD_PATH=/tmp modules_install
Valid HTML 4.01 Transitional Valid CSS! Copyright © 2000-2014 Linux/m68k for Macintosh Project.