adding-packages-directory.txt 19 KB

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