MacPenguin
  ::documentation::cross compilation under mac os x  

Cross Compilation Under Mac OS X on PowerPC

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.

These tools require Mac OS X 10.3 or later running on a Power Mac. An Intel Mac with the Rosetta PowerPC emulator is not recommended (but YMMV). 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 FTP site 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 http://ftp.gnu.org/gnu/gawk/gawk-3.1.4.tar.bz2
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 -d:pserver:anonymous@linux-mac68k.cvs.sourceforge.net:/cvsroot/linux-mac68k login
cvs -z3 -d:pserver:anonymous@linux-mac68k.cvs.sourceforge.net:/cvsroot/linux-mac68k 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-2.12.90.0.1-glibc-2.2.5/bin

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 kernel.org source).

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

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

Compile

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),

./make_kernel_and_modules

or the traditional way.

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

Instructions for Linux/m68k (kernel.org sources)

Install gettext

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

curl -O http://ftp.gnu.org/gnu/gettext/gettext-0.14.5.tar.gz
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 kernel.org.

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-2.15.94.0.2.2-glibc-2.3.5/bin/

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

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

Compile

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).

make

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! sourceforge.net Copyright © 2000-2020 Linux/m68k for Macintosh Project.