Merge tag 'rtc-5.3' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux
[sfrench/cifs-2.6.git] / Documentation / kbuild / kbuild.rst
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
26 Environment variables
27 =====================
28
29 KCPPFLAGS
30 ---------
31 Additional options to pass when preprocessing. The preprocessing options
32 will be used in all cases where kbuild does preprocessing including
33 building C files and assembler files.
34
35 KAFLAGS
36 -------
37 Additional options to the assembler (for built-in and modules).
38
39 AFLAGS_MODULE
40 -------------
41 Additional module specific options to use for $(AS).
42
43 AFLAGS_KERNEL
44 -------------
45 Additional options for $(AS) when used for assembler
46 code for code that is compiled as built-in.
47
48 KCFLAGS
49 -------
50 Additional options to the C compiler (for built-in and modules).
51
52 CFLAGS_KERNEL
53 -------------
54 Additional options for $(CC) when used to compile
55 code that is compiled as built-in.
56
57 CFLAGS_MODULE
58 -------------
59 Additional module specific options to use for $(CC).
60
61 LDFLAGS_MODULE
62 --------------
63 Additional options used for $(LD) when linking modules.
64
65 HOSTCFLAGS
66 ----------
67 Additional flags to be passed to $(HOSTCC) when building host programs.
68
69 HOSTCXXFLAGS
70 ------------
71 Additional flags to be passed to $(HOSTCXX) when building host programs.
72
73 HOSTLDFLAGS
74 -----------
75 Additional flags to be passed when linking host programs.
76
77 HOSTLDLIBS
78 ----------
79 Additional libraries to link against when building host programs.
80
81 KBUILD_KCONFIG
82 --------------
83 Set the top-level Kconfig file to the value of this environment
84 variable.  The default name is "Kconfig".
85
86 KBUILD_VERBOSE
87 --------------
88 Set the kbuild verbosity. Can be assigned same values as "V=...".
89
90 See make help for the full list.
91
92 Setting "V=..." takes precedence over KBUILD_VERBOSE.
93
94 KBUILD_EXTMOD
95 -------------
96 Set the directory to look for the kernel source when building external
97 modules.
98
99 Setting "M=..." takes precedence over KBUILD_EXTMOD.
100
101 KBUILD_OUTPUT
102 -------------
103 Specify the output directory when building the kernel.
104
105 The output directory can also be specified using "O=...".
106
107 Setting "O=..." takes precedence over KBUILD_OUTPUT.
108
109 KBUILD_DEBARCH
110 --------------
111 For the deb-pkg target, allows overriding the normal heuristics deployed by
112 deb-pkg. Normally deb-pkg attempts to guess the right architecture based on
113 the UTS_MACHINE variable, and on some architectures also the kernel config.
114 The value of KBUILD_DEBARCH is assumed (not checked) to be a valid Debian
115 architecture.
116
117 ARCH
118 ----
119 Set ARCH to the architecture to be built.
120
121 In most cases the name of the architecture is the same as the
122 directory name found in the arch/ directory.
123
124 But some architectures such as x86 and sparc have aliases.
125
126 - x86: i386 for 32 bit, x86_64 for 64 bit
127 - sh: sh for 32 bit, sh64 for 64 bit
128 - sparc: sparc32 for 32 bit, sparc64 for 64 bit
129
130 CROSS_COMPILE
131 -------------
132 Specify an optional fixed part of the binutils filename.
133 CROSS_COMPILE can be a part of the filename or the full path.
134
135 CROSS_COMPILE is also used for ccache in some setups.
136
137 CF
138 --
139 Additional options for sparse.
140
141 CF is often used on the command-line like this::
142
143     make CF=-Wbitwise C=2
144
145 INSTALL_PATH
146 ------------
147 INSTALL_PATH specifies where to place the updated kernel and system map
148 images. Default is /boot, but you can set it to other values.
149
150 INSTALLKERNEL
151 -------------
152 Install script called when using "make install".
153 The default name is "installkernel".
154
155 The script will be called with the following arguments:
156
157    - $1 - kernel version
158    - $2 - kernel image file
159    - $3 - kernel map file
160    - $4 - default install path (use root directory if blank)
161
162 The implementation of "make install" is architecture specific
163 and it may differ from the above.
164
165 INSTALLKERNEL is provided to enable the possibility to
166 specify a custom installer when cross compiling a kernel.
167
168 MODLIB
169 ------
170 Specify where to install modules.
171 The default value is::
172
173      $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE)
174
175 The value can be overridden in which case the default value is ignored.
176
177 INSTALL_MOD_PATH
178 ----------------
179 INSTALL_MOD_PATH specifies a prefix to MODLIB for module directory
180 relocations required by build roots.  This is not defined in the
181 makefile but the argument can be passed to make if needed.
182
183 INSTALL_MOD_STRIP
184 -----------------
185 INSTALL_MOD_STRIP, if defined, will cause modules to be
186 stripped after they are installed.  If INSTALL_MOD_STRIP is '1', then
187 the default option --strip-debug will be used.  Otherwise,
188 INSTALL_MOD_STRIP value will be used as the options to the strip command.
189
190 INSTALL_HDR_PATH
191 ----------------
192 INSTALL_HDR_PATH specifies where to install user space headers when
193 executing "make headers_*".
194
195 The default value is::
196
197     $(objtree)/usr
198
199 $(objtree) is the directory where output files are saved.
200 The output directory is often set using "O=..." on the commandline.
201
202 The value can be overridden in which case the default value is ignored.
203
204 KBUILD_ABS_SRCTREE
205 --------------------------------------------------
206 Kbuild uses a relative path to point to the tree when possible. For instance,
207 when building in the source tree, the source tree path is '.'
208
209 Setting this flag requests Kbuild to use absolute path to the source tree.
210 There are some useful cases to do so, like when generating tag files with
211 absolute path entries etc.
212
213 KBUILD_SIGN_PIN
214 ---------------
215 This variable allows a passphrase or PIN to be passed to the sign-file
216 utility when signing kernel modules, if the private key requires such.
217
218 KBUILD_MODPOST_WARN
219 -------------------
220 KBUILD_MODPOST_WARN can be set to avoid errors in case of undefined
221 symbols in the final module linking stage. It changes such errors
222 into warnings.
223
224 KBUILD_MODPOST_NOFINAL
225 ----------------------
226 KBUILD_MODPOST_NOFINAL can be set to skip the final link of modules.
227 This is solely useful to speed up test compiles.
228
229 KBUILD_EXTRA_SYMBOLS
230 --------------------
231 For modules that use symbols from other modules.
232 See more details in modules.txt.
233
234 ALLSOURCE_ARCHS
235 ---------------
236 For tags/TAGS/cscope targets, you can specify more than one arch
237 to be included in the databases, separated by blank space. E.g.::
238
239     $ make ALLSOURCE_ARCHS="x86 mips arm" tags
240
241 To get all available archs you can also specify all. E.g.::
242
243     $ make ALLSOURCE_ARCHS=all tags
244
245 KBUILD_ENABLE_EXTRA_GCC_CHECKS
246 ------------------------------
247 If enabled over the make command line with "W=1", it turns on additional
248 gcc -W... options for more extensive build-time checking.
249
250 KBUILD_BUILD_TIMESTAMP
251 ----------------------
252 Setting this to a date string overrides the timestamp used in the
253 UTS_VERSION definition (uname -v in the running kernel). The value has to
254 be a string that can be passed to date -d. The default value
255 is the output of the date command at one point during build.
256
257 KBUILD_BUILD_USER, KBUILD_BUILD_HOST
258 ------------------------------------
259 These two variables allow to override the user@host string displayed during
260 boot and in /proc/version. The default value is the output of the commands
261 whoami and host, respectively.
262
263 KBUILD_LDS
264 ----------
265 The linker script with full path. Assigned by the top-level Makefile.
266
267 KBUILD_VMLINUX_OBJS
268 -------------------
269 All object files for vmlinux. They are linked to vmlinux in the same
270 order as listed in KBUILD_VMLINUX_OBJS.
271
272 KBUILD_VMLINUX_LIBS
273 -------------------
274 All .a "lib" files for vmlinux. KBUILD_VMLINUX_OBJS and KBUILD_VMLINUX_LIBS
275 together specify all the object files used to link vmlinux.