2013-12-05 20:11:13 +01:00
|
|
|
// -*- mode:doc -*- ;
|
2014-11-15 17:29:20 +01:00
|
|
|
// vim: set syntax=asciidoc:
|
2013-12-05 20:11:13 +01:00
|
|
|
|
|
|
|
[[outside-br-custom]]
|
2014-08-29 21:50:41 +02:00
|
|
|
=== Keeping customizations outside of Buildroot
|
2013-12-05 20:11:13 +01:00
|
|
|
|
2014-08-29 21:50:41 +02:00
|
|
|
As already briefly mentioned in xref:customize-dir-structure[], you can
|
|
|
|
place project-specific customizations in two locations:
|
2013-12-05 20:11:13 +01:00
|
|
|
|
2014-08-29 21:50:41 +02:00
|
|
|
* directly within the Buildroot tree, typically maintaining them using
|
|
|
|
branches in a version control system so that upgrading to a newer
|
|
|
|
Buildroot release is easy.
|
2013-12-05 20:11:13 +01:00
|
|
|
|
2016-10-14 16:39:18 +02:00
|
|
|
* outside of the Buildroot tree, using the _br2-external_ mechanism.
|
2014-08-29 21:50:41 +02:00
|
|
|
This mechanism allows to keep package recipes, board support and
|
|
|
|
configuration files outside of the Buildroot tree, while still
|
2016-10-14 16:39:18 +02:00
|
|
|
having them nicely integrated in the build logic. We call this
|
|
|
|
location a _br2-external tree_. This section explains how to use
|
|
|
|
the br2-external mechanism and what to provide in a br2-external
|
|
|
|
tree.
|
|
|
|
|
2016-10-14 16:39:21 +02:00
|
|
|
One can tell Buildroot to use one or more br2-external trees by setting
|
|
|
|
the +BR2_EXTERNAL+ make variable set to the path(s) of the br2-external
|
|
|
|
tree(s) to use. It can be passed to any Buildroot +make+ invocation. It
|
|
|
|
is automatically saved in the hidden +.br-external.mk+ file in the output
|
2016-10-14 16:39:18 +02:00
|
|
|
directory. Thanks to this, there is no need to pass +BR2_EXTERNAL+ at
|
|
|
|
every +make+ invocation. It can however be changed at any time by
|
|
|
|
passing a new value, and can be removed by passing an empty value.
|
2013-12-05 20:11:13 +01:00
|
|
|
|
2015-05-24 23:49:56 +02:00
|
|
|
.Note
|
2016-10-14 16:39:18 +02:00
|
|
|
The path to a br2-external tree can be either absolute or relative.
|
|
|
|
If it is passed as a relative path, it is important to note that it is
|
|
|
|
interpreted relative to the main Buildroot source directory, *not* to
|
|
|
|
the Buildroot output directory.
|
2013-12-05 20:11:13 +01:00
|
|
|
|
2016-10-14 16:39:19 +02:00
|
|
|
.Note:
|
|
|
|
If using an br2-external tree from before Buildroot 2016.11, you need to
|
|
|
|
convert it before you can use it with Buildroot 2016.11 onward. See
|
|
|
|
xref:br2-external-converting[] for help on doing so.
|
|
|
|
|
2013-12-05 20:11:13 +01:00
|
|
|
Some examples:
|
|
|
|
|
|
|
|
-----
|
2016-10-14 16:39:21 +02:00
|
|
|
buildroot/ $ make BR2_EXTERNAL=/path/to/foo menuconfig
|
2013-12-05 20:11:13 +01:00
|
|
|
-----
|
|
|
|
|
2016-10-14 16:39:21 +02:00
|
|
|
From now on, definitions from the +/path/to/foo+ br2-external tree
|
2016-10-14 16:39:18 +02:00
|
|
|
will be used:
|
2013-12-05 20:11:13 +01:00
|
|
|
|
|
|
|
-----
|
2015-05-24 23:49:55 +02:00
|
|
|
buildroot/ $ make
|
|
|
|
buildroot/ $ make legal-info
|
2013-12-05 20:11:13 +01:00
|
|
|
-----
|
|
|
|
|
2016-10-14 16:39:18 +02:00
|
|
|
We can switch to another br2-external tree at any time:
|
2013-12-05 20:11:13 +01:00
|
|
|
|
|
|
|
-----
|
2016-10-14 16:39:21 +02:00
|
|
|
buildroot/ $ make BR2_EXTERNAL=/where/we/have/bar xconfig
|
2013-12-05 20:11:13 +01:00
|
|
|
-----
|
|
|
|
|
2016-10-14 16:39:21 +02:00
|
|
|
We can also use multiple br2-external trees:
|
|
|
|
|
|
|
|
----
|
|
|
|
buildroot/ $ make BR2_EXTERNAL=/path/to/foo:/where/we/have/bar menuconfig
|
|
|
|
----
|
|
|
|
|
2016-10-14 16:39:18 +02:00
|
|
|
Or disable the usage of any br2-external tree:
|
2013-12-05 20:11:13 +01:00
|
|
|
|
|
|
|
-----
|
2015-05-24 23:49:55 +02:00
|
|
|
buildroot/ $ make BR2_EXTERNAL= xconfig
|
2013-12-05 20:11:13 +01:00
|
|
|
-----
|
|
|
|
|
2016-10-14 16:39:24 +02:00
|
|
|
==== Layout of a br2-external tree
|
|
|
|
|
|
|
|
A br2-external tree must contain at least those three files, described
|
|
|
|
in the following chapters:
|
|
|
|
|
|
|
|
* +external.desc+
|
|
|
|
* +external.mk+
|
|
|
|
* +Config.in+
|
|
|
|
|
|
|
|
Apart from those mandatory files, there may be additional and optional
|
|
|
|
content that may be present in a br2-external tree, like the +configs/+
|
|
|
|
directory. They are described in the following chapters as well.
|
|
|
|
|
|
|
|
A complete example br2-external tree layout is also described later.
|
|
|
|
|
|
|
|
===== The +external.desc+ file
|
|
|
|
|
|
|
|
That file describes the br2-external tree: the _name_ and _description_
|
|
|
|
for that br2-external tree.
|
|
|
|
|
|
|
|
The format for this file is line based, with each line starting by a
|
|
|
|
keyword, followed by a colon and one or more spaces, followed by the
|
|
|
|
value assigned to that keyword. There are two keywords currently
|
|
|
|
recognised:
|
|
|
|
|
|
|
|
* +name+, mandatory, defines the name for that br2-external tree. That
|
|
|
|
name must only use ASCII characters in the set +[A-Za-z0-9_]+; any
|
|
|
|
other character is forbidden. Buildroot sets the variable
|
|
|
|
+BR2_EXTERNAL_$(NAME)_PATH+ to the absolute path of the br2-external
|
|
|
|
tree, so that you can use it to refer to your br2-external tree. This
|
|
|
|
variable is available both in Kconfig, so you can use it to source your
|
|
|
|
Kconfig files (see below) and in the Makefile, so that you can use it
|
|
|
|
to include other Makefiles (see below) or refer to other files (like
|
|
|
|
data files) from your br2-external tree.
|
2016-10-14 16:39:18 +02:00
|
|
|
+
|
2016-10-14 16:39:21 +02:00
|
|
|
.Note:
|
|
|
|
Since it is possible to use multiple br2-external trees at once, this
|
|
|
|
name is used by Buildroot to generate variables for each of those trees.
|
|
|
|
That name is used to identify your br2-external tree, so try to come up
|
|
|
|
with a name that really describes your br2-external tree, in order for
|
|
|
|
it to be relatively unique, so that it does not clash with another name
|
|
|
|
from another br2-external tree, especially if you are planning on
|
|
|
|
somehow sharing your br2-external tree with third parties or using
|
|
|
|
br2-external trees from third parties.
|
2016-10-14 16:39:24 +02:00
|
|
|
|
|
|
|
* +desc+, optional, provides a short description for that br2-external
|
|
|
|
tree. It shall fit on a single line, is mostly free-form (see below),
|
|
|
|
and is used when displaying information about a br2-external tree (e.g.
|
|
|
|
above the list of defconfig files, or as the prompt in the menuconfig);
|
|
|
|
as such, it should relatively brief (40 chars is probably a good upper
|
2016-10-19 22:56:05 +02:00
|
|
|
limit). The description is available in the +BR2_EXTERNAL_$(NAME)_DESC+
|
|
|
|
variable.
|
2016-10-14 16:39:24 +02:00
|
|
|
|
2016-10-14 16:39:18 +02:00
|
|
|
Examples of names and the corresponding +BR2_EXTERNAL_$(NAME)_PATH+
|
|
|
|
variables:
|
2016-10-14 16:39:24 +02:00
|
|
|
|
2016-10-14 16:39:18 +02:00
|
|
|
* +FOO+ -> +BR2_EXTERNAL_FOO_PATH+
|
|
|
|
* +BAR_42+ -> +BR2_EXTERNAL_BAR_42_PATH+
|
2016-10-14 16:39:24 +02:00
|
|
|
|
2016-10-14 16:39:18 +02:00
|
|
|
In the following examples, it is assumed the name to be set to +BAR_42+.
|
|
|
|
|
2016-10-19 22:56:05 +02:00
|
|
|
.Note:
|
|
|
|
Both +BR2_EXTERNAL_$(NAME)_PATH+ and `BR2_EXTERNAL_$(NAME)_DESC` are
|
|
|
|
available in the Kconfig files and the Makefiles. They are also
|
|
|
|
exported in the environment so are available in post-build, post-image
|
|
|
|
and in-fakeroot scripts.
|
|
|
|
|
2016-10-14 16:39:24 +02:00
|
|
|
===== The +Config.in+ and +external.mk+ files
|
|
|
|
|
|
|
|
Those files (which may each be empty) can be used to define package
|
|
|
|
recipes (i.e. +foo/Config.in+ and +foo/foo.mk+ like for packages bundled
|
|
|
|
in Buildroot itself) or other custom configuration options or make logic.
|
|
|
|
|
|
|
|
Buildroot automatically includes the +Config.in+ from each br2-external
|
|
|
|
tree to make it appear in the top-level configuration menu, and includes
|
|
|
|
the +external.mk+ from each br2-external tree with the rest of the
|
|
|
|
makefile logic.
|
2016-10-14 16:39:18 +02:00
|
|
|
|
|
|
|
The main usage of this is to store package recipes. The recommended way
|
2016-10-14 16:39:24 +02:00
|
|
|
to do this is to write a +Config.in+ file that looks like:
|
|
|
|
|
2013-12-05 20:11:13 +01:00
|
|
|
------
|
2016-10-14 16:39:18 +02:00
|
|
|
source "$BR2_EXTERNAL_BAR_42_PATH/package/package1/Config.in"
|
|
|
|
source "$BR2_EXTERNAL_BAR_42_PATH/package/package2/Config.in"
|
2013-12-05 20:11:13 +01:00
|
|
|
------
|
2016-10-14 16:39:24 +02:00
|
|
|
|
2016-10-14 16:39:18 +02:00
|
|
|
Then, have an +external.mk+ file that looks like:
|
2016-10-14 16:39:24 +02:00
|
|
|
|
2013-12-05 20:11:13 +01:00
|
|
|
------
|
2016-10-14 16:39:18 +02:00
|
|
|
include $(sort $(wildcard $(BR2_EXTERNAL_BAR_42_PATH)/package/*/*.mk))
|
2013-12-05 20:11:13 +01:00
|
|
|
------
|
2016-10-14 16:39:24 +02:00
|
|
|
|
|
|
|
And then in +$(BR2_EXTERNAL_BAR_42_PATH)/package/package1+ and
|
|
|
|
+$(BR2_EXTERNAL_BAR_42_PATH)/package/package2+ create normal
|
|
|
|
Buildroot package recipes, as explained in xref:adding-packages[].
|
|
|
|
If you prefer, you can also group the packages in subdirectories
|
|
|
|
called <boardname> and adapt the above paths accordingly.
|
|
|
|
|
|
|
|
You can also define custom configuration options in +Config.in+ and
|
|
|
|
custom make logic in +external.mk+.
|
|
|
|
|
|
|
|
===== The +configs/+ directory
|
|
|
|
|
|
|
|
One can store Buildroot defconfigs in the +configs+ subdirectory of
|
|
|
|
the br2-external tree. Buildroot will automatically show them in the
|
|
|
|
output of +make list-defconfigs+ and allow them to be loaded with the
|
|
|
|
normal +make <name>_defconfig+ command. They will be visible in the
|
|
|
|
'make list-defconfigs' output, below an +External configs+ label that
|
2016-11-29 18:17:03 +01:00
|
|
|
contains the name of the br2-external tree they are defined in.
|
2016-10-14 16:39:24 +02:00
|
|
|
|
2016-10-14 16:39:21 +02:00
|
|
|
.Note:
|
|
|
|
If a defconfig file is present in more than one br2-external tree, then
|
2016-10-14 16:39:24 +02:00
|
|
|
the one from the last br2-external tree is used. It is thus possible
|
|
|
|
to override a defconfig bundled in Buildroot or another br2-external
|
|
|
|
tree.
|
|
|
|
|
|
|
|
===== Free-form content
|
|
|
|
|
|
|
|
One can store all the board-specific configuration files there, such
|
|
|
|
as the kernel configuration, the root filesystem overlay, or any other
|
|
|
|
configuration file for which Buildroot allows to set the location (by
|
|
|
|
using the +BR2_EXTERNAL_$(NAME)_PATH+ variable). For example, you
|
|
|
|
could set the paths to a global patch directory, to a rootfs overlay
|
|
|
|
and to the kernel configuration file as follows (e.g. by running
|
|
|
|
`make menuconfig` and filling in these options):
|
|
|
|
|
|
|
|
----
|
|
|
|
BR2_GLOBAL_PATCH_DIR=$(BR2_EXTERNAL_BAR_42_PATH)/patches/
|
|
|
|
BR2_ROOTFS_OVERLAY=$(BR2_EXTERNAL_BAR_42_PATH)/board/<boardname>/overlay/
|
2017-10-15 02:55:07 +02:00
|
|
|
BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE=$(BR2_EXTERNAL_BAR_42_PATH)/board/<boardname>/kernel.config
|
2016-10-14 16:39:24 +02:00
|
|
|
----
|
|
|
|
|
|
|
|
===== Example layout
|
|
|
|
|
|
|
|
Here is an example layout using all features of br2-external (the sample
|
|
|
|
content is shown for the file above it, when it is relevant to explain
|
|
|
|
the br2-external tree; this is all entirely made up just for the sake of
|
|
|
|
illustration, of course):
|
|
|
|
|
|
|
|
----
|
|
|
|
/path/to/br2-ext-tree/
|
|
|
|
|- external.desc
|
|
|
|
| |name: BAR_42
|
|
|
|
| |desc: Example br2-external tree
|
|
|
|
| `----
|
|
|
|
|
|
|
|
|
|- Config.in
|
2016-11-20 14:28:36 +01:00
|
|
|
| |source "$BR2_EXTERNAL_BAR_42_PATH/package/pkg-1/Config.in"
|
|
|
|
| |source "$BR2_EXTERNAL_BAR_42_PATH/package/pkg-2/Config.in"
|
2016-10-14 16:39:24 +02:00
|
|
|
| |
|
|
|
|
| |config BAR_42_FLASH_ADDR
|
|
|
|
| | hex "my-board flash address"
|
|
|
|
| | default 0x10AD
|
|
|
|
| `----
|
|
|
|
|
|
|
|
|
|- external.mk
|
|
|
|
| |include $(sort $(wildcard $(BR2_EXTERNAL_BAR_42_PATH)/package/*/*.mk))
|
|
|
|
| |
|
|
|
|
| |flash-my-board:
|
2016-11-20 14:28:36 +01:00
|
|
|
| | $(BR2_EXTERNAL_BAR_42_PATH)/board/my-board/flash-image \
|
2016-10-14 16:39:24 +02:00
|
|
|
| | --image $(BINARIES_DIR)/image.bin \
|
|
|
|
| | --address $(BAR_42_FLASH_ADDR)
|
|
|
|
| `----
|
|
|
|
|
|
|
|
|
|- package/pkg-1/Config.in
|
|
|
|
| |config BR2_PACKAGE_PKG_1
|
|
|
|
| | bool "pkg-1"
|
|
|
|
| | help
|
|
|
|
| | Some help about pkg-1
|
|
|
|
| `----
|
|
|
|
|- package/pkg-1/pkg-1.hash
|
|
|
|
|- package/pkg-1/pkg-1.mk
|
|
|
|
| |PKG_1_VERSION = 1.2.3
|
|
|
|
| |PKG_1_SITE = /some/where/to/get/pkg-1
|
|
|
|
| |PKG_1_LICENSE = blabla
|
|
|
|
| |
|
|
|
|
| |define PKG_1_INSTALL_INIT_SYSV
|
|
|
|
| | $(INSTALL) -D -m 0755 $(PKG_1_PKGDIR)/S99my-daemon \
|
|
|
|
| | $(TARGET_DIR)/etc/init.d/S99my-daemon
|
|
|
|
| |endef
|
|
|
|
| |
|
|
|
|
| |$(eval $(autotools-package))
|
|
|
|
| `----
|
|
|
|
|- package/pkg-1/S99my-daemon
|
|
|
|
|
|
|
|
|
|- package/pkg-2/Config.in
|
|
|
|
|- package/pkg-2/pkg-2.hash
|
|
|
|
|- package/pkg-2/pkg-2.mk
|
|
|
|
|
|
|
|
|
|- configs/my-board_defconfig
|
|
|
|
| |BR2_GLOBAL_PATCH_DIR="$(BR2_EXTERNAL_BAR_42_PATH)/patches/"
|
|
|
|
| |BR2_ROOTFS_OVERLAY="$(BR2_EXTERNAL_BAR_42_PATH)/board/my-board/overlay/"
|
|
|
|
| |BR2_ROOTFS_POST_IMAGE_SCRIPT="$(BR2_EXTERNAL_BAR_42_PATH)/board/my-board/post-image.sh"
|
2017-10-15 02:55:07 +02:00
|
|
|
| |BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="$(BR2_EXTERNAL_BAR_42_PATH)/board/my-board/kernel.config"
|
2016-10-14 16:39:24 +02:00
|
|
|
| `----
|
|
|
|
|
|
|
|
|
|- patches/linux/0001-some-change.patch
|
|
|
|
|- patches/linux/0002-some-other-change.patch
|
|
|
|
|- patches/busybox/0001-fix-something.patch
|
|
|
|
|
|
|
|
|
|- board/my-board/kernel.config
|
|
|
|
|- board/my-board/overlay/var/www/index.html
|
|
|
|
|- board/my-board/overlay/var/www/my.css
|
|
|
|
|- board/my-board/flash-image
|
|
|
|
`- board/my-board/post-image.sh
|
|
|
|
|#!/bin/sh
|
|
|
|
|generate-my-binary-image \
|
|
|
|
| --root ${BINARIES_DIR}/rootfs.tar \
|
|
|
|
| --kernel ${BINARIES_DIR}/zImage \
|
|
|
|
| --dtb ${BINARIES_DIR}/my-board.dtb \
|
|
|
|
| --output ${BINARIES_DIR}/image.bin
|
|
|
|
`----
|
|
|
|
----
|
|
|
|
|
|
|
|
The br2-external tree will then be visible in the menuconfig (with
|
|
|
|
the layout expanded):
|
|
|
|
|
|
|
|
----
|
|
|
|
External options --->
|
|
|
|
*** Example br2-external tree (in /path/to/br2-ext-tree/)
|
|
|
|
[ ] pkg-1
|
|
|
|
[ ] pkg-2
|
|
|
|
(0x10AD) my-board flash address
|
|
|
|
----
|
|
|
|
|
|
|
|
If you are using more than one br2-external tree, it would look like
|
|
|
|
(with the layout expanded and the second one with name +FOO_27+ but no
|
|
|
|
+desc:+ field in +external.desc+):
|
|
|
|
|
|
|
|
----
|
|
|
|
External options --->
|
|
|
|
Example br2-external tree --->
|
|
|
|
*** Example br2-external tree (in /path/to/br2-ext-tree)
|
|
|
|
[ ] pkg-1
|
|
|
|
[ ] pkg-2
|
|
|
|
(0x10AD) my-board flash address
|
|
|
|
FOO_27 --->
|
|
|
|
*** FOO_27 (in /path/to/another-br2-ext)
|
|
|
|
[ ] foo
|
|
|
|
[ ] bar
|
|
|
|
----
|