From 216f4e78a87ace8cbef7a11c38963efbe76e4774 Mon Sep 17 00:00:00 2001 From: Junjie Mao Date: Sat, 9 Jun 2018 15:37:55 +0800 Subject: [PATCH] HV: make: append dependency checking targets to a given variable The current implementation of the check_dep_* macros always append the prerequisite checking target to BUILD_DEPS, but there are some cases when some prerequisites are only necessary for some specific targets instead of general builds. This patch adds a second parameter to the check_dep_* macros specifying which variable the generated target should be appended to. Signed-off-by: Junjie Mao Acked-by: Anthony Xu Acked-by: Geoffroy VanCutsem --- hypervisor/Makefile | 2 +- hypervisor/scripts/kconfig/kconfig.mk | 10 +++++----- scripts/deps.mk | 21 +++++++++++++-------- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/hypervisor/Makefile b/hypervisor/Makefile index 2020c66e0..6ae96b906 100644 --- a/hypervisor/Makefile +++ b/hypervisor/Makefile @@ -183,7 +183,7 @@ DISTCLEAN_OBJS := $(shell find $(BASEDIR) -name '*.o') VERSION := bsp/$(PLATFORM)/include/bsp/version.h .PHONY: all -all: $(BUILD_DEPS) $(VERSION) $(HV_OBJDIR)/$(HV_FILE).32.out $(HV_OBJDIR)/$(HV_FILE).bin +all: $(VERSION) $(HV_OBJDIR)/$(HV_FILE).32.out $(HV_OBJDIR)/$(HV_FILE).bin rm -f $(VERSION) ifeq ($(PLATFORM), uefi) diff --git a/hypervisor/scripts/kconfig/kconfig.mk b/hypervisor/scripts/kconfig/kconfig.mk index d8a30d45a..fc4736d15 100644 --- a/hypervisor/scripts/kconfig/kconfig.mk +++ b/hypervisor/scripts/kconfig/kconfig.mk @@ -5,9 +5,9 @@ HV_CONFIG_MK := include/config.mk KCONFIG_DIR := $(BASEDIR)/../scripts/kconfig -$(eval $(call check_dep_exec,python)) -$(eval $(call check_dep_exec,pip)) -$(eval $(call check_dep_pylib,kconfiglib)) +$(eval $(call check_dep_exec,python3,KCONFIG_DEPS)) +$(eval $(call check_dep_exec,pip3,KCONFIG_DEPS)) +$(eval $(call check_dep_py3lib,kconfiglib,KCONFIG_DEPS)) # This target invoke silentoldconfig to generate or update a .config. Useful as # a prerequisite of other targets depending on .config. @@ -26,7 +26,7 @@ $(HV_OBJDIR)/$(HV_CONFIG_H): $(HV_OBJDIR)/$(HV_CONFIG) # This target forcefully generate a .config based on a given default # one. Overwrite the current .config if it exists. .PHONY: defconfig -defconfig: +defconfig: $(KCONFIG_DEPS) @mkdir -p $(HV_OBJDIR) @python $(KCONFIG_DIR)/defconfig.py Kconfig arch/x86/configs/$(PLATFORM).config $(HV_OBJDIR)/$(HV_CONFIG) @@ -35,7 +35,7 @@ defconfig: # prerequisite of all the others to make sure that the .config is consistent # even it has been modified manually before. .PHONY: oldconfig -oldconfig: +oldconfig: $(KCONFIG_DEPS) @mkdir -p $(HV_OBJDIR) @python $(KCONFIG_DIR)/silentoldconfig.py Kconfig $(HV_OBJDIR)/$(HV_CONFIG) PLATFORM_$(shell echo $(PLATFORM) | tr a-z A-Z)=y diff --git a/scripts/deps.mk b/scripts/deps.mk index a2199f066..8e8759fc0 100644 --- a/scripts/deps.mk +++ b/scripts/deps.mk @@ -1,8 +1,10 @@ -# check the existence of a specific executable -# usage: check_dep_exec +# usage: check_dep_exec +# +# Create a target that checks the existence of the specified executable, and +# append that target to the given variable. define check_dep_exec = -BUILD_DEPS += check_$(1) -check_$(1): +$(2) += check_exec_$(1) +check_exec_$(1): @if ! which $(1) > /dev/null; then \ echo "******** Missing prerequisite tool ********"; \ echo "Cannot find executable *$(1)*"; \ @@ -12,11 +14,14 @@ check_$(1): fi endef -# check the existence of a specific python library -# usage: check_dep_pylib +# usage: check_dep_pylib +# +# Create a target that checks the existence of the specified python library, and +# append that target to the given variable. The default python version (which +# can be either 2.x or 3.x) is used. define check_dep_pylib = -BUILD_DEPS += check_$(1) -check_$(1): +$(2) += check_pylib_$(1) +check_pylib_$(1): @if ! pip list 2>/dev/null | grep $(1) > /dev/null 2>&1; then \ echo "******** Missing prerequisite tool ********"; \ echo "The python library *$(1)* is not installed"; \