Cross Compiling of ports Makefiles.

Garrett Cooper yanegomi at
Mon Dec 31 15:37:20 UTC 2012

On Mon, Dec 31, 2012 at 6:33 AM, Michael Vale <masked at> wrote:
> -----Original Message----- From: Simon J. Gerraty
> Sent: Friday, December 28, 2012 5:00 AM
> To: Michael Vale
> Cc: freebsd-hackers at ; freebsd-arch at ;
> freebsd-ports at
> Subject: Re: Cross Compiling of ports Makefiles.
>> Doing the same thing could also prevent the need for a DESTDIR JAIL
>> install at all and just use the real build machine’s build env, rather
>> than a jail.  Regardless.  We still have to install these targets and
>> their DESTDIR is skewed.  There is a few options,
> I think I know what you mean, but not clear on the "their DESTDIR is
> skewed" bit.

You were probably thinking of PREFIX, not DESTDIR. DESTDIR in
ports-land should be an install directory wherein if I do...

./configure --prefix=/usr/local
make all
make install DESTDIR=/chroot/

It would install all (well, ok most if it needs to touch more of the
base system) of the package files into /chroot/usr/local and pathing
would be setup appropriately that way.

> I'm not sure what I meant here either.  Thank-you for taking the time to
> read the entire e-mail! :)
>> One is to have a MAKEOBJDIRPREFIX like option, and redefine every
>> target’s DESTDIR ${makeobjDESTDIR} before running do-install.  Now i’ve
>> yet to complete this stage, but I believe this is the way to do it.
> Would it be sufficient to have an INSTALL_PREFIX and/or INSTALL_DESTDIR
> so that DESTDIR can be different during install ?
> [I was recently experimenting with something similar...]
> So how would that work?
> pre-install:
> INSTALL_DESTDIR=/usr/obj/crossoutroot/
> do-install:
> ?  I will try something like that.
> Thank-you for taking the time to reply Simon,

I've thought about this item quite a bit and while I might not have
hashed out all of the internal details, I think that it should go
something like this:

0. Run standard build/install targets which will go and create
necessary binaries into a predefined world dir.

Once the installation is complete (installworld / distribution)...
1. Mount the necessary mountpoints.
2. Install the "host-compiled" tools into a predefined set of
directories. Example:


3. Do a nullfs overlay of the "host-compiled" tools on top of the
target system's equivalent directories in order to provide the needed
bits for executing the build.
4. Verify sanity for the install base (just in case the new binaries
don't run on the host system due to KPI differences) with a basic
check like we use for make in `upgrade_checks`.
5. Mock up the build environment to look like the target system, like
what's described .
6. Jump into the world dir.
7. Start building/installing packages.


I'm suggesting steps 2. and 3. because while fixing hardcoding in
ports packages is a noble effort, there's just way too much work to be
done in order to accomplish the job (we have other problems to contend
with around the ports tree) and it's an ongoing battle trying to get
everyone to use sane build methodologies (I'm making an assumption
based on several projects I've used, but many devs aren't capable
build system engineers because it takes a bit of mental skewing, so
hardcoding abounds in a number of places). Doing this will allow us to
have a working prototype quicker, so in the event that others wish to
make the process more streamlined in the future, they could do so.

Whether or not this handled in the FreeBSD build system or outside it
is an implementation detail, but for the sake of modularity (and to
keep KISS principle with the FreeBSD build system, which I would argue
is complicated enough) I would say make them separate processes.
Besides, we already have canned methods for doing this in NanoBSD,
PicoBSD, etc already -- and they really could deserve some
consolidation (speaking of which, have you looked at using these in

You might want to look at FreeNAS 8.x's build architecture and use
that as a starting point for how to do things. imp@ designed the
initial system, I (gcooper@) modified it heavily, and
jhixson@/jpaetzel@ modified it more after I left iXsystems in order to
work with their plugin architecture. I can send you a copy of the
system I was starting to architect ("Avatar") if you wish.

Overall, I like the direction you're going in and I'm glad someone is
picking this up. I greatly appreciate it because it's been on my
laundry list of items that need to get done for some time :).


More information about the freebsd-ports mailing list