Skip to content

Commit f9bb202

Browse files
junjiemao1lijinxia
authored andcommitted
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>
1 parent 10518de commit f9bb202

File tree

2 files changed

+56
-1
lines changed

2 files changed

+56
-1
lines changed

hypervisor/Makefile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ PLATFORM ?= sbl
2222
HV_OBJDIR ?= $(CURDIR)/build
2323
HV_FILE := acrn
2424

25+
.PHONY: default
26+
default: all
27+
28+
include $(BASEDIR)/../scripts/deps.mk
29+
30+
include scripts/kconfig/kconfig.mk
31+
2532
CFLAGS += -Wall -W
2633
CFLAGS += -ffunction-sections -fdata-sections
2734
CFLAGS += -fshort-wchar -ffreestanding
@@ -173,7 +180,7 @@ DISTCLEAN_OBJS := $(shell find $(BASEDIR) -name '*.o')
173180
VERSION := bsp/$(PLATFORM)/include/bsp/version.h
174181

175182
.PHONY: all
176-
all: $(VERSION) $(HV_OBJDIR)/$(HV_FILE).32.out $(HV_OBJDIR)/$(HV_FILE).bin
183+
all: $(BUILD_DEPS) $(VERSION) $(HV_OBJDIR)/$(HV_FILE).32.out $(HV_OBJDIR)/$(HV_FILE).bin
177184
rm -f $(VERSION)
178185

179186
ifeq ($(PLATFORM), uefi)

hypervisor/scripts/kconfig/kconfig.mk

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
HV_CONFIG := .config
2+
HV_DEFCONFIG := defconfig
3+
HV_CONFIG_H := include/config.h
4+
HV_CONFIG_MK := include/config.mk
5+
6+
KCONFIG_DIR := $(BASEDIR)/../scripts/kconfig
7+
8+
$(eval $(call check_dep_exec,python))
9+
$(eval $(call check_dep_exec,pip))
10+
$(eval $(call check_dep_pylib,kconfiglib))
11+
12+
# This target invoke silentoldconfig to generate a .config only if a .config
13+
# does not exist. Useful as a dependency for source compilation.
14+
$(HV_OBJDIR)/$(HV_CONFIG):
15+
@mkdir -p $(HV_OBJDIR)
16+
@python $(KCONFIG_DIR)/silentoldconfig.py Kconfig $(HV_OBJDIR)/$(HV_CONFIG) PLATFORM_$(shell echo $(PLATFORM) | tr a-z A-Z)=y
17+
18+
$(HV_OBJDIR)/$(HV_CONFIG_MK): $(HV_OBJDIR)/$(HV_CONFIG)
19+
@mkdir -p $(dir $@)
20+
@cp $< $@
21+
22+
$(HV_OBJDIR)/$(HV_CONFIG_H): $(HV_OBJDIR)/$(HV_CONFIG)
23+
@mkdir -p $(dir $@)
24+
@python $(KCONFIG_DIR)/generate_header.py Kconfig $< $@
25+
26+
# This target forcefully generate a .config based on a given default
27+
# one. Overwrite the current .config if it exists.
28+
.PHONY: defconfig
29+
defconfig:
30+
@mkdir -p $(HV_OBJDIR)
31+
@python $(KCONFIG_DIR)/defconfig.py Kconfig arch/x86/configs/$(PLATFORM).config $(HV_OBJDIR)/$(HV_CONFIG)
32+
33+
# Use silentoldconfig to forcefully update the current .config, or generate a
34+
# new one if no previous .config exists. This target can be used as a
35+
# prerequisite of all the others to make sure that the .config is consistent
36+
# even it has been modified manually before.
37+
.PHONY: oldconfig
38+
oldconfig:
39+
@mkdir -p $(HV_OBJDIR)
40+
@python $(KCONFIG_DIR)/silentoldconfig.py Kconfig $(HV_OBJDIR)/$(HV_CONFIG) PLATFORM_$(shell echo $(PLATFORM) | tr a-z A-Z)=y
41+
42+
# Minimize the current .config. This target can be used to generate a defconfig
43+
# for future use.
44+
.PHONY: minimalconfig
45+
minimalconfig: $(HV_OBJDIR)/$(HV_CONFIG)
46+
@python $(KCONFIG_DIR)/minimalconfig.py Kconfig $(HV_OBJDIR)/$(HV_CONFIG) $(HV_OBJDIR)/$(HV_DEFCONFIG)
47+
48+
-include $(HV_OBJDIR)/$(HV_CONFIG_MK)

0 commit comments

Comments
 (0)