Subject: Re: Cross-build question.
To: Frederick Bruckman <fredb@immanent.net>
From: Greywolf <greywolf@starwolf.com>
List: current-users
Date: 02/04/2003 16:53:26
[FB: Subject: Re: Cross-build question.
[FB:
[FB: On Tue, 4 Feb 2003, Simon J. Gerraty wrote:
[FB:
[FB: > I put:
[FB: >
[FB: > .if ${MACHINE_ARCH} == "sparc"
[FB: > DEFCOPTS=-O2 -msupersparc
[FB: > .endif
[FB: >
[FB: > in /etc/mk.conf and it does the right thing - for kernel builds
[FB: > at least.  The same trick should work for other bits of the build.
[FB:
[FB: ${DEFCOPTS} doesn't work for other parts of the build, only ${COPTS}.
[FB: I have something like this in "/etc/mk.conf":
[FB:
[FB:     HOST_CFLAGS?=          -O2 -march=k6
[FB:
[FB:     .if     ${MACHINE} == "i386"
[FB:     COPTS?=                -O2 -mcpu=k6
[FB:     .elif   ${MACHINE} == "mac68k"
[FB:     COPTS?=                -O2 -m68020-40
[FB:     .endif
[FB:
[FB: So, the tools get built with "-O2 -march=k6", the i386 release gets
[FB: built with "-O2 -mcpu=k6", and so on. Note the question mark '?'!
[FB: Without that, you're likely to break the INSTALL* kernels.
[FB:
[FB: Frederick



Simon, Frederick,

I thank you both very much for your efforts.  I must be missing something
here, like my brain, because when I go to build the tools explicitly,
mk.conf never picks up the MKTOOLS=no.

Here's what I have at the top of my mk.conf:
%==
# Force for i386

HOST_CFLAGS?=   -O2 -march=k6

.if     ${MACHINE} == "i386"
.ifdef KERNEL
COPTS?=         -O2 -mcpu=k6
.else
COPTS?=         -O3 -mcpu=k6
.endif  # !kernel-i386
.elif   ${MACHINE} == "sparc"
.ifdef KERNEL
COPTS?=         -O2 -mv8 -mcpu=supersparc
.else
COPTS?=         -O3 -mv8 -mcpu=supersparc
.endif  # !kernel-sparc
.endif  # mach-select
%==

Now, I know that KERNEL isn't (necessarily) defined/passed on to a makefile,
although I can drop it into a config file if I need to (I'm just looking
for a nice way to achieve this...).

And never mind that my COPTS might be asking for trouble with -O3 -- the
important part is the cpu-specific flags, here.

Here's what I (effectively) end up running:
#<***

export TOOLDIR
export MACHINE MACHINE_ARCH
export SHELL
SHELL=/bin/sh
MACHINE=sparc MACHINE_ARCH=sparc;
TOOLDIR=/usr/src/tools/tools.NetBSD-1.6M-sparc;
PATH=/usr/src/tools/tools.NetBSD-1.6M-sparc/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/X11/bin:/usr/X11/sbin:/root/bin:/usr/src;
build.sh -O /export/obj/sparc -D /export/build/sparc tools

#<***

And here's what I end up getting:

#>***
[objdirs get made]
[cleandir runs]
dependall ===> host-mkdep
rm -f host-mkdep
CC=cc CFLAGS=-O3\ -mcpu=supersparc\ -mv8 LDFLAGS=  /usr/src/tools/host-mkdep/configure --cache-file=config.cache
configure: creating cache config.cache
checking for sh... /bin/sh
checking for mawk... no
checking for gawk... no
checking for nawk... no
checking for awk... awk
checking for gcc... cc
checking for C compiler default output... configure: error: C compiler cannot create executables
*** Error code 77

Stop.
nbmake: stopped in /usr/src/tools/host-mkdep
*** Error code 1

Stop.
nbmake: stopped in /usr/src/tools/host-mkdep
*** Error code 1

Stop.
nbmake: stopped in /usr/src/tools

ERROR: failed to make tools
*** BUILD ABORTED ***
#>***

As you can see, the flags I want applied only during a cross-build are not
getting enabled during the cross-build!

[not to mention, I keep getting this directory called

"^Jnbmake: stopped in /usr/src/bin/nbmake-sparc"

[yes, that's a LF in there.]]

Go figure.

				--*greywolf;
--
NetBSD: I Wanna Be Sedated!