Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| warnerlosh:a_brief_guide_to_cross_compiling_freebsd [2006/07/20 22:29] – WarnerLosh | warnerlosh:a_brief_guide_to_cross_compiling_freebsd [2021/04/26 04:26] (current) – Add CategoryStale KubilayKocak | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Cross Compiling FreeBSD for Fun and Profit ====== | ====== Cross Compiling FreeBSD for Fun and Profit ====== | ||
| - | ===== Summary | + | ===== Summary ===== |
| - | * Obtain | + | * Introduction |
| - | * setup build environment | + | * Obtaining |
| - | * Build | + | * Setting up Build Environment |
| + | * Building World | ||
| + | * What's Next | ||
| + | * Cheatsheet | ||
| - | ===== Obtaining FreeBSD sources | + | ===== Introduction |
| - | See http:// | + | ==== Notes ==== |
| - | ===== Setup Build Environment ===== | + | For the sake of illustration, |
| - | For architectures that are supported by %%FreeBSD%%, | + | * All files will be placed under /// |
| + | * The architecture being built will be (big-endian) ARM, aka // | ||
| + | * The installed world will be placed under /// | ||
| - | The %%FreeBSD%% build system uses three environment variables to control which platform to build for, and where to put the results. | + | ==== Notation Used ==== |
| - | Most people will want to change the location of the build. | + | * Any line preceded by a //%// is to be executed in a system shell. |
| + | * The reader can specify make variables in one of three ways: | ||
| + | * In a custom // | ||
| + | * Set the variables in the environment, e.g. with env, export, or setenv. | ||
| + | * Explicitly on the command line. **NOTE**: this is how the writeup specifies | ||
| - | setenv MAKEOBJDIRPREFIX / | + | ===== Obtaining FreeBSD ===== |
| - | To control which architecture to build for, set TARGET and TARGET_ARCH | + | The reader can obtain the sources as noted in the Handbook chapter titled [[http:// |
| - | setenv TARGET arm | + | ===== Setting up Build Environment ===== |
| - | setenv TARGET_ARCH | + | |
| - | TARGET | + | For architectures that are supported by %%FreeBSD%%, |
| + | |||
| + | The %%FreeBSD%% build system uses three environment variables to control which platform to build (TARGET), which target architecture to build (TARGET_ARCH), and where to put the results (MAKEOBJDIRPREFX). By default, %%FreeBSD%% builds the current architecture and places the results in /// | ||
| + | |||
| + | When cross-compiling however, %%FreeBSD%% places binaries in // | ||
| + | |||
| + | Note that a non-default value of MAKEOBJDIRPREFIX must be passed to make as an environment variable. | ||
| + | |||
| + | ==== make.conf / src.conf ==== | ||
| + | |||
| + | A standard make.conf and src.conf file can contain variables or make snippets which tune build behavior. / | ||
| + | |||
| + | * Explicitly setting CPUTYPE. The following incorrect example would explicitly attempt to build binaries optimizing for the core2 Intel architecture: | ||
| + | |||
| + | < | ||
| + | CPUTYPE= core2 | ||
| + | </ | ||
| + | |||
| + | The reader should instead set the CPUTYPE as follows: | ||
| + | |||
| + | < | ||
| + | CPUTYPE?= core2 | ||
| + | </ | ||
| + | |||
| + | * Explicitly setting KERNCONF. The following incorrect example would explicitly build the XEN KERNCONF (which only exists for i386 and amd64): | ||
| + | |||
| + | < | ||
| + | KERNCONF= XEN | ||
| + | </ | ||
| + | |||
| + | The reader should instead set KERNCONF as follows: | ||
| + | |||
| + | < | ||
| + | KERNCONF?= XEN | ||
| + | </ | ||
| + | |||
| + | ===== Building and Installing World ===== | ||
| + | |||
| + | The following subsections show the reader how they could build and install world for the big-endian ARM architecture from scratch. | ||
| + | |||
| + | ==== Go to the Source Directory ==== | ||
| + | |||
| + | < | ||
| + | % cd / | ||
| + | </ | ||
| + | |||
| + | ==== Build World ==== | ||
| + | |||
| + | < | ||
| + | % env MAKEOBJDIRPREFIX=/ | ||
| + | </ | ||
| + | |||
| + | ==== Install World ==== | ||
| + | |||
| + | * First and foremost, one must create the install directory: | ||
| + | |||
| + | < | ||
| + | % mkdir / | ||
| + | </ | ||
| + | |||
| + | * Then one must run make installworld to install the binaries produced in buildworld: | ||
| + | |||
| + | < | ||
| + | % env MAKEOBJDIRPREFIX=/ | ||
| + | </ | ||
| + | |||
| + | * And last but not least, one must run make distribution to populate the world with important files from ///etc//: | ||
| + | |||
| + | < | ||
| + | % env MAKEOBJDIRPREFIX=/ | ||
| + | </ | ||
| + | |||
| + | **NOTE**: You could invoke mergemaster instead of running make distribution; | ||
| + | |||
| + | ===== What's Next ===== | ||
| + | |||
| + | The above example demonstrated how one could build world and install world with armeb. This should provide you with the building blocks required to build the %%FreeBSD%% base system for any cross-compilation environment. | ||
| ===== Cheat sheet ===== | ===== Cheat sheet ===== | ||
| http:// | http:// | ||
| + | |||
| + | ---- | ||
| + | |||
| + | {{tag> | ||