This is a makefile that simplifies the creation of GCC cross-toolchains for a wide variety of target platforms.
The toolchains produced by this makefile are probably not appropriate for building production software. The point of this makefile is just to be able to type a single command and have a toolchain that is useful for development and testing purposes in less than 15 minutes.
- This makefile is only tested regularly on modern Linux machines. It might work in other Unix-like environments, but we make no promises.
- The versions for Linux kernel headers, glibc, and musl are generally pinned to whatever the latest release of Zig supports.
- You need to install various build prerequisites yourself, including some libraries. The build is done in this way to reduce the size of the generated toolchains.
In a nutshell, usage is as follows:
- Clone this repository.
- Run
make list
to get a list of supported targets. - Run
make <target> PREFIX=...
to build and install a toolchain. - Run
make clean
to remove leftover build artifacts.
For example, make arm-linux-gnueabi PREFIX=$HOME/cross
will install a
toolchain targeting Linux and glibc under $HOME/cross/arm-linux-gnueabi
with a
sysroot under $HOME/cross/arm-linux-gnueabi/sysroot
.
If you need to use your computer as an expensive space heater and/or you have a
burning hatred for your CPU and disk drive, you can run make all
to build a
toolchain for every single supported target. That is 400+ toolchains, just to be
clear. You probably should not do that. But you can.
The following variables affect the makefile:
PREFIX
: The location to install the built toolchain in. Note that the toolchain will actually be installed under$PREFIX/<target>
. Defaults to theout
directory in the root of the repository.BUILD
: The platform that you are building the toolchain on. This defaults tox86_64-cross-linux-gnu
. Thecross
vendor component is crucial here, as it forces Autotools to run in cross-compilation mode. You only need to set this if you are building on a different platform, e.g.aarch64-cross-linux-gnu
.JOBS
: The maximum number of concurrent jobs that will be used while building each software package. Defaults to the output ofnproc
, i.e. as many jobs as you have CPU cores.V
: Can be set to any value to get verbose output from the makefile.
The build system is licensed under the terms found in
LICENSE-0BSD
. Each software package that is built has its own
license terms.