xbuild.9.txt 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. XBUILD(9)
  2. ========
  3. :doctype: manpage
  4. :man source: X15
  5. :man manual: X15 build system
  6. NAME
  7. ----
  8. xbuild - The kernel build system
  9. DESCRIPTION
  10. -----------
  11. This document describes the build system of the kernel. The build system is
  12. the software used to generate the configuration, to build the kernel, its
  13. documentation, and install generated files.
  14. USAGE
  15. -----
  16. The build system is meant to be used directly from the root directory.
  17. Online help
  18. ~~~~~~~~~~~
  19. In order to obtain online help from the build system, use the following
  20. command :
  21. [source,sh]
  22. --------------------------------------------------------------------------------
  23. $ make help
  24. --------------------------------------------------------------------------------
  25. The output of this command is a list of make targets to use to trigger
  26. specific actions, such as generating the kernel configuration, building
  27. the kernel, or the documentation.
  28. Configuration
  29. ~~~~~~~~~~~~~
  30. Before building the kernel, its configuration must be generated. The current
  31. configuration is stored into a file named .config inside the root directory.
  32. Most configuration targets generate this .config file. Some such as *oldconfig*
  33. reuse an existing .config file placed by the user before invoking the build
  34. system.
  35. Default configurations
  36. ^^^^^^^^^^^^^^^^^^^^^^
  37. A default configuration can be generated with the *defconfig* target. It
  38. selects a default configuration depending on the target architecture. In
  39. addition, each architecture may provide more predefined configurations,
  40. all reported by the online help.
  41. You may create your own default configuration with the *savedefconfig*
  42. target, which creates a file named defconfig inside the root directory.
  43. This file may then be renamed and added to the list of architecture-specific
  44. default configurations.
  45. Cleaning
  46. ~~~~~~~~
  47. The following targets may be used to clean the working tree :
  48. *clean*::
  49. This target removes most generated files, such as the kernel, any object
  50. file used to build the kernel, as well as the generated documentation files.
  51. It ignores the current configuration.
  52. *distclean*::
  53. This target removes all generated files, including the configuration.
  54. Building
  55. ~~~~~~~~
  56. If no target is passed, or if the target is *all* or *x15*, the kernel is
  57. built. There are several ways to influence a build in addition to the
  58. configuration. Builds are incremental, meaning that, when a source file
  59. is modified, the build system only rebuilds files that depend on the
  60. modified source. The build system itself as well as the configuration
  61. are considered global dependencies, so that any modification to either
  62. will make all generated files obsolete.
  63. Parallel builds
  64. ^^^^^^^^^^^^^^^
  65. In order to speed up builds, it is possible to make them parallel. This
  66. only has a real effect if your machine has multiple processors. For example :
  67. [source,sh]
  68. --------------------------------------------------------------------------------
  69. make -j4
  70. --------------------------------------------------------------------------------
  71. If unsure about the value, use the number of available processors.
  72. Verbosity
  73. ^^^^^^^^^
  74. By default, or if the _V_ variable is set to 0, the build is quiet, only
  75. reporting a short name of actions along with their target file. If the _V_
  76. variable is set to 1, the build is verbose, showing all commands with their
  77. arguments.
  78. Compiler and flags
  79. ^^^^^^^^^^^^^^^^^^
  80. In order to make the kernel easy to integrate in meta builders such as
  81. distribution packaging systems, the compiler and its flags may be given
  82. at configuration time through the traditional _CC_ and _CFLAGS_ variables.
  83. For example :
  84. [source,sh]
  85. --------------------------------------------------------------------------------
  86. make i386_defconfig CC=clang CFLAGS="-Os -march=geode"
  87. --------------------------------------------------------------------------------
  88. Out-of-tree builds
  89. ^^^^^^^^^^^^^^^^^^
  90. The kernel may be built outside the working tree. In order to perform such a
  91. build, simply use the -f make option with a path to the root Makefile.
  92. For example :
  93. [source,sh]
  94. --------------------------------------------------------------------------------
  95. mkdir build
  96. cd build
  97. make -f /path/to/x15/Makefile defconfig
  98. make -f /path/to/x15/Makefile -j4 x15
  99. --------------------------------------------------------------------------------
  100. Installation
  101. ^^^^^^^^^^^^
  102. The various *install* targets are used to install the kernel and its
  103. documentation. The installation process can be altered with the _DESTDIR_
  104. and _PREFIX_ variables. The _DESTDIR_ variable is normally empty, but can
  105. be set to the root of a staging directory tree. This is particularly useful
  106. when building images for embedded systems. The _PREFIX_ variable has the
  107. value "/usr/local" by default, and may be changed to another insallation
  108. path relative to _DESTDIR_.
  109. DEVELOPMENT
  110. -----------
  111. Configuration
  112. ~~~~~~~~~~~~~
  113. The configuration part of the build system is known as _kconfig_, originally
  114. imported from the Linux kernel. Description of the format used in Kconfig
  115. files can be found as part of the Linux kernel documentation. Module options
  116. are however not supported.
  117. Makefiles
  118. ~~~~~~~~~
  119. When adding or removing source files to/from the project, the _x15_SOURCES-y_
  120. variable should be updated accordingly. The reason for such a name is that it
  121. makes conditional compilation very easy to achieve. When adding a source file
  122. that should be built only when an option is enabled, use the following syntax :
  123. [source,make]
  124. --------------------------------------------------------------------------------
  125. x15_SOURCES-$(CONFIG_OPTION) += path/to/source.c
  126. --------------------------------------------------------------------------------
  127. SEE
  128. ---
  129. manpage:intro
  130. {the-kconfig-language}