blob: 9c8d1d046ea564d9e7f00c2032ac7a67ae039f74 [file] [log] [blame]
Mauro Carvalho Chehabcd238ef2019-06-12 14:52:48 -03001======
2Kbuild
3======
4
5
Michal Marekbc081dd2009-12-07 16:38:33 +01006Output files
Mauro Carvalho Chehabcd238ef2019-06-12 14:52:48 -03007============
Michal Marekbc081dd2009-12-07 16:38:33 +01008
9modules.order
Mauro Carvalho Chehabcd238ef2019-06-12 14:52:48 -030010-------------
Michal Marekbc081dd2009-12-07 16:38:33 +010011This file records the order in which modules appear in Makefiles. This
12is used by modprobe to deterministically resolve aliases that match
13multiple modules.
14
15modules.builtin
Mauro Carvalho Chehabcd238ef2019-06-12 14:52:48 -030016---------------
Michal Marekbc081dd2009-12-07 16:38:33 +010017This file lists all modules that are built into the kernel. This is used
18by modprobe to not fail when trying to load something builtin.
19
Alexey Gladkov898490c2019-04-29 18:11:14 +020020modules.builtin.modinfo
Mauro Carvalho Chehab16886942019-07-09 13:25:51 -030021-----------------------
Alexey Gladkov898490c2019-04-29 18:11:14 +020022This file contains modinfo from all modules that are built into the kernel.
23Unlike modinfo of a separate module, all fields are prefixed with module name.
24
Michal Marekbc081dd2009-12-07 16:38:33 +010025
Sam Ravnborgacc08b52008-12-29 13:45:52 +010026Environment variables
Mauro Carvalho Chehabcd238ef2019-06-12 14:52:48 -030027=====================
Sam Ravnborgacc08b52008-12-29 13:45:52 +010028
29KCPPFLAGS
Mauro Carvalho Chehabcd238ef2019-06-12 14:52:48 -030030---------
Sam Ravnborgacc08b52008-12-29 13:45:52 +010031Additional options to pass when preprocessing. The preprocessing options
Randy Dunlapdf291fa2009-01-08 10:59:34 -080032will be used in all cases where kbuild does preprocessing including
Sam Ravnborgacc08b52008-12-29 13:45:52 +010033building C files and assembler files.
34
35KAFLAGS
Mauro Carvalho Chehabcd238ef2019-06-12 14:52:48 -030036-------
Sam Ravnborg65881692010-07-28 17:33:09 +020037Additional options to the assembler (for built-in and modules).
38
39AFLAGS_MODULE
Mauro Carvalho Chehabcd238ef2019-06-12 14:52:48 -030040-------------
Masahiro Yamada5ef87262019-07-13 11:45:58 +090041Additional assembler options for modules.
Sam Ravnborgacc08b52008-12-29 13:45:52 +010042
Sam Ravnborg80c00ba2010-07-28 19:11:27 +020043AFLAGS_KERNEL
Mauro Carvalho Chehabcd238ef2019-06-12 14:52:48 -030044-------------
Masahiro Yamada5ef87262019-07-13 11:45:58 +090045Additional assembler options for built-in.
Sam Ravnborgacc08b52008-12-29 13:45:52 +010046
47KCFLAGS
Mauro Carvalho Chehabcd238ef2019-06-12 14:52:48 -030048-------
Sam Ravnborg65881692010-07-28 17:33:09 +020049Additional options to the C compiler (for built-in and modules).
50
Miguel Ojedad07479b2021-07-03 17:23:16 +020051KRUSTFLAGS
52----------
53Additional options to the Rust compiler (for built-in and modules).
54
Sam Ravnborg80c00ba2010-07-28 19:11:27 +020055CFLAGS_KERNEL
Mauro Carvalho Chehabcd238ef2019-06-12 14:52:48 -030056-------------
Lucas De Marchi25985ed2011-03-30 22:57:33 -030057Additional options for $(CC) when used to compile
Sam Ravnborg80c00ba2010-07-28 19:11:27 +020058code that is compiled as built-in.
59
Sam Ravnborg65881692010-07-28 17:33:09 +020060CFLAGS_MODULE
Mauro Carvalho Chehabcd238ef2019-06-12 14:52:48 -030061-------------
Lucas De Marchi25985ed2011-03-30 22:57:33 -030062Additional module specific options to use for $(CC).
Sam Ravnborg65881692010-07-28 17:33:09 +020063
Miguel Ojedad07479b2021-07-03 17:23:16 +020064RUSTFLAGS_KERNEL
65----------------
66Additional options for $(RUSTC) when used to compile
67code that is compiled as built-in.
68
69RUSTFLAGS_MODULE
70----------------
71Additional module specific options to use for $(RUSTC).
72
Sam Ravnborg65881692010-07-28 17:33:09 +020073LDFLAGS_MODULE
Mauro Carvalho Chehabcd238ef2019-06-12 14:52:48 -030074--------------
Sam Ravnborg65881692010-07-28 17:33:09 +020075Additional options used for $(LD) when linking modules.
Sam Ravnborgacc08b52008-12-29 13:45:52 +010076
Laura Abbottf92d19e2018-07-09 17:46:02 -070077HOSTCFLAGS
Mauro Carvalho Chehabcd238ef2019-06-12 14:52:48 -030078----------
Laura Abbottf92d19e2018-07-09 17:46:02 -070079Additional flags to be passed to $(HOSTCC) when building host programs.
80
81HOSTCXXFLAGS
Mauro Carvalho Chehabcd238ef2019-06-12 14:52:48 -030082------------
Laura Abbottf92d19e2018-07-09 17:46:02 -070083Additional flags to be passed to $(HOSTCXX) when building host programs.
84
Miguel Ojedad07479b2021-07-03 17:23:16 +020085HOSTRUSTFLAGS
86-------------
87Additional flags to be passed to $(HOSTRUSTC) when building host programs.
88
Laura Abbottf92d19e2018-07-09 17:46:02 -070089HOSTLDFLAGS
Mauro Carvalho Chehabcd238ef2019-06-12 14:52:48 -030090-----------
Laura Abbottf92d19e2018-07-09 17:46:02 -070091Additional flags to be passed when linking host programs.
92
93HOSTLDLIBS
Mauro Carvalho Chehabcd238ef2019-06-12 14:52:48 -030094----------
Laura Abbottf92d19e2018-07-09 17:46:02 -070095Additional libraries to link against when building host programs.
96
Elliot Bermanf67695c92022-02-01 13:35:42 -080097.. _userkbuildflags:
98
99USERCFLAGS
100----------
101Additional options used for $(CC) when compiling userprogs.
102
103USERLDFLAGS
104-----------
105Additional options used for $(LD) when linking userprogs. userprogs are linked
106with CC, so $(USERLDFLAGS) should include "-Wl," prefix as applicable.
107
Randy Dunlap00e07932018-07-04 19:47:39 -0700108KBUILD_KCONFIG
Mauro Carvalho Chehabcd238ef2019-06-12 14:52:48 -0300109--------------
Randy Dunlap00e07932018-07-04 19:47:39 -0700110Set the top-level Kconfig file to the value of this environment
111variable. The default name is "Kconfig".
112
Sam Ravnborgacc08b52008-12-29 13:45:52 +0100113KBUILD_VERBOSE
Mauro Carvalho Chehabcd238ef2019-06-12 14:52:48 -0300114--------------
Randy Dunlapdf291fa2009-01-08 10:59:34 -0800115Set the kbuild verbosity. Can be assigned same values as "V=...".
Mauro Carvalho Chehabcd238ef2019-06-12 14:52:48 -0300116
Sam Ravnborgacc08b52008-12-29 13:45:52 +0100117See make help for the full list.
Mauro Carvalho Chehabcd238ef2019-06-12 14:52:48 -0300118
Sam Ravnborgacc08b52008-12-29 13:45:52 +0100119Setting "V=..." takes precedence over KBUILD_VERBOSE.
120
121KBUILD_EXTMOD
Mauro Carvalho Chehabcd238ef2019-06-12 14:52:48 -0300122-------------
Sam Ravnborgacc08b52008-12-29 13:45:52 +0100123Set the directory to look for the kernel source when building external
124modules.
Mauro Carvalho Chehabcd238ef2019-06-12 14:52:48 -0300125
Masahiro Yamada0126be32018-11-21 00:04:18 +0900126Setting "M=..." takes precedence over KBUILD_EXTMOD.
Sam Ravnborgacc08b52008-12-29 13:45:52 +0100127
128KBUILD_OUTPUT
Mauro Carvalho Chehabcd238ef2019-06-12 14:52:48 -0300129-------------
Sam Ravnborgacc08b52008-12-29 13:45:52 +0100130Specify the output directory when building the kernel.
Mauro Carvalho Chehabcd238ef2019-06-12 14:52:48 -0300131
Nicolas Kaiserc95940f2010-08-05 11:23:11 -0700132The output directory can also be specified using "O=...".
Mauro Carvalho Chehabcd238ef2019-06-12 14:52:48 -0300133
Randy Dunlapdf291fa2009-01-08 10:59:34 -0800134Setting "O=..." takes precedence over KBUILD_OUTPUT.
Sam Ravnborgacc08b52008-12-29 13:45:52 +0100135
Masahiro Yamadae27128d2019-09-01 01:25:55 +0900136KBUILD_EXTRA_WARN
137-----------------
138Specify the extra build checks. The same value can be assigned by passing
139W=... from the command line.
140
141See `make help` for the list of the supported values.
142
143Setting "W=..." takes precedence over KBUILD_EXTRA_WARN.
144
Asbjoern Sloth Toennesen55f88ec2010-12-12 17:39:40 +0000145KBUILD_DEBARCH
Mauro Carvalho Chehabcd238ef2019-06-12 14:52:48 -0300146--------------
Asbjoern Sloth Toennesen55f88ec2010-12-12 17:39:40 +0000147For the deb-pkg target, allows overriding the normal heuristics deployed by
148deb-pkg. Normally deb-pkg attempts to guess the right architecture based on
149the UTS_MACHINE variable, and on some architectures also the kernel config.
150The value of KBUILD_DEBARCH is assumed (not checked) to be a valid Debian
151architecture.
152
Johannes Berg56b0f452023-06-09 10:46:41 +0200153KDOCFLAGS
154---------
155Specify extra (warning/error) flags for kernel-doc checks during the build,
156see scripts/kernel-doc for which flags are supported. Note that this doesn't
157(currently) apply to documentation builds.
158
Sam Ravnborgacc08b52008-12-29 13:45:52 +0100159ARCH
Mauro Carvalho Chehabcd238ef2019-06-12 14:52:48 -0300160----
Sam Ravnborgacc08b52008-12-29 13:45:52 +0100161Set ARCH to the architecture to be built.
Mauro Carvalho Chehabcd238ef2019-06-12 14:52:48 -0300162
Sam Ravnborgacc08b52008-12-29 13:45:52 +0100163In most cases the name of the architecture is the same as the
164directory name found in the arch/ directory.
Mauro Carvalho Chehabcd238ef2019-06-12 14:52:48 -0300165
Randy Dunlapdf291fa2009-01-08 10:59:34 -0800166But some architectures such as x86 and sparc have aliases.
Mauro Carvalho Chehabcd238ef2019-06-12 14:52:48 -0300167
168- x86: i386 for 32 bit, x86_64 for 64 bit
Randy Dunlape0838a92023-02-05 08:37:52 -0800169- parisc: parisc64 for 64 bit
Mauro Carvalho Chehabcd238ef2019-06-12 14:52:48 -0300170- sparc: sparc32 for 32 bit, sparc64 for 64 bit
Sam Ravnborgacc08b52008-12-29 13:45:52 +0100171
172CROSS_COMPILE
Mauro Carvalho Chehabcd238ef2019-06-12 14:52:48 -0300173-------------
Sam Ravnborgacc08b52008-12-29 13:45:52 +0100174Specify an optional fixed part of the binutils filename.
175CROSS_COMPILE can be a part of the filename or the full path.
176
Kirill Smelkove8d400a2010-02-17 11:45:33 +0300177CROSS_COMPILE is also used for ccache in some setups.
Sam Ravnborgacc08b52008-12-29 13:45:52 +0100178
179CF
Mauro Carvalho Chehabcd238ef2019-06-12 14:52:48 -0300180--
Sam Ravnborgacc08b52008-12-29 13:45:52 +0100181Additional options for sparse.
Mauro Carvalho Chehabcd238ef2019-06-12 14:52:48 -0300182
183CF is often used on the command-line like this::
Sam Ravnborgacc08b52008-12-29 13:45:52 +0100184
185 make CF=-Wbitwise C=2
186
187INSTALL_PATH
Mauro Carvalho Chehabcd238ef2019-06-12 14:52:48 -0300188------------
Sam Ravnborgacc08b52008-12-29 13:45:52 +0100189INSTALL_PATH specifies where to place the updated kernel and system map
Randy Dunlapdf291fa2009-01-08 10:59:34 -0800190images. Default is /boot, but you can set it to other values.
Sam Ravnborgacc08b52008-12-29 13:45:52 +0100191
Sam Ravnborgcaa27b62009-07-20 21:37:11 +0200192INSTALLKERNEL
Mauro Carvalho Chehabcd238ef2019-06-12 14:52:48 -0300193-------------
Sam Ravnborgcaa27b62009-07-20 21:37:11 +0200194Install script called when using "make install".
195The default name is "installkernel".
196
197The script will be called with the following arguments:
Mauro Carvalho Chehab16886942019-07-09 13:25:51 -0300198
Mauro Carvalho Chehabcd238ef2019-06-12 14:52:48 -0300199 - $1 - kernel version
200 - $2 - kernel image file
201 - $3 - kernel map file
202 - $4 - default install path (use root directory if blank)
Sam Ravnborgcaa27b62009-07-20 21:37:11 +0200203
Nicolas Kaiserc95940f2010-08-05 11:23:11 -0700204The implementation of "make install" is architecture specific
Sam Ravnborgcaa27b62009-07-20 21:37:11 +0200205and it may differ from the above.
206
207INSTALLKERNEL is provided to enable the possibility to
208specify a custom installer when cross compiling a kernel.
Sam Ravnborgacc08b52008-12-29 13:45:52 +0100209
210MODLIB
Mauro Carvalho Chehabcd238ef2019-06-12 14:52:48 -0300211------
Sam Ravnborgacc08b52008-12-29 13:45:52 +0100212Specify where to install modules.
Mauro Carvalho Chehabcd238ef2019-06-12 14:52:48 -0300213The default value is::
Sam Ravnborgacc08b52008-12-29 13:45:52 +0100214
215 $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE)
216
217The value can be overridden in which case the default value is ignored.
218
219INSTALL_MOD_PATH
Mauro Carvalho Chehabcd238ef2019-06-12 14:52:48 -0300220----------------
Sam Ravnborgacc08b52008-12-29 13:45:52 +0100221INSTALL_MOD_PATH specifies a prefix to MODLIB for module directory
222relocations required by build roots. This is not defined in the
223makefile but the argument can be passed to make if needed.
224
225INSTALL_MOD_STRIP
Mauro Carvalho Chehabcd238ef2019-06-12 14:52:48 -0300226-----------------
Sam Ravnborgacc08b52008-12-29 13:45:52 +0100227INSTALL_MOD_STRIP, if defined, will cause modules to be
228stripped after they are installed. If INSTALL_MOD_STRIP is '1', then
229the default option --strip-debug will be used. Otherwise,
Gilles Espinasse177b2412011-01-09 08:59:49 +0100230INSTALL_MOD_STRIP value will be used as the options to the strip command.
Sam Ravnborgacc08b52008-12-29 13:45:52 +0100231
Sam Ravnborgacc08b52008-12-29 13:45:52 +0100232INSTALL_HDR_PATH
Mauro Carvalho Chehabcd238ef2019-06-12 14:52:48 -0300233----------------
Randy Dunlapdf291fa2009-01-08 10:59:34 -0800234INSTALL_HDR_PATH specifies where to install user space headers when
Sam Ravnborgacc08b52008-12-29 13:45:52 +0100235executing "make headers_*".
Mauro Carvalho Chehabcd238ef2019-06-12 14:52:48 -0300236
237The default value is::
Sam Ravnborgacc08b52008-12-29 13:45:52 +0100238
239 $(objtree)/usr
240
241$(objtree) is the directory where output files are saved.
242The output directory is often set using "O=..." on the commandline.
243
244The value can be overridden in which case the default value is ignored.
245
Ricardo B. Marliere1b627282023-10-12 07:54:21 -0300246INSTALL_DTBS_PATH
247-----------------
248INSTALL_DTBS_PATH specifies where to install device tree blobs for
249relocations required by build roots. This is not defined in the
250makefile but the argument can be passed to make if needed.
251
Linus Torvalds39ceda52019-07-12 16:03:16 -0700252KBUILD_ABS_SRCTREE
253--------------------------------------------------
254Kbuild uses a relative path to point to the tree when possible. For instance,
255when building in the source tree, the source tree path is '.'
256
257Setting this flag requests Kbuild to use absolute path to the source tree.
258There are some useful cases to do so, like when generating tag files with
259absolute path entries etc.
260
David Woodhouseaf1eb292015-07-20 21:16:28 +0100261KBUILD_SIGN_PIN
Mauro Carvalho Chehabcd238ef2019-06-12 14:52:48 -0300262---------------
David Woodhouseaf1eb292015-07-20 21:16:28 +0100263This variable allows a passphrase or PIN to be passed to the sign-file
264utility when signing kernel modules, if the private key requires such.
265
Sam Ravnborgacc08b52008-12-29 13:45:52 +0100266KBUILD_MODPOST_WARN
Mauro Carvalho Chehabcd238ef2019-06-12 14:52:48 -0300267-------------------
Randy Dunlapdf291fa2009-01-08 10:59:34 -0800268KBUILD_MODPOST_WARN can be set to avoid errors in case of undefined
269symbols in the final module linking stage. It changes such errors
270into warnings.
Sam Ravnborgacc08b52008-12-29 13:45:52 +0100271
Randy Dunlapdf291fa2009-01-08 10:59:34 -0800272KBUILD_MODPOST_NOFINAL
Mauro Carvalho Chehabcd238ef2019-06-12 14:52:48 -0300273----------------------
Sam Ravnborgacc08b52008-12-29 13:45:52 +0100274KBUILD_MODPOST_NOFINAL can be set to skip the final link of modules.
Randy Dunlapdf291fa2009-01-08 10:59:34 -0800275This is solely useful to speed up test compiles.
Sam Ravnborgacc08b52008-12-29 13:45:52 +0100276
277KBUILD_EXTRA_SYMBOLS
Mauro Carvalho Chehabcd238ef2019-06-12 14:52:48 -0300278--------------------
Randy Dunlapdf291fa2009-01-08 10:59:34 -0800279For modules that use symbols from other modules.
Masahiro Yamada2eebb7a2020-03-12 07:50:44 +0900280See more details in modules.rst.
Jike Song4f628242009-01-05 14:57:03 +0800281
282ALLSOURCE_ARCHS
Mauro Carvalho Chehabcd238ef2019-06-12 14:52:48 -0300283---------------
Randy Dunlapdf291fa2009-01-08 10:59:34 -0800284For tags/TAGS/cscope targets, you can specify more than one arch
Mauro Carvalho Chehabcd238ef2019-06-12 14:52:48 -0300285to be included in the databases, separated by blank space. E.g.::
Jike Song4f628242009-01-05 14:57:03 +0800286
287 $ make ALLSOURCE_ARCHS="x86 mips arm" tags
John Kacurbc75cc62010-03-02 16:57:52 +0100288
Mauro Carvalho Chehabcd238ef2019-06-12 14:52:48 -0300289To get all available archs you can also specify all. E.g.::
John Kacurbc75cc62010-03-02 16:57:52 +0100290
291 $ make ALLSOURCE_ARCHS=all tags
Borislav Petkov4a5838a2011-03-01 09:35:29 +0100292
Paulo Miguel Almeida40bf2fc2022-12-14 09:26:15 +1300293IGNORE_DIRS
294-----------
295For tags/TAGS/cscope targets, you can choose which directories won't
296be included in the databases, separated by blank space. E.g.::
297
298 $ make IGNORE_DIRS="drivers/gpu/drm/radeon tools" cscope
299
Michal Marek53e68922011-04-05 14:32:30 +0200300KBUILD_BUILD_TIMESTAMP
Mauro Carvalho Chehabcd238ef2019-06-12 14:52:48 -0300301----------------------
Michal Marek53e68922011-04-05 14:32:30 +0200302Setting this to a date string overrides the timestamp used in the
Michal Mareka8b80172011-03-31 23:16:42 +0200303UTS_VERSION definition (uname -v in the running kernel). The value has to
304be a string that can be passed to date -d. The default value
Michal Marek53e68922011-04-05 14:32:30 +0200305is the output of the date command at one point during build.
306
307KBUILD_BUILD_USER, KBUILD_BUILD_HOST
Mauro Carvalho Chehabcd238ef2019-06-12 14:52:48 -0300308------------------------------------
Michal Marek53e68922011-04-05 14:32:30 +0200309These two variables allow to override the user@host string displayed during
310boot and in /proc/version. The default value is the output of the commands
311whoami and host, respectively.
Masahiro Yamadaa0d1c952020-04-08 10:36:23 +0900312
313LLVM
314----
315If this variable is set to 1, Kbuild will use Clang and LLVM utilities instead
316of GCC and GNU binutils to build the kernel.