common-usage.txt 8.4 KB

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