adding-packages-directory.txt 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  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. * Kernel headers
  175. ** Dependency symbol: +BR2_TOOLCHAIN_HEADERS_AT_LEAST_X_Y+, (replace
  176. +X_Y+ with the proper version, see +toolchain/toolchain-common.in+)
  177. ** Comment string: +headers >= X.Y+ (replace +X.Y+ with the
  178. proper version)
  179. * C library
  180. ** Dependency symbol: +BR2_TOOLCHAIN_USES_GLIBC+,
  181. +BR2_TOOLCHAIN_USES_UCLIBC+
  182. ** Comment string: for the C library, a slightly different comment text
  183. is used: +foo needs an (e)glibc toolchain+, or `foo needs an (e)glibc
  184. toolchain w/ C++`
  185. * C++ support
  186. ** Dependency symbol: +BR2_INSTALL_LIBSTDCPP+
  187. ** Comment string: `C++`
  188. * largefile support
  189. ** Dependency symbol: +BR2_LARGEFILE+
  190. ** Comment string: +largefile+
  191. * thread support
  192. ** Dependency symbol: +BR2_TOOLCHAIN_HAS_THREADS+
  193. ** Comment string: +threads+ (unless +BR2_TOOLCHAIN_HAS_THREADS_NPTL+
  194. is also needed, in which case, specifying only +NPTL+ is sufficient)
  195. * NPTL thread support
  196. ** Dependency symbol: +BR2_TOOLCHAIN_HAS_THREADS_NPTL+
  197. ** Comment string: +NPTL+
  198. * RPC support
  199. ** Dependency symbol: +BR2_TOOLCHAIN_HAS_NATIVE_RPC+
  200. ** Comment string: +RPC+
  201. * IPv6 support
  202. ** Dependency symbol: +BR2_INET_IPV6+
  203. ** Comment string: +IPv6+ (lowercase v)
  204. * wchar support
  205. ** Dependency symbol: +BR2_USE_WCHAR+
  206. ** Comment string: +wchar+
  207. * dynamic library
  208. ** Dependency symbol: +!BR2_PREFER_STATIC_LIB+
  209. ** Comment string: +dynamic library+
  210. ==== Dependencies on a Linux kernel built by buildroot
  211. Some packages need a Linux kernel to be built by buildroot. These are
  212. typically kernel modules or firmware. A comment should be added in the
  213. Config.in file to express this dependency, similar to dependencies on
  214. toolchain options. The general format is:
  215. --------------------------
  216. foo needs a Linux kernel to be built
  217. --------------------------
  218. If there is a dependency on both toolchain options and the Linux
  219. kernel, use this format:
  220. --------------------------
  221. foo needs a toolchain w/ featA, featB, featC and a Linux kernel to be built
  222. --------------------------
  223. ==== Dependencies on udev /dev management
  224. If a package needs udev /dev management, it should depend on symbol
  225. +BR2_PACKAGE_HAS_UDEV+, and the following comment should be added:
  226. --------------------------
  227. foo needs udev /dev management
  228. --------------------------
  229. If there is a dependency on both toolchain options and udev /dev
  230. management, use this format:
  231. --------------------------
  232. foo needs udev /dev management and a toolchain w/ featA, featB, featC
  233. --------------------------
  234. ==== Dependencies on features provided by virtual packages
  235. Some features can be provided by more than one package, such as the
  236. openGL libraries.
  237. See xref:virtual-package-tutorial[] for more on the virtual packages.
  238. See xref:virtual-package-list[] for the symbols to depend on if your package
  239. depends on a feature provided by a virtual package.
  240. === The +.mk+ file
  241. [[adding-packages-mk]]
  242. Finally, here's the hardest part. Create a file named +libfoo.mk+. It
  243. describes how the package should be downloaded, configured, built,
  244. installed, etc.
  245. Depending on the package type, the +.mk+ file must be written in a
  246. different way, using different infrastructures:
  247. * *Makefiles for generic packages* (not using autotools or CMake):
  248. These are based on an infrastructure similar to the one used for
  249. autotools-based packages, but require a little more work from the
  250. developer. They specify what should be done for the configuration,
  251. compilation and installation of the package. This
  252. infrastructure must be used for all packages that do not use the
  253. autotools as their build system. In the future, other specialized
  254. infrastructures might be written for other build systems. We cover
  255. them through in a xref:generic-package-tutorial[tutorial] and a
  256. xref:generic-package-reference[reference].
  257. * *Makefiles for autotools-based software* (autoconf, automake, etc.):
  258. We provide a dedicated infrastructure for such packages, since
  259. autotools is a very common build system. This infrastructure 'must'
  260. be used for new packages that rely on the autotools as their build
  261. system. We cover them through a xref:autotools-package-tutorial[tutorial]
  262. and xref:autotools-package-reference[reference].
  263. * *Makefiles for cmake-based software*: We provide a dedicated
  264. infrastructure for such packages, as CMake is a more and more
  265. commonly used build system and has a standardized behaviour. This
  266. infrastructure 'must' be used for new packages that rely on
  267. CMake. We cover them through a xref:cmake-package-tutorial[tutorial]
  268. and xref:cmake-package-reference[reference].
  269. * *Makefiles for Python modules*: We have a dedicated infrastructure
  270. for Python modules that use either the +distutils+ or the
  271. +setuptools+ mechanism. We cover them through a
  272. xref:python-package-tutorial[tutorial] and a
  273. xref:python-package-reference[reference].
  274. * *Makefiles for Lua modules*: We have a dedicated infrastructure for
  275. Lua modules available through the LuaRocks web site. We cover them
  276. through a xref:luarocks-package-tutorial[tutorial] and a
  277. xref:luarocks-package-reference[reference].
  278. Further formatting details: see xref:writing-rules-mk[the writing
  279. rules].