acrn-hypervisor/hypervisor/scripts/kconfig/kconfig.mk
Junjie Mao c4493cc1f8 HV: make: skip duplicated PLATFORM= on command line
Since .config has PLATFORM now, it is expected that the PLATFORM= command line
option is no longer necessary as long as a proper .config exists.

This patch implements this expectation. Now the platform to be selected is
determined by the following steps.

    1. If PLATFORM= is provided on the command line, the specified value is
       used.
    2. If there is no PLATFORM= on the command line and PLATFORM is defined in
       config.mk, its value is used.
    3. If neither PLATFORM= on the command line nor config.mk is available, a
       predefined default value is used.

v1 -> v2:

    * 'make oldconfig' should not pass CONFIG_xxx to the script since config.mk
      can be out-dated.
    * Change the default value of PLATFORM to SBL for backward compatibility of
      'make all'.

Signed-off-by: Junjie Mao <junjie.mao@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
Acked-by: Geoffroy VanCutsem <geoffroy.vancutsem@intel.com>
2018-06-15 15:50:09 +08:00

81 lines
2.8 KiB
Makefile

# 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)/../scripts/kconfig
-include $(HV_OBJDIR)/$(HV_CONFIG_MK)
$(eval $(call override_config,PLATFORM,sbl))
$(eval $(call check_dep_exec,python3,KCONFIG_DEPS))
$(eval $(call check_dep_exec,pip3,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.
$(HV_OBJDIR)/$(HV_CONFIG): oldconfig
# 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)
@python3 $(KCONFIG_DIR)/defconfig.py Kconfig \
arch/x86/configs/$(CONFIG_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.
#
# Note: Should not pass CONFIG_xxx to silentoldconfig here because config.mk can
# be out-dated.
.PHONY: oldconfig
oldconfig: $(KCONFIG_DEPS)
@mkdir -p $(HV_OBJDIR)
@python3 $(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)
@python3 $(KCONFIG_DIR)/minimalconfig.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)