summaryrefslogtreecommitdiffstats
path: root/docs/manual/adding-packages-directory.txt
blob: 52eb6539dbc74d3b80d1ca18655f8ca137e5a9e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
// -*- mode:doc; -*-
// vim: set syntax=asciidoc:

Package directory
~~~~~~~~~~~~~~~~~

First of all, create a directory under the +package+ directory for
your software, for example +libfoo+.

Some packages have been grouped by topic in a sub-directory:
+x11r7+, +efl+ and +matchbox+. If your package fits in
one of these categories, then create your package directory in these.
New subdirectories are discouraged, however.


+Config.in+ file
~~~~~~~~~~~~~~~~

Then, create a file named +Config.in+. This file will contain the
option descriptions related to our +libfoo+ software that will be used
and displayed in the configuration tool. It should basically contain:

---------------------------
config BR2_PACKAGE_LIBFOO
	bool "libfoo"
	help
	  This is a comment that explains what libfoo is.

	  http://foosoftware.org/libfoo/
---------------------------

The +bool+ line, +help+ line and other meta-informations about the
configuration option must be indented with one tab. The help text
itself should be indented with one tab and two spaces, and it must
mention the upstream URL of the project.

You can add other sub-options into a +if
BR2_PACKAGE_LIBFOO...endif+ statement to configure particular things
in your software. You can look at examples in other packages. The
syntax of the +Config.in+ file is the same as the one for the kernel
Kconfig file. The documentation for this syntax is available at
http://kernel.org/doc/Documentation/kbuild/kconfig-language.txt[]

Finally you have to add your new +libfoo/Config.in+ to
+package/Config.in+ (or in a category subdirectory if you decided to
put your package in one of the existing categories). The files
included there are 'sorted alphabetically' per category and are 'NOT'
supposed to contain anything but the 'bare' name of the package.

--------------------------
source "package/libfoo/Config.in"
--------------------------

[[depends-on-vs-select]]
Choosing +depends on+ or +select+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The +Config.in+ file of your package must also ensure that
dependencies are enabled. Typically, Buildroot uses the following
rules:

* Use a +select+ type of dependency for dependencies on
  libraries. These dependencies are generally not obvious and it
  therefore make sense to have the kconfig system ensure that the
  dependencies are selected. For example, the _libgtk2_ package uses
  +select BR2_PACKAGE_LIBGLIB2+ to make sure this library is also
  enabled.
  The +select+ keyword expresses the dependency with a backward
  semantic.

* Use a +depends on+ type of dependency when the user really needs to
  be aware of the dependency. Typically, Buildroot uses this type of
  dependency for dependencies on target architecture, MMU support and
  toolchain options (see xref:dependencies-target-toolchain-options[]),
  or for dependencies on "big" things, such as the X.org system.
  The +depends on+ keyword expresses the dependency with a forward
  semantic.

.Note
The current problem with the _kconfig_ language is that these two
dependency semantics are not internally linked. Therefore, it may be
possible to select a package, whom one of its dependencies/requirement
is not met.

An example illustrates both the usage of +select+ and +depends on+.

--------------------------
config BR2_PACKAGE_ACL
        bool "acl"
        select BR2_PACKAGE_ATTR
        depends on BR2_LARGEFILE
        help
          POSIX Access Control Lists, which are used to define more
          fine-grained discretionary access rights for files and
          directories.
          This package also provides libacl.

          http://savannah.nongnu.org/projects/acl

comment "acl needs a toolchain w/ largefile"
        depends on !BR2_LARGEFILE
--------------------------


Note that these two dependency types are only transitive with the
dependencies of the same kind.

This means, in the following example:

--------------------------
config BR2_PACKAGE_A
        bool "Package A"

config BR2_PACKAGE_B
        bool "Package B"
        depends on BR2_PACKAGE_A

config BR2_PACKAGE_C
        bool "Package C"
        depends on BR2_PACKAGE_B

config BR2_PACKAGE_D
        bool "Package D"
        select BR2_PACKAGE_B

config BR2_PACKAGE_E
        bool "Package E"
        select BR2_PACKAGE_D
--------------------------

* Selecting +Package C+ will be visible if +Package B+ has been
  selected, which in turn is only visible if +Package A+ has been
  selected.

* Selecting +Package E+ will select +Package D+, which will select
  +Package B+, it will not check for the dependencies of +Package B+,
  so it will not select +Package A+.

* Since +Package B+ is selected but +Package A+ is not, this violates
  the dependency of +Package B+ on +Package A+.  Therefore, in such a
  situation, the transitive dependency has to be added explicitly:

--------------------------
config BR2_PACKAGE_D
	bool "Package D"
	select BR2_PACKAGE_B
	depends on BR2_PACKAGE_A

config BR2_PACKAGE_E
	bool "Package E"
	select BR2_PACKAGE_D
	depends on BR2_PACKAGE_A
--------------------------

Overall, for package library dependencies, +select+ should be
preferred.

Note that such dependencies will ensure that the dependency option
is also enabled, but not necessarily built before your package. To do
so, the dependency also needs to be expressed in the +.mk+ file of the
package.

Further formatting details: see xref:writing-rules-config-in[the
coding style].

[[dependencies-target-toolchain-options]]
Dependencies on target and toolchain options
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Many packages depend on certain options of the toolchain: the choice of
C library, C++ support, largefile support, thread support, RPC support,
IPv6 support, wchar support, or dynamic library support. Some packages
can only be built on certain target architectures, or if an MMU is
available in the processor.

These dependencies have to be expressed with the appropriate 'depends
on' statements in the Config.in file. Additionally, for dependencies on
toolchain options, a +comment+ should be displayed when the option is
not enabled, so that the user knows why the package is not available.
Dependencies on target architecture or MMU support should not be
made visible in a comment: since it is unlikely that the user can
freely choose another target, it makes little sense to show these
dependencies explicitly.

The +comment+ should only be visible if the +config+ option itself would
be visible when the toolchain option dependencies are met. This means
that all other dependencies of the package (including dependencies on
target architecture and MMU support) have to be repeated on the
+comment+ definition. To keep it clear, the +depends on+ statement for
these non-toolchain option should be kept separate from the +depends on+
statement for the toolchain options.
If there is a dependency on a config option in that same file (typically
the main package) it is preferable to have a global +if ... endif+
construct rather than repeating the +depends on+ statement on the
comment and other config options.

The general format of a dependency +comment+ for package foo is:
--------------------------
foo needs a toolchain w/ featA, featB, featC
--------------------------

for example:
--------------------------
aircrack-ng needs a toolchain w/ largefile, threads
--------------------------
or
--------------------------
crda needs a toolchain w/ threads
--------------------------

Note that this text is kept brief on purpose, so that it will fit on a
80-character terminal.

The rest of this section enumerates the different target and toolchain
options, the corresponding config symbols to depend on, and the text to
use in the comment.

* Target architecture
** Dependency symbol: +BR2_powerpc+, +BR2_mips+, ... (see +arch/Config.in+)
** Comment string: no comment to be added

* MMU support
** Dependency symbol: +BR2_USE_MMU+
** Comment string: no comment to be added

* Kernel headers
** Dependency symbol: +BR2_TOOLCHAIN_HEADERS_AT_LEAST_X_Y+, (replace
   +X_Y+ with the proper version, see +toolchain/toolchain-common.in+)
** Comment string: +headers >= X.Y+ (replace +X.Y+ with the
   proper version)

* C library
** Dependency symbol: +BR2_TOOLCHAIN_USES_GLIBC+,
+BR2_TOOLCHAIN_USES_UCLIBC+
** Comment string: for the C library, a slightly different comment text
   is used: +foo needs an (e)glibc toolchain+, or `foo needs an (e)glibc
   toolchain w/ C++ support`

* C++ support
** Dependency symbol: +BR2_INSTALL_LIBSTDCPP+
** Comment string: `C++`

* largefile support
** Dependency symbol: +BR2_LARGEFILE+
** Comment string: +largefile+

* thread support
** Dependency symbol: +BR2_TOOLCHAIN_HAS_THREADS+
** Comment string: +threads+ (unless +BR2_TOOLCHAIN_HAS_THREADS_NPTL+
   is also needed, in which case, specifying only +NPTL+ is sufficient)

* NPTL thread support
** Dependency symbol: +BR2_TOOLCHAIN_HAS_THREADS_NPTL+
** Comment string: +NPTL+

* RPC support
** Dependency symbol: +BR2_TOOLCHAIN_HAS_NATIVE_RPC+
** Comment string: +RPC+

* IPv6 support
** Dependency symbol: +BR2_INET_IPV6+
** Comment string: +IPv6+ (lowercase v)

* wchar support
** Dependency symbol: +BR2_USE_WCHAR+
** Comment string: +wchar+

* dynamic library
** Dependency symbol: +!BR2_PREFER_STATIC_LIB+
** Comment string: +dynamic library+

Dependencies on a Linux kernel built by buildroot
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Some packages need a Linux kernel to be built by buildroot. These are
typically kernel modules or firmware. A comment should be added in the
Config.in file to express this dependency, similar to dependencies on
toolchain options. The general format is:

--------------------------
foo needs a Linux kernel to be built
--------------------------

If there is a dependency on both toolchain options and the Linux
kernel, use this format:
--------------------------
foo needs a toolchain w/ featA, featB, featC and a Linux kernel to be built
--------------------------

Dependencies on udev /dev management
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
If a package needs udev /dev management, it should depend on symbol
+BR2_PACKAGE_HAS_UDEV+, and the following comment should be added:

--------------------------
foo needs udev /dev management
--------------------------

If there is a dependency on both toolchain options and udev /dev
management, use this format:

--------------------------
foo needs udev /dev management and a toolchain w/ featA, featB, featC
--------------------------

The +.mk+ file
~~~~~~~~~~~~~~
[[adding-packages-mk]]

Finally, here's the hardest part. Create a file named +libfoo.mk+. It
describes how the package should be downloaded, configured, built,
installed, etc.

Depending on the package type, the +.mk+ file must be written in a
different way, using different infrastructures:

* *Makefiles for generic packages* (not using autotools or CMake):
  These are based on an infrastructure similar to the one used for
  autotools-based packages, but require a little more work from the
  developer. They specify what should be done for the configuration,
  compilation and installation of the package. This
  infrastructure must be used for all packages that do not use the
  autotools as their build system. In the future, other specialized
  infrastructures might be written for other build systems.  We cover
  them through in a xref:generic-package-tutorial[tutorial] and a
  xref:generic-package-reference[reference].

* *Makefiles for autotools-based software* (autoconf, automake, etc.):
  We provide a dedicated infrastructure for such packages, since
  autotools is a very common build system. This infrastructure 'must'
  be used for new packages that rely on the autotools as their build
  system. We cover them through a xref:autotools-package-tutorial[tutorial]
  and xref:autotools-package-reference[reference].

* *Makefiles for cmake-based software*: We provide a dedicated
   infrastructure for such packages, as CMake is a more and more
   commonly used build system and has a standardized behaviour. This
   infrastructure 'must' be used for new packages that rely on
   CMake. We cover them through a xref:cmake-package-tutorial[tutorial]
   and xref:cmake-package-reference[reference].

* *Makefiles for Python modules*: We have a dedicated infrastructure
   for Python modules that use either the +distutils+ or the
   +setuptools+ mechanism. We cover them through a
   xref:python-package-tutorial[tutorial] and a
   xref:python-package-reference[reference].

* *Makefiles for Lua modules*: We have a dedicated infrastructure for
   Lua modules available through the LuaRocks web site. We cover them
   through a xref:luarocks-package-tutorial[tutorial] and a
   xref:luarocks-package-reference[reference].

Further formatting details: see xref:writing-rules-mk[the writing
rules].
OpenPOWER on IntegriCloud