License flag matching allows you to control what recipes
the OpenEmbedded build system includes in the build.
Fundamentally, the build system attempts to match
LICENSE_FLAGS
strings found in recipes against
LICENSE_FLAGS_WHITELIST
strings found in the whitelist.
A match causes the build system to include a recipe in the
build, while failure to find a match causes the build
system to exclude a recipe.
In general, license flag matching is simple. However, understanding some concepts will help you correctly and effectively use matching.
Before a flag
defined by a particular recipe is tested against the
contents of the whitelist, the expanded string
_${PN}
is appended to the flag.
This expansion makes each
LICENSE_FLAGS
value recipe-specific.
After expansion, the string is then matched against the
whitelist.
Thus, specifying
LICENSE_FLAGS = "commercial"
in recipe "foo", for example, results in the string
"commercial_foo"
.
And, to create a match, that string must appear in the
whitelist.
Judicious use of the LICENSE_FLAGS
strings and the contents of the
LICENSE_FLAGS_WHITELIST
variable
allows you a lot of flexibility for including or excluding
recipes based on licensing.
For example, you can broaden the matching capabilities by
using license flags string subsets in the whitelist.
usethispart_1.3
,
usethispart_1.4
, and so forth).
For example, simply specifying the string "commercial" in
the whitelist matches any expanded
LICENSE_FLAGS
definition that starts
with the string "commercial" such as "commercial_foo" and
"commercial_bar", which are the strings the build system
automatically generates for hypothetical recipes named
"foo" and "bar" assuming those recipes simply specify the
following:
LICENSE_FLAGS = "commercial"
Thus, you can choose to exhaustively enumerate each license flag in the whitelist and allow only specific recipes into the image, or you can use a string subset that causes a broader range of matches to allow a range of recipes into the image.
This scheme works even if the
LICENSE_FLAGS
string already
has _${PN}
appended.
For example, the build system turns the license flag
"commercial_1.2_foo" into "commercial_1.2_foo_foo" and
would match both the general "commercial" and the specific
"commercial_1.2_foo" strings found in the whitelist, as
expected.
Here are some other scenarios:
You can specify a versioned string in the recipe such as "commercial_foo_1.2" in a "foo" recipe. The build system expands this string to "commercial_foo_1.2_foo". Combine this license flag with a whitelist that has the string "commercial" and you match the flag along with any other flag that starts with the string "commercial".
Under the same circumstances, you can use "commercial_foo" in the whitelist and the build system not only matches "commercial_foo_1.2" but also matches any license flag with the string "commercial_foo", regardless of the version.
You can be very specific and use both the package and version parts in the whitelist (e.g. "commercial_foo_1.2") to specifically match a versioned recipe.