# Compile FreeBSD for a Different Target



## Toad39 (Oct 21, 2020)

Hello,

I would like to compile part of the FreeBSD sources (compiling  on FreeBSD) for a different target string, e.g. `x86_64-pc-linux-gnu`. Is there a way to specifiy `make` to compile for this architecture/target?

Thank you for your consideration,


----------



## a6h (Oct 21, 2020)

Mailing list:
Can FreeBSD-amd64 cross compile FreeBSD-i386

Wiki:
External Toolchain Support

Forums:
Thread cross-compiling-to-arm64-img.76194
Thread cross-compiling-world-for-i386-on-amd64-platform.23136

Related man pages:
build(7), release(7), arch(7), make.conf(5), rc.conf(5), src.conf(5), make(1)

Related files:
/usr/src/Makefile
/usr/src/Makefile.inc
/usr/share/examples/etc/make.conf


----------



## Phishfry (Oct 21, 2020)

Here was my example cross-compiling BBB on amd64








						Cross-compiling Beaglebone on amd64
					

Well I got tired of using crochet as a crutch and I figured out how to cross compile for Beaglebone. At first I cheated and wrote to the microSD Card, but I buckled down and figured out how to manipulate a memory disk.   [Copy Source to Build Dir] mkdir /BBB cp -vipr /usr/src /BBB/src mkdir...




					forums.freebsd.org


----------



## Toad39 (Oct 22, 2020)

Hello,

All I've seen is the cross-compilation of FreeBSD onto different architectures of FreeBSD. Is there a way to compile FreeBSD, specifying the four-field target to compile for?


----------



## Phishfry (Oct 22, 2020)

Toad39 said:


> Is there a way to compile FreeBSD, specifying the four-field target to compile for?


Could you be more specific what you mean by 'four-field target'?
As you may notice from my instructions, you must set the environment for a specific architecture.
Are you talking about building -STABLE on -RELEASE or something like that?


----------



## Jose (Oct 23, 2020)

Phishfry said:


> Could you be more specific what you mean by 'four-field target'?


It's a GNU toolchain thing. They're sometimes called "GNU triplets" or "tuples":




__





						Embedded Handbook/Tuples - Gentoo Wiki
					






					wiki.gentoo.org
				




The one he mentions is x86_64-pc-linux-gnu


----------



## ralphbsz (Oct 23, 2020)

Exactly. And that's where I thought the question made no sense: How can you compile FreeBSD for Linux? Either you're compiling to run FreeBSD on the machine, or you're compiling (the Linux source) to run Linux, right? I can not understand what the OP means.


----------



## Phishfry (Oct 23, 2020)

There was some recent news regarding cross compiling but it went the other direction.
Compiling FreeBSD on Linux.


			FreeBSD Quarterly Status Report


----------



## Jose (Oct 23, 2020)

Gentoo Freebsd had a way to build Freebsd kernel and base using a GNU toolchain. It did have some -freebsd triplets, but I forget what they were. That project died years ago anyway.


----------

