adding-packages-directory.txt 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  1. // -*- mode:doc; -*-
  2. // vim: set syntax=asciidoc:
  3. === Package directory
  4. First of all, create a directory under the +package+ directory for
  5. your software, for example +libfoo+.
  6. Some packages have been grouped by topic in a sub-directory:
  7. +x11r7+, +efl+ and +matchbox+. If your package fits in
  8. one of these categories, then create your package directory in these.
  9. New subdirectories are discouraged, however.
  10. === +Config.in+ file
  11. Then, create a file named +Config.in+. This file will contain the
  12. option descriptions related to our +libfoo+ software that will be used
  13. and displayed in the configuration tool. It should basically contain:
  14. ---------------------------
  15. config BR2_PACKAGE_LIBFOO
  16. bool "libfoo"
  17. help
  18. This is a comment that explains what libfoo is.
  19. http://foosoftware.org/libfoo/
  20. ---------------------------
  21. The +bool+ line, +help+ line and other metadata information about the
  22. configuration option must be indented with one tab. The help text
  23. itself should be indented with one tab and two spaces, and it must
  24. mention the upstream URL of the project.
  25. You can add other sub-options into a +if
  26. BR2_PACKAGE_LIBFOO...endif+ statement to configure particular things
  27. in your software. You can look at examples in other packages. The
  28. syntax of the +Config.in+ file is the same as the one for the kernel
  29. Kconfig file. The documentation for this syntax is available at
  30. http://kernel.org/doc/Documentation/kbuild/kconfig-language.txt[]
  31. Finally you have to add your new +libfoo/Config.in+ to
  32. +package/Config.in+ (or in a category subdirectory if you decided to
  33. put your package in one of the existing categories). The files
  34. included there are 'sorted alphabetically' per category and are 'NOT'
  35. supposed to contain anything but the 'bare' name of the package.
  36. --------------------------
  37. source "package/libfoo/Config.in"
  38. --------------------------
  39. [[depends-on-vs-select]]
  40. ==== Choosing +depends on+ or +select+
  41. The +Config.in+ file of your package must also ensure that
  42. dependencies are enabled. Typically, Buildroot uses the following
  43. rules:
  44. * Use a +select+ type of dependency for dependencies on
  45. libraries. These dependencies are generally not obvious and it
  46. therefore make sense to have the kconfig system ensure that the
  47. dependencies are selected. For example, the _libgtk2_ package uses
  48. +select BR2_PACKAGE_LIBGLIB2+ to make sure this library is also
  49. enabled.
  50. The +select+ keyword expresses the dependency with a backward
  51. semantic.
  52. * Use a +depends on+ type of dependency when the user really needs to
  53. be aware of the dependency. Typically, Buildroot uses this type of
  54. dependency for dependencies on target architecture, MMU support and
  55. toolchain options (see xref:dependencies-target-toolchain-options[]),
  56. or for dependencies on "big" things, such as the X.org system.
  57. The +depends on+ keyword expresses the dependency with a forward
  58. semantic.
  59. .Note
  60. The current problem with the _kconfig_ language is that these two
  61. dependency semantics are not internally linked. Therefore, it may be
  62. possible to select a package, whom one of its dependencies/requirement
  63. is not met.
  64. An example illustrates both the usage of +select+ and +depends on+.
  65. --------------------------
  66. config BR2_PACKAGE_ACL
  67. bool "acl"
  68. select BR2_PACKAGE_ATTR
  69. depends on BR2_LARGEFILE
  70. help
  71. POSIX Access Control Lists, which are used to define more
  72. fine-grained discretionary access rights for files and
  73. directories.
  74. This package also provides libacl.
  75. http://savannah.nongnu.org/projects/acl
  76. comment "acl needs a toolchain w/ largefile"
  77. depends on !BR2_LARGEFILE
  78. --------------------------
  79. Note that these two dependency types are only transitive with the
  80. dependencies of the same kind.
  81. This means, in the following example:
  82. --------------------------
  83. config BR2_PACKAGE_A
  84. bool "Package A"
  85. config BR2_PACKAGE_B
  86. bool "Package B"
  87. depends on BR2_PACKAGE_A
  88. config BR2_PACKAGE_C
  89. bool "Package C"
  90. depends on BR2_PACKAGE_B
  91. config BR2_PACKAGE_D
  92. bool "Package D"
  93. select BR2_PACKAGE_B
  94. config BR2_PACKAGE_E
  95. bool "Package E"
  96. select BR2_PACKAGE_D
  97. --------------------------
  98. * Selecting +Package C+ will be visible if +Package B+ has been
  99. selected, which in turn is only visible if +Package A+ has been
  100. selected.
  101. * Selecting +Package E+ will select +Package D+, which will select
  102. +Package B+, it will not check for the dependencies of +Package B+,
  103. so it will not select +Package A+.
  104. * Since +Package B+ is selected but +Package A+ is not, this violates
  105. the dependency of +Package B+ on +Package A+. Therefore, in such a
  106. situation, the transitive dependency has to be added explicitly:
  107. --------------------------
  108. config BR2_PACKAGE_D
  109. bool "Package D"
  110. select BR2_PACKAGE_B
  111. depends on BR2_PACKAGE_A
  112. config BR2_PACKAGE_E
  113. bool "Package E"
  114. select BR2_PACKAGE_D
  115. depends on BR2_PACKAGE_A
  116. --------------------------
  117. Overall, for package library dependencies, +select+ should be
  118. preferred.
  119. Note that such dependencies will ensure that the dependency option
  120. is also enabled, but not necessarily built before your package. To do
  121. so, the dependency also needs to be expressed in the +.mk+ file of the
  122. package.
  123. Further formatting details: see xref:writing-rules-config-in[the
  124. coding style].
  125. [[dependencies-target-toolchain-options]]
  126. ==== Dependencies on target and toolchain options
  127. Many packages depend on certain options of the toolchain: the choice of
  128. C library, C++ support, largefile support, thread support, RPC support,
  129. IPv6 support, wchar support, or dynamic library support. Some packages
  130. can only be built on certain target architectures, or if an MMU is
  131. available in the processor.
  132. These dependencies have to be expressed with the appropriate 'depends
  133. on' statements in the Config.in file. Additionally, for dependencies on
  134. toolchain options, a +comment+ should be displayed when the option is
  135. not enabled, so that the user knows why the package is not available.
  136. Dependencies on target architecture or MMU support should not be
  137. made visible in a comment: since it is unlikely that the user can
  138. freely choose another target, it makes little sense to show these
  139. dependencies explicitly.
  140. The +comment+ should only be visible if the +config+ option itself would
  141. be visible when the toolchain option dependencies are met. This means
  142. that all other dependencies of the package (including dependencies on
  143. target architecture and MMU support) have to be repeated on the
  144. +comment+ definition. To keep it clear, the +depends on+ statement for
  145. these non-toolchain option should be kept separate from the +depends on+
  146. statement for the toolchain options.
  147. If there is a dependency on a config option in that same file (typically
  148. the main package) it is preferable to have a global +if ... endif+
  149. construct rather than repeating the +depends on+ statement on the
  150. comment and other config options.
  151. The general format of a dependency +comment+ for package foo is:
  152. --------------------------
  153. foo needs a toolchain w/ featA, featB, featC
  154. --------------------------
  155. for example:
  156. --------------------------
  157. aircrack-ng needs a toolchain w/ largefile, threads
  158. --------------------------
  159. or
  160. --------------------------
  161. crda needs a toolchain w/ threads
  162. --------------------------
  163. Note that this text is kept brief on purpose, so that it will fit on a
  164. 80-character terminal.
  165. The rest of this section enumerates the different target and toolchain
  166. options, the corresponding config symbols to depend on, and the text to
  167. use in the comment.
  168. * Target architecture
  169. ** Dependency symbol: +BR2_powerpc+, +BR2_mips+, ... (see +arch/Config.in+)
  170. ** Comment string: no comment to be added
  171. * MMU support
  172. ** Dependency symbol: +BR2_USE_MMU+
  173. ** Comment string: no comment to be added
  174. * Atomic instructions (whereby the architecture has instructions to
  175. perform some operations atomically, like LOCKCMPXCHG on x86)
  176. ** Dependency symbol: +BR2_ARCH_HAS_ATOMICS+
  177. ** Comment string: no comment to be added
  178. * Kernel headers
  179. ** Dependency symbol: +BR2_TOOLCHAIN_HEADERS_AT_LEAST_X_Y+, (replace
  180. +X_Y+ with the proper version, see +toolchain/toolchain-common.in+)
  181. ** Comment string: +headers >= X.Y+ and/or `headers <= X.Y` (replace
  182. +X.Y+ with the proper version)
  183. * C library
  184. ** Dependency symbol: +BR2_TOOLCHAIN_USES_GLIBC+,
  185. +BR2_TOOLCHAIN_USES_MUSL+, +BR2_TOOLCHAIN_USES_UCLIBC+
  186. ** Comment string: for the C library, a slightly different comment text
  187. is used: +foo needs an (e)glibc toolchain+, or `foo needs an (e)glibc
  188. toolchain w/ C++`
  189. * C++ support
  190. ** Dependency symbol: +BR2_INSTALL_LIBSTDCPP+
  191. ** Comment string: `C++`
  192. * largefile support
  193. ** Dependency symbol: +BR2_LARGEFILE+
  194. ** Comment string: +largefile+
  195. * thread support
  196. ** Dependency symbol: +BR2_TOOLCHAIN_HAS_THREADS+
  197. ** Comment string: +threads+ (unless +BR2_TOOLCHAIN_HAS_THREADS_NPTL+
  198. is also needed, in which case, specifying only +NPTL+ is sufficient)
  199. * NPTL thread support
  200. ** Dependency symbol: +BR2_TOOLCHAIN_HAS_THREADS_NPTL+
  201. ** Comment string: +NPTL+
  202. * RPC support
  203. ** Dependency symbol: +BR2_TOOLCHAIN_HAS_NATIVE_RPC+
  204. ** Comment string: +RPC+
  205. * IPv6 support
  206. ** Dependency symbol: +BR2_INET_IPV6+
  207. ** Comment string: +IPv6+ (lowercase v)
  208. * wchar support
  209. ** Dependency symbol: +BR2_USE_WCHAR+
  210. ** Comment string: +wchar+
  211. * dynamic library
  212. ** Dependency symbol: +!BR2_STATIC_LIBS+
  213. ** Comment string: +dynamic library+
  214. ==== Dependencies on a Linux kernel built by buildroot
  215. Some packages need a Linux kernel to be built by buildroot. These are
  216. typically kernel modules or firmware. A comment should be added in the
  217. Config.in file to express this dependency, similar to dependencies on
  218. toolchain options. The general format is:
  219. --------------------------
  220. foo needs a Linux kernel to be built
  221. --------------------------
  222. If there is a dependency on both toolchain options and the Linux
  223. kernel, use this format:
  224. --------------------------
  225. foo needs a toolchain w/ featA, featB, featC and a Linux kernel to be built
  226. --------------------------
  227. ==== Dependencies on udev /dev management
  228. If a package needs udev /dev management, it should depend on symbol
  229. +BR2_PACKAGE_HAS_UDEV+, and the following comment should be added:
  230. --------------------------
  231. foo needs udev /dev management
  232. --------------------------
  233. If there is a dependency on both toolchain options and udev /dev
  234. management, use this format:
  235. --------------------------
  236. foo needs udev /dev management and a toolchain w/ featA, featB, featC
  237. --------------------------
  238. ==== Dependencies on features provided by virtual packages
  239. Some features can be provided by more than one package, such as the
  240. openGL libraries.
  241. See xref:virtual-package-tutorial[] for more on the virtual packages.
  242. See xref:virtual-package-list[] for the symbols to depend on if your package
  243. depends on a feature provided by a virtual package.
  244. === The +.mk+ file
  245. [[adding-packages-mk]]
  246. Finally, here's the hardest part. Create a file named +libfoo.mk+. It
  247. describes how the package should be downloaded, configured, built,
  248. installed, etc.
  249. Depending on the package type, the +.mk+ file must be written in a
  250. different way, using different infrastructures:
  251. * *Makefiles for generic packages* (not using autotools or CMake):
  252. These are based on an infrastructure similar to the one used for
  253. autotools-based packages, but require a little more work from the
  254. developer. They specify what should be done for the configuration,
  255. compilation and installation of the package. This
  256. infrastructure must be used for all packages that do not use the
  257. autotools as their build system. In the future, other specialized
  258. infrastructures might be written for other build systems. We cover
  259. them through in a xref:generic-package-tutorial[tutorial] and a
  260. xref:generic-package-reference[reference].
  261. * *Makefiles for autotools-based software* (autoconf, automake, etc.):
  262. We provide a dedicated infrastructure for such packages, since
  263. autotools is a very common build system. This infrastructure 'must'
  264. be used for new packages that rely on the autotools as their build
  265. system. We cover them through a xref:autotools-package-tutorial[tutorial]
  266. and xref:autotools-package-reference[reference].
  267. * *Makefiles for cmake-based software*: We provide a dedicated
  268. infrastructure for such packages, as CMake is a more and more
  269. commonly used build system and has a standardized behaviour. This
  270. infrastructure 'must' be used for new packages that rely on
  271. CMake. We cover them through a xref:cmake-package-tutorial[tutorial]
  272. and xref:cmake-package-reference[reference].
  273. * *Makefiles for Python modules*: We have a dedicated infrastructure
  274. for Python modules that use either the +distutils+ or the
  275. +setuptools+ mechanism. We cover them through a
  276. xref:python-package-tutorial[tutorial] and a
  277. xref:python-package-reference[reference].
  278. * *Makefiles for Lua modules*: We have a dedicated infrastructure for
  279. Lua modules available through the LuaRocks web site. We cover them
  280. through a xref:luarocks-package-tutorial[tutorial] and a
  281. xref:luarocks-package-reference[reference].
  282. Further formatting details: see xref:writing-rules-mk[the writing
  283. rules].
  284. [[adding-packages-hash]]
  285. === The +.hash+ file
  286. Optionally, you can add a third file, named +libfoo.hash+, that contains
  287. the hashes of the downloaded files for the +libfoo+ package.
  288. The hashes stored in that file are used to validate the integrity of the
  289. downloaded files.
  290. The format of this file is one line for each file for which to check the
  291. hash, each line being space-separated, with these three fields:
  292. * the type of hash, one of:
  293. ** +sha1+, +sha224+, +sha256+, +sha384+, +sha512+
  294. * the hash of the file:
  295. ** for +sha1+, 40 hexadecimal characters
  296. ** for +sha224+, 56 hexadecimal characters
  297. ** for +sha256+, 64 hexadecimal characters
  298. ** for +sha384+, 96 hexadecimal characters
  299. ** for +sha512+, 128 hexadecimal characters
  300. * the name of the file, without any directory component
  301. Lines starting with a +#+ sign are considered comments, and ignored. Empty
  302. lines are ignored.
  303. There can be more than one hash for a single file, each on its own line. In
  304. this case, all hashes must match.
  305. Ideally, the hashes stored in this file should match the hashes published by
  306. upstream, e.g. on their website, in the e-mail announcement... If upstream
  307. provides more than one type of hash (say, +sha1+ and +sha512+), then it is
  308. best to add all those hashes in the +.hash+ file. If upstream does not
  309. provide any hash, then compute at least one yourself, and mention this in a
  310. comment line above the hashes.
  311. *Note:* the number of spaces does not matter, so one can use spaces to
  312. properly align the different fields.
  313. The example below defines a +sha1+ and a +sha256+ published by upstream for
  314. the main +libfoo-1.2.3.tar.bz2+ tarball, plus two locally-computed hashes,
  315. a +sha256+ for a downloaded patch, and a +sha1+ for a downloaded binary blob:
  316. ----
  317. # Hashes from: http://www.foosoftware.org/download/libfoo-1.2.3.tar.bz2.{sha1,sha256}:
  318. sha1 486fb55c3efa71148fe07895fd713ea3a5ae343a libfoo-1.2.3.tar.bz2
  319. sha256 efc8103cc3bcb06bda6a781532d12701eb081ad83e8f90004b39ab81b65d4369 libfoo-1.2.3.tar.bz2
  320. # No upstream hashes for the following:
  321. sha256 ff52101fb90bbfc3fe9475e425688c660f46216d7e751c4bbdb1dc85cdccacb9 libfoo-fix-blabla.patch
  322. sha1 2d608f3c318c6b7557d551a5a09314f03452f1a1 libfoo-data.bin
  323. ----
  324. If the +.hash+ file is present, and it contains one or more hashes for a
  325. downloaded file, the hash(es) computed by Buildroot (after download) must
  326. match the hash(es) stored in the +.hash+ file. If one or more hashes do
  327. not match, Buildroot considers this an error, deletes the downloaded file,
  328. and aborts.
  329. If the +.hash+ file is present, but it does not contain a hash for a
  330. downloaded file, no check is done for that file. If you set the
  331. environment variable +BR2_ENFORCE_CHECK_HASH+ to a non-empty value, and
  332. there is no hash for a downloaded file, Buildroot considers this an
  333. error, deletes the downloaded file, and aborts.
  334. If the +.hash+ file is missing, then no check is done at all.