From nobody Sat Sep 28 15:02:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=intel.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1548228441143419.63347545257056; Tue, 22 Jan 2019 23:27:21 -0800 (PST) Received: from localhost ([127.0.0.1]:57171 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gmCwS-0000LN-1a for importer@patchew.org; Wed, 23 Jan 2019 02:27:20 -0500 Received: from eggs.gnu.org ([209.51.188.92]:60057) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gmCW2-0004i1-Og for qemu-devel@nongnu.org; Wed, 23 Jan 2019 02:00:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gmCW0-0003di-Ux for qemu-devel@nongnu.org; Wed, 23 Jan 2019 02:00:02 -0500 Received: from mga18.intel.com ([134.134.136.126]:36921) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gmCW0-0002NF-LL for qemu-devel@nongnu.org; Wed, 23 Jan 2019 02:00:00 -0500 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Jan 2019 22:59:20 -0800 Received: from he.bj.intel.com ([10.238.157.85]) by orsmga001.jf.intel.com with ESMTP; 22 Jan 2019 22:59:19 -0800 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,510,1539673200"; d="scan'208";a="129980962" From: Yang Zhong To: qemu-devel@nongnu.org Date: Wed, 23 Jan 2019 14:56:01 +0800 Message-Id: <20190123065618.3520-28-yang.zhong@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190123065618.3520-1-yang.zhong@intel.com> References: <20190123065618.3520-1-yang.zhong@intel.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 134.134.136.126 Subject: [Qemu-devel] [RFC PATCH v4 27/44] 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, ehabkost@redhat.com, pbonzini@redhat.com, sameo@linux.intel.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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. =20 config KVM bool diff --git a/Makefile b/Makefile index c9bdb67274..c4b5c35ff5 100644 --- a/Makefile +++ b/Makefile @@ -326,9 +326,19 @@ endif =20 -include $(SUBDIR_DEVICES_MAK_DEP) =20 -%/config-devices.mak: default-configs/%.mak $(SRC_PATH)/scripts/make_devic= e_config.sh +# This has to be kept in sync with Kconfig.host. +MINIKCONF_ARGS =3D \ + CONFIG_KVM=3D$(CONFIG_KVM) \ + CONFIG_SPICE=3D$(CONFIG_SPICE) \ + CONFIG_TPM=3D$(CONFIG_TPM) \ + CONFIG_XEN=3D$(CONFIG_XEN) \ + CONFIG_OPENGL=3D$(CONFIG_OPENGL) + +MINIKCONF =3D $(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 $< $*-confi= g-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 39f72e81be..f31692cba8 100644 --- a/Makefile.target +++ b/Makefile.target @@ -4,9 +4,12 @@ BUILD_DIR?=3D$(CURDIR)/.. =20 include ../config-host.mak include config-target.mak -include config-devices.mak include $(SRC_PATH)/rules.mak =20 +ifdef CONFIG_SOFTMMU +include config-devices.mak +endif + $(call set-vpath, $(SRC_PATH):$(BUILD_DIR)) ifdef CONFIG_LINUX QEMU_CFLAGS +=3D -I../linux-headers @@ -190,7 +193,9 @@ all-obj-$(CONFIG_SOFTMMU) +=3D $(crypto-obj-y) all-obj-$(CONFIG_SOFTMMU) +=3D $(io-obj-y) all-obj-$(CONFIG_SOFTMMU) +=3D $(slirp-obj-y) =20 +ifdef CONFIG_SOFTMMU $(QEMU_PROG_BUILD): config-devices.mak +endif =20 COMMON_LDADDS =3D ../libqemuutil.a =20 diff --git a/default-configs/i386-softmmu.mak b/default-configs/i386-softmm= u.mak index 71c9f6fbcb..66829feada 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=3D$(CONFIG_SPICE) CONFIG_VGA_ISA=3Dy CONFIG_VGA_CIRRUS=3Dy CONFIG_VMWARE_VGA=3Dy @@ -37,8 +36,6 @@ CONFIG_HPET=3Dy CONFIG_APPLESMC=3Dy CONFIG_I8259=3Dy CONFIG_PFLASH_CFI01=3Dy -CONFIG_TPM_TIS=3D$(CONFIG_TPM) -CONFIG_TPM_CRB=3D$(CONFIG_TPM) CONFIG_MC146818RTC=3Dy CONFIG_PCI_PIIX=3Dy CONFIG_WDT_IB700=3Dy 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 =20 config MILKYMIST_TMU2 bool + depends on OPENGL =20 config SM501 bool @@ -66,6 +67,7 @@ config VGA =20 config QXL bool + depends on SPICE =20 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 =20 config I440FX bool + select QXL if SPICE + select TPM_TIS if TPM + select XEN_I386 if XEN =20 config ISAPC bool =20 config Q35 bool + select QXL if SPICE + select TPM_TIS if TPM + select XEN_I386 if XEN =20 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 =20 config ARM_GIC_KVM bool + default y + depends on ARM_GIC && KVM =20 config OPENPIC_KVM bool + default y + depends on OPENPIC && KVM =20 config XICS bool @@ -33,6 +37,8 @@ config XICS_SPAPR =20 config XICS_KVM bool + default y + depends on XICS && KVM =20 config ALLWINNER_A10_PIC bool @@ -42,6 +48,8 @@ config S390_FLIC =20 config S390_FLIC_KVM bool + default y + depends on S390_FLIC && KVM =20 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 =20 config IVSHMEM_DEVICE bool + default y + depends on PCI =20 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 =20 config TPM_TIS bool + depends on TPM =20 config TPM_CRB bool diff --git a/rules.mak b/rules.mak index 86e033d815..62cf02e92b 100644 --- a/rules.mak +++ b/rules.mak @@ -144,7 +144,7 @@ cc-option =3D $(if $(shell $(CC) $1 $2 -S -o /dev/null = -xc /dev/null \ cc-c-option =3D $(if $(shell $(CC) $1 $2 -c -o /dev/null -xc /dev/null \ >/dev/null 2>&1 && echo OK), $2, $3) =20 -VPATH_SUFFIXES =3D %.c %.h %.S %.cc %.cpp %.m %.mak %.texi %.sh %.rc +VPATH_SUFFIXES =3D %.c %.h %.S %.cc %.cpp %.m %.mak %.texi %.sh %.rc Kconf= ig% set-vpath =3D $(if $1,$(foreach PATTERN,$(VPATH_SUFFIXES),$(eval vpath $(P= ATTERN) $1))) =20 # 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=3D$1 -dep=3D$2 -target=3D$3 -src_dir=3D$(dirname $src) -all_includes=3D - -process_includes () { - cat $1 | grep '^include' | \ - while read include file ; do - all_includes=3D"$all_includes $src_dir/$file" - process_includes $src_dir/$file - done -} - -f=3D$src -while [ -n "$f" ] ; do - f=3D$(cat $f | tr -d '\r' | awk '/^include / {printf "'$src_dir'/%s ", $= 2}') - [ $? =3D 0 ] || exit 1 - all_includes=3D"$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 @@ =20 import os import sys +import re =20 __all__ =3D [ 'KconfigParserError', 'KconfigData', 'KconfigParser' ] =20 @@ -329,6 +330,12 @@ class KconfigParser: self.get_token() self.parse_config() =20 + def do_assignment(self, var, val): + if not var.startswith("CONFIG_"): + raise Error('assigned variable should start with CONFIG_') + var =3D self.data.do_var(var[7:]) + self.data.do_assignment(var, val) + # file management ----- =20 def error_path(self): @@ -617,6 +624,28 @@ class KconfigParser: return None =20 if __name__ =3D=3D '__main__': - fname =3D len(sys.argv) > 1 and sys.argv[1] or 'Kconfig.test' - data =3D KconfigParser.parse(open(fname, 'r')) - print data.compute_config() + argv =3D sys.argv + if len(argv) =3D=3D 1: + print >>sys.stderr, "%s: at least one argument is required" % argv= [0] + os.exit(1) + + data =3D KconfigData() + parser =3D KconfigParser(data) + for arg in argv[3:]: + m =3D re.match(r'^(CONFIG_[A-Z0-9_]+)=3D([yn]?)$', arg) + if m is not None: + name, value =3D m.groups() + parser.do_assignment(name, value =3D=3D 'y') + else: + fp =3D open(arg, 'r') + parser.parse_file(fp) + fp.close() + + config =3D data.compute_config() + for key in sorted(config.keys()): + print 'CONFIG_%s=3D%s'% (key, (config[key] and 'y' or 'n')) + + deps =3D open(argv[2], 'w') + for fname in data.previously_included: + print >>deps, '%s: %s' % (argv[1], fname) + deps.close() --=20 2.17.1