Subject: Need help: Out-of-tree cross compilation.
To: None <tech-toolchain@netbsd.org>
From: marty fouts <mf.danger@gmail.com>
List: tech-toolchain
Date: 05/26/2006 11:39:23
I've confused myself and need advice.

I'm trying to set up a build system that allows me to build
applications out-of-tree but cross compiled for NetBSD, because I need
to crosscompile aps for NetBSD on a Linux box, as I've mentioned
before.

I've looked at the log output from a system build, and, as far as I
can tell, the Makefile below duplicates the command arguments
necessary for the crosscompile.

I get a hello binary, and it looks fine, except that it's missing the
elf section with the NetBSD note, which, I presume, is the reason why
NetBSD gives a 'wrong architecture' message and refuses to run the
binary.

What is the last bit of magic I'm missing in my compilation to make
the binary a NetBSD binary?

Here's the makefile (cut'n'paste, so tabs are screwed up)

CC=../netbsd_quilt/src/tooldir.Linux-2.6.16-1.2111_FC5smp-i686/bin/arm--netbsdel
f-gcc
LD=../netbsd_quilt/src/tooldir.Linux-2.6.16-1.2111_FC5smp-i686/bin/arm--netbsdel
f-gcc

CFLAGS=-nostdinc -isystem ../netbsd_quilt/src/obj/destdir.evbarm/usr/include
BASE=../netbsd_quilt/src/obj/destdir.evbarm
LDFLAGS= -Wl,-nostdlib
LDFLAGS1=-Wl,-rpath-link,$(BASE)/lib:$(BASE)/usr/lib -L$(BASE)/lib
-B$(BASE)/lib -B$(BASE)/usr/lib

hello:  hello.o
        $(LD) $(LDFLAGS) -o hello $(LDFLAGS1) hello.o $(LIBS)

hello.o:        hello.c
                $(CC) $(CFLAGS) -c hello.c