Building the Ubuntu kernel: fakeroot debian/rules¶
Before submitting any patch, make sure it builds inside the devel chroot (e.g. Lunar):
$ schroot -c lunar-amd64
(lunar-amd64)$ fakeroot debian/rules clean
(lunar-amd64)$ debian/rules build
# building takes some time, be patient
(lunar-amd64)$ fakeroot debian/rules binary
Depending on your build box resources (cpus, memory, disk, etc) the process could take minutes or hours, be patient.
If the build is successful, a set of .deb binary packages will be present in the parent directory: you can install these (sudo dpkg -i linux-generic-...deb linux-modules-...deb
) to test the resulting kernel.
Cross compilation¶
Cross compiling is a matter of setting the target dpkg-architecture
before starting the build (e.g. to cross-compile an arm64 kernel):
$ schroot -c lunar-amd64
(lunar-amd64)$ export $(dpkg-architecture -aarm64)
(lunar-amd64)$ fakeroot debian/rules clean
(lunar-amd64)$ debian/rules build
# build time...
(lunar-amd64)$ fakeroot debian/rules binary
These are the available dpkg-architecture
targets, and the corresponding
Kbuild vars:
Target architecture |
ARCH |
CROSS_COMPILE |
dpkg-architecture |
---|---|---|---|
arm64 |
arm64 |
aarch64-linux-gnu- |
arm64 |
armhf |
arm |
aarch64-linux-gnu- |
armhf |
ppc64el |
powerpc |
aarch64-linux-gnu- |
ppc64el |
riscv64 |
riscv |
aarch64-linux-gnu- |
riscv64 |
s390x |
s390x |
aarch64-linux-gnu- |
s390x |