adding-packages-directory.txt 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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 toolchain options (target
  58. architecture, MMU support, C library, C++ support, large file
  59. support, thread support, RPC support, IPV6 support, WCHAR support),
  60. or for dependencies on "big" things, such as the X.org system. For
  61. dependencies on toolchain options, there should be a +comment+ that
  62. is displayed when the option is not
  63. enabled, so that the user knows why the package is not available.
  64. The +depends on+ keyword expresses the dependency with a forward
  65. semantic.
  66. .Note
  67. The current problem with the _kconfig_ language is that these two
  68. dependency semantics are not internally linked. Therefore, it may be
  69. possible to select a package, whom one of its dependencies/requirement
  70. is not met.
  71. An example illustrates both the usage of +select+ and +depends on+.
  72. --------------------------
  73. config BR2_PACKAGE_ACL
  74. bool "acl"
  75. select BR2_PACKAGE_ATTR
  76. depends on BR2_LARGEFILE
  77. help
  78. POSIX Access Control Lists, which are used to define more
  79. fine-grained discretionary access rights for files and
  80. directories.
  81. This package also provides libacl.
  82. http://savannah.nongnu.org/projects/acl
  83. comment "acl requires a toolchain with LARGEFILE support"
  84. depends on !BR2_LARGEFILE
  85. --------------------------
  86. Note that these two dependency types are only transitive with the
  87. dependencies of the same kind.
  88. This means, in the following example:
  89. --------------------------
  90. config BR2_PACKAGE_A
  91. bool "Package A"
  92. config BR2_PACKAGE_B
  93. bool "Package B"
  94. depends on BR2_PACKAGE_A
  95. config BR2_PACKAGE_C
  96. bool "Package C"
  97. depends on BR2_PACKAGE_B
  98. config BR2_PACKAGE_D
  99. bool "Package D"
  100. select BR2_PACKAGE_B
  101. config BR2_PACKAGE_E
  102. bool "Package E"
  103. select BR2_PACKAGE_D
  104. --------------------------
  105. * Selecting +Package C+ will be visible if +Package B+ has been
  106. selected, which in turn is only visible if +Package A+ has been
  107. selected.
  108. * Selecting +Package E+ will select +Package D+, which will select
  109. +Package B+, it will not check for the dependencies of +Package B+,
  110. so it will not select +Package A+.
  111. * Since +Package B+ is selected but +Package A+ is not, this violates
  112. the dependency of +Package B+ on +Package A+. Therefore, in such a
  113. situation, the transitive dependency has to be added explicitly:
  114. --------------------------
  115. config BR2_PACKAGE_D
  116. bool "Package D"
  117. select BR2_PACKAGE_B
  118. depends on BR2_PACKAGE_A
  119. config BR2_PACKAGE_E
  120. bool "Package E"
  121. select BR2_PACKAGE_D
  122. depends on BR2_PACKAGE_A
  123. --------------------------
  124. Overall, for package library dependencies, +select+ should be
  125. preferred.
  126. Note that such dependencies will ensure that the dependency option
  127. is also enabled, but not necessarily built before your package. To do
  128. so, the dependency also needs to be expressed in the +.mk+ file of the
  129. package.
  130. Further formatting details: see xref:writing-rules-config-in[the
  131. coding style].
  132. The +.mk+ file
  133. ~~~~~~~~~~~~~~
  134. [[adding-packages-mk]]
  135. Finally, here's the hardest part. Create a file named +libfoo.mk+. It
  136. describes how the package should be downloaded, configured, built,
  137. installed, etc.
  138. Depending on the package type, the +.mk+ file must be written in a
  139. different way, using different infrastructures:
  140. * *Makefiles for generic packages* (not using autotools or CMake):
  141. These are based on an infrastructure similar to the one used for
  142. autotools-based packages, but require a little more work from the
  143. developer. They specify what should be done for the configuration,
  144. compilation, installation and cleanup of the package. This
  145. infrastructure must be used for all packages that do not use the
  146. autotools as their build system. In the future, other specialized
  147. infrastructures might be written for other build systems. We cover
  148. them through in a xref:generic-package-tutorial[tutorial] and a
  149. xref:generic-package-reference[reference].
  150. * *Makefiles for autotools-based software* (autoconf, automake, etc.):
  151. We provide a dedicated infrastructure for such packages, since
  152. autotools is a very common build system. This infrastructure 'must'
  153. be used for new packages that rely on the autotools as their build
  154. system. We cover them through a xref:autotools-package-tutorial[tutorial]
  155. and xref:autotools-package-reference[reference].
  156. * *Makefiles for cmake-based software*: We provide a dedicated
  157. infrastructure for such packages, as CMake is a more and more
  158. commonly used build system and has a standardized behaviour. This
  159. infrastructure 'must' be used for new packages that rely on
  160. CMake. We cover them through a xref:cmake-package-tutorial[tutorial]
  161. and xref:cmake-package-reference[reference].
  162. Further formatting details: see xref:writing-rules-mk[the writing
  163. rules].