xref: /OK3568_Linux_fs/kernel/Documentation/kbuild/kbuild.rst (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun======
2*4882a593SmuzhiyunKbuild
3*4882a593Smuzhiyun======
4*4882a593Smuzhiyun
5*4882a593Smuzhiyun
6*4882a593SmuzhiyunOutput files
7*4882a593Smuzhiyun============
8*4882a593Smuzhiyun
9*4882a593Smuzhiyunmodules.order
10*4882a593Smuzhiyun-------------
11*4882a593SmuzhiyunThis file records the order in which modules appear in Makefiles. This
12*4882a593Smuzhiyunis used by modprobe to deterministically resolve aliases that match
13*4882a593Smuzhiyunmultiple modules.
14*4882a593Smuzhiyun
15*4882a593Smuzhiyunmodules.builtin
16*4882a593Smuzhiyun---------------
17*4882a593SmuzhiyunThis file lists all modules that are built into the kernel. This is used
18*4882a593Smuzhiyunby modprobe to not fail when trying to load something builtin.
19*4882a593Smuzhiyun
20*4882a593Smuzhiyunmodules.builtin.modinfo
21*4882a593Smuzhiyun-----------------------
22*4882a593SmuzhiyunThis file contains modinfo from all modules that are built into the kernel.
23*4882a593SmuzhiyunUnlike modinfo of a separate module, all fields are prefixed with module name.
24*4882a593Smuzhiyun
25*4882a593Smuzhiyun
26*4882a593SmuzhiyunEnvironment variables
27*4882a593Smuzhiyun=====================
28*4882a593Smuzhiyun
29*4882a593SmuzhiyunKCPPFLAGS
30*4882a593Smuzhiyun---------
31*4882a593SmuzhiyunAdditional options to pass when preprocessing. The preprocessing options
32*4882a593Smuzhiyunwill be used in all cases where kbuild does preprocessing including
33*4882a593Smuzhiyunbuilding C files and assembler files.
34*4882a593Smuzhiyun
35*4882a593SmuzhiyunKAFLAGS
36*4882a593Smuzhiyun-------
37*4882a593SmuzhiyunAdditional options to the assembler (for built-in and modules).
38*4882a593Smuzhiyun
39*4882a593SmuzhiyunAFLAGS_MODULE
40*4882a593Smuzhiyun-------------
41*4882a593SmuzhiyunAdditional assembler options for modules.
42*4882a593Smuzhiyun
43*4882a593SmuzhiyunAFLAGS_KERNEL
44*4882a593Smuzhiyun-------------
45*4882a593SmuzhiyunAdditional assembler options for built-in.
46*4882a593Smuzhiyun
47*4882a593SmuzhiyunKCFLAGS
48*4882a593Smuzhiyun-------
49*4882a593SmuzhiyunAdditional options to the C compiler (for built-in and modules).
50*4882a593Smuzhiyun
51*4882a593SmuzhiyunCFLAGS_KERNEL
52*4882a593Smuzhiyun-------------
53*4882a593SmuzhiyunAdditional options for $(CC) when used to compile
54*4882a593Smuzhiyuncode that is compiled as built-in.
55*4882a593Smuzhiyun
56*4882a593SmuzhiyunCFLAGS_MODULE
57*4882a593Smuzhiyun-------------
58*4882a593SmuzhiyunAdditional module specific options to use for $(CC).
59*4882a593Smuzhiyun
60*4882a593SmuzhiyunLDFLAGS_MODULE
61*4882a593Smuzhiyun--------------
62*4882a593SmuzhiyunAdditional options used for $(LD) when linking modules.
63*4882a593Smuzhiyun
64*4882a593SmuzhiyunHOSTCFLAGS
65*4882a593Smuzhiyun----------
66*4882a593SmuzhiyunAdditional flags to be passed to $(HOSTCC) when building host programs.
67*4882a593Smuzhiyun
68*4882a593SmuzhiyunHOSTCXXFLAGS
69*4882a593Smuzhiyun------------
70*4882a593SmuzhiyunAdditional flags to be passed to $(HOSTCXX) when building host programs.
71*4882a593Smuzhiyun
72*4882a593SmuzhiyunHOSTLDFLAGS
73*4882a593Smuzhiyun-----------
74*4882a593SmuzhiyunAdditional flags to be passed when linking host programs.
75*4882a593Smuzhiyun
76*4882a593SmuzhiyunHOSTLDLIBS
77*4882a593Smuzhiyun----------
78*4882a593SmuzhiyunAdditional libraries to link against when building host programs.
79*4882a593Smuzhiyun
80*4882a593Smuzhiyun.. _userkbuildflags:
81*4882a593Smuzhiyun
82*4882a593SmuzhiyunUSERCFLAGS
83*4882a593Smuzhiyun----------
84*4882a593SmuzhiyunAdditional options used for $(CC) when compiling userprogs.
85*4882a593Smuzhiyun
86*4882a593SmuzhiyunUSERLDFLAGS
87*4882a593Smuzhiyun-----------
88*4882a593SmuzhiyunAdditional options used for $(LD) when linking userprogs. userprogs are linked
89*4882a593Smuzhiyunwith CC, so $(USERLDFLAGS) should include "-Wl," prefix as applicable.
90*4882a593Smuzhiyun
91*4882a593SmuzhiyunKBUILD_KCONFIG
92*4882a593Smuzhiyun--------------
93*4882a593SmuzhiyunSet the top-level Kconfig file to the value of this environment
94*4882a593Smuzhiyunvariable.  The default name is "Kconfig".
95*4882a593Smuzhiyun
96*4882a593SmuzhiyunKBUILD_VERBOSE
97*4882a593Smuzhiyun--------------
98*4882a593SmuzhiyunSet the kbuild verbosity. Can be assigned same values as "V=...".
99*4882a593Smuzhiyun
100*4882a593SmuzhiyunSee make help for the full list.
101*4882a593Smuzhiyun
102*4882a593SmuzhiyunSetting "V=..." takes precedence over KBUILD_VERBOSE.
103*4882a593Smuzhiyun
104*4882a593SmuzhiyunKBUILD_EXTMOD
105*4882a593Smuzhiyun-------------
106*4882a593SmuzhiyunSet the directory to look for the kernel source when building external
107*4882a593Smuzhiyunmodules.
108*4882a593Smuzhiyun
109*4882a593SmuzhiyunSetting "M=..." takes precedence over KBUILD_EXTMOD.
110*4882a593Smuzhiyun
111*4882a593SmuzhiyunKBUILD_OUTPUT
112*4882a593Smuzhiyun-------------
113*4882a593SmuzhiyunSpecify the output directory when building the kernel.
114*4882a593Smuzhiyun
115*4882a593SmuzhiyunThe output directory can also be specified using "O=...".
116*4882a593Smuzhiyun
117*4882a593SmuzhiyunSetting "O=..." takes precedence over KBUILD_OUTPUT.
118*4882a593Smuzhiyun
119*4882a593SmuzhiyunKBUILD_EXTRA_WARN
120*4882a593Smuzhiyun-----------------
121*4882a593SmuzhiyunSpecify the extra build checks. The same value can be assigned by passing
122*4882a593SmuzhiyunW=... from the command line.
123*4882a593Smuzhiyun
124*4882a593SmuzhiyunSee `make help` for the list of the supported values.
125*4882a593Smuzhiyun
126*4882a593SmuzhiyunSetting "W=..." takes precedence over KBUILD_EXTRA_WARN.
127*4882a593Smuzhiyun
128*4882a593SmuzhiyunKBUILD_DEBARCH
129*4882a593Smuzhiyun--------------
130*4882a593SmuzhiyunFor the deb-pkg target, allows overriding the normal heuristics deployed by
131*4882a593Smuzhiyundeb-pkg. Normally deb-pkg attempts to guess the right architecture based on
132*4882a593Smuzhiyunthe UTS_MACHINE variable, and on some architectures also the kernel config.
133*4882a593SmuzhiyunThe value of KBUILD_DEBARCH is assumed (not checked) to be a valid Debian
134*4882a593Smuzhiyunarchitecture.
135*4882a593Smuzhiyun
136*4882a593SmuzhiyunARCH
137*4882a593Smuzhiyun----
138*4882a593SmuzhiyunSet ARCH to the architecture to be built.
139*4882a593Smuzhiyun
140*4882a593SmuzhiyunIn most cases the name of the architecture is the same as the
141*4882a593Smuzhiyundirectory name found in the arch/ directory.
142*4882a593Smuzhiyun
143*4882a593SmuzhiyunBut some architectures such as x86 and sparc have aliases.
144*4882a593Smuzhiyun
145*4882a593Smuzhiyun- x86: i386 for 32 bit, x86_64 for 64 bit
146*4882a593Smuzhiyun- sh: sh for 32 bit, sh64 for 64 bit
147*4882a593Smuzhiyun- sparc: sparc32 for 32 bit, sparc64 for 64 bit
148*4882a593Smuzhiyun
149*4882a593SmuzhiyunCROSS_COMPILE
150*4882a593Smuzhiyun-------------
151*4882a593SmuzhiyunSpecify an optional fixed part of the binutils filename.
152*4882a593SmuzhiyunCROSS_COMPILE can be a part of the filename or the full path.
153*4882a593Smuzhiyun
154*4882a593SmuzhiyunCROSS_COMPILE is also used for ccache in some setups.
155*4882a593Smuzhiyun
156*4882a593SmuzhiyunCF
157*4882a593Smuzhiyun--
158*4882a593SmuzhiyunAdditional options for sparse.
159*4882a593Smuzhiyun
160*4882a593SmuzhiyunCF is often used on the command-line like this::
161*4882a593Smuzhiyun
162*4882a593Smuzhiyun    make CF=-Wbitwise C=2
163*4882a593Smuzhiyun
164*4882a593SmuzhiyunINSTALL_PATH
165*4882a593Smuzhiyun------------
166*4882a593SmuzhiyunINSTALL_PATH specifies where to place the updated kernel and system map
167*4882a593Smuzhiyunimages. Default is /boot, but you can set it to other values.
168*4882a593Smuzhiyun
169*4882a593SmuzhiyunINSTALLKERNEL
170*4882a593Smuzhiyun-------------
171*4882a593SmuzhiyunInstall script called when using "make install".
172*4882a593SmuzhiyunThe default name is "installkernel".
173*4882a593Smuzhiyun
174*4882a593SmuzhiyunThe script will be called with the following arguments:
175*4882a593Smuzhiyun
176*4882a593Smuzhiyun   - $1 - kernel version
177*4882a593Smuzhiyun   - $2 - kernel image file
178*4882a593Smuzhiyun   - $3 - kernel map file
179*4882a593Smuzhiyun   - $4 - default install path (use root directory if blank)
180*4882a593Smuzhiyun
181*4882a593SmuzhiyunThe implementation of "make install" is architecture specific
182*4882a593Smuzhiyunand it may differ from the above.
183*4882a593Smuzhiyun
184*4882a593SmuzhiyunINSTALLKERNEL is provided to enable the possibility to
185*4882a593Smuzhiyunspecify a custom installer when cross compiling a kernel.
186*4882a593Smuzhiyun
187*4882a593SmuzhiyunMODLIB
188*4882a593Smuzhiyun------
189*4882a593SmuzhiyunSpecify where to install modules.
190*4882a593SmuzhiyunThe default value is::
191*4882a593Smuzhiyun
192*4882a593Smuzhiyun     $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE)
193*4882a593Smuzhiyun
194*4882a593SmuzhiyunThe value can be overridden in which case the default value is ignored.
195*4882a593Smuzhiyun
196*4882a593SmuzhiyunINSTALL_MOD_PATH
197*4882a593Smuzhiyun----------------
198*4882a593SmuzhiyunINSTALL_MOD_PATH specifies a prefix to MODLIB for module directory
199*4882a593Smuzhiyunrelocations required by build roots.  This is not defined in the
200*4882a593Smuzhiyunmakefile but the argument can be passed to make if needed.
201*4882a593Smuzhiyun
202*4882a593SmuzhiyunINSTALL_MOD_STRIP
203*4882a593Smuzhiyun-----------------
204*4882a593SmuzhiyunINSTALL_MOD_STRIP, if defined, will cause modules to be
205*4882a593Smuzhiyunstripped after they are installed.  If INSTALL_MOD_STRIP is '1', then
206*4882a593Smuzhiyunthe default option --strip-debug will be used.  Otherwise,
207*4882a593SmuzhiyunINSTALL_MOD_STRIP value will be used as the options to the strip command.
208*4882a593Smuzhiyun
209*4882a593SmuzhiyunINSTALL_HDR_PATH
210*4882a593Smuzhiyun----------------
211*4882a593SmuzhiyunINSTALL_HDR_PATH specifies where to install user space headers when
212*4882a593Smuzhiyunexecuting "make headers_*".
213*4882a593Smuzhiyun
214*4882a593SmuzhiyunThe default value is::
215*4882a593Smuzhiyun
216*4882a593Smuzhiyun    $(objtree)/usr
217*4882a593Smuzhiyun
218*4882a593Smuzhiyun$(objtree) is the directory where output files are saved.
219*4882a593SmuzhiyunThe output directory is often set using "O=..." on the commandline.
220*4882a593Smuzhiyun
221*4882a593SmuzhiyunThe value can be overridden in which case the default value is ignored.
222*4882a593Smuzhiyun
223*4882a593SmuzhiyunKBUILD_ABS_SRCTREE
224*4882a593Smuzhiyun--------------------------------------------------
225*4882a593SmuzhiyunKbuild uses a relative path to point to the tree when possible. For instance,
226*4882a593Smuzhiyunwhen building in the source tree, the source tree path is '.'
227*4882a593Smuzhiyun
228*4882a593SmuzhiyunSetting this flag requests Kbuild to use absolute path to the source tree.
229*4882a593SmuzhiyunThere are some useful cases to do so, like when generating tag files with
230*4882a593Smuzhiyunabsolute path entries etc.
231*4882a593Smuzhiyun
232*4882a593SmuzhiyunKBUILD_SIGN_PIN
233*4882a593Smuzhiyun---------------
234*4882a593SmuzhiyunThis variable allows a passphrase or PIN to be passed to the sign-file
235*4882a593Smuzhiyunutility when signing kernel modules, if the private key requires such.
236*4882a593Smuzhiyun
237*4882a593SmuzhiyunKBUILD_MODPOST_WARN
238*4882a593Smuzhiyun-------------------
239*4882a593SmuzhiyunKBUILD_MODPOST_WARN can be set to avoid errors in case of undefined
240*4882a593Smuzhiyunsymbols in the final module linking stage. It changes such errors
241*4882a593Smuzhiyuninto warnings.
242*4882a593Smuzhiyun
243*4882a593SmuzhiyunKBUILD_MODPOST_NOFINAL
244*4882a593Smuzhiyun----------------------
245*4882a593SmuzhiyunKBUILD_MODPOST_NOFINAL can be set to skip the final link of modules.
246*4882a593SmuzhiyunThis is solely useful to speed up test compiles.
247*4882a593Smuzhiyun
248*4882a593SmuzhiyunKBUILD_EXTRA_SYMBOLS
249*4882a593Smuzhiyun--------------------
250*4882a593SmuzhiyunFor modules that use symbols from other modules.
251*4882a593SmuzhiyunSee more details in modules.rst.
252*4882a593Smuzhiyun
253*4882a593SmuzhiyunALLSOURCE_ARCHS
254*4882a593Smuzhiyun---------------
255*4882a593SmuzhiyunFor tags/TAGS/cscope targets, you can specify more than one arch
256*4882a593Smuzhiyunto be included in the databases, separated by blank space. E.g.::
257*4882a593Smuzhiyun
258*4882a593Smuzhiyun    $ make ALLSOURCE_ARCHS="x86 mips arm" tags
259*4882a593Smuzhiyun
260*4882a593SmuzhiyunTo get all available archs you can also specify all. E.g.::
261*4882a593Smuzhiyun
262*4882a593Smuzhiyun    $ make ALLSOURCE_ARCHS=all tags
263*4882a593Smuzhiyun
264*4882a593SmuzhiyunKBUILD_BUILD_TIMESTAMP
265*4882a593Smuzhiyun----------------------
266*4882a593SmuzhiyunSetting this to a date string overrides the timestamp used in the
267*4882a593SmuzhiyunUTS_VERSION definition (uname -v in the running kernel). The value has to
268*4882a593Smuzhiyunbe a string that can be passed to date -d. The default value
269*4882a593Smuzhiyunis the output of the date command at one point during build.
270*4882a593Smuzhiyun
271*4882a593SmuzhiyunKBUILD_BUILD_USER, KBUILD_BUILD_HOST
272*4882a593Smuzhiyun------------------------------------
273*4882a593SmuzhiyunThese two variables allow to override the user@host string displayed during
274*4882a593Smuzhiyunboot and in /proc/version. The default value is the output of the commands
275*4882a593Smuzhiyunwhoami and host, respectively.
276*4882a593Smuzhiyun
277*4882a593SmuzhiyunLLVM
278*4882a593Smuzhiyun----
279*4882a593SmuzhiyunIf this variable is set to 1, Kbuild will use Clang and LLVM utilities instead
280*4882a593Smuzhiyunof GCC and GNU binutils to build the kernel.
281