From 3e1b33a5349b21197da88405f32d3fc57a385421 Mon Sep 17 00:00:00 2001 From: Thomas Petazzoni Date: Fri, 1 Jan 2016 01:01:23 +0100 Subject: pkg-generic: improve incorrectly used package detection Currently, the check that packages we build are indeed enabled is done at the time a package is configured. This can come quite late in the build process, and does not provide direct knowledge of the real culprit for the incorrect dependency. However, we can improve these two issues quite easily, albeit at the expense of a very slightly more complicated make code. First, the check can not be done at the time we define the package, i.e. in the inner-generic-pacakge, because all its dependencies might have not been parsed yet, so we can't yet know whether it is enabled or not (because we can't match the package name of the dependency to its Kconfig variable yet). But then, we know we have all packages definitions after we scanned the the bundled packages, kernel, bootloaders and toolchains, as well as the br2-external tree (if any). So, at this location, we iterate through the list of enabled packages, and check that the packages they each depend on are indeed enabled. This allows us to: 1- do the check very early, before any build action, 2- report on the exact offending package very easily. Signed-off-by: "Yann E. MORIN" Cc: Thomas Petazzoni Signed-off-by: Peter Korsgaard --- Makefile | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 0883175e4..a21869a81 100644 --- a/Makefile +++ b/Makefile @@ -434,6 +434,34 @@ include fs/common.mk include $(BR2_EXTERNAL)/external.mk +# Now we are sure we have all the packages scanned and defined. We now +# check for each package in the list of enabled packages, that all its +# dependencies are indeed enabled. +# +# Only trigger the check for default builds. If the user forces building +# a package, even if not enabled in the configuration, we want to accept +# it. +# +ifeq ($(MAKECMDGOALS),) + +define CHECK_ONE_DEPENDENCY +ifeq ($$($(2)_TYPE),target) +ifeq ($$($(2)_IS_VIRTUAL),) +ifneq ($$($$($(2)_KCONFIG_VAR)),y) +$$(error $$($(2)_NAME) is in the dependency chain of $$($(1)_NAME) that \ +has added it to its _DEPENDENCIES variable without selecting it or \ +depending on it from Config.in) +endif +endif +endif +endef + +$(foreach pkg,$(call UPPERCASE,$(PACKAGES)),\ + $(foreach dep,$(call UPPERCASE,$($(pkg)_FINAL_ALL_DEPENDENCIES)),\ + $(eval $(call CHECK_ONE_DEPENDENCY,$(pkg),$(dep))$(sep)))) + +endif + dirs: $(BUILD_DIR) $(STAGING_DIR) $(TARGET_DIR) \ $(HOST_DIR) $(BINARIES_DIR) -- cgit v1.2.3