| 1 |
====== |
| 2 |
Kbuild |
| 3 |
====== |
| 4 |
|
| 5 |
|
| 6 |
Output files |
| 7 |
============ |
| 8 |
|
| 9 |
modules.order |
| 10 |
------------- |
| 11 |
This file records the order in which modules appear in Makefiles. This |
| 12 |
is used by modprobe to deterministically resolve aliases that match |
| 13 |
multiple modules. |
| 14 |
|
| 15 |
modules.builtin |
| 16 |
--------------- |
| 17 |
This file lists all modules that are built into the kernel. This is used |
| 18 |
by modprobe to not fail when trying to load something builtin. |
| 19 |
|
| 20 |
modules.builtin.modinfo |
| 21 |
----------------------- |
| 22 |
This file contains modinfo from all modules that are built into the kernel. |
| 23 |
Unlike modinfo of a separate module, all fields are prefixed with module name. |
| 24 |
|
| 25 |
modules.builtin.ranges |
| 26 |
---------------------- |
| 27 |
This file contains address offset ranges (per ELF section) for all modules |
| 28 |
that are built into the kernel. Together with System.map, it can be used |
| 29 |
to associate module names with symbols. |
| 30 |
|
| 31 |
Environment variables |
| 32 |
===================== |
| 33 |
|
| 34 |
KCPPFLAGS |
| 35 |
--------- |
| 36 |
Additional options to pass when preprocessing. The preprocessing options |
| 37 |
will be used in all cases where kbuild does preprocessing including |
| 38 |
building C files and assembler files. |
| 39 |
|
| 40 |
KAFLAGS |
| 41 |
------- |
| 42 |
Additional options to the assembler (for built-in and modules). |
| 43 |
|
| 44 |
AFLAGS_MODULE |
| 45 |
------------- |
| 46 |
Additional assembler options for modules. |
| 47 |
|
| 48 |
AFLAGS_KERNEL |
| 49 |
------------- |
| 50 |
Additional assembler options for built-in. |
| 51 |
|
| 52 |
KCFLAGS |
| 53 |
------- |
| 54 |
Additional options to the C compiler (for built-in and modules). |
| 55 |
|
| 56 |
KRUSTFLAGS |
| 57 |
---------- |
| 58 |
Additional options to the Rust compiler (for built-in and modules). |
| 59 |
|
| 60 |
CFLAGS_KERNEL |
| 61 |
------------- |
| 62 |
Additional options for $(CC) when used to compile |
| 63 |
code that is compiled as built-in. |
| 64 |
|
| 65 |
CFLAGS_MODULE |
| 66 |
------------- |
| 67 |
Additional module specific options to use for $(CC). |
| 68 |
|
| 69 |
RUSTFLAGS_KERNEL |
| 70 |
---------------- |
| 71 |
Additional options for $(RUSTC) when used to compile |
| 72 |
code that is compiled as built-in. |
| 73 |
|
| 74 |
RUSTFLAGS_MODULE |
| 75 |
---------------- |
| 76 |
Additional module specific options to use for $(RUSTC). |
| 77 |
|
| 78 |
LDFLAGS_MODULE |
| 79 |
-------------- |
| 80 |
Additional options used for $(LD) when linking modules. |
| 81 |
|
| 82 |
HOSTCFLAGS |
| 83 |
---------- |
| 84 |
Additional flags to be passed to $(HOSTCC) when building host programs. |
| 85 |
|
| 86 |
HOSTCXXFLAGS |
| 87 |
------------ |
| 88 |
Additional flags to be passed to $(HOSTCXX) when building host programs. |
| 89 |
|
| 90 |
HOSTRUSTFLAGS |
| 91 |
------------- |
| 92 |
Additional flags to be passed to $(HOSTRUSTC) when building host programs. |
| 93 |
|
| 94 |
PROCMACROLDFLAGS |
| 95 |
---------------- |
| 96 |
Flags to be passed when linking Rust proc macros. Since proc macros are loaded |
| 97 |
by rustc at build time, they must be linked in a way that is compatible with |
| 98 |
the rustc toolchain being used. |
| 99 |
|
| 100 |
For instance, it can be useful when rustc uses a different C library than |
| 101 |
the one the user wants to use for host programs. |
| 102 |
|
| 103 |
If unset, it defaults to the flags passed when linking host programs. |
| 104 |
|
| 105 |
HOSTLDFLAGS |
| 106 |
----------- |
| 107 |
Additional flags to be passed when linking host programs. |
| 108 |
|
| 109 |
HOSTLDLIBS |
| 110 |
---------- |
| 111 |
Additional libraries to link against when building host programs. |
| 112 |
|
| 113 |
.. _userkbuildflags: |
| 114 |
|
| 115 |
USERCFLAGS |
| 116 |
---------- |
| 117 |
Additional options used for $(CC) when compiling userprogs. |
| 118 |
|
| 119 |
USERLDFLAGS |
| 120 |
----------- |
| 121 |
Additional options used for $(LD) when linking userprogs. userprogs are linked |
| 122 |
with CC, so $(USERLDFLAGS) should include "-Wl," prefix as applicable. |
| 123 |
|
| 124 |
KBUILD_KCONFIG |
| 125 |
-------------- |
| 126 |
Set the top-level Kconfig file to the value of this environment |
| 127 |
variable. The default name is "Kconfig". |
| 128 |
|
| 129 |
KBUILD_VERBOSE |
| 130 |
-------------- |
| 131 |
Set the kbuild verbosity. Can be assigned same values as "V=...". |
| 132 |
|
| 133 |
See make help for the full list. |
| 134 |
|
| 135 |
Setting "V=..." takes precedence over KBUILD_VERBOSE. |
| 136 |
|
| 137 |
KBUILD_EXTMOD |
| 138 |
------------- |
| 139 |
Set the directory to look for the kernel source when building external |
| 140 |
modules. |
| 141 |
|
| 142 |
Setting "M=..." takes precedence over KBUILD_EXTMOD. |
| 143 |
|
| 144 |
KBUILD_OUTPUT |
| 145 |
------------- |
| 146 |
Specify the output directory when building the kernel. |
| 147 |
|
| 148 |
This variable can also be used to point to the kernel output directory when |
| 149 |
building external modules against a pre-built kernel in a separate build |
| 150 |
directory. Please note that this does NOT specify the output directory for the |
| 151 |
external modules themselves. (Use KBUILD_EXTMOD_OUTPUT for that purpose.) |
| 152 |
|
| 153 |
The output directory can also be specified using "O=...". |
| 154 |
|
| 155 |
Setting "O=..." takes precedence over KBUILD_OUTPUT. |
| 156 |
|
| 157 |
KBUILD_EXTMOD_OUTPUT |
| 158 |
-------------------- |
| 159 |
Specify the output directory for external modules. |
| 160 |
|
| 161 |
Setting "MO=..." takes precedence over KBUILD_EXTMOD_OUTPUT. |
| 162 |
|
| 163 |
KBUILD_EXTRA_WARN |
| 164 |
----------------- |
| 165 |
Specify the extra build checks. The same value can be assigned by passing |
| 166 |
W=... from the command line. |
| 167 |
|
| 168 |
See `make help` for the list of the supported values. |
| 169 |
|
| 170 |
Setting "W=..." takes precedence over KBUILD_EXTRA_WARN. |
| 171 |
|
| 172 |
KBUILD_DEBARCH |
| 173 |
-------------- |
| 174 |
For the deb-pkg target, allows overriding the normal heuristics deployed by |
| 175 |
deb-pkg. Normally deb-pkg attempts to guess the right architecture based on |
| 176 |
the UTS_MACHINE variable, and on some architectures also the kernel config. |
| 177 |
The value of KBUILD_DEBARCH is assumed (not checked) to be a valid Debian |
| 178 |
architecture. |
| 179 |
|
| 180 |
KDOCFLAGS |
| 181 |
--------- |
| 182 |
Specify extra (warning/error) flags for kernel-doc checks during the build, |
| 183 |
see tools/docs/kernel-doc for which flags are supported. Note that this doesn't |
| 184 |
(currently) apply to documentation builds. |
| 185 |
|
| 186 |
ARCH |
| 187 |
---- |
| 188 |
Set ARCH to the architecture to be built. |
| 189 |
|
| 190 |
In most cases the name of the architecture is the same as the |
| 191 |
directory name found in the arch/ directory. |
| 192 |
|
| 193 |
But some architectures such as x86 and sparc have aliases. |
| 194 |
|
| 195 |
- x86: i386 for 32 bit, x86_64 for 64 bit |
| 196 |
- parisc: parisc64 for 64 bit |
| 197 |
- sparc: sparc32 for 32 bit, sparc64 for 64 bit |
| 198 |
|
| 199 |
CROSS_COMPILE |
| 200 |
------------- |
| 201 |
Specify an optional fixed part of the binutils filename. |
| 202 |
CROSS_COMPILE can be a part of the filename or the full path. |
| 203 |
|
| 204 |
CROSS_COMPILE is also used for ccache in some setups. |
| 205 |
|
| 206 |
CF |
| 207 |
-- |
| 208 |
Additional options for sparse. |
| 209 |
|
| 210 |
CF is often used on the command-line like this:: |
| 211 |
|
| 212 |
make CF=-Wbitwise C=2 |
| 213 |
|
| 214 |
INSTALL_PATH |
| 215 |
------------ |
| 216 |
INSTALL_PATH specifies where to place the updated kernel and system map |
| 217 |
images. Default is /boot, but you can set it to other values. |
| 218 |
|
| 219 |
INSTALLKERNEL |
| 220 |
------------- |
| 221 |
Install script called when using "make install". |
| 222 |
The default name is "installkernel". |
| 223 |
|
| 224 |
The script will be called with the following arguments: |
| 225 |
|
| 226 |
- $1 - kernel version |
| 227 |
- $2 - kernel image file |
| 228 |
- $3 - kernel map file |
| 229 |
- $4 - default install path (use root directory if blank) |
| 230 |
|
| 231 |
The implementation of "make install" is architecture specific |
| 232 |
and it may differ from the above. |
| 233 |
|
| 234 |
INSTALLKERNEL is provided to enable the possibility to |
| 235 |
specify a custom installer when cross compiling a kernel. |
| 236 |
|
| 237 |
MODLIB |
| 238 |
------ |
| 239 |
Specify where to install modules. |
| 240 |
The default value is:: |
| 241 |
|
| 242 |
$(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE) |
| 243 |
|
| 244 |
The value can be overridden in which case the default value is ignored. |
| 245 |
|
| 246 |
INSTALL_MOD_PATH |
| 247 |
---------------- |
| 248 |
INSTALL_MOD_PATH specifies a prefix to MODLIB for module directory |
| 249 |
relocations required by build roots. This is not defined in the |
| 250 |
makefile but the argument can be passed to make if needed. |
| 251 |
|
| 252 |
INSTALL_MOD_STRIP |
| 253 |
----------------- |
| 254 |
INSTALL_MOD_STRIP, if defined, will cause modules to be |
| 255 |
stripped after they are installed. If INSTALL_MOD_STRIP is '1', then |
| 256 |
the default option --strip-debug will be used. Otherwise, |
| 257 |
INSTALL_MOD_STRIP value will be used as the options to the strip command. |
| 258 |
|
| 259 |
INSTALL_HDR_PATH |
| 260 |
---------------- |
| 261 |
INSTALL_HDR_PATH specifies where to install user space headers when |
| 262 |
executing "make headers_*". |
| 263 |
|
| 264 |
The default value is:: |
| 265 |
|
| 266 |
$(objtree)/usr |
| 267 |
|
| 268 |
$(objtree) is the directory where output files are saved. |
| 269 |
The output directory is often set using "O=..." on the commandline. |
| 270 |
|
| 271 |
The value can be overridden in which case the default value is ignored. |
| 272 |
|
| 273 |
INSTALL_DTBS_PATH |
| 274 |
----------------- |
| 275 |
INSTALL_DTBS_PATH specifies where to install device tree blobs for |
| 276 |
relocations required by build roots. This is not defined in the |
| 277 |
makefile but the argument can be passed to make if needed. |
| 278 |
|
| 279 |
KBUILD_ABS_SRCTREE |
| 280 |
-------------------------------------------------- |
| 281 |
Kbuild uses a relative path to point to the tree when possible. For instance, |
| 282 |
when building in the source tree, the source tree path is '.' |
| 283 |
|
| 284 |
Setting this flag requests Kbuild to use absolute path to the source tree. |
| 285 |
There are some useful cases to do so, like when generating tag files with |
| 286 |
absolute path entries etc. |
| 287 |
|
| 288 |
KBUILD_SIGN_PIN |
| 289 |
--------------- |
| 290 |
This variable allows a passphrase or PIN to be passed to the sign-file |
| 291 |
utility when signing kernel modules, if the private key requires such. |
| 292 |
|
| 293 |
KBUILD_MODPOST_WARN |
| 294 |
------------------- |
| 295 |
KBUILD_MODPOST_WARN can be set to avoid errors in case of undefined |
| 296 |
symbols in the final module linking stage. It changes such errors |
| 297 |
into warnings. |
| 298 |
|
| 299 |
KBUILD_MODPOST_NOFINAL |
| 300 |
---------------------- |
| 301 |
KBUILD_MODPOST_NOFINAL can be set to skip the final link of modules. |
| 302 |
This is solely useful to speed up test compiles. |
| 303 |
|
| 304 |
KBUILD_EXTRA_SYMBOLS |
| 305 |
-------------------- |
| 306 |
For modules that use symbols from other modules. |
| 307 |
See more details in modules.rst. |
| 308 |
|
| 309 |
ALLSOURCE_ARCHS |
| 310 |
--------------- |
| 311 |
For tags/TAGS/cscope targets, you can specify more than one arch |
| 312 |
to be included in the databases, separated by blank space. E.g.:: |
| 313 |
|
| 314 |
$ make ALLSOURCE_ARCHS="x86 mips arm" tags |
| 315 |
|
| 316 |
To get all available archs you can also specify all. E.g.:: |
| 317 |
|
| 318 |
$ make ALLSOURCE_ARCHS=all tags |
| 319 |
|
| 320 |
IGNORE_DIRS |
| 321 |
----------- |
| 322 |
For tags/TAGS/cscope targets, you can choose which directories won't |
| 323 |
be included in the databases, separated by blank space. E.g.:: |
| 324 |
|
| 325 |
$ make IGNORE_DIRS="drivers/gpu/drm/radeon tools" cscope |
| 326 |
|
| 327 |
KBUILD_BUILD_TIMESTAMP |
| 328 |
---------------------- |
| 329 |
Setting this to a date string overrides the timestamp used in the |
| 330 |
UTS_VERSION definition (uname -v in the running kernel). The value has to |
| 331 |
be a string that can be passed to date -d. E.g.:: |
| 332 |
|
| 333 |
$ KBUILD_BUILD_TIMESTAMP="Mon Oct 13 00:00:00 UTC 2025" make |
| 334 |
|
| 335 |
The default value is the output of the date command at one point during |
| 336 |
build. If provided, this timestamp will also be used for mtime fields |
| 337 |
within any initramfs archive. Initramfs mtimes are 32-bit, so dates before |
| 338 |
the 1970 Unix epoch, or after 2106-02-07 06:28:15 UTC will fail. |
| 339 |
|
| 340 |
KBUILD_BUILD_USER, KBUILD_BUILD_HOST |
| 341 |
------------------------------------ |
| 342 |
These two variables allow to override the user@host string displayed during |
| 343 |
boot and in /proc/version. The default value is the output of the commands |
| 344 |
whoami and host, respectively. |
| 345 |
|
| 346 |
LLVM |
| 347 |
---- |
| 348 |
If this variable is set to 1, Kbuild will use Clang and LLVM utilities instead |
| 349 |
of GCC and GNU binutils to build the kernel. |