HV: make: introduce targets for generating configs

This patch implements the following targets as an includable .mk to the make
system of the hypervisor.

    make defconfig PLATFORM=xx:
        force (re)generating the default configuration for xx

    make oldconfig PLATFORM=xx:
        generate a configuration for platform xx based on .config if available

    make minimalconfig
        save a minimized .config to defconfig

The default target (make all) will generate a default configuration if no
.config is available.

The values defined in .config are available in the toplevel Makefile after
kconfig/kconfig.mk is included.

v4 -> v5:

    * Add minimalconfig for generating default configs.

v3 -> v4:

    * No changes.

v2 -> v3:

    * "make defconfig" now correctly overwrite an existing .config.
    * Add short descriptions on where each target is supposed to be used.

v1 -> v2:

    * Add proper dependency checks in the Makefile of hypervisor.

Signed-off-by: Junjie Mao <junjie.mao@intel.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
This commit is contained in:
Junjie Mao 2018-05-25 22:38:24 +08:00 committed by lijinxia
parent 10518de722
commit f9bb2024cc
2 changed files with 56 additions and 1 deletions

View File

@ -22,6 +22,13 @@ PLATFORM ?= sbl
HV_OBJDIR ?= $(CURDIR)/build HV_OBJDIR ?= $(CURDIR)/build
HV_FILE := acrn HV_FILE := acrn
.PHONY: default
default: all
include $(BASEDIR)/../scripts/deps.mk
include scripts/kconfig/kconfig.mk
CFLAGS += -Wall -W CFLAGS += -Wall -W
CFLAGS += -ffunction-sections -fdata-sections CFLAGS += -ffunction-sections -fdata-sections
CFLAGS += -fshort-wchar -ffreestanding CFLAGS += -fshort-wchar -ffreestanding
@ -173,7 +180,7 @@ DISTCLEAN_OBJS := $(shell find $(BASEDIR) -name '*.o')
VERSION := bsp/$(PLATFORM)/include/bsp/version.h VERSION := bsp/$(PLATFORM)/include/bsp/version.h
.PHONY: all .PHONY: all
all: $(VERSION) $(HV_OBJDIR)/$(HV_FILE).32.out $(HV_OBJDIR)/$(HV_FILE).bin all: $(BUILD_DEPS) $(VERSION) $(HV_OBJDIR)/$(HV_FILE).32.out $(HV_OBJDIR)/$(HV_FILE).bin
rm -f $(VERSION) rm -f $(VERSION)
ifeq ($(PLATFORM), uefi) ifeq ($(PLATFORM), uefi)

View File

@ -0,0 +1,48 @@
HV_CONFIG := .config
HV_DEFCONFIG := defconfig
HV_CONFIG_H := include/config.h
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))
# This target invoke silentoldconfig to generate a .config only if a .config
# does not exist. Useful as a dependency for source compilation.
$(HV_OBJDIR)/$(HV_CONFIG):
@mkdir -p $(HV_OBJDIR)
@python $(KCONFIG_DIR)/silentoldconfig.py Kconfig $(HV_OBJDIR)/$(HV_CONFIG) PLATFORM_$(shell echo $(PLATFORM) | tr a-z A-Z)=y
$(HV_OBJDIR)/$(HV_CONFIG_MK): $(HV_OBJDIR)/$(HV_CONFIG)
@mkdir -p $(dir $@)
@cp $< $@
$(HV_OBJDIR)/$(HV_CONFIG_H): $(HV_OBJDIR)/$(HV_CONFIG)
@mkdir -p $(dir $@)
@python $(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:
@mkdir -p $(HV_OBJDIR)
@python $(KCONFIG_DIR)/defconfig.py Kconfig arch/x86/configs/$(PLATFORM).config $(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:
@mkdir -p $(HV_OBJDIR)
@python $(KCONFIG_DIR)/silentoldconfig.py Kconfig $(HV_OBJDIR)/$(HV_CONFIG) PLATFORM_$(shell echo $(PLATFORM) | tr a-z A-Z)=y
# Minimize the current .config. This target can be used to generate a defconfig
# for future use.
.PHONY: minimalconfig
minimalconfig: $(HV_OBJDIR)/$(HV_CONFIG)
@python $(KCONFIG_DIR)/minimalconfig.py Kconfig $(HV_OBJDIR)/$(HV_CONFIG) $(HV_OBJDIR)/$(HV_DEFCONFIG)
-include $(HV_OBJDIR)/$(HV_CONFIG_MK)