adding-packages-directory.txt 6.8 KB

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