Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 16 Nov 1999 17:44:39 +0100
From:      Marcel Moolenaar <marcel@scc.nl>
To:        Warner Losh <imp@village.org>
Cc:        cvs-committers@freebsd.org, cvs-all@freebsd.org
Subject:   Re: cvs commit: src Makefile.inc1 src/usr.bin/make Makefile
Message-ID:  <383189F7.67E89E8B@scc.nl>
References:  <38310A94.B1939A83@scc.nl>  <199911151707.JAA03820@freefall.freebsd.org> <199911160533.WAA02391@harmony.village.org> <199911161544.IAA08642@harmony.village.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Warner Losh wrote:
> 
> In message <38310A94.B1939A83@scc.nl> Marcel Moolenaar writes:
> : If make is compiled against the right set of headers, you are never
> : going to need this. The Makefiles are full of those `cross-compilation'
> : hacks that are basicly only needed because cross-building is broken by
> : design. The only way to fix cross-building is to get to the bones of
> : things and CROSS_MAKE_FLAGS is currently in the way.
> 
> But without them, make won't define MACHINE and MACHINE_ARCH
> correctly, which is critical to have any sort of cross building work.

When MACHINE_ARCH is used to denote the target machine instead of the
host machine (which it represents by definition), then you only have to
set MACHINE_ARCH in the environment (although the commandline works as
well). Make uses the environment variables if they are present. Make is
not a cross-tool.

> I was unable to get cross compiling working at all by defining MACHINE
> and MACHINE_ARCH on the command line, but I think that is due to make
> trying to second guess things (maybe this code has been slain inside
> of make). That's why it was needed.  What are you replacing it with?
> What's your cross building direction?

My first approach was to leave MACHINE{_ARCH} alone and use
TARGET{_ARCH} for that. The problem is that you need to modify a lot of
makefiles. I abandoned it. I now want the main makefile (ie
/usr/src/Makefile) to add MACHINE and MACHINE_ARCH to the environment
used by the sub-makes (although it's not actually needed):

Assume the following makefile:

default: second
	make second

second:
	@echo machine=${MACHINE}
	@echo machine_arch=${MACHINE_ARCH}

% make
machine=i386
machine_arch=i386
make second
machine=i386
machine_arch=i386
% make MACHINE_ARCH=alpha
machine=i386
machine_arch=alpha
make second
machine=i386
machine_arch=alpha

I want to use TARGET_ARCH for building the cross-compiler:

[Assume we're running on an i386]

MACHINE_ARCH = i386, TARGET_ARCH = i386
	Regular build and no cross-compiler.
MACHINE_ARCH = i386, TARGET_ARCH = mips
	Make a cross-compiler to cross-build for MIPS (used for
	building cross-tools on i386).
MACHINE_ARCH = mips, TARGET_ARCH = mips
	Cross-build for MIPS and don't build a cross-compiler
	(used to make the native MIPS compiler).
MACHINE_ARCH = mips, TARGET_ARCH = alpha
	Cross-build for MIPS and make a cross-compiler for Alpha
	(to run on MIPS) (It's free :-)

Currently MACHINE_ARCH is tested against `sysctl -n hw.machine_arch` and
if they differ then we're building a cross-compiler. This obviously
doesn't work if we are making the native MIPS compiler in a
cross-build...

-- 
Marcel Moolenaar                        mailto:marcel@scc.nl
SCC Internetworking & Databases           http://www.scc.nl/
The FreeBSD project                mailto:marcel@FreeBSD.org


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe cvs-all" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?383189F7.67E89E8B>