adding-packages-directory.txt 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. // -*- mode:doc; -*-
  2. Package directory
  3. ~~~~~~~~~~~~~~~~~
  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. +multimedia+, +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. ~~~~~~~~~~~~~~~~
  12. Then, create a file named +Config.in+. This file will contain the
  13. option descriptions related to our +libfoo+ software that will be used
  14. and displayed in the configuration tool. It should basically contain:
  15. ---------------------------
  16. config BR2_PACKAGE_LIBFOO
  17. bool "libfoo"
  18. help
  19. This is a comment that explains what libfoo is.
  20. http://foosoftware.org/libfoo/
  21. ---------------------------
  22. The +bool+ line, +help+ line and other meta-informations about the
  23. configuration option must be indented with one tab. The help text
  24. itself should be indented with one tab and two spaces, and it must
  25. mention the upstream URL of the project.
  26. You can add other sub-options into a +if
  27. BR2_PACKAGE_LIBFOO...endif+ statement to configure particular things
  28. in your software. You can look at examples in other packages. The
  29. syntax of the +Config.in+ file is the same as the one for the kernel
  30. Kconfig file. The documentation for this syntax is available at
  31. http://kernel.org/doc/Documentation/kbuild/kconfig-language.txt[]
  32. Finally you have to add your new +libfoo/Config.in+ to
  33. +package/Config.in+ (or in a category subdirectory if you decided to
  34. put your package in one of the existing categories). The files
  35. included there are 'sorted alphabetically' per category and are 'NOT'
  36. supposed to contain anything but the 'bare' name of the package.
  37. --------------------------
  38. source "package/libfoo/Config.in"
  39. --------------------------
  40. [[depends-on-vs-select]]
  41. Choosing +depends on+ or +select+
  42. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  43. The +Config.in+ file of your package must also ensure that
  44. dependencies are enabled. Typically, Buildroot uses the following
  45. rules:
  46. * Use a +select+ type of dependency for dependencies on
  47. libraries. These dependencies are generally not obvious and it
  48. therefore make sense to have the kconfig system ensure that the
  49. dependencies are selected. For example, the _libgtk2_ package uses
  50. +select BR2_PACKAGE_LIBGLIB2+ to make sure this library is also
  51. enabled.
  52. The +select+ keyword express the dependency with a backward
  53. semantic.
  54. * Use a +depends on+ type of dependency when the user really needs to
  55. be aware of the dependency. Typically, Buildroot uses this type of
  56. dependency for dependencies on toolchain options (target
  57. architecture, MMU support, C library, C++ support, large file
  58. support, thread support, RPC support, IPV6 support, WCHAR support),
  59. or for dependencies on "big" things, such as the X.org system. For
  60. dependencies on toolchain options, there should be a +comment+ that
  61. is displayed when the option is not
  62. enabled, so that the user knows why the package is not available.
  63. The +depends on+ keyword express the dependency with a forward
  64. semantic.
  65. .Note
  66. The current problem with the _kconfig_ language is that these two
  67. dependency semantics are not internally linked. Therefore, it may be
  68. possible to select a package, whom one of its dependencies/requirement
  69. is not met.
  70. An example illustrates both the usage of +select+ and +depends on+.
  71. --------------------------
  72. config BR2_PACKAGE_ACL
  73. bool "acl"
  74. select BR2_PACKAGE_ATTR
  75. depends on BR2_LARGEFILE
  76. help
  77. POSIX Access Control Lists, which are used to define more
  78. fine-grained discretionary access rights for files and
  79. directories.
  80. This package also provides libacl.
  81. http://savannah.nongnu.org/projects/acl
  82. comment "acl requires a toolchain with LARGEFILE support"
  83. depends on !BR2_LARGEFILE
  84. --------------------------
  85. Note that these two dependency types are only transitive with the
  86. dependencies of the same kind.
  87. This means, in the following example:
  88. --------------------------
  89. config BR2_PACKAGE_A
  90. bool "Package A"
  91. config BR2_PACKAGE_B
  92. bool "Package B"
  93. depends on BR2_PACKAGE_A
  94. config BR2_PACKAGE_C
  95. bool "Package C"
  96. depends on BR2_PACKAGE_B
  97. config BR2_PACKAGE_D
  98. bool "Package D"
  99. select BR2_PACKAGE_B
  100. config BR2_PACKAGE_E
  101. bool "Package E"
  102. select BR2_PACKAGE_D
  103. --------------------------
  104. * Selecting +Package C+ will be visible if +Package B+ has been
  105. selected, which in turn is only visible if +Package A+ has been
  106. selected.
  107. * Selecting +Package E+ will select +Package D+, which will select
  108. +Package B+, it will not check for the dependencies of +Package B+,
  109. so it will not select +Package A+.
  110. * Since +Package B+ is selected but +Package A+ is not, this violates
  111. the dependency of +Package B+ on +Package A+. Therefore, in such a
  112. situation, the transitive dependency has to be added explicitly:
  113. --------------------------
  114. config BR2_PACKAGE_D
  115. bool "Package D"
  116. select BR2_PACKAGE_B
  117. depends on BR2_PACKAGE_A
  118. config BR2_PACKAGE_E
  119. bool "Package E"
  120. select BR2_PACKAGE_D
  121. depends on BR2_PACKAGE_A
  122. --------------------------
  123. Overall, for package library dependencies, +select+ should be
  124. preferred.
  125. Note that such dependencies will ensure that the dependency option
  126. is also enabled, but not necessarily built before your package. To do
  127. so, the dependency also needs to be expressed in the +.mk+ file of the
  128. package.
  129. Further formatting details: see xref:writing-rules-config-in[the
  130. coding style].
  131. The +.mk+ file
  132. ~~~~~~~~~~~~~~
  133. Finally, here's the hardest part. Create a file named +libfoo.mk+. It
  134. describes how the package should be downloaded, configured, built,
  135. installed, etc.
  136. Depending on the package type, the +.mk+ file must be written in a
  137. different way, using different infrastructures:
  138. * *Makefiles for generic packages* (not using autotools or CMake):
  139. These are based on an infrastructure similar to the one used for
  140. autotools-based packages, but require a little more work from the
  141. developer. They specify what should be done for the configuration,
  142. compilation, installation and cleanup of the package. This
  143. infrastructure must be used for all packages that do not use the
  144. autotools as their build system. In the future, other specialized
  145. infrastructures might be written for other build systems. We cover
  146. them through in a xref:generic-package-tutorial[tutorial] and a
  147. xref:generic-package-reference[reference].
  148. * *Makefiles for autotools-based software* (autoconf, automake, etc.):
  149. We provide a dedicated infrastructure for such packages, since
  150. autotools is a very common build system. This infrastructure 'must'
  151. be used for new packages that rely on the autotools as their build
  152. system. We cover them through a xref:autotools-package-tutorial[tutorial]
  153. and xref:autotools-package-reference[reference].
  154. * *Makefiles for cmake-based software*: We provide a dedicated
  155. infrastructure for such packages, as CMake is a more and more
  156. commonly used build system and has a standardized behaviour. This
  157. infrastructure 'must' be used for new packages that rely on
  158. CMake. We cover them through a xref:cmake-package-tutorial[tutorial]
  159. and xref:cmake-package-reference[reference].
  160. Further formating details: see xref:writing-rules-mk[the writing
  161. rules].