2 // vim: set syntax=asciidoc:
6 First of all, create a directory under the +package+ directory for
7 your software, for example +libfoo+.
9 Some packages have been grouped by topic in a sub-directory:
10 +x11r7+, +qt5+ and +gstreamer+. If your package fits in
11 one of these categories, then create your package directory in these.
12 New subdirectories are discouraged, however.
16 For the package to be displayed in the configuration tool, you need to
17 create a Config file in your package directory. There are two types:
18 +Config.in+ and +Config.in.host+.
22 For packages used on the target, create a file named +Config.in+. This
23 file will contain the option descriptions related to our +libfoo+ software
24 that will be used and displayed in the configuration tool. It should basically
27 ---------------------------
28 config BR2_PACKAGE_LIBFOO
31 This is a comment that explains what libfoo is. The help text
34 http://foosoftware.org/libfoo/
35 ---------------------------
37 The +bool+ line, +help+ line and other metadata information about the
38 configuration option must be indented with one tab. The help text
39 itself should be indented with one tab and two spaces, lines should
40 be wrapped to fit 72 columns, where tab counts for 8, so 62 characters
41 in the text itself. The help text must mention the upstream URL of the
42 project after an empty line.
44 As a convention specific to Buildroot, the ordering of the attributes
47 1. The type of option: +bool+, +string+... with the prompt
48 2. If needed, the +default+ value(s)
49 3. Any dependency of the +depends on+ form
50 4. Any dependency of the +select+ form
51 5. The help keyword and help text.
53 You can add other sub-options into a +if BR2_PACKAGE_LIBFOO...endif+
54 statement to configure particular things in your software. You can look at
55 examples in other packages. The syntax of the +Config.in+ file is the same
56 as the one for the kernel Kconfig file. The documentation for this syntax is
57 available at http://kernel.org/doc/Documentation/kbuild/kconfig-language.txt[]
59 Finally you have to add your new +libfoo/Config.in+ to
60 +package/Config.in+ (or in a category subdirectory if you decided to
61 put your package in one of the existing categories). The files
62 included there are 'sorted alphabetically' per category and are 'NOT'
63 supposed to contain anything but the 'bare' name of the package.
65 --------------------------
66 source "package/libfoo/Config.in"
67 --------------------------
70 ==== +Config.in.host+ file
72 Some packages also need to be built for the host system. There are two
75 * The host package is only required to satisfy build-time
76 dependencies of one or more target packages. In this case, add
77 +host-foo+ to the target package's +BAR_DEPENDENCIES+ variable. No
78 +Config.in.host+ file should be created.
80 * The host package should be explicitly selectable by the user from
81 the configuration menu. In this case, create a +Config.in.host+ file
82 for that host package:
84 ---------------------------
85 config BR2_PACKAGE_HOST_FOO
88 This is a comment that explains what foo for the host is.
90 http://foosoftware.org/foo/
91 ---------------------------
93 The same coding style and options as for the +Config.in+ file are valid.
95 Finally you have to add your new +libfoo/Config.in.host+ to
96 +package/Config.in.host+. The files included there are 'sorted alphabetically'
97 and are 'NOT' supposed to contain anything but the 'bare' name of the package.
99 --------------------------
100 source "package/foo/Config.in.host"
101 --------------------------
103 The host package will then be available from the +Host utilities+ menu.
105 [[depends-on-vs-select]]
106 ==== Choosing +depends on+ or +select+
108 The +Config.in+ file of your package must also ensure that
109 dependencies are enabled. Typically, Buildroot uses the following
112 * Use a +select+ type of dependency for dependencies on
113 libraries. These dependencies are generally not obvious and it
114 therefore make sense to have the kconfig system ensure that the
115 dependencies are selected. For example, the _libgtk2_ package uses
116 +select BR2_PACKAGE_LIBGLIB2+ to make sure this library is also
118 The +select+ keyword expresses the dependency with a backward
121 * Use a +depends on+ type of dependency when the user really needs to
122 be aware of the dependency. Typically, Buildroot uses this type of
123 dependency for dependencies on target architecture, MMU support and
124 toolchain options (see xref:dependencies-target-toolchain-options[]),
125 or for dependencies on "big" things, such as the X.org system.
126 The +depends on+ keyword expresses the dependency with a forward
130 The current problem with the _kconfig_ language is that these two
131 dependency semantics are not internally linked. Therefore, it may be
132 possible to select a package, whom one of its dependencies/requirement
135 An example illustrates both the usage of +select+ and +depends on+.
137 --------------------------
138 config BR2_PACKAGE_RRDTOOL
140 depends on BR2_USE_WCHAR
141 select BR2_PACKAGE_FREETYPE
142 select BR2_PACKAGE_LIBART
143 select BR2_PACKAGE_LIBPNG
144 select BR2_PACKAGE_ZLIB
146 RRDtool is the OpenSource industry standard, high performance
147 data logging and graphing system for time series data.
149 http://oss.oetiker.ch/rrdtool/
151 comment "rrdtool needs a toolchain w/ wchar"
152 depends on !BR2_USE_WCHAR
153 --------------------------
156 Note that these two dependency types are only transitive with the
157 dependencies of the same kind.
159 This means, in the following example:
161 --------------------------
167 depends on BR2_PACKAGE_A
171 depends on BR2_PACKAGE_B
180 --------------------------
182 * Selecting +Package C+ will be visible if +Package B+ has been
183 selected, which in turn is only visible if +Package A+ has been
186 * Selecting +Package E+ will select +Package D+, which will select
187 +Package B+, it will not check for the dependencies of +Package B+,
188 so it will not select +Package A+.
190 * Since +Package B+ is selected but +Package A+ is not, this violates
191 the dependency of +Package B+ on +Package A+. Therefore, in such a
192 situation, the transitive dependency has to be added explicitly:
194 --------------------------
198 depends on BR2_PACKAGE_A
203 depends on BR2_PACKAGE_A
204 --------------------------
206 Overall, for package library dependencies, +select+ should be
209 Note that such dependencies will ensure that the dependency option
210 is also enabled, but not necessarily built before your package. To do
211 so, the dependency also needs to be expressed in the +.mk+ file of the
214 Further formatting details: see xref:writing-rules-config-in[the
217 [[dependencies-target-toolchain-options]]
218 ==== Dependencies on target and toolchain options
220 Many packages depend on certain options of the toolchain: the choice of
221 C library, C++ support, thread support, RPC support, wchar support,
222 or dynamic library support. Some packages can only be built on certain
223 target architectures, or if an MMU is available in the processor.
225 These dependencies have to be expressed with the appropriate 'depends
226 on' statements in the Config.in file. Additionally, for dependencies on
227 toolchain options, a +comment+ should be displayed when the option is
228 not enabled, so that the user knows why the package is not available.
229 Dependencies on target architecture or MMU support should not be
230 made visible in a comment: since it is unlikely that the user can
231 freely choose another target, it makes little sense to show these
232 dependencies explicitly.
234 The +comment+ should only be visible if the +config+ option itself would
235 be visible when the toolchain option dependencies are met. This means
236 that all other dependencies of the package (including dependencies on
237 target architecture and MMU support) have to be repeated on the
238 +comment+ definition. To keep it clear, the +depends on+ statement for
239 these non-toolchain option should be kept separate from the +depends on+
240 statement for the toolchain options.
241 If there is a dependency on a config option in that same file (typically
242 the main package) it is preferable to have a global +if ... endif+
243 construct rather than repeating the +depends on+ statement on the
244 comment and other config options.
246 The general format of a dependency +comment+ for package foo is:
248 --------------------------
249 foo needs a toolchain w/ featA, featB, featC
250 --------------------------
254 --------------------------
255 mpd needs a toolchain w/ C++, threads, wchar
256 --------------------------
260 --------------------------
261 crda needs a toolchain w/ threads
262 --------------------------
264 Note that this text is kept brief on purpose, so that it will fit on a
265 80-character terminal.
267 The rest of this section enumerates the different target and toolchain
268 options, the corresponding config symbols to depend on, and the text to
271 * Target architecture
272 ** Dependency symbol: +BR2_powerpc+, +BR2_mips+, ... (see +arch/Config.in+)
273 ** Comment string: no comment to be added
276 ** Dependency symbol: +BR2_USE_MMU+
277 ** Comment string: no comment to be added
279 * Gcc +__sync_*+ built-ins used for atomic operations. They are
280 available in variants operating on 1 byte, 2 bytes, 4 bytes and 8
281 bytes. Since different architectures support atomic operations on
282 different sizes, one dependency symbol is available for each size:
283 ** Dependency symbol: +BR2_TOOLCHAIN_HAS_SYNC_1+ for 1 byte,
284 +BR2_TOOLCHAIN_HAS_SYNC_2+ for 2 bytes,
285 +BR2_TOOLCHAIN_HAS_SYNC_4+ for 4 bytes, +BR2_TOOLCHAIN_HAS_SYNC_8+
287 ** Comment string: no comment to be added
289 * Gcc +__atomic_*+ built-ins used for atomic operations.
290 ** Dependency symbol: +BR2_TOOLCHAIN_HAS_ATOMIC+.
291 ** Comment string: no comment to be added
294 ** Dependency symbol: +BR2_TOOLCHAIN_HEADERS_AT_LEAST_X_Y+, (replace
295 +X_Y+ with the proper version, see +toolchain/Config.in+)
296 ** Comment string: +headers >= X.Y+ and/or `headers <= X.Y` (replace
297 +X.Y+ with the proper version)
300 ** Dependency symbol: +BR2_TOOLCHAIN_GCC_AT_LEAST_X_Y+, (replace
301 +X_Y+ with the proper version, see +toolchain/Config.in+)
302 ** Comment string: +gcc >= X.Y+ and/or `gcc <= X.Y` (replace
303 +X.Y+ with the proper version)
306 ** Dependency symbol: +BR2_HOST_GCC_AT_LEAST_X_Y+, (replace
307 +X_Y+ with the proper version, see +Config.in+)
308 ** Comment string: no comment to be added
309 ** Note that it is usually not the package itself that has a minimum
310 host GCC version, but rather a host-package on which it depends.
313 ** Dependency symbol: +BR2_TOOLCHAIN_USES_GLIBC+,
314 +BR2_TOOLCHAIN_USES_MUSL+, +BR2_TOOLCHAIN_USES_UCLIBC+
315 ** Comment string: for the C library, a slightly different comment text
316 is used: +foo needs a glibc toolchain+, or `foo needs a glibc
320 ** Dependency symbol: +BR2_INSTALL_LIBSTDCPP+
321 ** Comment string: `C++`
324 ** Dependency symbol: +BR2_TOOLCHAIN_HAS_FORTRAN+
325 ** Comment string: `fortran`
328 ** Dependency symbol: +BR2_TOOLCHAIN_HAS_THREADS+
329 ** Comment string: +threads+ (unless +BR2_TOOLCHAIN_HAS_THREADS_NPTL+
330 is also needed, in which case, specifying only +NPTL+ is sufficient)
332 * NPTL thread support
333 ** Dependency symbol: +BR2_TOOLCHAIN_HAS_THREADS_NPTL+
334 ** Comment string: +NPTL+
337 ** Dependency symbol: +BR2_TOOLCHAIN_HAS_NATIVE_RPC+
338 ** Comment string: +RPC+
341 ** Dependency symbol: +BR2_USE_WCHAR+
342 ** Comment string: +wchar+
345 ** Dependency symbol: +!BR2_STATIC_LIBS+
346 ** Comment string: +dynamic library+
348 ==== Dependencies on a Linux kernel built by buildroot
350 Some packages need a Linux kernel to be built by buildroot. These are
351 typically kernel modules or firmware. A comment should be added in the
352 Config.in file to express this dependency, similar to dependencies on
353 toolchain options. The general format is:
355 --------------------------
356 foo needs a Linux kernel to be built
357 --------------------------
359 If there is a dependency on both toolchain options and the Linux
360 kernel, use this format:
362 --------------------------
363 foo needs a toolchain w/ featA, featB, featC and a Linux kernel to be built
364 --------------------------
366 ==== Dependencies on udev /dev management
368 If a package needs udev /dev management, it should depend on symbol
369 +BR2_PACKAGE_HAS_UDEV+, and the following comment should be added:
371 --------------------------
372 foo needs udev /dev management
373 --------------------------
375 If there is a dependency on both toolchain options and udev /dev
376 management, use this format:
378 --------------------------
379 foo needs udev /dev management and a toolchain w/ featA, featB, featC
380 --------------------------
382 ==== Dependencies on features provided by virtual packages
384 Some features can be provided by more than one package, such as the
387 See xref:virtual-package-tutorial[] for more on the virtual packages.
391 [[adding-packages-mk]]
393 Finally, here's the hardest part. Create a file named +libfoo.mk+. It
394 describes how the package should be downloaded, configured, built,
397 Depending on the package type, the +.mk+ file must be written in a
398 different way, using different infrastructures:
400 * *Makefiles for generic packages* (not using autotools or CMake):
401 These are based on an infrastructure similar to the one used for
402 autotools-based packages, but require a little more work from the
403 developer. They specify what should be done for the configuration,
404 compilation and installation of the package. This
405 infrastructure must be used for all packages that do not use the
406 autotools as their build system. In the future, other specialized
407 infrastructures might be written for other build systems. We cover
408 them through in a xref:generic-package-tutorial[tutorial] and a
409 xref:generic-package-reference[reference].
411 * *Makefiles for autotools-based software* (autoconf, automake, etc.):
412 We provide a dedicated infrastructure for such packages, since
413 autotools is a very common build system. This infrastructure 'must'
414 be used for new packages that rely on the autotools as their build
415 system. We cover them through a xref:autotools-package-tutorial[tutorial]
416 and xref:autotools-package-reference[reference].
418 * *Makefiles for cmake-based software*: We provide a dedicated
419 infrastructure for such packages, as CMake is a more and more
420 commonly used build system and has a standardized behaviour. This
421 infrastructure 'must' be used for new packages that rely on
422 CMake. We cover them through a xref:cmake-package-tutorial[tutorial]
423 and xref:cmake-package-reference[reference].
425 * *Makefiles for Python modules*: We have a dedicated infrastructure
426 for Python modules that use either the +distutils+ or the
427 +setuptools+ mechanism. We cover them through a
428 xref:python-package-tutorial[tutorial] and a
429 xref:python-package-reference[reference].
431 * *Makefiles for Lua modules*: We have a dedicated infrastructure for
432 Lua modules available through the LuaRocks web site. We cover them
433 through a xref:luarocks-package-tutorial[tutorial] and a
434 xref:luarocks-package-reference[reference].
436 Further formatting details: see xref:writing-rules-mk[the writing
439 [[adding-packages-hash]]
442 When possible, you must add a third file, named +libfoo.hash+, that
443 contains the hashes of the downloaded files for the +libfoo+
444 package. The only reason for not adding a +.hash+ file is when hash
445 checking is not possible due to how the package is downloaded.
447 The hashes stored in that file are used to validate the integrity of the
448 downloaded files and of the license files.
450 The format of this file is one line for each file for which to check the
451 hash, each line being space-separated, with these three fields:
453 * the type of hash, one of:
454 ** +md5+, +sha1+, +sha224+, +sha256+, +sha384+, +sha512+, +none+
455 * the hash of the file:
456 ** for +none+, one or more non-space chars, usually just the string +xxx+
457 ** for +md5+, 32 hexadecimal characters
458 ** for +sha1+, 40 hexadecimal characters
459 ** for +sha224+, 56 hexadecimal characters
460 ** for +sha256+, 64 hexadecimal characters
461 ** for +sha384+, 96 hexadecimal characters
462 ** for +sha512+, 128 hexadecimal characters
463 * the name of the file:
464 ** for a source archive: the basename of the file, without any directory
466 ** for a license file: the path as it appears in +FOO_LICENSE_FILES+.
468 Lines starting with a +#+ sign are considered comments, and ignored. Empty
471 There can be more than one hash for a single file, each on its own line. In
472 this case, all hashes must match.
475 Ideally, the hashes stored in this file should match the hashes published by
476 upstream, e.g. on their website, in the e-mail announcement... If upstream
477 provides more than one type of hash (e.g. +sha1+ and +sha512+), then it is
478 best to add all those hashes in the +.hash+ file. If upstream does not
479 provide any hash, or only provides an +md5+ hash, then compute at least one
480 strong hash yourself (preferably +sha256+, but not +md5+), and mention
481 this in a comment line above the hashes.
484 The hashes for license files are used to detect a license change when a
485 package version is bumped. The hashes are checked during the make legal-info
486 target run. For a package with multiple versions (like Qt5),
487 create the hash file in a subdirectory +<packageversion>+ of that package
488 (see also xref:patch-apply-order[]).
491 The number of spaces does not matter, so one can use spaces (or tabs) to
492 properly align the different fields.
494 The +none+ hash type is reserved to those archives downloaded from a
495 repository, like a 'git clone', a 'subversion checkout'...
497 The example below defines a +sha1+ and a +sha256+ published by upstream for
498 the main +libfoo-1.2.3.tar.bz2+ tarball, an +md5+ from upstream and a
499 locally-computed +sha256+ hashes for a binary blob, a +sha256+ for a
500 downloaded patch, and an archive with no hash:
503 # Hashes from: http://www.foosoftware.org/download/libfoo-1.2.3.tar.bz2.{sha1,sha256}:
504 sha1 486fb55c3efa71148fe07895fd713ea3a5ae343a libfoo-1.2.3.tar.bz2
505 sha256 efc8103cc3bcb06bda6a781532d12701eb081ad83e8f90004b39ab81b65d4369 libfoo-1.2.3.tar.bz2
507 # md5 from: http://www.foosoftware.org/download/libfoo-1.2.3.tar.bz2.md5, sha256 locally computed:
508 md5 2d608f3c318c6b7557d551a5a09314f03452f1a1 libfoo-data.bin
509 sha256 01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b libfoo-data.bin
512 sha256 ff52101fb90bbfc3fe9475e425688c660f46216d7e751c4bbdb1dc85cdccacb9 libfoo-fix-blabla.patch
515 none xxx libfoo-1234.tar.gz
517 # Hash for license files:
518 sha256 a45a845012742796534f7e91fe623262ccfb99460a2bd04015bd28d66fba95b8 COPYING
519 sha256 01b1f9f2c8ee648a7a596a1abe8aa4ed7899b1c9e5551bda06da6e422b04aa55 doc/COPYING.LGPL
522 If the +.hash+ file is present, and it contains one or more hashes for a
523 downloaded file, the hash(es) computed by Buildroot (after download) must
524 match the hash(es) stored in the +.hash+ file. If one or more hashes do
525 not match, Buildroot considers this an error, deletes the downloaded file,
528 If the +.hash+ file is present, but it does not contain a hash for a
529 downloaded file, Buildroot considers this an error and aborts. However,
530 the downloaded file is left in the download directory since this
531 typically indicates that the +.hash+ file is wrong but the downloaded
534 Hashes are currently checked for files fetched from http/ftp servers,
535 Git repositories, files copied using scp and local files. Hashes are
536 not checked for other version control systems (such as Subversion,
537 CVS, etc.) because Buildroot currently does not generate reproducible
538 tarballs when source code is fetched from such version control
541 Hashes should only be added in +.hash+ files for files that are
542 guaranteed to be stable. For example, patches auto-generated by Github
543 are not guaranteed to be stable, and therefore their hashes can change
544 over time. Such patches should not be downloaded, and instead be added
545 locally to the package folder.
547 If the +.hash+ file is missing, then no check is done at all.