Skip to content

Commit 82e93b7

Browse files
jsun26intelwenlingz
authored andcommitted
Makefile: make hypervisor from specified Kconfig
When user finish doing "make menuconfig", the .config file is saved in acrn-config/hypervisor/build/ by default. So current Makefile will check whether this customized .config file exists and then continue to do following make process. But this might not true in the real user case, user could put this customized .config file anywhere. To resolve this problem, the patch add a KCONFIG_FILE parameter to handle such case. When KCONFIG_FILE is specified, hypervisor could build hypervisor with the specific configuration file. Tracked-On: #4517 Signed-off-by: Victor Sun <victor.sun@intel.com>
1 parent f8abeb0 commit 82e93b7

File tree

1 file changed

+33
-24
lines changed

1 file changed

+33
-24
lines changed

Makefile

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
1+
# acrn-hypervisor/Makefile
12

23
# global helper variables
34
T := $(CURDIR)
45

6+
ifneq ($(KCONFIG_FILE),)
7+
ifneq ($(KCONFIG_FILE), $(wildcard $(KCONFIG_FILE)))
8+
$(error KCONFIG_FILE: $(KCONFIG_FILE) does not exist)
9+
endif
10+
override KCONFIG_FILE := $(realpath $(KCONFIG_FILE))
11+
else
12+
override KCONFIG_FILE := $(T)/hypervisor/build/.config
13+
endif
14+
515
BOARD ?= kbl-nuc-i7
616

717
ifneq (,$(filter $(BOARD),apl-mrb))
@@ -22,7 +32,6 @@ TOOLS_OUT := $(ROOT_OUT)/misc/tools
2232
DOC_OUT := $(ROOT_OUT)/doc
2333
BUILD_VERSION ?=
2434
BUILD_TAG ?=
25-
DEFAULT_MENU_CONFIG_FILE ?= $(T)/hypervisor/build/.config
2635
GENED_ACPI_INFO_HEADER = $(T)/hypervisor/arch/x86/configs/$(BOARD)/$(BOARD)_acpi_info.h
2736
HV_CFG_LOG = $(HV_OUT)/cfg.log
2837

@@ -59,22 +68,22 @@ endif
5968

6069
include $(T)/hypervisor/scripts/makefile/cfg_update.mk
6170

62-
ifeq ($(DEFAULT_MENU_CONFIG_FILE), $(wildcard $(DEFAULT_MENU_CONFIG_FILE)))
63-
BOARD_IN_MENUCONFIG := $(shell grep CONFIG_BOARD= $(DEFAULT_MENU_CONFIG_FILE) | awk -F '"' '{print $$2}')
64-
SCENARIO_IN_MENUCONFIG := $(shell grep -E "SDC=y|SDC2=y|INDUSTRY=y|LOGICAL_PARTITION=y|HYBRID=y" \
65-
$(DEFAULT_MENU_CONFIG_FILE) | awk -F "=" '{print $$1}' | cut -d '_' -f 2- | tr A-Z a-z)
71+
ifeq ($(KCONFIG_FILE), $(wildcard $(KCONFIG_FILE)))
72+
BOARD_IN_KCONFIG := $(shell grep CONFIG_BOARD= $(KCONFIG_FILE) | awk -F '"' '{print $$2}')
73+
SCENARIO_IN_KCONFIG := $(shell grep -E "SDC=y|SDC2=y|INDUSTRY=y|LOGICAL_PARTITION=y|HYBRID=y" \
74+
$(KCONFIG_FILE) | awk -F "=" '{print $$1}' | cut -d '_' -f 2- | tr A-Z a-z)
6675

67-
RELEASE := $(shell grep CONFIG_RELEASE=y $(DEFAULT_MENU_CONFIG_FILE))
76+
RELEASE := $(shell grep CONFIG_RELEASE=y $(KCONFIG_FILE))
6877
ifneq ($(RELEASE),)
6978
override RELEASE := 1
7079
endif
7180

72-
ifneq ($(BOARD_IN_MENUCONFIG),$(BOARD))
73-
override BOARD := $(BOARD_IN_MENUCONFIG)
81+
ifneq ($(BOARD_IN_KCONFIG),$(BOARD))
82+
override BOARD := $(BOARD_IN_KCONFIG)
7483
endif
7584

76-
ifneq ($(SCENARIO_IN_MENUCONFIG),$(SCENARIO))
77-
override SCENARIO := $(SCENARIO_IN_MENUCONFIG)
85+
ifneq ($(SCENARIO_IN_KCONFIG),$(SCENARIO))
86+
override SCENARIO := $(SCENARIO_IN_KCONFIG)
7887
endif
7988

8089
endif
@@ -111,19 +120,17 @@ hypervisor:
111120
&& [ "$(SCENARIO)" != "logical_partition" ] && [ "$(SCENARIO)" != "hybrid" ]; then \
112121
echo "SCENARIO <$(SCENARIO)> is not supported. "; exit 1; \
113122
fi
114-
$(MAKE) -C $(T)/hypervisor HV_OBJDIR=$(HV_OUT) clean;
115-
@if [ -f $(DEFAULT_MENU_CONFIG_FILE) ]; then \
116-
mkdir -p $(HV_OUT) && cp $(DEFAULT_MENU_CONFIG_FILE) $(HV_OUT)/.config; \
117-
else \
118-
$(MAKE) -C $(T)/hypervisor HV_OBJDIR=$(HV_OUT) BOARD_FILE=$(BOARD_FILE) SCENARIO_FILE=$(SCENARIO_FILE) defconfig; \
119-
echo "CONFIG_$(shell echo $(SCENARIO) | tr a-z A-Z)=y" >> $(HV_OUT)/.config; \
123+
$(MAKE) -C $(T)/hypervisor HV_OBJDIR=$(HV_OUT) BOARD_FILE=$(BOARD_FILE) SCENARIO_FILE=$(SCENARIO_FILE) clean;
124+
$(MAKE) -C $(T)/hypervisor HV_OBJDIR=$(HV_OUT) BOARD_FILE=$(BOARD_FILE) SCENARIO_FILE=$(SCENARIO_FILE) defconfig;
125+
@if [ -f $(KCONFIG_FILE) ]; then \
126+
cp $(KCONFIG_FILE) $(HV_OUT)/.config; \
127+
elif [ "$(CONFIG_XML_ENABLED)" != "true" ]; then \
128+
echo "CONFIG_$(shell echo $(SCENARIO) | tr a-z A-Z)=y" >> $(HV_OUT)/.config; \
120129
if [ "$(SCENARIO)" != "sdc" ]; then \
121130
echo "CONFIG_MAX_KATA_VM_NUM=0" >> $(HV_OUT)/.config; \
122131
fi; \
123-
if [ "$(CONFIG_XML_ENABLED)" = "true" ]; then \
124-
echo "CONFIG_ENFORCE_VALIDATED_ACPI_INFO=y" >> $(HV_OUT)/.config; \
125-
fi; \
126-
fi
132+
fi; \
133+
$(MAKE) -C $(T)/hypervisor HV_OBJDIR=$(HV_OUT) BOARD_FILE=$(BOARD_FILE) SCENARIO_FILE=$(SCENARIO_FILE) oldconfig;
127134
$(MAKE) -C $(T)/hypervisor HV_OBJDIR=$(HV_OUT) BOARD_FILE=$(BOARD_FILE) SCENARIO_FILE=$(SCENARIO_FILE)
128135
#ifeq ($(FIRMWARE),uefi)
129136
@if [ "$(SCENARIO)" != "logical_partition" ] && [ "$(SCENARIO)" != "hybrid" ]; then \
@@ -132,13 +139,15 @@ hypervisor:
132139
fi
133140
#endif
134141
@echo -e "\n\033[47;30mACRN Configuration Summary:\033[0m \nBOARD = $(BOARD)\t SCENARIO = $(SCENARIO)" > $(HV_CFG_LOG); \
135-
if [ -f $(DEFAULT_MENU_CONFIG_FILE) ]; then \
136-
echo "Hypervisor configuration is based on menuconfig file: ./hypervisor/build/.config;" >> $(HV_CFG_LOG); \
142+
if [ -f $(KCONFIG_FILE) ]; then \
143+
echo -e "Hypervisor configuration is based on:\n\tKconfig file:\t$(KCONFIG_FILE);" >> $(HV_CFG_LOG); \
137144
else \
138-
echo "Hypervisor configuration is based on ./hypervisor/arch/x86/Kconfig and ./hypervisor/arch/x86/configs/$(BOARD).config;" >> $(HV_CFG_LOG); \
145+
echo -e "Hypervisor configuration is based on:\n\t$(BOARD) defconfig file:\t$(T)/hypervisor/arch/x86/configs/$(BOARD).config;" \
146+
"\n\tOthers are set by default in:\t$(T)/hypervisor/arch/x86/Kconfig;" >> $(HV_CFG_LOG); \
139147
fi; \
140148
if [ "$(CONFIG_XML_ENABLED)" = "true" ]; then \
141-
echo "VM configuration is based on $(BOARD_FILE) and $(SCENARIO_FILE);" >> $(HV_CFG_LOG); \
149+
echo -e "VM configuration is based on:\n\tBOARD File:\t$(BOARD_FILE);" \
150+
"\n\tSCENARIO File:\t$(SCENARIO_FILE);" >> $(HV_CFG_LOG); \
142151
else \
143152
echo "VM configuration is based on current code base;" >> $(HV_CFG_LOG); \
144153
fi; \

0 commit comments

Comments
 (0)