adding-packages-directory.txt 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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+, +java+, +x11r7+, and +games+. If your package fits in
  8. one of these categories, then create your package directory in these.
  9. +Config.in+ file
  10. ^^^^^^^^^^^^^^^^
  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 meta-informations 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. Of course, 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://lxr.free-electrons.com/source/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. The +Config.in+ file of your package must also ensure that
  41. dependencies are enabled. Typically, Buildroot uses the following
  42. rules:
  43. * Use a +select+ type of dependency for dependencies on
  44. libraries. These dependencies are generally not obvious and it
  45. therefore make sense to have the kconfig system ensure that the
  46. dependencies are selected. For example, the _libgtk2_ package uses
  47. +select BR2_PACKAGE_LIBGLIB2+ to make sure this library is also
  48. enabled.
  49. The +select+ keyword express the dependency with a backward
  50. semantic.
  51. * Use a +depends on+ type of dependency when the user really needs to
  52. be aware of the dependency. Typically, Buildroot uses this type of
  53. dependency for dependencies on toolchain options (target
  54. architecture, MMU support, C library, C++ support, large file
  55. support, thread support, RPC support, IPV6 support, WCHAR support),
  56. or for dependencies on "big" things, such as the X.org system. In
  57. some cases, especially dependency on toolchain options, it is
  58. recommended to add a +comment+ displayed when the option is not
  59. enabled, so that the user knows why the package is not available.
  60. The +depends on+ keyword express 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 requires a toolchain with LARGEFILE support"
  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. writing rules].
  128. The +.mk+ file
  129. ^^^^^^^^^^^^^^
  130. Finally, here's the hardest part. Create a file named +libfoo.mk+. It
  131. describes how the package should be downloaded, configured, built,
  132. installed, etc.
  133. Depending on the package type, the +.mk+ file must be written in a
  134. different way, using different infrastructures:
  135. * *Makefiles for generic packages* (not using autotools or CMake):
  136. These are based on an infrastructure similar to the one used for
  137. autotools-based packages, but require a little more work from the
  138. developer. They specify what should be done for the configuration,
  139. compilation, installation and cleanup of the package. This
  140. infrastructure must be used for all packages that do not use the
  141. autotools as their build system. In the future, other specialized
  142. infrastructures might be written for other build systems. We cover
  143. them through in a xref:generic-package-tutorial[tutorial] and a
  144. xref:generic-package-reference[reference].
  145. * *Makefiles for autotools-based software* (autoconf, automake, etc.):
  146. We provide a dedicated infrastructure for such packages, since
  147. autotools is a very common build system. This infrastructure 'must'
  148. be used for new packages that rely on the autotools as their build
  149. system. We cover them through a xref:autotools-package-tutorial[tutorial]
  150. and xref:autotools-package-reference[reference].
  151. * *Makefiles for cmake-based software*: We provide a dedicated
  152. infrastructure for such packages, as CMake is a more and more
  153. commonly used build system and has a standardized behaviour. This
  154. infrastructure 'must' be used for new packages that rely on
  155. CMake. We cover them through a xref:cmake-package-tutorial[tutorial]
  156. and xref:cmake-package-reference[reference].
  157. Further formating details: see xref:writing-rules-mk[the writing
  158. rules].