kbuild.rst 7.7 KB

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