adding-packages-directory.txt 20 KB

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