Subject: Re: cross compiling -cuurent on 1.4/alpha
To: None <Havard.Eidnes@runit.sintef.no>
From: Bill Studenmund <wrstuden@nas.nasa.gov>
List: current-users
Date: 12/26/1999 15:23:55
On Fri, 24 Dec 1999 Havard.Eidnes@runit.sintef.no wrote:

> > Now: how does your cross-compiler find its headers? If it takes
> > _anything_ from /usr/include then it's going to have problems. We
> > should be compiling with "-nostdinc -I$(BSDSRCDIR)/xinclude" and
> > have 'make includes' install into $(BSDSRCDIR)/xinclude.
> > $(DESTDIR)/usr/include should get updated at 'make install' time,
> > not 'make includes' time.
> 
> I don't think it should be $(BSDSRCDIR); rather, I think it should
> be $(DESTDIR)/include, or a variant thereof (?).  I think that would
> ease compilation of binaries for multiple separate machine
> architectures from the same source tree, and would allow you to do
> that without modifying the source tree.  But the really hard part is
> of course to get the cross compile environment (compiler and tools)
> working properly.

How about ${DESTDIR}/usr/include ? ;-)

Here's the macppc cross-compile setup script I've used:

> more powerpc-env
#! /bin/sh
MACHINE=macppc;         export MACHINE
MACHINE_ARCH=powerpc;   export MACHINE_ARCH
TNAM=powerpc-netbsd

DESTDIR=/destdirs/$MACHINE;                     export DESTDIR
NOLINT=1;                                       export NOLINT

AR=/usr/pkg/cross/bin/$TNAM-ar;                 export AR
AS=/usr/pkg/cross/bin/$TNAM-as;                 export AS
CC=/usr/pkg/cross/bin/$TNAM-cc;                 export CC
LD=/usr/pkg/cross/bin/$TNAM-ld;                 export LD
NM=/usr/pkg/cross/bin/$TNAM-nm;                 export NM
RANLIB=/usr/pkg/cross/bin/$TNAM-ranlib;         export RANLIB
SIZE=/usr/pkg/cross/bin/$TNAM-size;             export SIZE
OBJCOPY=/usr/pkg/cross/bin/$TNAM-objcopy;       export OBJCOPY
OBJDUMP=/usr/pkg/cross/bin/$TNAM-objdump;       export OBJDUMP
STRIP=/usr/pkg/cross/bin/$TNAM-strip;           export STRIP
CXX=/usr/pkg/cross/bin/$TNAM-c++;               export CXX
CPP="/usr/pkg/cross/lib/gcc-lib/powerpc-netbsd/egcs-2.91.60/cpp -traditional -D__GNUC__ -nostdinc";
                                                export CPP
exec $SHELL


I also have BSDSRCDIR and BSDOBJDIR set in /etc/mk.conf to the right
directories, and OBJMACHINE is set also.

When I want to cross-build, I run the above script (usually after su'ing
to root). Then I update source. Then I occasionally make obj (should do it
every time, but I"m lazy). Then I do "make build -m $BSDSRCDIR/share/mk".

In the past I did this for m68k and macppc (m68k used a different script
since it's not in the cross-build packages) on an i386. I had obj.mac68k,
obj.i386, and obj.macppc directories, and they all built from the same
source.

Take care,

Bill