adding-packages-directory.txt 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. // -*- mode:doc; -*-
  2. // vim: set syntax=asciidoc:
  3. Package directory
  4. ~~~~~~~~~~~~~~~~~
  5. First of all, create a directory under the +package+ directory for
  6. your software, for example +libfoo+.
  7. Some packages have been grouped by topic in a sub-directory:
  8. +x11r7+, +efl+ and +matchbox+. If your package fits in
  9. one of these categories, then create your package directory in these.
  10. New subdirectories are discouraged, however.
  11. +Config.in+ file
  12. ~~~~~~~~~~~~~~~~
  13. Then, create a file named +Config.in+. This file will contain the
  14. option descriptions related to our +libfoo+ software that will be used
  15. and displayed in the configuration tool. It should basically contain:
  16. ---------------------------
  17. config BR2_PACKAGE_LIBFOO
  18. bool "libfoo"
  19. help
  20. This is a comment that explains what libfoo is.
  21. http://foosoftware.org/libfoo/
  22. ---------------------------
  23. The +bool+ line, +help+ line and other meta-informations about the
  24. configuration option must be indented with one tab. The help text
  25. itself should be indented with one tab and two spaces, and it must
  26. mention the upstream URL of the project.
  27. You can add other sub-options into a +if
  28. BR2_PACKAGE_LIBFOO...endif+ statement to configure particular things
  29. in your software. You can look at examples in other packages. The
  30. syntax of the +Config.in+ file is the same as the one for the kernel
  31. Kconfig file. The documentation for this syntax is available at
  32. http://kernel.org/doc/Documentation/kbuild/kconfig-language.txt[]
  33. Finally you have to add your new +libfoo/Config.in+ to
  34. +package/Config.in+ (or in a category subdirectory if you decided to
  35. put your package in one of the existing categories). The files
  36. included there are 'sorted alphabetically' per category and are 'NOT'
  37. supposed to contain anything but the 'bare' name of the package.
  38. --------------------------
  39. source "package/libfoo/Config.in"
  40. --------------------------
  41. [[depends-on-vs-select]]
  42. Choosing +depends on+ or +select+
  43. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  44. The +Config.in+ file of your package must also ensure that
  45. dependencies are enabled. Typically, Buildroot uses the following
  46. rules:
  47. * Use a +select+ type of dependency for dependencies on
  48. libraries. These dependencies are generally not obvious and it
  49. therefore make sense to have the kconfig system ensure that the
  50. dependencies are selected. For example, the _libgtk2_ package uses
  51. +select BR2_PACKAGE_LIBGLIB2+ to make sure this library is also
  52. enabled.
  53. The +select+ keyword expresses the dependency with a backward
  54. semantic.
  55. * Use a +depends on+ type of dependency when the user really needs to
  56. be aware of the dependency. Typically, Buildroot uses this type of
  57. dependency for dependencies on target architecture, MMU support and
  58. toolchain options (see xref:dependencies-target-toolchain-options[]),
  59. or for dependencies on "big" things, such as the X.org system.
  60. The +depends on+ keyword expresses the dependency with a forward
  61. semantic.
  62. .Note
  63. The current problem with the _kconfig_ language is that these two
  64. dependency semantics are not internally linked. Therefore, it may be
  65. possible to select a package, whom one of its dependencies/requirement
  66. is not met.
  67. An example illustrates both the usage of +select+ and +depends on+.
  68. --------------------------
  69. config BR2_PACKAGE_ACL
  70. bool "acl"
  71. select BR2_PACKAGE_ATTR
  72. depends on BR2_LARGEFILE
  73. help
  74. POSIX Access Control Lists, which are used to define more
  75. fine-grained discretionary access rights for files and
  76. directories.
  77. This package also provides libacl.
  78. http://savannah.nongnu.org/projects/acl
  79. comment "acl needs a toolchain w/ largefile"
  80. depends on !BR2_LARGEFILE
  81. --------------------------
  82. Note that these two dependency types are only transitive with the
  83. dependencies of the same kind.
  84. This means, in the following example:
  85. --------------------------
  86. config BR2_PACKAGE_A
  87. bool "Package A"
  88. config BR2_PACKAGE_B
  89. bool "Package B"
  90. depends on BR2_PACKAGE_A
  91. config BR2_PACKAGE_C
  92. bool "Package C"
  93. depends on BR2_PACKAGE_B
  94. config BR2_PACKAGE_D
  95. bool "Package D"
  96. select BR2_PACKAGE_B
  97. config BR2_PACKAGE_E
  98. bool "Package E"
  99. select BR2_PACKAGE_D
  100. --------------------------
  101. * Selecting +Package C+ will be visible if +Package B+ has been
  102. selected, which in turn is only visible if +Package A+ has been
  103. selected.
  104. * Selecting +Package E+ will select +Package D+, which will select
  105. +Package B+, it will not check for the dependencies of +Package B+,
  106. so it will not select +Package A+.
  107. * Since +Package B+ is selected but +Package A+ is not, this violates
  108. the dependency of +Package B+ on +Package A+. Therefore, in such a
  109. situation, the transitive dependency has to be added explicitly:
  110. --------------------------
  111. config BR2_PACKAGE_D
  112. bool "Package D"
  113. select BR2_PACKAGE_B
  114. depends on BR2_PACKAGE_A
  115. config BR2_PACKAGE_E
  116. bool "Package E"
  117. select BR2_PACKAGE_D
  118. depends on BR2_PACKAGE_A
  119. --------------------------
  120. Overall, for package library dependencies, +select+ should be
  121. preferred.
  122. Note that such dependencies will ensure that the dependency option
  123. is also enabled, but not necessarily built before your package. To do
  124. so, the dependency also needs to be expressed in the +.mk+ file of the
  125. package.
  126. Further formatting details: see xref:writing-rules-config-in[the
  127. coding style].
  128. [[dependencies-target-toolchain-options]]
  129. Dependencies on target and toolchain options
  130. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  131. Many packages depend on certain options of the toolchain: the choice of
  132. C library, C++ support, largefile support, thread support, RPC support,
  133. IPv6 support, wchar support, or dynamic library support. Some packages
  134. can only be built on certain target architectures, or if an MMU is
  135. available in the processor.
  136. These dependencies have to be expressed with the appropriate 'depends
  137. on' statements in the Config.in file. Additionally, for dependencies on
  138. toolchain options, a +comment+ should be displayed when the option is
  139. not enabled, so that the user knows why the package is not available.
  140. Dependencies on target architecture or MMU support should not be
  141. made visible in a comment: since it is unlikely that the user can
  142. freely choose another target, it makes little sense to show these
  143. dependencies explicitly.
  144. The +comment+ should only be visible if the +config+ option itself would
  145. be visible when the toolchain option dependencies are met. This means
  146. that all other dependencies of the package (including dependencies on
  147. target architecture and MMU support) have to be repeated on the
  148. +comment+ definition. To keep it clear, the +depends on+ statement for
  149. these non-toolchain option should be kept separate from the +depends on+
  150. statement for the toolchain options.
  151. If there is a dependency on a config option in that same file (typically
  152. the main package) it is preferable to have a global +if ... endif+
  153. construct rather than repeating the +depends on+ statement on the
  154. comment and other config options.
  155. The general format of a dependency +comment+ for package foo is:
  156. --------------------------
  157. foo needs a toolchain w/ featA, featB, featC
  158. --------------------------
  159. for example:
  160. --------------------------
  161. aircrack-ng needs a toolchain w/ largefile, 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. * C library
  175. ** Dependency symbol: +BR2_TOOLCHAIN_USES_GLIBC+,
  176. +BR2_TOOLCHAIN_USES_UCLIBC+
  177. ** Comment string: for the C library, a slightly different comment text
  178. is used: +foo needs an (e)glibc toolchain+, or `foo needs an (e)glibc
  179. toolchain w/ C++ support`
  180. * C++ support
  181. ** Dependency symbol: +BR2_INSTALL_LIBSTDCPP+
  182. ** Comment string: `C++`
  183. * largefile support
  184. ** Dependency symbol: +BR2_LARGEFILE+
  185. ** Comment string: +largefile+
  186. * thread support
  187. ** Dependency symbol: +BR2_TOOLCHAIN_HAS_THREADS+
  188. ** Comment string: +threads+
  189. * RPC support
  190. ** Dependency symbol: +BR2_TOOLCHAIN_HAS_NATIVE_RPC+
  191. ** Comment string: +RPC+
  192. * IPv6 support
  193. ** Dependency symbol: +BR2_INET_IPV6+
  194. ** Comment string: +IPv6+ (lowercase v)
  195. * wchar support
  196. ** Dependency symbol: +BR2_USE_WCHAR+
  197. ** Comment string: +wchar+
  198. * dynamic library
  199. ** Dependency symbol: +!BR2_PREFER_STATIC_LIB+
  200. ** Comment string: +dynamic library+
  201. Dependencies on a Linux kernel built by buildroot
  202. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  203. Some packages need a Linux kernel to be built by buildroot. These are
  204. typically kernel modules or firmware. A comment should be added in the
  205. Config.in file to express this dependency, similar to dependencies on
  206. toolchain options. The general format is:
  207. --------------------------
  208. foo needs a Linux kernel to be built
  209. --------------------------
  210. If there is a dependency on both toolchain options and the Linux
  211. kernel, use this format:
  212. --------------------------
  213. foo needs a toolchain w/ featA, featB, featC and a Linux kernel to be built
  214. --------------------------
  215. Dependencies on udev /dev management
  216. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  217. If a package needs udev /dev management, it should depend on symbol
  218. +BR2_PACKAGE_HAS_UDEV+, and the following comment should be added:
  219. --------------------------
  220. foo needs udev /dev management
  221. --------------------------
  222. If there is a dependency on both toolchain options and udev /dev
  223. management, use this format:
  224. --------------------------
  225. foo needs udev /dev management and a toolchain w/ featA, featB, featC
  226. --------------------------
  227. The +.mk+ file
  228. ~~~~~~~~~~~~~~
  229. [[adding-packages-mk]]
  230. Finally, here's the hardest part. Create a file named +libfoo.mk+. It
  231. describes how the package should be downloaded, configured, built,
  232. installed, etc.
  233. Depending on the package type, the +.mk+ file must be written in a
  234. different way, using different infrastructures:
  235. * *Makefiles for generic packages* (not using autotools or CMake):
  236. These are based on an infrastructure similar to the one used for
  237. autotools-based packages, but require a little more work from the
  238. developer. They specify what should be done for the configuration,
  239. compilation and installation of the package. This
  240. infrastructure must be used for all packages that do not use the
  241. autotools as their build system. In the future, other specialized
  242. infrastructures might be written for other build systems. We cover
  243. them through in a xref:generic-package-tutorial[tutorial] and a
  244. xref:generic-package-reference[reference].
  245. * *Makefiles for autotools-based software* (autoconf, automake, etc.):
  246. We provide a dedicated infrastructure for such packages, since
  247. autotools is a very common build system. This infrastructure 'must'
  248. be used for new packages that rely on the autotools as their build
  249. system. We cover them through a xref:autotools-package-tutorial[tutorial]
  250. and xref:autotools-package-reference[reference].
  251. * *Makefiles for cmake-based software*: We provide a dedicated
  252. infrastructure for such packages, as CMake is a more and more
  253. commonly used build system and has a standardized behaviour. This
  254. infrastructure 'must' be used for new packages that rely on
  255. CMake. We cover them through a xref:cmake-package-tutorial[tutorial]
  256. and xref:cmake-package-reference[reference].
  257. Further formatting details: see xref:writing-rules-mk[the writing
  258. rules].