summaryrefslogtreecommitdiffstats
path: root/Documentation/kbuild/kbuild.rst
blob: f1e5dce86af7cfe586cb2b751c8d4801cc810155 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
======
Kbuild
======


Output files
============

modules.order
-------------
This file records the order in which modules appear in Makefiles. This
is used by modprobe to deterministically resolve aliases that match
multiple modules.

modules.builtin
---------------
This file lists all modules that are built into the kernel. This is used
by modprobe to not fail when trying to load something builtin.

modules.builtin.modinfo
-----------------------
This file contains modinfo from all modules that are built into the kernel.
Unlike modinfo of a separate module, all fields are prefixed with module name.


Environment variables
=====================

KCPPFLAGS
---------
Additional options to pass when preprocessing. The preprocessing options
will be used in all cases where kbuild does preprocessing including
building C files and assembler files.

KAFLAGS
-------
Additional options to the assembler (for built-in and modules).

AFLAGS_MODULE
-------------
Additional assembler options for modules.

AFLAGS_KERNEL
-------------
Additional assembler options for built-in.

KCFLAGS
-------
Additional options to the C compiler (for built-in and modules).

CFLAGS_KERNEL
-------------
Additional options for $(CC) when used to compile
code that is compiled as built-in.

CFLAGS_MODULE
-------------
Additional module specific options to use for $(CC).

LDFLAGS_MODULE
--------------
Additional options used for $(LD) when linking modules.

HOSTCFLAGS
----------
Additional flags to be passed to $(HOSTCC) when building host programs.

HOSTCXXFLAGS
------------
Additional flags to be passed to $(HOSTCXX) when building host programs.

HOSTLDFLAGS
-----------
Additional flags to be passed when linking host programs.

HOSTLDLIBS
----------
Additional libraries to link against when building host programs.

KBUILD_KCONFIG
--------------
Set the top-level Kconfig file to the value of this environment
variable.  The default name is "Kconfig".

KBUILD_VERBOSE
--------------
Set the kbuild verbosity. Can be assigned same values as "V=...".

See make help for the full list.

Setting "V=..." takes precedence over KBUILD_VERBOSE.

KBUILD_EXTMOD
-------------
Set the directory to look for the kernel source when building external
modules.

Setting "M=..." takes precedence over KBUILD_EXTMOD.

KBUILD_OUTPUT
-------------
Specify the output directory when building the kernel.

The output directory can also be specified using "O=...".

Setting "O=..." takes precedence over KBUILD_OUTPUT.

KBUILD_EXTRA_WARN
-----------------
Specify the extra build checks. The same value can be assigned by passing
W=... from the command line.

See `make help` for the list of the supported values.

Setting "W=..." takes precedence over KBUILD_EXTRA_WARN.

KBUILD_DEBARCH
--------------
For the deb-pkg target, allows overriding the normal heuristics deployed by
deb-pkg. Normally deb-pkg attempts to guess the right architecture based on
the UTS_MACHINE variable, and on some architectures also the kernel config.
The value of KBUILD_DEBARCH is assumed (not checked) to be a valid Debian
architecture.

ARCH
----
Set ARCH to the architecture to be built.

In most cases the name of the architecture is the same as the
directory name found in the arch/ directory.

But some architectures such as x86 and sparc have aliases.

- x86: i386 for 32 bit, x86_64 for 64 bit
- sh: sh for 32 bit, sh64 for 64 bit
- sparc: sparc32 for 32 bit, sparc64 for 64 bit

CROSS_COMPILE
-------------
Specify an optional fixed part of the binutils filename.
CROSS_COMPILE can be a part of the filename or the full path.

CROSS_COMPILE is also used for ccache in some setups.

CF
--
Additional options for sparse.

CF is often used on the command-line like this::

    make CF=-Wbitwise C=2

INSTALL_PATH
------------
INSTALL_PATH specifies where to place the updated kernel and system map
images. Default is /boot, but you can set it to other values.

INSTALLKERNEL
-------------
Install script called when using "make install".
The default name is "installkernel".

The script will be called with the following arguments:

   - $1 - kernel version
   - $2 - kernel image file
   - $3 - kernel map file
   - $4 - default install path (use root directory if blank)

The implementation of "make install" is architecture specific
and it may differ from the above.

INSTALLKERNEL is provided to enable the possibility to
specify a custom installer when cross compiling a kernel.

MODLIB
------
Specify where to install modules.
The default value is::

     $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE)

The value can be overridden in which case the default value is ignored.

INSTALL_MOD_PATH
----------------
INSTALL_MOD_PATH specifies a prefix to MODLIB for module directory
relocations required by build roots.  This is not defined in the
makefile but the argument can be passed to make if needed.

INSTALL_MOD_STRIP
-----------------
INSTALL_MOD_STRIP, if defined, will cause modules to be
stripped after they are installed.  If INSTALL_MOD_STRIP is '1', then
the default option --strip-debug will be used.  Otherwise,
INSTALL_MOD_STRIP value will be used as the options to the strip command.

INSTALL_HDR_PATH
----------------
INSTALL_HDR_PATH specifies where to install user space headers when
executing "make headers_*".

The default value is::

    $(objtree)/usr

$(objtree) is the directory where output files are saved.
The output directory is often set using "O=..." on the commandline.

The value can be overridden in which case the default value is ignored.

KBUILD_ABS_SRCTREE
--------------------------------------------------
Kbuild uses a relative path to point to the tree when possible. For instance,
when building in the source tree, the source tree path is '.'

Setting this flag requests Kbuild to use absolute path to the source tree.
There are some useful cases to do so, like when generating tag files with
absolute path entries etc.

KBUILD_SIGN_PIN
---------------
This variable allows a passphrase or PIN to be passed to the sign-file
utility when signing kernel modules, if the private key requires such.

KBUILD_MODPOST_WARN
-------------------
KBUILD_MODPOST_WARN can be set to avoid errors in case of undefined
symbols in the final module linking stage. It changes such errors
into warnings.

KBUILD_MODPOST_NOFINAL
----------------------
KBUILD_MODPOST_NOFINAL can be set to skip the final link of modules.
This is solely useful to speed up test compiles.

KBUILD_EXTRA_SYMBOLS
--------------------
For modules that use symbols from other modules.
See more details in modules.txt.

ALLSOURCE_ARCHS
---------------
For tags/TAGS/cscope targets, you can specify more than one arch
to be included in the databases, separated by blank space. E.g.::

    $ make ALLSOURCE_ARCHS="x86 mips arm" tags

To get all available archs you can also specify all. E.g.::

    $ make ALLSOURCE_ARCHS=all tags

KBUILD_BUILD_TIMESTAMP
----------------------
Setting this to a date string overrides the timestamp used in the
UTS_VERSION definition (uname -v in the running kernel). The value has to
be a string that can be passed to date -d. The default value
is the output of the date command at one point during build.

KBUILD_BUILD_USER, KBUILD_BUILD_HOST
------------------------------------
These two variables allow to override the user@host string displayed during
boot and in /proc/version. The default value is the output of the commands
whoami and host, respectively.