kbuild.rst 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. ======
  2. Kbuild
  3. ======
  4. Output files
  5. ============
  6. modules.order
  7. -------------
  8. This file records the order in which modules appear in Makefiles. This
  9. is used by modprobe to deterministically resolve aliases that match
  10. multiple modules.
  11. modules.builtin
  12. ---------------
  13. This file lists all modules that are built into the kernel. This is used
  14. by modprobe to not fail when trying to load something builtin.
  15. modules.builtin.modinfo
  16. -----------------------
  17. This file contains modinfo from all modules that are built into the kernel.
  18. Unlike modinfo of a separate module, all fields are prefixed with module name.
  19. Environment variables
  20. =====================
  21. KCPPFLAGS
  22. ---------
  23. Additional options to pass when preprocessing. The preprocessing options
  24. will be used in all cases where kbuild does preprocessing including
  25. building C files and assembler files.
  26. KAFLAGS
  27. -------
  28. Additional options to the assembler (for built-in and modules).
  29. AFLAGS_MODULE
  30. -------------
  31. Additional assembler options for modules.
  32. AFLAGS_KERNEL
  33. -------------
  34. Additional assembler options for built-in.
  35. KCFLAGS
  36. -------
  37. Additional options to the C compiler (for built-in and modules).
  38. KRUSTFLAGS
  39. ----------
  40. Additional options to the Rust compiler (for built-in and modules).
  41. CFLAGS_KERNEL
  42. -------------
  43. Additional options for $(CC) when used to compile
  44. code that is compiled as built-in.
  45. CFLAGS_MODULE
  46. -------------
  47. Additional module specific options to use for $(CC).
  48. RUSTFLAGS_KERNEL
  49. ----------------
  50. Additional options for $(RUSTC) when used to compile
  51. code that is compiled as built-in.
  52. RUSTFLAGS_MODULE
  53. ----------------
  54. Additional module specific options to use for $(RUSTC).
  55. LDFLAGS_MODULE
  56. --------------
  57. Additional options used for $(LD) when linking modules.
  58. HOSTCFLAGS
  59. ----------
  60. Additional flags to be passed to $(HOSTCC) when building host programs.
  61. HOSTCXXFLAGS
  62. ------------
  63. Additional flags to be passed to $(HOSTCXX) when building host programs.
  64. HOSTRUSTFLAGS
  65. -------------
  66. Additional flags to be passed to $(HOSTRUSTC) when building host programs.
  67. HOSTLDFLAGS
  68. -----------
  69. Additional flags to be passed when linking host programs.
  70. HOSTLDLIBS
  71. ----------
  72. Additional libraries to link against when building host programs.
  73. .. _userkbuildflags:
  74. USERCFLAGS
  75. ----------
  76. Additional options used for $(CC) when compiling userprogs.
  77. USERLDFLAGS
  78. -----------
  79. Additional options used for $(LD) when linking userprogs. userprogs are linked
  80. with CC, so $(USERLDFLAGS) should include "-Wl," prefix as applicable.
  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. KBUILD_VERBOSE
  86. --------------
  87. Set the kbuild verbosity. Can be assigned same values as "V=...".
  88. See make help for the full list.
  89. Setting "V=..." takes precedence over KBUILD_VERBOSE.
  90. KBUILD_EXTMOD
  91. -------------
  92. Set the directory to look for the kernel source when building external
  93. modules.
  94. Setting "M=..." takes precedence over KBUILD_EXTMOD.
  95. KBUILD_OUTPUT
  96. -------------
  97. Specify the output directory when building the kernel.
  98. The output directory can also be specified using "O=...".
  99. Setting "O=..." takes precedence over KBUILD_OUTPUT.
  100. KBUILD_EXTRA_WARN
  101. -----------------
  102. Specify the extra build checks. The same value can be assigned by passing
  103. W=... from the command line.
  104. See `make help` for the list of the supported values.
  105. Setting "W=..." takes precedence over KBUILD_EXTRA_WARN.
  106. KBUILD_DEBARCH
  107. --------------
  108. For the deb-pkg target, allows overriding the normal heuristics deployed by
  109. deb-pkg. Normally deb-pkg attempts to guess the right architecture based on
  110. the UTS_MACHINE variable, and on some architectures also the kernel config.
  111. The value of KBUILD_DEBARCH is assumed (not checked) to be a valid Debian
  112. architecture.
  113. ARCH
  114. ----
  115. Set ARCH to the architecture to be built.
  116. In most cases the name of the architecture is the same as the
  117. directory name found in the arch/ directory.
  118. But some architectures such as x86 and sparc have aliases.
  119. - x86: i386 for 32 bit, x86_64 for 64 bit
  120. - sh: sh for 32 bit, sh64 for 64 bit
  121. - sparc: sparc32 for 32 bit, sparc64 for 64 bit
  122. CROSS_COMPILE
  123. -------------
  124. Specify an optional fixed part of the binutils filename.
  125. CROSS_COMPILE can be a part of the filename or the full path.
  126. CROSS_COMPILE is also used for ccache in some setups.
  127. CF
  128. --
  129. Additional options for sparse.
  130. CF is often used on the command-line like this::
  131. make CF=-Wbitwise C=2
  132. INSTALL_PATH
  133. ------------
  134. INSTALL_PATH specifies where to place the updated kernel and system map
  135. images. Default is /boot, but you can set it to other values.
  136. INSTALLKERNEL
  137. -------------
  138. Install script called when using "make install".
  139. The default name is "installkernel".
  140. The script will be called with the following arguments:
  141. - $1 - kernel version
  142. - $2 - kernel image file
  143. - $3 - kernel map file
  144. - $4 - default install path (use root directory if blank)
  145. The implementation of "make install" is architecture specific
  146. and it may differ from the above.
  147. INSTALLKERNEL is provided to enable the possibility to
  148. specify a custom installer when cross compiling a kernel.
  149. MODLIB
  150. ------
  151. Specify where to install modules.
  152. The default value is::
  153. $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE)
  154. The value can be overridden in which case the default value is ignored.
  155. INSTALL_MOD_PATH
  156. ----------------
  157. INSTALL_MOD_PATH specifies a prefix to MODLIB for module directory
  158. relocations required by build roots. This is not defined in the
  159. makefile but the argument can be passed to make if needed.
  160. INSTALL_MOD_STRIP
  161. -----------------
  162. INSTALL_MOD_STRIP, if defined, will cause modules to be
  163. stripped after they are installed. If INSTALL_MOD_STRIP is '1', then
  164. the default option --strip-debug will be used. Otherwise,
  165. INSTALL_MOD_STRIP value will be used as the options to the strip command.
  166. INSTALL_HDR_PATH
  167. ----------------
  168. INSTALL_HDR_PATH specifies where to install user space headers when
  169. executing "make headers_*".
  170. The default value is::
  171. $(objtree)/usr
  172. $(objtree) is the directory where output files are saved.
  173. The output directory is often set using "O=..." on the commandline.
  174. The value can be overridden in which case the default value is ignored.
  175. KBUILD_ABS_SRCTREE
  176. --------------------------------------------------
  177. Kbuild uses a relative path to point to the tree when possible. For instance,
  178. when building in the source tree, the source tree path is '.'
  179. Setting this flag requests Kbuild to use absolute path to the source tree.
  180. There are some useful cases to do so, like when generating tag files with
  181. absolute path entries etc.
  182. KBUILD_SIGN_PIN
  183. ---------------
  184. This variable allows a passphrase or PIN to be passed to the sign-file
  185. utility when signing kernel modules, if the private key requires such.
  186. KBUILD_MODPOST_WARN
  187. -------------------
  188. KBUILD_MODPOST_WARN can be set to avoid errors in case of undefined
  189. symbols in the final module linking stage. It changes such errors
  190. into warnings.
  191. KBUILD_MODPOST_NOFINAL
  192. ----------------------
  193. KBUILD_MODPOST_NOFINAL can be set to skip the final link of modules.
  194. This is solely useful to speed up test compiles.
  195. KBUILD_EXTRA_SYMBOLS
  196. --------------------
  197. For modules that use symbols from other modules.
  198. See more details in modules.rst.
  199. ALLSOURCE_ARCHS
  200. ---------------
  201. For tags/TAGS/cscope targets, you can specify more than one arch
  202. to be included in the databases, separated by blank space. E.g.::
  203. $ make ALLSOURCE_ARCHS="x86 mips arm" tags
  204. To get all available archs you can also specify all. E.g.::
  205. $ make ALLSOURCE_ARCHS=all tags
  206. KBUILD_BUILD_TIMESTAMP
  207. ----------------------
  208. Setting this to a date string overrides the timestamp used in the
  209. UTS_VERSION definition (uname -v in the running kernel). The value has to
  210. be a string that can be passed to date -d. The default value
  211. is the output of the date command at one point during build.
  212. KBUILD_BUILD_USER, KBUILD_BUILD_HOST
  213. ------------------------------------
  214. These two variables allow to override the user@host string displayed during
  215. boot and in /proc/version. The default value is the output of the commands
  216. whoami and host, respectively.
  217. LLVM
  218. ----
  219. If this variable is set to 1, Kbuild will use Clang and LLVM utilities instead
  220. of GCC and GNU binutils to build the kernel.