Makefile: move .mk file to hv scripts folder

The *.mk files under misc/acrn-config/library are all rules for hypervisor
makefiles only, so move these files to hypervisor/scripts/makefile/ folder.

The folder of acrn-config/library/ will be used to store python script lib only.

Tracked-On: #3779

Signed-off-by: Victor Sun <victor.sun@intel.com>
Reviewed-by: Terry Zou <terry.zou@intel.com>
This commit is contained in:
Victor Sun
2019-11-12 14:11:58 +08:00
committed by wenlingz
parent acd0deb8a1
commit 0d52f933da
5 changed files with 4 additions and 4 deletions

View File

@@ -0,0 +1,48 @@
CONFIG_XML_ENABLED ?=
UPDATE_RESULT = $(HV_OBJDIR)/.cfg_src_result
define check_xml_enabled =
CONFIG_XML_ENABLED := $(shell if [ "$(1)" != "" ] || [ "$(2)" != "" ]; then echo false; fi)
BOARD_IN_XML := $(shell echo `if [ "$(1)" != "" ]; then sed -n '/<acrn-config/p' $(1) | sed -r 's/.*board="(.*)".*/\1/g'; fi`)
SCENARIO_IN_XML := $(shell echo `if [ "$(2)" != "" ]; then sed -n '/<acrn-config/p' $(2) | sed -r 's/.*scenario="(.*)".*/\1/g'; fi`)
ifneq ($$(BOARD_IN_XML),)
ifneq ($$(SCENARIO_IN_XML),)
CONFIG_XML_ENABLED := true
endif
endif
ifeq ($$(CONFIG_XML_ENABLED),true)
override BOARD := $$(BOARD_IN_XML)
override SCENARIO := $$(SCENARIO_IN_XML)
endif
endef
ifeq ($(CONFIG_XML_ENALBED),)
$(eval $(call check_xml_enabled,$(BOARD_FILE),$(SCENARIO_FILE)))
endif
update_config:
ifeq ($(CONFIG_XML_ENABLED),true)
@if [ ! -f $(UPDATE_RESULT) ]; then \
mkdir -p $(dir $(UPDATE_RESULT));\
python3 ../misc/acrn-config/board_config/board_cfg_gen.py --board $(BOARD_FILE) --scenario $(SCENARIO_FILE) > $(UPDATE_RESULT);\
cat $(UPDATE_RESULT);\
if [ "`sed -n /successfully/p $(UPDATE_RESULT)`" = "" ]; then rm -f $(UPDATE_RESULT); exit 1; fi;\
python3 ../misc/acrn-config/scenario_config/scenario_cfg_gen.py --board $(BOARD_FILE) --scenario $(SCENARIO_FILE) > $(UPDATE_RESULT);\
cat $(UPDATE_RESULT);\
if [ "`sed -n /successfully/p $(UPDATE_RESULT)`" = "" ]; then rm -f $(UPDATE_RESULT); exit 1; fi;\
echo "Import hypervisor Board/VM configuration from XMLs, configurations in source code has been overwritten!";\
elif [ "`sed -n /successfully/p $(UPDATE_RESULT)`" = "" ]; then \
echo "Problem is found on Board/VM configration patching, please rebuild."; rm -f $(UPDATE_RESULT); exit 1; \
else \
echo "Configurations is patched already!";\
fi;
else ifeq ($(CONFIG_XML_ENABLED),false)
@echo "Config XML file does not exist or with unknown format."
@exit 1
else
@echo "Using hypervisor configurations from source code directly."
endif

View File

@@ -0,0 +1,31 @@
# usage: check_dep_exec <executable name> <variable>
#
# Create a target that checks the existence of the specified executable, and
# append that target to the given variable.
define check_dep_exec =
$(2) += check_exec_$(1)
check_exec_$(1):
@if ! which $(1) > /dev/null; then \
echo "******** Missing prerequisite tool ********"; \
echo "Cannot find executable *$(1)*"; \
echo "Please refer to the Getting Started Guide" \
"for installation instructions"; \
exit 1; \
fi
endef
# usage: check_dep_py3lib <library name> <variable>
#
# Create a target that checks the existence of the specified python 3 library, and
# append that target to the given variable.
define check_dep_py3lib =
$(2) += check_py3lib_$(1)
check_py3lib_$(1):
@if ! python3 -c "import $(1)" > /dev/null 2>&1; then \
echo "******** Missing prerequisite tool ********"; \
echo "The python3 library *$(1)* is not installed"; \
echo "Please refer to the Getting Started Guide" \
"for installation instructions"; \
exit 1; \
fi
endef

View File

@@ -0,0 +1,104 @@
# usage: override_config <symbol> <default>
#
# Given a configuration symbol (without the CONFIG_ prefix), this macro
# overrides its value as follows.
# 1. If a value is specified from command line, that value is used.
# 2. If neither config.mk nor the command line specifies a value, the given
# default is used.
define override_config =
ifdef $(1)
CONFIG_$(1) := $($(1))
else ifndef CONFIG_$(1)
CONFIG_$(1) := $(2)
endif
endef
HV_CONFIG := .config
HV_DEFCONFIG := defconfig
HV_CONFIG_H := include/config.h
HV_CONFIG_MK := include/config.mk
KCONFIG_DIR := $(BASEDIR)/../misc/acrn-config/kconfig
# Backward-compatibility for RELEASE=(0|1)
ifdef RELEASE
ifeq ($(RELEASE),1)
override RELEASE := y
else
override RELEASE := n
endif
endif
-include $(HV_OBJDIR)/$(HV_CONFIG_MK)
ifeq ($(shell [ $(HV_OBJDIR)/$(HV_CONFIG) -nt $(HV_OBJDIR)/$(HV_CONFIG_MK) ] && echo 1),1)
# config.mk may be outdated if .config has been overwritten. To update config.mk
# in such cases, we include .config again to get the new configurations. This
# only happens when GNU make checks the prerequisites.
-include $(HV_OBJDIR)/$(HV_CONFIG)
endif
$(eval $(call override_config,BOARD,apl-mrb))
$(eval $(call override_config,RELEASE,n))
ifdef BOARD
TARGET_BOARD=$(BOARD)
else
TARGET_BOARD=$(CONFIG_BOARD)
endif
$(eval $(call check_dep_exec,python3,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.
#
# A dummy command is necessary to trigger the remaking of config.mk right after
# oldconfig changes HV_CONFIG in the same execution of make.
$(HV_OBJDIR)/$(HV_CONFIG): update_config oldconfig
@true
# Note: This target must not depend on a phony target (e.g. oldconfig) because
# it'll trigger endless re-execution of make.
$(HV_OBJDIR)/$(HV_CONFIG_MK): $(HV_OBJDIR)/$(HV_CONFIG)
@mkdir -p $(dir $@)
@sed 's/="\(.*\)"$$/=\1/g' $(HV_OBJDIR)/$(HV_CONFIG) > $@
$(HV_OBJDIR)/$(HV_CONFIG_H): $(HV_OBJDIR)/$(HV_CONFIG)
@mkdir -p $(dir $@)
@python3 $(KCONFIG_DIR)/generate_header.py Kconfig $< $@
# This target forcefully generate a .config based on a given default
# one. Overwrite the current .config if it exists.
.PHONY: defconfig
defconfig: $(KCONFIG_DEPS)
@mkdir -p $(HV_OBJDIR)
@BOARD=$(TARGET_BOARD) \
python3 $(KCONFIG_DIR)/defconfig.py Kconfig \
$(HV_OBJDIR)/$(HV_CONFIG)
# Use silentoldconfig to forcefully update the current .config, or generate a
# new one if no previous .config exists. This target can be used as a
# prerequisite of all the others to make sure that the .config is consistent
# even it has been modified manually before.
.PHONY: oldconfig
oldconfig: $(KCONFIG_DEPS)
@mkdir -p $(HV_OBJDIR)
@BOARD=$(TARGET_BOARD) \
python3 $(KCONFIG_DIR)/silentoldconfig.py Kconfig \
$(HV_OBJDIR)/$(HV_CONFIG) \
RELEASE=$(RELEASE)
# Minimize the current .config. This target can be used to generate a defconfig
# for future use.
.PHONY: savedefconfig
savedefconfig: $(HV_OBJDIR)/$(HV_CONFIG)
@python3 $(KCONFIG_DIR)/savedefconfig.py Kconfig \
$(HV_OBJDIR)/$(HV_CONFIG) \
$(HV_OBJDIR)/$(HV_DEFCONFIG)
$(eval $(call check_dep_exec,menuconfig,MENUCONFIG_DEPS))
export KCONFIG_CONFIG := $(HV_OBJDIR)/$(HV_CONFIG)
menuconfig: $(MENUCONFIG_DEPS) $(HV_OBJDIR)/$(HV_CONFIG)
@python3 $(shell which menuconfig) Kconfig
CFLAGS += -include $(HV_OBJDIR)/$(HV_CONFIG_H)