adding-packages-directory.txt 19 KB

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