2 // vim: set syntax=asciidoc:
4 == General Buildroot usage
6 include::make-tips.txt[]
8 include::rebuilding-packages.txt[]
12 If you intend to do an offline build and just want to download
13 all sources that you previously selected in the configurator
14 ('menuconfig', 'nconfig', 'xconfig' or 'gconfig'), then issue:
20 You can now disconnect or copy the content of your +dl+
21 directory to the build-host.
23 === Building out-of-tree
25 As default, everything built by Buildroot is stored in the directory
26 +output+ in the Buildroot tree.
28 Buildroot also supports building out of tree with a syntax similar to
29 the Linux kernel. To use it, add +O=<directory>+ to the make command
39 $ cd /tmp/build; make O=$PWD -C path/to/buildroot
42 All the output files will be located under +/tmp/build+. If the +O+
43 path does not exist, Buildroot will create it.
45 *Note:* the +O+ path can be either an absolute or a relative path, but if it's
46 passed as a relative path, it is important to note that it is interpreted
47 relative to the main Buildroot source directory, *not* the current working
50 When using out-of-tree builds, the Buildroot +.config+ and temporary
51 files are also stored in the output directory. This means that you can
52 safely run multiple builds in parallel using the same source tree as
53 long as they use unique output directories.
55 For ease of use, Buildroot generates a Makefile wrapper in the output
56 directory - so after the first run, you no longer need to pass +O=<...>+
57 and +-C <...>+, simply run (in the output directory):
65 === Environment variables
67 Buildroot also honors some environment variables, when they are passed
68 to +make+ or set in the environment:
70 * +HOSTCXX+, the host C++ compiler to use
71 * +HOSTCC+, the host C compiler to use
72 * +UCLIBC_CONFIG_FILE=<path/to/.config>+, path to
73 the uClibc configuration file, used to compile uClibc, if an
74 internal toolchain is being built.
76 Note that the uClibc configuration file can also be set from the
77 configuration interface, so through the Buildroot +.config+ file; this
78 is the recommended way of setting it.
80 * +BUSYBOX_CONFIG_FILE=<path/to/.config>+, path to
81 the BusyBox configuration file.
83 Note that the BusyBox configuration file can also be set from the
84 configuration interface, so through the Buildroot +.config+ file; this
85 is the recommended way of setting it.
87 * +BR2_CCACHE_DIR+ to override the directory where
88 Buildroot stores the cached files when using ccache.
90 * +BR2_DL_DIR+ to override the directory in which
91 Buildroot stores/retrieves downloaded files
93 Note that the Buildroot download directory can also be set from the
94 configuration interface, so through the Buildroot +.config+ file. See
95 xref:download-location[] for more details on how you can set the download
97 * +BR2_GRAPH_ALT+, if set and non-empty, to use an alternate color-scheme in
99 * +BR2_GRAPH_OUT+ to set the filetype of generated graphs, either +pdf+ (the
101 * +BR2_GRAPH_DEPS_OPTS+ to pass extra options to the dependency graph; see
102 xref:graph-depends[] for the accepted options
103 * +BR2_GRAPH_DOT_OPTS+ is passed verbatim as options to the +dot+ utility to
104 draw the dependency graph.
106 An example that uses config files located in the toplevel directory and
110 $ make UCLIBC_CONFIG_FILE=uClibc.config BUSYBOX_CONFIG_FILE=$HOME/bb.config
113 If you want to use a compiler other than the default +gcc+
114 or +g+++ for building helper-binaries on your host, then do
117 $ make HOSTCXX=g++-4.3-HEAD HOSTCC=gcc-4.3-HEAD
120 === Dealing efficiently with filesystem images
122 Filesystem images can get pretty big, depending on the filesystem you choose,
123 the number of packages, whether you provisioned free space... Yet, some
124 locations in the filesystems images may just be _empty_ (e.g. a long run of
125 'zeroes'); such a file is called a _sparse_ file.
127 Most tools can handle sparse files efficiently, and will only store or write
128 those parts of a sparse file that are not empty.
132 * +tar+ accepts the +-S+ option to tell it to only store non-zero blocks
134 ** +tar cf archive.tar -S [files...]+ will efficiently store sparse files
136 ** +tar xf archive.tar -S+ will efficiently store sparse files extracted
139 * +cp+ accepts the +--sparse=WHEN+ option (+WHEN+ is one of +auto+,
140 +never+ or +always+):
141 ** +cp --sparse=always source.file dest.file+ will make +dest.file+ a
142 sparse file if +source.file+ has long runs of zeroes
144 Other tools may have similar options. Please consult their respective man
147 You can use sparse files if you need to store the filesystem images (e.g.
148 to transfer from one machine to another), or if you need to send them (e.g.
151 Note however that flashing a filesystem image to a device while using the
152 sparse mode of +dd+ may result in a broken filesystem (e.g. the block bitmap
153 of an ext2 filesystem may be corrupted; or, if you have sparse files in
154 your filesystem, those parts may not be all-zeroes when read back). You
155 should only use sparse files when handling files on the build machine, not
156 when transferring them to an actual device that will be used on the target.
158 === Graphing the dependencies between packages
162 One of Buildroot's jobs is to know the dependencies between packages,
163 and make sure they are built in the right order. These dependencies
164 can sometimes be quite complicated, and for a given system, it is
165 often not easy to understand why such or such package was brought into
166 the build by Buildroot.
168 In order to help understanding the dependencies, and therefore better
169 understand what is the role of the different components in your
170 embedded Linux system, Buildroot is capable of generating dependency
173 To generate a dependency graph of the full system you have compiled,
176 ------------------------
178 ------------------------
180 You will find the generated graph in
181 +output/graphs/graph-depends.pdf+.
183 If your system is quite large, the dependency graph may be too complex
184 and difficult to read. It is therefore possible to generate the
185 dependency graph just for a given package:
187 ------------------------
188 make <pkg>-graph-depends
189 ------------------------
191 You will find the generated graph in
192 +output/graph/<pkg>-graph-depends.pdf+.
194 Note that the dependency graphs are generated using the +dot+ tool
195 from the _Graphviz_ project, which you must have installed on your
196 system to use this feature. In most distributions, it is available as
197 the +graphviz+ package.
199 By default, the dependency graphs are generated in the PDF
200 format. However, by passing the +BR2_GRAPH_OUT+ environment variable, you
201 can switch to other output formats, such as PNG, PostScript or
202 SVG. All formats supported by the +-T+ option of the +dot+ tool are
205 --------------------------------
206 BR2_GRAPH_OUT=svg make graph-depends
207 --------------------------------
209 The +graph-depends+ behaviour can be controlled by setting options in the
210 +BR2_GRAPH_DEPS_OPTS+ environment variable. The accepted options are:
212 * +--depth N+, +-d N+, to limit the dependency depth to +N+ levels. The
213 default, +0+, means no limit.
215 * +--stop-on PKG+, +-s PKG+, to stop the graph on the package +PKG+.
216 +PKG+ can be an actual package name, a glob, the keyword 'virtual'
217 (to stop on virtual packages), or the keyword 'host' (to stop on
218 host packages). The package is still present on the graph, but its
219 dependencies are not.
221 * +--exclude PKG+, +-x PKG+, like +--stop-on+, but also omits +PKG+ from
224 * +--transitive+, +--no-transitive+, to draw (or not) the transitive
225 dependencies. The default is to not draw transitive dependencies.
227 * +--colours R,T,H+, the comma-separated list of colours to draw the
228 root package (+R+), the target packages (+T+) and the host packages
229 (+H+). Defaults to: +lightblue,grey,gainsboro+
231 --------------------------------
232 BR2_GRAPH_DEPS_OPTS='-d 3 --no-transitive --colours=red,green,blue' make graph-depends
233 --------------------------------
235 === Graphing the build duration
239 When the build of a system takes a long time, it is sometimes useful
240 to be able to understand which packages are the longest to build, to
241 see if anything can be done to speed up the build. In order to help
242 such build time analysis, Buildroot collects the build time of each
243 step of each package, and allows to generate graphs from this data.
245 To generate the build time graph after a build, run:
251 This will generate a set of files in +output/graphs+ :
253 * +build.hist-build.pdf+, a histogram of the build time for each
254 package, ordered in the build order.
256 * +build.hist-duration.pdf+, a histogram of the build time for each
257 package, ordered by duration (longest first)
259 * +build.hist-name.pdf+, a histogram of the build time for each
260 package, order by package name.
262 * +build.pie-packages.pdf+, a pie chart of the build time per package
264 * +build.pie-steps.pdf+, a pie chart of the global time spent in each
265 step of the packages build process.
267 This +graph-build+ target requires the Python Matplotlib and Numpy
268 libraries to be installed (+python-matplotlib+ and +python-numpy+ on
269 most distributions), and also the +argparse+ module if you're using a
270 Python version older than 2.7 (+python-argparse+ on most
273 By default, the output format for the graph is PDF, but a different
274 format can be selected using the +BR2_GRAPH_OUT+ environment variable. The
275 only other format supported is PNG:
278 BR2_GRAPH_OUT=png make graph-build
281 === Graphing the filesystem size contribution of packages
283 When your target system grows, it is sometimes useful to understand
284 how much each Buildroot package is contributing to the overall root
285 filesystem size. To help with such an analysis, Buildroot collects
286 data about files installed by each package and using this data,
287 generates a graph and CSV files detailing the size contribution of
288 the different packages.
290 To generate these data after a build, run:
298 * +output/graphs/graph-size.pdf+, a pie chart of the contribution of
299 each package to the overall root filesystem size
301 * +output/graphs/package-size-stats.csv+, a CSV file giving the size
302 contribution of each package to the overall root filesystem size
304 * +output/graphs/file-size-stats.csv+, a CSV file giving the size
305 contribution of each installed file to the package it belongs, and
306 to the overall filesystem size.
308 This +graph-size+ target requires the Python Matplotlib library to be
309 installed (+python-matplotlib+ on most distributions), and also the
310 +argparse+ module if you're using a Python version older than 2.7
311 (+python-argparse+ on most distributions).
313 Just like for the duration graph, a +BR2_GRAPH_OUT+ environment is
314 supported to adjust the output file format. See xref:graph-depends[]
315 for details about this environment variable.
318 The collected filesystem size data is only meaningful after a complete
319 clean rebuild. Be sure to run +make clean all+ before using +make
322 To compare the root filesystem size of two different Buildroot compilations,
323 for example after adjusting the configuration or when switching to another
324 Buildroot release, use the +size-stats-compare+ script. It takes two
325 +file-size-stats.csv+ files (produced by +make graph-size+) as input.
326 Refer to the help text of this script for more details:
329 support/scripts/size-stats-compare -h
332 include::eclipse-integration.txt[]
334 include::advanced.txt[]