adding-packages-directory.txt 18 KB

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