How to Cross-compile your kernel
This section is for Linux users with moderate to advanced skills.
In this section I will explain how to setup a m68k-linux cross-compiler on a faster x86-linux system.
The new 2.2.x kernels require almost three hours to compile on my stock A4000-40. This is just too long to permit fine-tuning my kernel setups. I love my Amiga, but its in the same class as a low-end 80486. The cross-compiler is able to generate a new m68k 2.2.x kernel in less than fifteen minutes (2.0.36 in under 4 minutes), which leaves time to use my Amiga for fun stuff, instead of simply building kernels.
As Linux users we have the ability to do something windoze users can't even dream of: we can compile programs for a slow Linux machine using a faster Linux machine, for the most part, regardless of which CPU it has. This process is called cross-compiling. The host machine is where we will compile the programs, and the target machine is where we will execute the programs, so the x86 machine is our host, and our m68k Amiga is our target.
Download the Files
I will assume that a x86 machine will be used to cross-compile our m68k-linux programs, although there's no reason a fast Alpha or Sparc couldn't be used. Also I assume you have a fully operational and configured m68k Amiga running Linux. The gcc C/C++ compiler, headers, libraries, in addition to binutils, must be present on your Amiga.
First you need to download the source archives for
binutils and gcc. You may download these from your favorite FTP site such as GNU or Sunsite (1 ). I know that binutils-2.8.1 and gcc-2.7.2.3 work together for our needs (newer versions may, or may not work. binutils-2.9.1.0.19a did NOT work in one test case).On your x86 Linux machine login as user
root. cd to a scratch directory ( /tmp/ works fine ) and extract the binutils and gcc source archives ( tar -xvzf bin*.tgz ; tar -xvzf gcc*.tgz ).Build the m68k binutils
Next cd to the binutils directory created in the previous section and issue the command:
./configure --host=i486-linux --target=m68k-linux --prefix=/usr/local --exec-prefix=/usr/local
This will take a few moments to generate the required makefiles.
Type make to compile the binutils.
If the compile is successful, type make install
Build the m68k gcc compiler
Since we are building a compiler that generates object code that is unknown to the current x86 system, we must copy include files and libraries from our m68k system to the directory structure containing the cross-compiler. You may copy these files by using FTP or NFS. My examples below assume the Amiga is NFS mounted to a local mountpoint called /Amiga. (the Amiga will need the
no_root_squash option in the /etc/exports entry for the x86 machines IP entry ).mount Amiga:/ /Amiga
cd /usr/local/m68k-linux
cp -Rpv /Amiga/usr/include .
cd lib
cp -Rpv /Amiga/usr/lib/*.[ao] .
Note
: the -Rp switches above are very important.Now cd back to the directory where you extracted the gcc archive and issue the same ./configure command you did for the binutils (it should still be in your keyboard buffer if you up-arrow enough times ). This will create the required makefiles.
./configure --host=i486-linux --target=m68k-linux --prefix=/usr/local --exec-prefix=/usr/local
Type make to compile gcc.
If the compile is successful, type make install
Test the cross-compiler
Using another shell, logged in as a normal user, compile a small C program such as the famous hello_world :
/usr/local/m68k-linux/bin/gcc -o hello_world hello_world.c
Or if /usr/local/bin is in your default search path:
m68k-linux-gcc -o hello_world hello_world.c
Copy the resulting executable to a directory on your Amiga (such as /Amiga/tmp , [ /tmp on your Amiga ] ).
From a shell on your Amiga, execute the cross-compiled hello_world program, which should run as expected.
If you are curious, run the Linux file command on your hello-world program.
file hello_world hello_world: ELF 32-bit MSB executable, Motorola 68000, version 1
Now lets just see if microsoft can do that.
Cross-compile a m68k 2.0.36 kernel
In a scratch directory on your x86 machine (such as /tmp), extract the Amiga m68k 2.0.36-pre1 kernel from the tarfile.
cd to the new linux-2.0.36 directory.
Edit line 32 of the Makefile so that it reads:
CROSS_COMPILE = /usr/local/m68k-linux/bin/
Configure the m68k kernel with make menuconfig or make config .
If not already present, create the modules subdirectory:
mkdir include/linux/modules
Build your kernel:
make dep
make clean
make
make modules
This compile session completed in just under four minutes on my K6-2 350, compared to 110 minutes when compiled on the A4000.
Although you can cross-compile the kernel-modules, keep in mind that a make modules_install will write m68k object files into your x86 modules directories- which is something you probably do
NOT want to do.From your Amiga keyboard, cd to the (NFS mounted) directory on your x86 system where the cross-compile was performed. From the Amiga keyboard, run make modules_install , then to run depmod -a on the Amiga side.
Cross-compile a m68k 2.2.x kernel
Building a 2.2.x series kernel is essentially the same 2.0.x, however the top Makefile is now able to autodetect the native architecture. Since we are cross-compiling a m68k kernel on an x86 machine, we need to override the ARCH variable.
Comment-out the existing ARCH := directive at line 6, and add a line below stating ARCH = m68k .
Note
: Jes may have already done the above step for you…As you did for the 2.0.x kernel, specify the path to your m68k cross-compiler.
Build your kernel and modules, then install tem.