mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-21 21:19:35 +00:00
Makefile: parameters check for board and scenario
When user use make parameters to specify BOARD and SCENARIO, there might be some conflict because parameter of KCONFIG_FILE/BOARD_FILE/SCENARIO_FILE also includes BOARD/SCENARIO info. To simplify, we only alow below valid usages: 1. make <target> 2. make <target> KCONFIG_FILE=xxx 3. make <target> BOARD=xxx SCENARIO=xxx 4. make <target> BOARD_FILE=xxx SCENARIO_FILE=xxx 5. make <target> KCONFIG_FILE=xxx BOARD_FILE=xxx SCENARIO_FILE=xxx Especially for case 1 that no any parameters are specified: a. If hypervisor/build/.config file which generated by "make menuconfig" exist, the .config file will be loaded as KCONFIG_FILE: i.e. equal: make <target> KCONFIG_FILE=hypervisor/build/.config b. If hypervisor/build/.config file does not exist, the default BOARD/SCENARIO will be loaded: i.e. equal: make <target> BOARD=$(BOARD) SCENARIO=$(SCENARIO) Tracked-On: #4517 Signed-off-by: Victor Sun <victor.sun@intel.com>
This commit is contained in:
parent
82e93b77d5
commit
3774244d07
104
Makefile
104
Makefile
@ -3,6 +3,27 @@
|
||||
# global helper variables
|
||||
T := $(CURDIR)
|
||||
|
||||
# BOARD/SCENARIO/BOARD_FILE/SCENARIO_FILE/KCONFIG_FILE parameters sanity check:
|
||||
#
|
||||
# Only below usages are VALID: (target = all | hypervisor)
|
||||
# 1. make <target>
|
||||
# 2. make <target> KCONFIG_FILE=xxx
|
||||
# 3. make <target> BOARD=xxx SCENARIO=xxx
|
||||
# 4. make <target> BOARD_FILE=xxx SCENARIO_FILE=xxx
|
||||
# 5. make <target> KCONFIG_FILE=xxx BOARD_FILE=xxx SCENARIO_FILE=xxx
|
||||
#
|
||||
# Especially for case 1 that no any parameters are specified:
|
||||
# a. If hypervisor/build/.config file which generated by "make menuconfig" exist,
|
||||
# the .config file will be loaded as KCONFIG_FILE:
|
||||
# i.e. equal: make <target> KCONFIG_FILE=hypervisor/build/.config
|
||||
#
|
||||
# b. If hypervisor/build/.config file does not exist,
|
||||
# the default BOARD/SCENARIO will be loaded:
|
||||
# i.e. equal: make <target> BOARD=$(BOARD) SCENARIO=$(SCENARIO)
|
||||
#
|
||||
# The grep process did not handle corner case when '#' is manually put right after config value as comments,
|
||||
# i.e. it will be failed in the case of "CONFIG_XXX=y # some comments here "
|
||||
|
||||
ifneq ($(KCONFIG_FILE),)
|
||||
ifneq ($(KCONFIG_FILE), $(wildcard $(KCONFIG_FILE)))
|
||||
$(error KCONFIG_FILE: $(KCONFIG_FILE) does not exist)
|
||||
@ -12,6 +33,50 @@ else
|
||||
override KCONFIG_FILE := $(T)/hypervisor/build/.config
|
||||
endif
|
||||
|
||||
ifneq ($(BOARD)$(SCENARIO),)
|
||||
ifneq ($(BOARD_FILE)$(SCENARIO_FILE),)
|
||||
$(error BOARD/SCENARIO parameter could not coexist with BOARD_FILE/SCENARIO_FILE)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifneq ($(BOARD_FILE)$(SCENARIO_FILE),)
|
||||
ifneq ($(BOARD_FILE), $(wildcard $(BOARD_FILE)))
|
||||
$(error BOARD_FILE: $(BOARD_FILE) does not exist)
|
||||
endif
|
||||
ifneq ($(SCENARIO_FILE), $(wildcard $(SCENARIO_FILE)))
|
||||
$(error SCENARIO_FILE: $(SCENARIO_FILE) does not exist)
|
||||
endif
|
||||
|
||||
override BOARD_FILE := $(realpath $(BOARD_FILE))
|
||||
override SCENARIO_FILE := $(realpath $(SCENARIO_FILE))
|
||||
endif
|
||||
|
||||
ifeq ($(KCONFIG_FILE), $(wildcard $(KCONFIG_FILE)))
|
||||
ifneq ($(BOARD)$(SCENARIO),)
|
||||
$(error BOARD/SCENARIO parameter could not coexist with KCONFIG_FILE)
|
||||
endif
|
||||
|
||||
BOARD_IN_KCONFIG := $(shell grep CONFIG_BOARD= $(KCONFIG_FILE) | grep -v '\#' | awk -F '"' '{print $$2}')
|
||||
ifeq ($(BOARD_IN_KCONFIG),)
|
||||
$(error no BOARD info in KCONFIG_FILE: $(KCONFIG_FILE))
|
||||
endif
|
||||
|
||||
SCENARIO_IN_KCONFIG := $(shell grep -E "SDC=y|SDC2=y|INDUSTRY=y|LOGICAL_PARTITION=y|HYBRID=y" \
|
||||
$(KCONFIG_FILE) | grep -v '\#' | awk -F "=" '{print $$1}' | cut -d '_' -f 2- | tr A-Z a-z)
|
||||
ifeq ($(SCENARIO_IN_KCONFIG),)
|
||||
$(error no SCENARIO info in KCONFIG_FILE: $(KCONFIG_FILE))
|
||||
endif
|
||||
|
||||
override BOARD := $(BOARD_IN_KCONFIG)
|
||||
override SCENARIO := $(SCENARIO_IN_KCONFIG)
|
||||
|
||||
RELEASE := $(shell grep CONFIG_RELEASE=y $(KCONFIG_FILE) | grep -v '\#')
|
||||
ifneq ($(RELEASE),)
|
||||
override RELEASE := 1
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
BOARD ?= kbl-nuc-i7
|
||||
|
||||
ifneq (,$(filter $(BOARD),apl-mrb))
|
||||
@ -35,13 +100,6 @@ BUILD_TAG ?=
|
||||
GENED_ACPI_INFO_HEADER = $(T)/hypervisor/arch/x86/configs/$(BOARD)/$(BOARD)_acpi_info.h
|
||||
HV_CFG_LOG = $(HV_OUT)/cfg.log
|
||||
|
||||
ifneq ($(BOARD_FILE),)
|
||||
override BOARD_FILE := $(shell if [ -f $(BOARD_FILE) ]; then realpath $(BOARD_FILE); fi)
|
||||
endif
|
||||
ifneq ($(SCENARIO_FILE),)
|
||||
override SCENARIO_FILE := $(shell if [ -f $(SCENARIO_FILE) ]; then realpath $(SCENARIO_FILE); fi)
|
||||
endif
|
||||
|
||||
export TOOLS_OUT BOARD SCENARIO FIRMWARE RELEASE
|
||||
|
||||
.PHONY: all hypervisor devicemodel tools doc
|
||||
@ -54,40 +112,8 @@ else ifeq ($(BOARD), kbl-nuc-i7)
|
||||
override BOARD := nuc7i7dnb
|
||||
endif
|
||||
|
||||
#BOARD and SCENARIO definition priority:
|
||||
# If we do menuconfig in advance, the menuconfig will define
|
||||
# BOARD
|
||||
# SCENARIO
|
||||
# else if we have board/scenario file avaiable, BOARD and SCENARIO will be
|
||||
# extracted from files.
|
||||
# else if make comand has BORAD/SCENARIO parameters, BOARD and SCENARIO will
|
||||
# be gotten from parameters
|
||||
# else
|
||||
# default value defined in this make file will be used
|
||||
#
|
||||
|
||||
include $(T)/hypervisor/scripts/makefile/cfg_update.mk
|
||||
|
||||
ifeq ($(KCONFIG_FILE), $(wildcard $(KCONFIG_FILE)))
|
||||
BOARD_IN_KCONFIG := $(shell grep CONFIG_BOARD= $(KCONFIG_FILE) | awk -F '"' '{print $$2}')
|
||||
SCENARIO_IN_KCONFIG := $(shell grep -E "SDC=y|SDC2=y|INDUSTRY=y|LOGICAL_PARTITION=y|HYBRID=y" \
|
||||
$(KCONFIG_FILE) | awk -F "=" '{print $$1}' | cut -d '_' -f 2- | tr A-Z a-z)
|
||||
|
||||
RELEASE := $(shell grep CONFIG_RELEASE=y $(KCONFIG_FILE))
|
||||
ifneq ($(RELEASE),)
|
||||
override RELEASE := 1
|
||||
endif
|
||||
|
||||
ifneq ($(BOARD_IN_KCONFIG),$(BOARD))
|
||||
override BOARD := $(BOARD_IN_KCONFIG)
|
||||
endif
|
||||
|
||||
ifneq ($(SCENARIO_IN_KCONFIG),$(SCENARIO))
|
||||
override SCENARIO := $(SCENARIO_IN_KCONFIG)
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
#help functions to build acrn and install acrn/acrn symbols
|
||||
define build_acrn
|
||||
$(MAKE) -C $(T)/hypervisor HV_OBJDIR=$(HV_OUT)-$(1)/$(2) BOARD=$(2) FIRMWARE=$(1) SCENARIO=$(4) RELEASE=$(RELEASE) clean
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# ACRN Hypervisor
|
||||
# acrn-hypervisor/hypervisor/Makefile
|
||||
#
|
||||
|
||||
include ../VERSION
|
||||
@ -50,17 +50,30 @@ include scripts/makefile/deps.mk
|
||||
|
||||
include scripts/makefile/kconfig.mk
|
||||
|
||||
#initialize scenarios name
|
||||
#initialize BOARD if it is not specified
|
||||
ifeq ($(BOARD),)
|
||||
override BOARD := $(CONFIG_BOARD)
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_SDC),y)
|
||||
SCENARIO_NAME := sdc
|
||||
KCONFIG_SCENARIO := sdc
|
||||
else ifeq ($(CONFIG_SDC2),y)
|
||||
SCENARIO_NAME := sdc2
|
||||
KCONFIG_SCENARIO := sdc2
|
||||
else ifeq ($(CONFIG_LOGICAL_PARTITION),y)
|
||||
SCENARIO_NAME := logical_partition
|
||||
KCONFIG_SCENARIO := logical_partition
|
||||
else ifeq ($(CONFIG_INDUSTRY),y)
|
||||
SCENARIO_NAME := industry
|
||||
KCONFIG_SCENARIO := industry
|
||||
else ifeq ($(CONFIG_HYBRID),y)
|
||||
SCENARIO_NAME := hybrid
|
||||
KCONFIG_SCENARIO := hybrid
|
||||
endif
|
||||
|
||||
#initialize SCENARIO if it is not specified
|
||||
ifeq ($(SCENARIO),)
|
||||
ifeq ($(KCONFIG_SCENARIO),)
|
||||
override SCENARIO := sdc
|
||||
else
|
||||
override SCENARIO := $(KCONFIG_SCENARIO)
|
||||
endif
|
||||
endif
|
||||
|
||||
LD_IN_TOOL = scripts/genld.sh
|
||||
@ -153,8 +166,8 @@ INCLUDE_PATH += include/hw
|
||||
INCLUDE_PATH += boot/include
|
||||
INCLUDE_PATH += boot/include/guest
|
||||
INCLUDE_PATH += $(HV_OBJDIR)/include
|
||||
INCLUDE_PATH += arch/x86/configs/$(CONFIG_BOARD)
|
||||
INCLUDE_PATH += scenarios/$(SCENARIO_NAME)
|
||||
INCLUDE_PATH += arch/x86/configs/$(BOARD)
|
||||
INCLUDE_PATH += scenarios/$(SCENARIO)
|
||||
|
||||
CC ?= gcc
|
||||
AS ?= as
|
||||
@ -240,10 +253,10 @@ HW_C_SRCS += common/sched_bvt.c
|
||||
endif
|
||||
HW_C_SRCS += hw/pci.c
|
||||
HW_C_SRCS += arch/x86/configs/vm_config.c
|
||||
HW_C_SRCS += arch/x86/configs/$(CONFIG_BOARD)/board.c
|
||||
HW_C_SRCS += scenarios/$(SCENARIO_NAME)/vm_configurations.c
|
||||
ifneq (,$(wildcard scenarios/$(SCENARIO_NAME)/pci_dev.c))
|
||||
HW_C_SRCS += scenarios/$(SCENARIO_NAME)/pci_dev.c
|
||||
HW_C_SRCS += arch/x86/configs/$(BOARD)/board.c
|
||||
HW_C_SRCS += scenarios/$(SCENARIO)/vm_configurations.c
|
||||
ifneq (,$(wildcard scenarios/$(SCENARIO)/pci_dev.c))
|
||||
HW_C_SRCS += scenarios/$(SCENARIO)/pci_dev.c
|
||||
endif
|
||||
HW_C_SRCS += boot/acpi_base.c
|
||||
HW_C_SRCS += boot/cmdline.c
|
||||
@ -357,8 +370,8 @@ VERSION := $(HV_OBJDIR)/include/version.h
|
||||
|
||||
# Create platform_acpi_info.h
|
||||
TEMPLATE_ACPI_INFO_HEADER := arch/x86/configs/platform_acpi_info.h
|
||||
BOARDTEMPLATE_ACPI_INFO_HEADER := arch/x86/configs/$(CONFIG_BOARD)/platform_acpi_info.h
|
||||
SOURCE_ACPI_INFO_HEADER := arch/x86/configs/$(CONFIG_BOARD)/$(CONFIG_BOARD)_acpi_info.h
|
||||
BOARDTEMPLATE_ACPI_INFO_HEADER := arch/x86/configs/$(BOARD)/platform_acpi_info.h
|
||||
SOURCE_ACPI_INFO_HEADER := arch/x86/configs/$(BOARD)/$(BOARD)_acpi_info.h
|
||||
TARGET_ACPI_INFO_HEADER := $(HV_OBJDIR)/include/platform_acpi_info.h
|
||||
|
||||
$(TARGET_ACPI_INFO_HEADER): $(HV_OBJDIR)/$(HV_CONFIG)
|
||||
@ -393,11 +406,11 @@ endif
|
||||
all: pre_build $(HV_OBJDIR)/$(HV_FILE).32.out $(HV_OBJDIR)/$(HV_FILE).bin
|
||||
|
||||
install: $(HV_OBJDIR)/$(HV_FILE).32.out
|
||||
install -D $(HV_OBJDIR)/$(HV_FILE).32.out $(DESTDIR)/usr/lib/acrn/$(HV_FILE).$(BOARD).$(FIRMWARE).$(SCENARIO_NAME).32.out
|
||||
install -D $(HV_OBJDIR)/$(HV_FILE).32.out $(DESTDIR)/usr/lib/acrn/$(HV_FILE).$(BOARD).$(FIRMWARE).$(SCENARIO).32.out
|
||||
|
||||
install-debug: $(HV_OBJDIR)/$(HV_FILE).map $(HV_OBJDIR)/$(HV_FILE).out
|
||||
install -D $(HV_OBJDIR)/$(HV_FILE).out $(DESTDIR)/usr/lib/acrn/$(HV_FILE).$(BOARD).$(FIRMWARE).$(SCENARIO_NAME).out
|
||||
install -D $(HV_OBJDIR)/$(HV_FILE).map $(DESTDIR)/usr/lib/acrn/$(HV_FILE).$(BOARD).$(FIRMWARE).$(SCENARIO_NAME).map
|
||||
install -D $(HV_OBJDIR)/$(HV_FILE).out $(DESTDIR)/usr/lib/acrn/$(HV_FILE).$(BOARD).$(FIRMWARE).$(SCENARIO).out
|
||||
install -D $(HV_OBJDIR)/$(HV_FILE).map $(DESTDIR)/usr/lib/acrn/$(HV_FILE).$(BOARD).$(FIRMWARE).$(SCENARIO).map
|
||||
|
||||
.PHONY: pre_build
|
||||
pre_build: $(PRE_BUILD_OBJS)
|
||||
@ -485,10 +498,7 @@ distclean:
|
||||
|
||||
PHONY: (VERSION)
|
||||
$(VERSION):
|
||||
@echo "SCENARIO <$(SCENARIO_NAME)> for BOARD <$(BOARD)> is specified."
|
||||
@if [ "$(CONFIG_XML_ENABLED)" = "true" ] && [ "$(SCENARIO_NAME)" != "$(SCENARIO_IN_XML)" ]; then \
|
||||
echo "SCENARIO in XML <$(SCENARIO_IN_XML)> does not match SCENARIO in Kconfig <$(SCENARIO_NAME)> !" ; exit 1; \
|
||||
fi
|
||||
@echo "SCENARIO <$(SCENARIO)> for BOARD <$(BOARD)> is specified."
|
||||
touch $(VERSION)
|
||||
@COMMIT=`git rev-parse --verify --short HEAD 2>/dev/null`;\
|
||||
DIRTY=`git diff-index --name-only HEAD`;\
|
||||
|
@ -12,18 +12,27 @@ ifneq ($$(BOARD_IN_XML),)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($$(CONFIG_XML_ENABLED),true)
|
||||
override BOARD := $$(BOARD_IN_XML)
|
||||
override SCENARIO := $$(SCENARIO_IN_XML)
|
||||
endif
|
||||
|
||||
|
||||
endef
|
||||
|
||||
ifeq ($(CONFIG_XML_ENALBED),)
|
||||
ifeq ($(CONFIG_XML_ENABLED),)
|
||||
$(eval $(call check_xml_enabled,$(BOARD_FILE),$(SCENARIO_FILE)))
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_XML_ENABLED),true)
|
||||
ifneq ($(BOARD_IN_KCONFIG),)
|
||||
ifneq ($(BOARD_IN_XML),$(BOARD_IN_KCONFIG))
|
||||
$(error BOARD $(BOARD_IN_XML) in $(BOARD_FILE) does not match BOARD $(BOARD_IN_KCONFIG) in $(KCONFIG_FILE))
|
||||
endif
|
||||
endif
|
||||
ifneq ($(SCENARIO_IN_KCONFIG),)
|
||||
ifneq ($(SCENARIO_IN_XML),$(SCENARIO_IN_KCONFIG))
|
||||
$(error SCENARIO $(SCENARIO_IN_XML) in $(SCENARIO_FILE) does not match SCENARIO $(SCENARIO_IN_KCONFIG) in $(KCONFIG_FILE))
|
||||
endif
|
||||
endif
|
||||
override BOARD := $(BOARD_IN_XML)
|
||||
override SCENARIO := $(SCENARIO_IN_XML)
|
||||
endif
|
||||
|
||||
update_config:
|
||||
ifeq ($(CONFIG_XML_ENABLED),true)
|
||||
@if [ ! -f $(UPDATE_RESULT) ]; then \
|
||||
|
Loading…
Reference in New Issue
Block a user