package/pkg-kconfig: fix bad config with per-package-dirs

If BR2_PER_PACKAGE_DIRECTORIES is enabled and Buildroot is using
HOST_MAKE for a Kconfig package. The $(1)_KCONFIG_RULES does not work
correctly, and kconfig-package-regen-dot-config will always run the
'oldconfig' target.

This is because $(1)_KCONFIG_RULES expands before the first recipe line
of .stamp_dotconfig. $(1)_KCONFIG_RULES attempts to call $(HOST_MAKE),
which requires that the per-package/<pkg>/host directory has been setup.
But that directory is not setup until a later recipe line. This results
in $(1)_KCONFIG_RULES silently failing, and so always configuring with
'oldconfig'.

Fix the issue by calling the command as part of the recipe, so
$(HOST_MAKE) will be ready in time. As the comment on $(1)_KCONFIG_RULES
describes, we should not use backticks. Use an intermediary file to
store the output of the command, so that backticks are not needed.

Signed-off-by: Brandon Maier <brandon.maier@collins.com>
Signed-off-by: Arnout Vandecappelle <arnout@mind.be>
This commit is contained in:
Brandon Maier 2022-11-23 11:31:49 -06:00 committed by Arnout Vandecappelle
parent 1692691e45
commit fb449c72cd

View File

@ -45,11 +45,16 @@ endef
# only, as this can fail in complex cases.
# $(1): the name of the package in upper-case letters
define kconfig-package-regen-dot-config
$(if $(filter olddefconfig,$($(1)_KCONFIG_RULES)),
$(Q)$($(1)_KCONFIG_MAKE) olddefconfig,
$(if $(filter oldnoconfig,$($(1)_KCONFIG_RULES)),
$(Q)$($(1)_KCONFIG_MAKE) oldnoconfig,
$(Q)(yes "" | $($(1)_KCONFIG_MAKE) oldconfig)))
$(Q)[ -e $($(1)_DIR)/.br_regen_dot_config ] || \
$($(1)_KCONFIG_MAKE) -pn config 2>/dev/null \
| sed 's/^\([_0-9a-zA-Z]*config\):.*/\1/ p; d' >$($(1)_DIR)/.br_regen_dot_config
$(Q)if grep -q '\bolddefconfig\b' $($(1)_DIR)/.br_regen_dot_config; then \
$($(1)_KCONFIG_MAKE) olddefconfig; \
elif grep -q '\boldnoconfig\b' $($(1)_DIR)/.br_regen_dot_config; then \
$($(1)_KCONFIG_MAKE) oldnoconfig; \
else \
yes "" | $($(1)_KCONFIG_MAKE) oldconfig; \
fi
endef
# Macro to create a .config file where all given fragments are merged into.
@ -147,19 +152,6 @@ $(2)_KCONFIG_MAKE = \
$$($(2)_MAKE_ENV) $$($(2)_MAKE) -C $$($(2)_DIR) \
$$(PKG_KCONFIG_COMMON_OPTS) $$($(2)_KCONFIG_OPTS)
# $(2)_KCONFIG_MAKE may already rely on shell expansion. As the $() syntax
# of the shell conflicts with Make's own syntax, this means that backticks
# are used with those shell constructs. Unfortunately, the backtick syntax
# does not nest, and we need to use Make instead of the shell to handle
# conditions.
# A recursively expanded variable is necessary, to be sure that the shell
# command is called when the rule is processed during the build and not
# when the rule is created when parsing all packages.
$(2)_KCONFIG_RULES = \
$$(shell $$($(2)_KCONFIG_MAKE) -pn config 2>/dev/null | \
sed 's/^\([_0-9a-zA-Z]*config\):.*/\1/ p; d')
# The specified source configuration file and any additional configuration file
# fragments are merged together to .config, after the package has been patched.
# Since the file could be a defconfig file it needs to be expanded to a