Also referred to as «building the Linux kernel».
Prerequisites
Some prerequisites to compile the kernel include
- kernel sources (obviously)
- glibc kernheaders
- glibc devel
- cpp (c preprocessor)
- binutils
- gcc
- flex and bison (I assume to parse the Kconfig language (and possibly other syntaxes))
- ncurses (for
make menuconfig
)
- tcl (for
make xconfig
)
- tk (for
make xconfig
)
tk and tcl are required in configuration step
533 rene @ debian 14:15:28 ~/github/linux/temp/TODO/kernel/compilation/make-targets/tinyconfig/linux-src make tinyconfig
HOSTCC scripts/basic/fixdep
HOSTCC scripts/kconfig/conf.o
HOSTCC scripts/kconfig/confdata.o
HOSTCC scripts/kconfig/expr.o
LEX scripts/kconfig/lexer.lex.c
/bin/sh: 1: flex: not found
sudo apt install -y flex bison
Specifying an alternate config file
By default, the make system uses
./.config
as build configuration file.
An alternate file can be chosen by setting the environment variable KCONFIG_CONFIG
to the path of a config file or specyfing the alternate config file directly like so:
make KCONFIG_CONFIG=test.config
Specifying a separate build directory
By default, the generated files go into the same tree as the kernel sources. Invoking
make with
O=/path/to/output/dir
allows to specify an alternative destination
cd /usr/src/linux-4.X
make O=/home/name/build/kernel menuconfig
make O=/home/name/build/kernel
sudo make O=/home/name/build/kernel modules_install install