Subject: Re: Cross compile from NetBSD/i386?
To: Scott Ellis <scotte@warped.com>
From: Jeremy Cooper <jeremy@broder.com>
List: port-sun3
Date: 01/09/1997 17:51:45
On Thu, 9 Jan 1997, Scott Ellis wrote:

> I'm trying to setup a cross-compile environment on a NetBSD/i386
> box running -current, so that I can build m68k binaries on it,
> but think I'm doing it wrong. ;-)

The INSTALL document that comes with gcc-2.7.2 describes how to set up a
cross-compiler.  I think it is very well worded and has carefully outlined
steps that you should follow.  I never had to edit any of the include
files, and I doubt you will either.

Essentially gcc will create a base directory that will
(eventually) contain:
* BASE/bin - the cross compiler, assembler and linker for remote system
             (You will need the GNU bintools for the assembler and linker)
* BASE/include - an identical copy of /usr/include of the remote system
* BASE/lib - an identical copy of /usr/lib of the remote system

When I compile sun3 programs on my Sparc 2 running NetBSD, I use the m68k
cross compiler that I have installed in
/usr/local/m68k-sun-netbsd/bin/gcc.  I've linked this to
/usr/local/bin/3gcc, so that all I need to type to compile a sun3 binary
of a program is '3gcc main.c', for example.  This '3gcc' has been compiled
by gcc so that every header file and library referenced in the source code
will automatically prepend the BASE directory to the name.

Of course, hand compiling like this is a pain.  You obviously want to use
the Makefiles that come with a program to compile it.  While you can hack
most makefiles to use this new '3gcc', it can be very difficult to do so
if they are BSD style makefiles which define only the names of the source
files (and possible man pages), and use a .include <bsd.prog.mk>
statement to handle the rest of the compiling rules.

I have a solution for this too.  Mail me if you'd like more details.

Good luck.
-J