common-usage.txt 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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+.
  31. When using out-of-tree builds, the Buildroot +.config+ and temporary
  32. files are also stored in the output directory. This means that you can
  33. safely run multiple builds in parallel using the same source tree as
  34. long as they use unique output directories.
  35. For ease of use, Buildroot generates a Makefile wrapper in the output
  36. directory - so after the first run, you no longer need to pass +O=..+
  37. and +-C ..+, simply run (in the output directory):
  38. --------------------
  39. $ make <target>
  40. --------------------
  41. [[env-vars]]
  42. Environment variables
  43. ~~~~~~~~~~~~~~~~~~~~~
  44. Buildroot also honors some environment variables, when they are passed
  45. to +make+ or set in the environment:
  46. * +HOSTCXX+, the host C++ compiler to use
  47. * +HOSTCC+, the host C compiler to use
  48. * +UCLIBC_CONFIG_FILE=<path/to/.config>+, path to
  49. the uClibc configuration file, used to compile uClibc, if an
  50. internal toolchain is being built.
  51. +
  52. Note that the uClibc configuration file can also be set from the
  53. configuration interface, so through the Buildroot +.config+ file; this
  54. is the recommended way of setting it.
  55. +
  56. * +BUSYBOX_CONFIG_FILE=<path/to/.config>+, path to
  57. the Busybox configuration file.
  58. +
  59. Note that the Busybox configuration file can also be set from the
  60. configuration interface, so through the Buildroot +.config+ file; this
  61. is the recommended way of setting it.
  62. +
  63. * +BR2_DL_DIR+ to override the directory in which
  64. Buildroot stores/retrieves downloaded files
  65. +
  66. Note that the Buildroot download directory can also be set from the
  67. configuration interface, so through the Buildroot +.config+ file; this
  68. is the recommended way of setting it.
  69. * +GRAPH_ALT+, if set and non-empty, to use an alternate color-scheme in
  70. build-time graphs
  71. * +GRAPH_OUT+ to set the filetype of generated graphs, either +pdf+ (the
  72. default), or +png+.
  73. An example that uses config files located in the toplevel directory and
  74. in your $HOME:
  75. --------------------
  76. $ make UCLIBC_CONFIG_FILE=uClibc.config BUSYBOX_CONFIG_FILE=$HOME/bb.config
  77. --------------------
  78. If you want to use a compiler other than the default +gcc+
  79. or +g+++ for building helper-binaries on your host, then do
  80. --------------------
  81. $ make HOSTCXX=g++-4.3-HEAD HOSTCC=gcc-4.3-HEAD
  82. --------------------
  83. Dealing efficiently with filesystem images
  84. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  85. Filesystem images can get pretty big, depending on the filesystem you choose,
  86. the number of packages, whether you provisioned free space... Yet, some
  87. locations in the filesystems images may just be _empty_ (eg. a long run of
  88. 'zeroes'); such a file is called a _sparse_ file.
  89. Most tools can handle sparse files efficiently, and will only store or write
  90. those parts of a sparse file that are not empty.
  91. For example:
  92. * +tar+ accepts the +-S+ option to tell it to only store non-zero blocks
  93. of sparse files:
  94. ** +tar cf archive.tar -S [files...]+ will efficiently store sparse files
  95. in a tarball
  96. ** +tar xf archive.tar -S+ will efficiently store sparse files extracted
  97. from a tarball
  98. * +cp+ accepts the +--sparse=WHEN+ option (+WHEN+ is one of +auto+,
  99. +never+ or +always+):
  100. ** +cp --sparse=always source.file dest.file+ will make +dest.file+ a
  101. sparse file if +source.file+ has long runs of zeroes
  102. Other tools may have similar options. Please consult their respective man
  103. pages.
  104. You can use sparse files if you need to store the filesystem images (eg.
  105. to transfer from one machine to another), of if you need to send them (eg.
  106. to the Q&A team).
  107. Note however that flashing a filesystem image to a device while using the
  108. sparse mode of +dd+ may result in a broken filesystem (eg. the block bitmap
  109. of an ext2 filesystem may be corrupted; or, if you have sparse files in
  110. your filesystem, those parts may not be all-zeroes when read back). You
  111. should only use sparse files when handling files on the build machine, not
  112. when transferring them to an actual device that will be used on the target.