From patchwork Tue Jan 15 14:10:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Zhong X-Patchwork-Id: 10764649 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AE9461580 for ; Tue, 15 Jan 2019 14:42:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9D8A72CB82 for ; Tue, 15 Jan 2019 14:42:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 913C82CBE0; Tue, 15 Jan 2019 14:42:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BC42A2CB82 for ; Tue, 15 Jan 2019 14:42:51 +0000 (UTC) Received: from localhost ([127.0.0.1]:39634 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gjPvX-0004z7-2t for patchwork-qemu-devel@patchwork.kernel.org; Tue, 15 Jan 2019 09:42:51 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37462) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gjPYU-0002wr-2o for qemu-devel@nongnu.org; Tue, 15 Jan 2019 09:19:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gjPS7-0001O7-Dp for qemu-devel@nongnu.org; Tue, 15 Jan 2019 09:12:29 -0500 Received: from mga05.intel.com ([192.55.52.43]:56326) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gjPS0-0001A9-Vs for qemu-devel@nongnu.org; Tue, 15 Jan 2019 09:12:24 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Jan 2019 06:11:52 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,481,1539673200"; d="scan'208";a="267301446" Received: from he.bj.intel.com ([10.238.157.85]) by orsmga004.jf.intel.com with ESMTP; 15 Jan 2019 06:11:50 -0800 From: Yang Zhong To: qemu-devel@nongnu.org Date: Tue, 15 Jan 2019 22:10:51 +0800 Message-Id: <20190115141108.934-21-yang.zhong@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190115141108.934-1-yang.zhong@intel.com> References: <20190115141108.934-1-yang.zhong@intel.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.43 Subject: [Qemu-devel] [RFC PATCH v2 20/37] build: switch to Kconfig X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: yang.zhong@intel.com, peter.maydell@linaro.org, thuth@redhat.com, sameo@linux.intel.com, pbonzini@redhat.com, ehabkost@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Paolo Bonzini The make_device_config.sh script is replaced by minikconf, which is modified to support the same command line as its predecessor. The roots of the parsing are default-configs/*.mak, Kconfig.host and hw/Kconfig. One difference with make_device_config.sh is that all symbols have to be defined in a Kconfig file, including those coming from the configure script. This is the reason for the Kconfig.host file introduced in the previous patch. Whenever a file in default-configs/*.mak used $(...) to refer to a config-host.mak symbol, this is replaced by a Kconfig dependency. Signed-off-by: Paolo Bonzini Signed-off-by: Yang Zhong Acked-by: Thomas Huth --- Kconfig.host | 3 ++- Makefile | 14 +++++++++++-- Makefile.target | 7 ++++++- default-configs/i386-softmmu.mak | 3 --- hw/display/Kconfig | 2 ++ hw/i386/Kconfig | 6 ++++++ hw/intc/Kconfig | 8 ++++++++ hw/misc/Kconfig | 2 ++ hw/tpm/Kconfig | 1 + rules.mak | 2 +- scripts/make_device_config.sh | 30 --------------------------- scripts/minikconf.py | 35 +++++++++++++++++++++++++++++--- 12 files changed, 72 insertions(+), 41 deletions(-) delete mode 100644 scripts/make_device_config.sh diff --git a/Kconfig.host b/Kconfig.host index 2136a4c3ec..d7f503d0ca 100644 --- a/Kconfig.host +++ b/Kconfig.host @@ -1,5 +1,6 @@ # These are "proxy" symbols used to pass config-host.mak values -# down to Kconfig. +# down to Kconfig. See also MINIKCONF_ARGS in the Makefile: +# these two need to be kept in sync. config KVM bool diff --git a/Makefile b/Makefile index a9ac16d94e..01e7c60a0d 100644 --- a/Makefile +++ b/Makefile @@ -326,9 +326,19 @@ endif -include $(SUBDIR_DEVICES_MAK_DEP) -%/config-devices.mak: default-configs/%.mak $(SRC_PATH)/scripts/make_device_config.sh +# This has to be kept in sync with Kconfig.host. +MINIKCONF_ARGS = \ + CONFIG_KVM=$(CONFIG_KVM) \ + CONFIG_SPICE=$(CONFIG_SPICE) \ + CONFIG_TPM=$(CONFIG_TPM) \ + CONFIG_XEN=$(CONFIG_XEN) \ + CONFIG_OPENGL=$(CONFIG_OPENGL) + +MINIKCONF = $(SHELL) $(SRC_PATH)/scripts/minikconf.sh + +%/config-devices.mak: default-configs/%-softmmu.mak Kconfig.host hw/Kconfig $(call quiet-command, \ - $(SHELL) $(SRC_PATH)/scripts/make_device_config.sh $< $*-config-devices.mak.d $@ > $@.tmp,"GEN","$@.tmp") + $(MINIKCONF) $@ $*-config-devices.mak.d $^ $(MINIKCONF_ARGS) > $@.tmp, " GEN $@.tmp") $(call quiet-command, if test -f $@; then \ if cmp -s $@.old $@; then \ mv $@.tmp $@; \ diff --git a/Makefile.target b/Makefile.target index 44ec4b630c..5aa8596a96 100644 --- a/Makefile.target +++ b/Makefile.target @@ -4,9 +4,12 @@ BUILD_DIR?=$(CURDIR)/.. include ../config-host.mak include config-target.mak -include config-devices.mak include $(SRC_PATH)/rules.mak +ifdef CONFIG_SOFTMMU +include config-devices.mak +endif + $(call set-vpath, $(SRC_PATH):$(BUILD_DIR)) ifdef CONFIG_LINUX QEMU_CFLAGS += -I../linux-headers @@ -187,7 +190,9 @@ all-obj-$(CONFIG_USER_ONLY) += $(crypto-aes-obj-y) all-obj-$(CONFIG_SOFTMMU) += $(crypto-obj-y) all-obj-$(CONFIG_SOFTMMU) += $(io-obj-y) +ifdef CONFIG_SOFTMMU $(QEMU_PROG_BUILD): config-devices.mak +endif COMMON_LDADDS = ../libqemuutil.a diff --git a/default-configs/i386-softmmu.mak b/default-configs/i386-softmmu.mak index 8db7867015..f71284516c 100644 --- a/default-configs/i386-softmmu.mak +++ b/default-configs/i386-softmmu.mak @@ -4,7 +4,6 @@ include pci.mak include sound.mak include usb.mak include hyperv.mak -CONFIG_QXL=$(CONFIG_SPICE) CONFIG_VGA_ISA=y CONFIG_VGA_CIRRUS=y CONFIG_VMWARE_VGA=y @@ -37,8 +36,6 @@ CONFIG_HPET=y CONFIG_APPLESMC=y CONFIG_I8259=y CONFIG_PFLASH_CFI01=y -CONFIG_TPM_TIS=$(CONFIG_TPM) -CONFIG_TPM_CRB=$(CONFIG_TPM) CONFIG_MC146818RTC=y CONFIG_PCI_PIIX=y CONFIG_WDT_IB700=y diff --git a/hw/display/Kconfig b/hw/display/Kconfig index d5c022c886..132aeffdbe 100644 --- a/hw/display/Kconfig +++ b/hw/display/Kconfig @@ -51,6 +51,7 @@ config FRAMEBUFFER config MILKYMIST_TMU2 bool + depends on OPENGL config SM501 bool @@ -66,6 +67,7 @@ config VGA config QXL bool + depends on SPICE config VIRTIO_GPU bool diff --git a/hw/i386/Kconfig b/hw/i386/Kconfig index 2dbe2b5d3e..427bda3717 100644 --- a/hw/i386/Kconfig +++ b/hw/i386/Kconfig @@ -3,12 +3,18 @@ config KVM config I440FX bool + select QXL if SPICE + select TPM_TIS if TPM + select XEN_I386 if XEN config ISAPC bool config Q35 bool + select QXL if SPICE + select TPM_TIS if TPM + select XEN_I386 if XEN config VTD bool diff --git a/hw/intc/Kconfig b/hw/intc/Kconfig index 69adbd135f..226ef3ae2e 100644 --- a/hw/intc/Kconfig +++ b/hw/intc/Kconfig @@ -21,9 +21,13 @@ config APIC config ARM_GIC_KVM bool + default y + depends on ARM_GIC && KVM config OPENPIC_KVM bool + default y + depends on OPENPIC && KVM config XICS bool @@ -33,6 +37,8 @@ config XICS_SPAPR config XICS_KVM bool + default y + depends on XICS && KVM config ALLWINNER_A10_PIC bool @@ -42,6 +48,8 @@ config S390_FLIC config S390_FLIC_KVM bool + default y + depends on S390_FLIC && KVM config OMPIC bool diff --git a/hw/misc/Kconfig b/hw/misc/Kconfig index c006b046d4..cc8dbed24e 100644 --- a/hw/misc/Kconfig +++ b/hw/misc/Kconfig @@ -48,6 +48,8 @@ config MACIO config IVSHMEM_DEVICE bool + default y + depends on PCI config ECCMEMCTL bool diff --git a/hw/tpm/Kconfig b/hw/tpm/Kconfig index 2eee8eb865..da4bb5b6c7 100644 --- a/hw/tpm/Kconfig +++ b/hw/tpm/Kconfig @@ -3,6 +3,7 @@ config TPM config TPM_TIS bool + depends on TPM config TPM_CRB bool diff --git a/rules.mak b/rules.mak index bbb2667928..2d4559a6ce 100644 --- a/rules.mak +++ b/rules.mak @@ -142,7 +142,7 @@ cc-option = $(if $(shell $(CC) $1 $2 -S -o /dev/null -xc /dev/null \ cc-c-option = $(if $(shell $(CC) $1 $2 -c -o /dev/null -xc /dev/null \ >/dev/null 2>&1 && echo OK), $2, $3) -VPATH_SUFFIXES = %.c %.h %.S %.cc %.cpp %.m %.mak %.texi %.sh %.rc +VPATH_SUFFIXES = %.c %.h %.S %.cc %.cpp %.m %.mak %.texi %.sh %.rc Kconfig% set-vpath = $(if $1,$(foreach PATTERN,$(VPATH_SUFFIXES),$(eval vpath $(PATTERN) $1))) # install-prog list, dir diff --git a/scripts/make_device_config.sh b/scripts/make_device_config.sh deleted file mode 100644 index 354af317b3..0000000000 --- a/scripts/make_device_config.sh +++ /dev/null @@ -1,30 +0,0 @@ -#! /bin/sh -# Writes a target device config file to stdout, from a default and from -# include directives therein. Also emits Makefile dependencies. -# -# Usage: make_device_config.sh SRC DEPFILE-NAME DEPFILE-TARGET > DEST - -src=$1 -dep=$2 -target=$3 -src_dir=$(dirname $src) -all_includes= - -process_includes () { - cat $1 | grep '^include' | \ - while read include file ; do - all_includes="$all_includes $src_dir/$file" - process_includes $src_dir/$file - done -} - -f=$src -while [ -n "$f" ] ; do - f=$(cat $f | tr -d '\r' | awk '/^include / {printf "'$src_dir'/%s ", $2}') - [ $? = 0 ] || exit 1 - all_includes="$all_includes $f" -done -process_includes $src - -cat $src $all_includes | grep -v '^include' -echo "$target: $all_includes" > $dep diff --git a/scripts/minikconf.py b/scripts/minikconf.py index 48800591e2..b0b4f76733 100644 --- a/scripts/minikconf.py +++ b/scripts/minikconf.py @@ -12,6 +12,7 @@ import os import sys +import re __all__ = [ 'KconfigParserError', 'KconfigData', 'KconfigParser' ] @@ -329,6 +330,12 @@ class KconfigParser: self.get_token() self.parse_config() + def do_assignment(self, var, val): + if not var.startswith("CONFIG_"): + raise Error('assigned variable should start with CONFIG_') + var = self.data.do_var(var[7:]) + self.data.do_assignment(var, val) + # file management ----- def error_path(self): @@ -617,6 +624,28 @@ class KconfigParser: return None if __name__ == '__main__': - fname = len(sys.argv) > 1 and sys.argv[1] or 'Kconfig.test' - data = KconfigParser.parse(open(fname, 'r')) - print data.compute_config() + argv = sys.argv + if len(argv) == 1: + print >>sys.stderr, "%s: at least one argument is required" % argv[0] + os.exit(1) + + data = KconfigData() + parser = KconfigParser(data) + for arg in argv[3:]: + m = re.match(r'^(CONFIG_[A-Z0-9_]+)=([yn]?)$', arg) + if m is not None: + name, value = m.groups() + parser.do_assignment(name, value == 'y') + else: + fp = open(arg, 'r') + parser.parse_file(fp) + fp.close() + + config = data.compute_config() + for key in sorted(config.keys()): + print 'CONFIG_%s=%s'% (key, (config[key] and 'y' or 'n')) + + deps = open(argv[2], 'w') + for fname in data.previously_included: + print >>deps, '%s: %s' % (argv[1], fname) + deps.close()