Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 6 Feb 2010 20:54:59 -0600
From:      Peter Steele <psteele@maxiscale.com>
To:        Pieter de Goeje <pieter@degoeje.nl>, "freebsd-questions@freebsd.org" <freebsd-questions@freebsd.org>
Subject:   RE: What is easiest way to build a BSD 8 binary on a BSD 7 box?
Message-ID:  <7B9397B189EB6E46A5EE7B4C8A4BB7CB383B2501@MBX03.exg5.exghost.com>
In-Reply-To: <201002070227.48003.pieter@degoeje.nl>
References:  <7B9397B189EB6E46A5EE7B4C8A4BB7CB383B24D6@MBX03.exg5.exghost.com> <201002070227.48003.pieter@degoeje.nl>

next in thread | previous in thread | raw e-mail | index | archive | help
Okay, that looks doable. I'll see how this works out. Thanks very much for =
the info!

-----Original Message-----
From: Pieter de Goeje [mailto:pieter@degoeje.nl]=20
Sent: Saturday, February 06, 2010 5:28 PM
To: freebsd-questions@freebsd.org
Cc: Peter Steele
Subject: Re: What is easiest way to build a BSD 8 binary on a BSD 7 box?

On Saturday 06 February 2010 20:22:13 Peter Steele wrote:
> I have a BSD 7 system with the full BSD 8 sources loaded on it, and we=20
> use this box to build our custom BSD 8 kernel and tools. We do not=20
> install the custom code on the BSD 7 box but simply collect the=20
> artifacts as a basis for our custom BSD 8 image. I have a standalone=20
> tool that has previously been built on this same BSD 7 system, but it=20
> just uses gcc and links against the normal BSD 7 libraries that are locat=
ed on this box.
>
> When we run this tool on a BSD 7 box it works fine. However, we've=20
> discovered one function it performs doesn't work properly. It uses=20
> kvm_read to collect network statistics and apparently applications=20
> that use this function have to be linked against the libraries of the act=
ual target OS.
> One easy solution of course is to build our tool on a BSD 8 box, and=20
> in the long run we'll likely go that route as we move away from BSD 7.=20
> Right now though our build server is BSD 7 and we need to build this=20
> tool against BSD
> 8 libraries. This obviously can be done since "make world" does=20
> exactly that-it builds everything against 8.0 objects even if the=20
> build is done on a BSD 7 box.
>
> Without dissecting the magic going on in "make world", can any explain=20
> how I could do the same thing with my standalone tool? Specifically,=20
> build it on a BSD 7 box but link it against BSD 8 libraries.

The easiest way would probably be the following.

# SOMEDIR=3D/path/to/fbsd8buildenv
# mkdir -p ${SOMEDIR}
# cd /path/to/FreeBSD-8.0/src
# make buildworld
# make installworld DESTDIR=3D${SOMEDIR}

Then adding --sysroot=3D${SOMEDIR} to all invocations of gcc/ld and/or libe=
ral use of -I and -L gcc options should do the trick.

For example:
# export CFLAGS=3D"-I${SOMEDIR}/usr/include -L${SOMEDIR}/lib -L${SOMEDIR}/u=
sr/lib # make

Regards,

Pieter de Goeje



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?7B9397B189EB6E46A5EE7B4C8A4BB7CB383B2501>