common-usage.txt 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. // -*- mode:doc; -*-
  2. // vim: set syntax=asciidoc:
  3. == Daily use
  4. include::rebuilding-packages.txt[]
  5. === Offline builds
  6. If you intend to do an offline build and just want to download
  7. all sources that you previously selected in the configurator
  8. ('menuconfig', 'nconfig', 'xconfig' or 'gconfig'), then issue:
  9. --------------------
  10. $ make source
  11. --------------------
  12. You can now disconnect or copy the content of your +dl+
  13. directory to the build-host.
  14. === Building out-of-tree
  15. As default, everything built by Buildroot is stored in the directory
  16. +output+ in the Buildroot tree.
  17. Buildroot also supports building out of tree with a syntax similar to
  18. the Linux kernel. To use it, add +O=<directory>+ to the make command
  19. line:
  20. --------------------
  21. $ make O=/tmp/build
  22. --------------------
  23. Or:
  24. --------------------
  25. $ cd /tmp/build; make O=$PWD -C path/to/buildroot
  26. --------------------
  27. All the output files will be located under +/tmp/build+. If the +O+
  28. path does not exist, Buildroot will create it.
  29. *Note:* the +O+ path can be either an absolute or a relative path, but if it's
  30. passed as a relative path, it is important to note that it is interpreted
  31. relative to the main Buildroot source directory, *not* the current working
  32. directory.
  33. When using out-of-tree builds, the Buildroot +.config+ and temporary
  34. files are also stored in the output directory. This means that you can
  35. safely run multiple builds in parallel using the same source tree as
  36. long as they use unique output directories.
  37. For ease of use, Buildroot generates a Makefile wrapper in the output
  38. directory - so after the first run, you no longer need to pass +O=<...>+
  39. and +-C <...>+, simply run (in the output directory):
  40. --------------------
  41. $ make <target>
  42. --------------------
  43. [[env-vars]]
  44. === Environment variables
  45. Buildroot also honors some environment variables, when they are passed
  46. to +make+ or set in the environment:
  47. * +HOSTCXX+, the host C++ compiler to use
  48. * +HOSTCC+, the host C compiler to use
  49. * +UCLIBC_CONFIG_FILE=<path/to/.config>+, path to
  50. the uClibc configuration file, used to compile uClibc, if an
  51. internal toolchain is being built.
  52. +
  53. Note that the uClibc configuration file can also be set from the
  54. configuration interface, so through the Buildroot +.config+ file; this
  55. is the recommended way of setting it.
  56. +
  57. * +BUSYBOX_CONFIG_FILE=<path/to/.config>+, path to
  58. the BusyBox configuration file.
  59. +
  60. Note that the BusyBox configuration file can also be set from the
  61. configuration interface, so through the Buildroot +.config+ file; this
  62. is the recommended way of setting it.
  63. +
  64. * +BR2_DL_DIR+ to override the directory in which
  65. Buildroot stores/retrieves downloaded files
  66. +
  67. Note that the Buildroot download directory can also be set from the
  68. configuration interface, so through the Buildroot +.config+ file; this
  69. is the recommended way of setting it.
  70. * +BR2_GRAPH_ALT+, if set and non-empty, to use an alternate color-scheme in
  71. build-time graphs
  72. * +BR2_GRAPH_OUT+ to set the filetype of generated graphs, either +pdf+ (the
  73. default), or +png+.
  74. * +BR2_GRAPH_DEPS_OPTS+ to pass extra options to the dependency graph; see
  75. xref:graph-depends[] for the accepted options
  76. An example that uses config files located in the toplevel directory and
  77. in your $HOME:
  78. --------------------
  79. $ make UCLIBC_CONFIG_FILE=uClibc.config BUSYBOX_CONFIG_FILE=$HOME/bb.config
  80. --------------------
  81. If you want to use a compiler other than the default +gcc+
  82. or +g+++ for building helper-binaries on your host, then do
  83. --------------------
  84. $ make HOSTCXX=g++-4.3-HEAD HOSTCC=gcc-4.3-HEAD
  85. --------------------
  86. === Dealing efficiently with filesystem images
  87. Filesystem images can get pretty big, depending on the filesystem you choose,
  88. the number of packages, whether you provisioned free space... Yet, some
  89. locations in the filesystems images may just be _empty_ (e.g. a long run of
  90. 'zeroes'); such a file is called a _sparse_ file.
  91. Most tools can handle sparse files efficiently, and will only store or write
  92. those parts of a sparse file that are not empty.
  93. For example:
  94. * +tar+ accepts the +-S+ option to tell it to only store non-zero blocks
  95. of sparse files:
  96. ** +tar cf archive.tar -S [files...]+ will efficiently store sparse files
  97. in a tarball
  98. ** +tar xf archive.tar -S+ will efficiently store sparse files extracted
  99. from a tarball
  100. * +cp+ accepts the +--sparse=WHEN+ option (+WHEN+ is one of +auto+,
  101. +never+ or +always+):
  102. ** +cp --sparse=always source.file dest.file+ will make +dest.file+ a
  103. sparse file if +source.file+ has long runs of zeroes
  104. Other tools may have similar options. Please consult their respective man
  105. pages.
  106. You can use sparse files if you need to store the filesystem images (e.g.
  107. to transfer from one machine to another), or if you need to send them (e.g.
  108. to the Q&A team).
  109. Note however that flashing a filesystem image to a device while using the
  110. sparse mode of +dd+ may result in a broken filesystem (e.g. the block bitmap
  111. of an ext2 filesystem may be corrupted; or, if you have sparse files in
  112. your filesystem, those parts may not be all-zeroes when read back). You
  113. should only use sparse files when handling files on the build machine, not
  114. when transferring them to an actual device that will be used on the target.
  115. === Graphing the dependencies between packages
  116. [[graph-depends]]
  117. One of Buildroot's jobs is to know the dependencies between packages,
  118. and make sure they are built in the right order. These dependencies
  119. can sometimes be quite complicated, and for a given system, it is
  120. often not easy to understand why such or such package was brought into
  121. the build by Buildroot.
  122. In order to help understanding the dependencies, and therefore better
  123. understand what is the role of the different components in your
  124. embedded Linux system, Buildroot is capable of generating dependency
  125. graphs.
  126. To generate a dependency graph of the full system you have compiled,
  127. simply run:
  128. ------------------------
  129. make graph-depends
  130. ------------------------
  131. You will find the generated graph in
  132. +output/graphs/graph-depends.pdf+.
  133. If your system is quite large, the dependency graph may be too complex
  134. and difficult to read. It is therefore possible to generate the
  135. dependency graph just for a given package:
  136. ------------------------
  137. make <pkg>-graph-depends
  138. ------------------------
  139. You will find the generated graph in
  140. +output/graph/<pkg>-graph-depends.pdf+.
  141. Note that the dependency graphs are generated using the +dot+ tool
  142. from the _Graphviz_ project, which you must have installed on your
  143. system to use this feature. In most distributions, it is available as
  144. the +graphviz+ package.
  145. By default, the dependency graphs are generated in the PDF
  146. format. However, by passing the +BR2_GRAPH_OUT+ environment variable, you
  147. can switch to other output formats, such as PNG, PostScript or
  148. SVG. All formats supported by the +-T+ option of the +dot+ tool are
  149. supported.
  150. --------------------------------
  151. BR2_GRAPH_OUT=svg make graph-depends
  152. --------------------------------
  153. The +graph-depends+ behaviour can be controlled by setting options in the
  154. +BR2_GRAPH_DEPS_OPTS+ environment variable. The accepted options are:
  155. * +--depth N+, +-d N+, to limit the dependency depth to +N+ levels. The
  156. default, +0+, means no limit.
  157. --------------------------------
  158. BR2_GRAPH_DEPS_OPTS='-d 3' make graph-depends
  159. --------------------------------
  160. === Graphing the build duration
  161. [[graph-duration]]
  162. When the build of a system takes a long time, it is sometimes useful
  163. to be able to understand which packages are the longest to build, to
  164. see if anything can be done to speed up the build. In order to help
  165. such build time analysis, Buildroot collects the build time of each
  166. step of each package, and allows to generate graphs from this data.
  167. To generate the build time graph after a build, run:
  168. ----------------
  169. make graph-build
  170. ----------------
  171. This will generate a set of files in +output/graphs+ :
  172. * +build.hist-build.pdf+, a histogram of the build time for each
  173. package, ordered in the build order.
  174. * +build.hist-duration.pdf+, a histogram of the build time for each
  175. package, ordered by duration (longest first)
  176. * +build.hist-name.pdf+, a histogram of the build time for each
  177. package, order by package name.
  178. * +build.pie-packages.pdf+, a pie chart of the build time per package
  179. * +build.pie-steps.pdf+, a pie chart of the global time spent in each
  180. step of the packages build process.
  181. This +graph-build+ target requires the Python Matplotlib and Numpy
  182. libraries to be installed (+python-matplotlib+ and +python-numpy+ on
  183. most distributions), and also the +argparse+ module if you're using a
  184. Python version older than 2.7 (+python-argparse+ on most
  185. distributions).
  186. By default, the output format for the graph is PDF, but a different
  187. format can be selected using the +BR2_GRAPH_OUT+ environment variable. The
  188. only other format supported is PNG:
  189. ----------------
  190. BR2_GRAPH_OUT=png make graph-build
  191. ----------------