#### 3.4.2.1. License Flag Matching

The definition of 'matching' in reference to a recipe's `LICENSE_FLAGS` setting is simple. However, some things exist that you should know about in order to correctly and effectively use it.

Before a flag defined by a particular recipe is tested against the contents of the `LICENSE_FLAGS_WHITELIST` variable, the string `_${PN}` (with `PN` expanded of course) is appended to the flag, thus automatically making each `LICENSE_FLAGS` value recipe-specific. That string is then matched against the whitelist. So if you specify `LICENSE_FLAGS = "commercial"` in recipe "foo" for example, the string `"commercial_foo"` would normally be what is specified in the whitelist in order for it to match.

You can broaden the match by putting any "_"-separated beginning subset of a `LICENSE_FLAGS` flag in the whitelist, which will also match. For example, simply specifying "commercial" in the whitelist would match any expanded `LICENSE_FLAGS` definition starting with "commercial" such as "commercial_foo" and "commercial_bar", which are the strings that would be automatically generated for hypothetical "foo" and "bar" recipes assuming those recipes had simply specified the following:

         LICENSE_FLAGS = "commercial"

Broadening the match allows for a range of specificity for the items in the whitelist, from more general to perfectly specific. So you have the choice of exhaustively enumerating each license flag in the whitelist to allow only those specific recipes into the image, or of using a more general string to pick up anything matching just the first component or components of the specified string.

This scheme works even if the flag already has `_${PN}` appended - the extra `_${PN}` is redundant, but does not affect the outcome. For example, a license flag of "commercial_1.2_foo" would turn into "commercial_1.2_foo_foo" and would match both the general "commercial" and the specific "commercial_1.2_foo", as expected. The flag would also match "commercial_1.2_foo_foo" and "commercial_1.2", which does not make much sense regarding use in the whitelist.

For a versioned string, you could instead specify "commercial_foo_1.2", which would turn into "commercial_foo_1.2_foo". And, as expected, this flag allows you to pick up this package along with anything else "commercial" when you specify "commercial" in the whitelist. Or, the flag allows you to pick up this package along with anything "commercial_foo" regardless of version when you use "commercial_foo" in the whitelist. Finally, you can be completely specific about the package and version and specify "commercial_foo_1.2" package and version.