Subject: Re: How to built a system from another platform ?
To: Manuel Bouyer <bouyer@antioche.lip6.fr>
From: Richard Earnshaw <rearnsha@buzzard.freeserve.co.uk>
List: port-arm32
Date: 12/14/2000 22:19:45
>> On Wed, Dec 13, 2000 at 04:45:14PM +0100, Richard PLOIX wrote:
>> hello,
>> I have a RISCPC/arm32 and a laptop/i386 NetBSD machines.
>> I recently do an update of the arm32 machine with 1.4.3 version,
>> (SUP, kernel and make build).
>> The sources are on the 8Gb-arm32 machine.
>> I have a ppp link between the two machines.
>> The 1386 disk(250 Mb) is too small to support the sources on itself.
>> Is it possible to generate an i386 kernel and an i386 make build
>> from or via the arm32 machine?
> You could certainly set up a cross compiler on the arm32 machine. It's
> quite easy to build a kernel this way, but doing a 'make build' will
> require more tweaks. Another option is to mount the arm32's disk via
> NFS on the i386 machine, but over ppp it will be quite slow.
Actually building the sources for i386 from the ARM is not too hard (I did
it once when I first obtained the i386 machine that I use for a firewall);
you will need the following packages from the pkgsrc tree (but other than
that, it's largley a matter of "make build"):
cross-binutils-2.9.1.1 -- Unified GNU binutils for cross build environments
cross-i386-netbsdelf-1.3.0.0 -- Cross-compile environment for ELF
NetBSD/i386
I found that I needed to hask sys.mk around a bit, the easiest way was to
change most of the tools it defines as follows:
old: NM?= nm
new: NM?= $(CROSS_TOOL)nm
You could then pick up the cross tools simply by defining CROSS_TOOL to
"i386-netbsdelf-".
[looking back at my code, I see I also had similar settings for these
tools in mk.conf -- I cannot remember now why I had both, and which was
the one that finally made it work]
If you want to build the release tar-balls, things get more complicated.
First, you will need
bfd-crunchide-1.0 -- crunchide using libbfd. Used for cross-building
distributions
bfd-mdsetimage-1.0 -- mdsetimage using libbfd. Used for cross-building
distributions
Then you will have to hack the make files in a few places so that it is
possible to pick up the cross tool variants rather than the standard
binaries (in a few places commands like "strip" and "nm" are hard coded.
Finally you will need to create a bfd-based installboot program; there is
no package to do this, but I've hacked up a version that worked OK for me.
I can let you have a copy if you are interested.
The following is the shell script I used as a front-end to make, so that I
didn't leave something important out...
#! /bin/sh
PATH=/usr/pkg/cross/bin:/usr/sbin:/sbin:$PATH
export PATH
CC=/usr/pkg/cross/bin/i386-netbsdelf-cc
STRIP=/usr/pkg/cross/bin/i386-netbsdelf-strip
MAKECONF=/work/richard/cross/mk/mk.conf
export CC STRIP MAKECONF
# crunchide must create temporaries in '.'.
unset TMPDIR
make MACHINE=i386 MACHINE_ARCH=i386 DESTDIR=/mnt2/home/rearnsha/cross.i386
\
RELEASEDIR=/mnt2/home/rearnsha/release.i386 "$@"
# release UPDATE=1 NOINCLUDES=1 NBUILDJOBS=2