From patchwork Wed Oct 23 16:48:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 11207217 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D0B86112B for ; Wed, 23 Oct 2019 16:50:05 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id ACA9621906 for ; Wed, 23 Oct 2019 16:50:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="Z8WDYuRK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ACA9621906 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNJob-0007QC-Ju; Wed, 23 Oct 2019 16:48:53 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNJoa-0007PW-Dv for xen-devel@lists.xenproject.org; Wed, 23 Oct 2019 16:48:52 +0000 X-Inumbo-ID: f7e0cd29-f5b4-11e9-9487-12813bfff9fa Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id f7e0cd29-f5b4-11e9-9487-12813bfff9fa; Wed, 23 Oct 2019 16:48:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1571849322; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=cW9QUA2andQL4O4HOUDeg7g0PmkMcoU7/GKPsef2zGA=; b=Z8WDYuRKVVHj9M8clRTcnx//iuwfKsjJ2RZbUQoHDtx7xzOIHKDjIpTa iJbtzhVwYAhCq2JJ9sCB16drBfT5leQ/6JgKSoO7rGKHIe/5NQDJULOa5 oVgiXjXkcaxE+rn52Ms25aNcAOr9m4andaXZmYL5sGohfpmXRnHI7Zen2 Y=; Authentication-Results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=anthony.perard@citrix.com; spf=Pass smtp.mailfrom=anthony.perard@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa1.hc3370-68.iphmx.com: no sender authenticity information available from domain of anthony.perard@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa1.hc3370-68.iphmx.com: domain of anthony.perard@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa1.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: c2ahbwj45OpwMOadhGbNZ84+8kOMCOPBapvxYAOASmEy98DV1PgFx7cj+QimQVOIyISqelgJ7Q 92hcXNHu0MTBzg+YLvJh16q9uCAAF6pj9Wy7zxMQUnOeioogU0dbWDMzuU25AFInwAQ1I2uvDb gOS3MRPIwhy8mR91yMXu9ZkTnytdVbYELA+T5+yMSU6W6+siPXvQ3OrBexSLkEQXcO1dju7FmC hxETKjLrjruj2Xk4CVltwqCIlseAGLXbedEOuH3Ed5dYvMH2mpVOVZvZlgqjJG774ImT231Qw5 oj4= X-SBRS: 2.7 X-MesageID: 7427938 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.68,221,1569297600"; d="scan'208";a="7427938" From: Anthony PERARD To: Date: Wed, 23 Oct 2019 17:48:16 +0100 Message-ID: <20191023164837.2700240-3-anthony.perard@citrix.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191023164837.2700240-1-anthony.perard@citrix.com> References: <20191023164837.2700240-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [RFC XEN PATCH 02/23] xen: Makefile: Remove outdated comment X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Anthony PERARD Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" The comment could have been removed with 18cd4997d26b9df95dda87503e41c823279a07a0. Signed-off-by: Anthony PERARD --- xen/arch/x86/Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile index 2443fd2cc5bd..af6c83dfbae6 100644 --- a/xen/arch/x86/Makefile +++ b/xen/arch/x86/Makefile @@ -176,7 +176,6 @@ CFLAGS-$(XEN_BUILD_EFI) += -DXEN_BUILD_EFI $(TARGET).efi: VIRT_BASE = 0x$(shell $(NM) efi/relocs-dummy.o | sed -n 's, A VIRT_START$$,,p') $(TARGET).efi: ALT_BASE = 0x$(shell $(NM) efi/relocs-dummy.o | sed -n 's, A ALT_START$$,,p') -# Don't use $(wildcard ...) here - at least make 3.80 expands this too early! $(TARGET).efi: guard = $(if $(filter y,$(XEN_BUILD_PE)),,:) ifneq ($(build_id_linker),) From patchwork Wed Oct 23 16:48:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 11207237 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 35F98139A for ; Wed, 23 Oct 2019 16:55:10 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 61B5621906 for ; Wed, 23 Oct 2019 16:55:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="OTdU8Lmm" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 61B5621906 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNJsd-0000WL-JN; Wed, 23 Oct 2019 16:53:03 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNJou-0007fQ-Gm for xen-devel@lists.xenproject.org; Wed, 23 Oct 2019 16:49:12 +0000 X-Inumbo-ID: 01193cf4-f5b5-11e9-8aca-bc764e2007e4 Received: from esa5.hc3370-68.iphmx.com (unknown [216.71.155.168]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 01193cf4-f5b5-11e9-8aca-bc764e2007e4; Wed, 23 Oct 2019 16:48:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1571849337; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CP5b1rSPt7cL2COStOCSm3Ukf6Cac3G64m7xn4AKX5k=; b=OTdU8LmmCqwbnFbIFuV5I6NCFsMgTPJQKDHyed2WfAbPb4xUHilaaFLG l4rLnt1/4H7VE2NEio4UwjVXymvgvNP+jVaJ+YqT9A4zTIpUqWuvyvwh0 QK+y3QntZ3X5UjL0qGhwbf2pe4D8jKAdMIiPw6wQYIY/rpvhUukNdDo57 A=; Authentication-Results: esa5.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=anthony.perard@citrix.com; spf=Pass smtp.mailfrom=anthony.perard@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa5.hc3370-68.iphmx.com: no sender authenticity information available from domain of anthony.perard@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa5.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa5.hc3370-68.iphmx.com: domain of anthony.perard@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa5.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa5.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa5.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: 5xP2c12G+vIlVGrtaua4ezrsOelmaxxrYQy3A143R43Z83y9z6ZMlmAQltVXUANYXzKU0wbXRX gT4vMCu0bIHflOsycunzRIR9uwLZSQxn0Rn/f9LTvtrRL3wSH6tb+lFG3HeNm10iboqXSOCny5 bMErczDni58XIoZYwhi8anXlEwnmQhxdzv1hY5j2mS37aLGm5VoDKpj6S+U6Vc9bzA41QMblEP qmWb5Yvyu5yUf4kw33cEGPPNTnsWNc2/uKHWJc5vmIxi5VfTNPJ5ygMyx77mNZxwSWjvth/HF1 KFo= X-SBRS: 2.7 X-MesageID: 7640776 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.68,221,1569297600"; d="scan'208";a="7640776" From: Anthony PERARD To: Date: Wed, 23 Oct 2019 17:48:17 +0100 Message-ID: <20191023164837.2700240-4-anthony.perard@citrix.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191023164837.2700240-1-anthony.perard@citrix.com> References: <20191023164837.2700240-1-anthony.perard@citrix.com> MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 23 Oct 2019 16:53:02 +0000 Subject: [Xen-devel] [RFC XEN PATCH 03/23] xen: Update Kconfig to Linux v5.3 X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Anthony PERARD Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" This patch updates Kconfig to a more recent version of Kconfig, found in Linux v5.3.0, 4d856f72c10ecb060868ed10ff1b1453943fc6c8. With the updated version of Kconfig, other changes are necessary to avoid breaking the build. Kconfig files: - fix Kconfigs that where using option env=*: Since Linux commit 104daea149c45cc84842ce77a9bd6436d19f3dd8, we can access the environment directly via $() and "option env=" as been removed. - CONFIG_EXPERT='y' will now appear in .config file if XEN_CONFIG_EXPERT=y in the environment. The alternative is to change "EXPERT" to "$(XEN_CONFIG_EXPERT)" in all Kconfig files. Makefile: - silentoldconfig target as been removed from Kconfig. To update include/generated/autoconf.h, we need to use syncconfig target instead. Makefile.kconfig: - Import newer needed code from Linux's Makefile.lib and Kbuild.include and Makefile.build. - Set Q to empty, Xen build system doesn't silence commands. Having Q empty mean we can import stuff from Linux without having to remove the leading $(Q) from build commands. And quiet='' mean commands will be echoed. - Add $(PHONY) to .PHONY. Like it is intended by Kbuild. Dependency change: - Now depends on flex/bison, maybe we could _shipped those files like before. Linux doesn't do that anymore. Signed-off-by: Anthony PERARD --- docs/misc/kconfig-language.rst | 701 +++++ docs/misc/kconfig-language.txt | 395 --- docs/misc/kconfig-macro-language.rst | 247 ++ docs/misc/{kconfig.txt => kconfig.rst} | 185 +- xen/.gitignore | 2 + xen/Kconfig | 18 +- xen/Makefile | 4 +- xen/arch/arm/Kconfig | 2 +- xen/common/Kconfig | 12 +- xen/tools/kconfig/.gitignore | 6 +- xen/tools/kconfig/Makefile | 268 +- xen/tools/kconfig/Makefile.host | 94 +- xen/tools/kconfig/Makefile.kconfig | 72 +- xen/tools/kconfig/conf.c | 191 +- xen/tools/kconfig/confdata.c | 491 ++-- xen/tools/kconfig/expr.c | 213 +- xen/tools/kconfig/expr.h | 108 +- xen/tools/kconfig/gconf-cfg.sh | 30 + xen/tools/kconfig/gconf.c | 39 +- xen/tools/kconfig/images.c | 34 +- xen/tools/kconfig/images.h | 33 + xen/tools/kconfig/lexer.l | 471 +++ xen/tools/kconfig/list.h | 1 + xen/tools/kconfig/lkc.h | 38 +- xen/tools/kconfig/lkc_proto.h | 21 +- xen/tools/kconfig/lxdialog/.gitignore | 4 - xen/tools/kconfig/lxdialog/BIG.FAT.WARNING | 2 +- xen/tools/kconfig/lxdialog/check-lxdialog.sh | 91 - xen/tools/kconfig/lxdialog/checklist.c | 15 +- xen/tools/kconfig/lxdialog/dialog.h | 17 +- xen/tools/kconfig/lxdialog/inputbox.c | 18 +- xen/tools/kconfig/lxdialog/menubox.c | 15 +- xen/tools/kconfig/lxdialog/textbox.c | 15 +- xen/tools/kconfig/lxdialog/util.c | 15 +- xen/tools/kconfig/lxdialog/yesno.c | 15 +- xen/tools/kconfig/mconf-cfg.sh | 47 + xen/tools/kconfig/mconf.c | 27 +- xen/tools/kconfig/menu.c | 288 +- xen/tools/kconfig/merge_config.sh | 77 +- xen/tools/kconfig/nconf-cfg.sh | 47 + xen/tools/kconfig/nconf.c | 42 +- xen/tools/kconfig/nconf.gui.c | 30 +- xen/tools/kconfig/nconf.h | 9 +- xen/tools/kconfig/{zconf.y => parser.y} | 409 ++- xen/tools/kconfig/preprocess.c | 574 ++++ xen/tools/kconfig/qconf-cfg.sh | 32 + xen/tools/kconfig/qconf.cc | 750 +++-- xen/tools/kconfig/qconf.h | 153 +- xen/tools/kconfig/streamline_config.pl | 53 +- xen/tools/kconfig/symbol.c | 295 +- xen/tools/kconfig/tests/auto_submenu/Kconfig | 52 + .../kconfig/tests/auto_submenu/__init__.py | 13 + .../tests/auto_submenu/expected_stdout | 10 + xen/tools/kconfig/tests/choice/Kconfig | 56 + xen/tools/kconfig/tests/choice/__init__.py | 41 + .../tests/choice/alldef_expected_config | 5 + .../tests/choice/allmod_expected_config | 9 + .../tests/choice/allno_expected_config | 5 + .../tests/choice/allyes_expected_config | 9 + .../tests/choice/oldask0_expected_stdout | 10 + xen/tools/kconfig/tests/choice/oldask1_config | 2 + .../tests/choice/oldask1_expected_stdout | 15 + .../tests/choice_value_with_m_dep/Kconfig | 21 + .../tests/choice_value_with_m_dep/__init__.py | 16 + .../tests/choice_value_with_m_dep/config | 2 + .../choice_value_with_m_dep/expected_config | 3 + .../choice_value_with_m_dep/expected_stdout | 4 + xen/tools/kconfig/tests/conftest.py | 291 ++ .../kconfig/tests/err_recursive_dep/Kconfig | 63 + .../tests/err_recursive_dep/__init__.py | 10 + .../tests/err_recursive_dep/expected_stderr | 38 + .../kconfig/tests/err_recursive_inc/Kconfig | 2 + .../tests/err_recursive_inc/Kconfig.inc1 | 5 + .../tests/err_recursive_inc/Kconfig.inc2 | 4 + .../tests/err_recursive_inc/Kconfig.inc3 | 2 + .../tests/err_recursive_inc/__init__.py | 11 + .../tests/err_recursive_inc/expected_stderr | 6 + xen/tools/kconfig/tests/inter_choice/Kconfig | 25 + .../kconfig/tests/inter_choice/__init__.py | 15 + .../kconfig/tests/inter_choice/defconfig | 1 + .../tests/inter_choice/expected_config | 4 + .../kconfig/tests/new_choice_with_dep/Kconfig | 39 + .../tests/new_choice_with_dep/__init__.py | 15 + .../kconfig/tests/new_choice_with_dep/config | 3 + .../tests/new_choice_with_dep/expected_stdout | 10 + .../tests/no_write_if_dep_unmet/Kconfig | 16 + .../tests/no_write_if_dep_unmet/__init__.py | 20 + .../tests/no_write_if_dep_unmet/config | 1 + .../no_write_if_dep_unmet/expected_config | 5 + .../tests/preprocess/builtin_func/Kconfig | 27 + .../tests/preprocess/builtin_func/__init__.py | 9 + .../preprocess/builtin_func/expected_stderr | 5 + .../preprocess/builtin_func/expected_stdout | 1 + .../preprocess/circular_expansion/Kconfig | 5 + .../preprocess/circular_expansion/__init__.py | 11 + .../circular_expansion/expected_stderr | 1 + .../kconfig/tests/preprocess/escape/Kconfig | 44 + .../tests/preprocess/escape/__init__.py | 8 + .../tests/preprocess/escape/expected_stderr | 10 + .../kconfig/tests/preprocess/variable/Kconfig | 53 + .../tests/preprocess/variable/__init__.py | 8 + .../tests/preprocess/variable/expected_stderr | 9 + xen/tools/kconfig/tests/pytest.ini | 7 + .../kconfig/tests/rand_nested_choice/Kconfig | 35 + .../tests/rand_nested_choice/__init__.py | 17 + .../tests/rand_nested_choice/expected_stdout0 | 2 + .../tests/rand_nested_choice/expected_stdout1 | 4 + .../tests/rand_nested_choice/expected_stdout2 | 5 + xen/tools/kconfig/util.c | 86 +- xen/tools/kconfig/zconf.gperf | 49 - xen/tools/kconfig/zconf.hash.c_shipped | 293 -- xen/tools/kconfig/zconf.l | 374 --- xen/tools/kconfig/zconf.lex.c_shipped | 2473 ---------------- xen/tools/kconfig/zconf.tab.c_shipped | 2580 ----------------- 114 files changed, 5632 insertions(+), 8059 deletions(-) create mode 100644 docs/misc/kconfig-language.rst delete mode 100644 docs/misc/kconfig-language.txt create mode 100644 docs/misc/kconfig-macro-language.rst rename docs/misc/{kconfig.txt => kconfig.rst} (70%) create mode 100644 xen/.gitignore create mode 100755 xen/tools/kconfig/gconf-cfg.sh create mode 100644 xen/tools/kconfig/images.h create mode 100644 xen/tools/kconfig/lexer.l delete mode 100644 xen/tools/kconfig/lxdialog/.gitignore delete mode 100755 xen/tools/kconfig/lxdialog/check-lxdialog.sh create mode 100755 xen/tools/kconfig/mconf-cfg.sh create mode 100755 xen/tools/kconfig/nconf-cfg.sh rename xen/tools/kconfig/{zconf.y => parser.y} (66%) create mode 100644 xen/tools/kconfig/preprocess.c create mode 100755 xen/tools/kconfig/qconf-cfg.sh create mode 100644 xen/tools/kconfig/tests/auto_submenu/Kconfig create mode 100644 xen/tools/kconfig/tests/auto_submenu/__init__.py create mode 100644 xen/tools/kconfig/tests/auto_submenu/expected_stdout create mode 100644 xen/tools/kconfig/tests/choice/Kconfig create mode 100644 xen/tools/kconfig/tests/choice/__init__.py create mode 100644 xen/tools/kconfig/tests/choice/alldef_expected_config create mode 100644 xen/tools/kconfig/tests/choice/allmod_expected_config create mode 100644 xen/tools/kconfig/tests/choice/allno_expected_config create mode 100644 xen/tools/kconfig/tests/choice/allyes_expected_config create mode 100644 xen/tools/kconfig/tests/choice/oldask0_expected_stdout create mode 100644 xen/tools/kconfig/tests/choice/oldask1_config create mode 100644 xen/tools/kconfig/tests/choice/oldask1_expected_stdout create mode 100644 xen/tools/kconfig/tests/choice_value_with_m_dep/Kconfig create mode 100644 xen/tools/kconfig/tests/choice_value_with_m_dep/__init__.py create mode 100644 xen/tools/kconfig/tests/choice_value_with_m_dep/config create mode 100644 xen/tools/kconfig/tests/choice_value_with_m_dep/expected_config create mode 100644 xen/tools/kconfig/tests/choice_value_with_m_dep/expected_stdout create mode 100644 xen/tools/kconfig/tests/conftest.py create mode 100644 xen/tools/kconfig/tests/err_recursive_dep/Kconfig create mode 100644 xen/tools/kconfig/tests/err_recursive_dep/__init__.py create mode 100644 xen/tools/kconfig/tests/err_recursive_dep/expected_stderr create mode 100644 xen/tools/kconfig/tests/err_recursive_inc/Kconfig create mode 100644 xen/tools/kconfig/tests/err_recursive_inc/Kconfig.inc1 create mode 100644 xen/tools/kconfig/tests/err_recursive_inc/Kconfig.inc2 create mode 100644 xen/tools/kconfig/tests/err_recursive_inc/Kconfig.inc3 create mode 100644 xen/tools/kconfig/tests/err_recursive_inc/__init__.py create mode 100644 xen/tools/kconfig/tests/err_recursive_inc/expected_stderr create mode 100644 xen/tools/kconfig/tests/inter_choice/Kconfig create mode 100644 xen/tools/kconfig/tests/inter_choice/__init__.py create mode 100644 xen/tools/kconfig/tests/inter_choice/defconfig create mode 100644 xen/tools/kconfig/tests/inter_choice/expected_config create mode 100644 xen/tools/kconfig/tests/new_choice_with_dep/Kconfig create mode 100644 xen/tools/kconfig/tests/new_choice_with_dep/__init__.py create mode 100644 xen/tools/kconfig/tests/new_choice_with_dep/config create mode 100644 xen/tools/kconfig/tests/new_choice_with_dep/expected_stdout create mode 100644 xen/tools/kconfig/tests/no_write_if_dep_unmet/Kconfig create mode 100644 xen/tools/kconfig/tests/no_write_if_dep_unmet/__init__.py create mode 100644 xen/tools/kconfig/tests/no_write_if_dep_unmet/config create mode 100644 xen/tools/kconfig/tests/no_write_if_dep_unmet/expected_config create mode 100644 xen/tools/kconfig/tests/preprocess/builtin_func/Kconfig create mode 100644 xen/tools/kconfig/tests/preprocess/builtin_func/__init__.py create mode 100644 xen/tools/kconfig/tests/preprocess/builtin_func/expected_stderr create mode 100644 xen/tools/kconfig/tests/preprocess/builtin_func/expected_stdout create mode 100644 xen/tools/kconfig/tests/preprocess/circular_expansion/Kconfig create mode 100644 xen/tools/kconfig/tests/preprocess/circular_expansion/__init__.py create mode 100644 xen/tools/kconfig/tests/preprocess/circular_expansion/expected_stderr create mode 100644 xen/tools/kconfig/tests/preprocess/escape/Kconfig create mode 100644 xen/tools/kconfig/tests/preprocess/escape/__init__.py create mode 100644 xen/tools/kconfig/tests/preprocess/escape/expected_stderr create mode 100644 xen/tools/kconfig/tests/preprocess/variable/Kconfig create mode 100644 xen/tools/kconfig/tests/preprocess/variable/__init__.py create mode 100644 xen/tools/kconfig/tests/preprocess/variable/expected_stderr create mode 100644 xen/tools/kconfig/tests/pytest.ini create mode 100644 xen/tools/kconfig/tests/rand_nested_choice/Kconfig create mode 100644 xen/tools/kconfig/tests/rand_nested_choice/__init__.py create mode 100644 xen/tools/kconfig/tests/rand_nested_choice/expected_stdout0 create mode 100644 xen/tools/kconfig/tests/rand_nested_choice/expected_stdout1 create mode 100644 xen/tools/kconfig/tests/rand_nested_choice/expected_stdout2 delete mode 100644 xen/tools/kconfig/zconf.gperf delete mode 100644 xen/tools/kconfig/zconf.hash.c_shipped delete mode 100644 xen/tools/kconfig/zconf.l delete mode 100644 xen/tools/kconfig/zconf.lex.c_shipped delete mode 100644 xen/tools/kconfig/zconf.tab.c_shipped diff --git a/docs/misc/kconfig-language.rst b/docs/misc/kconfig-language.rst new file mode 100644 index 000000000000..74bef19f69f0 --- /dev/null +++ b/docs/misc/kconfig-language.rst @@ -0,0 +1,701 @@ +================ +Kconfig Language +================ + +Introduction +------------ + +The configuration database is a collection of configuration options +organized in a tree structure:: + + +- Code maturity level options + | +- Prompt for development and/or incomplete code/drivers + +- General setup + | +- Networking support + | +- System V IPC + | +- BSD Process Accounting + | +- Sysctl support + +- Loadable module support + | +- Enable loadable module support + | +- Set version information on all module symbols + | +- Kernel module loader + +- ... + +Every entry has its own dependencies. These dependencies are used +to determine the visibility of an entry. Any child entry is only +visible if its parent entry is also visible. + +Menu entries +------------ + +Most entries define a config option; all other entries help to organize +them. A single configuration option is defined like this:: + + config MODVERSIONS + bool "Set version information on all module symbols" + depends on MODULES + help + Usually, modules have to be recompiled whenever you switch to a new + kernel. ... + +Every line starts with a key word and can be followed by multiple +arguments. "config" starts a new config entry. The following lines +define attributes for this config option. Attributes can be the type of +the config option, input prompt, dependencies, help text and default +values. A config option can be defined multiple times with the same +name, but every definition can have only a single input prompt and the +type must not conflict. + +Menu attributes +--------------- + +A menu entry can have a number of attributes. Not all of them are +applicable everywhere (see syntax). + +- type definition: "bool"/"tristate"/"string"/"hex"/"int" + + Every config option must have a type. There are only two basic types: + tristate and string; the other types are based on these two. The type + definition optionally accepts an input prompt, so these two examples + are equivalent:: + + bool "Networking support" + + and:: + + bool + prompt "Networking support" + +- input prompt: "prompt" ["if" ] + + Every menu entry can have at most one prompt, which is used to display + to the user. Optionally dependencies only for this prompt can be added + with "if". + +- default value: "default" ["if" ] + + A config option can have any number of default values. If multiple + default values are visible, only the first defined one is active. + Default values are not limited to the menu entry where they are + defined. This means the default can be defined somewhere else or be + overridden by an earlier definition. + The default value is only assigned to the config symbol if no other + value was set by the user (via the input prompt above). If an input + prompt is visible the default value is presented to the user and can + be overridden by him. + Optionally, dependencies only for this default value can be added with + "if". + + The default value deliberately defaults to 'n' in order to avoid bloating the + build. With few exceptions, new config options should not change this. The + intent is for "make oldconfig" to add as little as possible to the config from + release to release. + + Note: + Things that merit "default y/m" include: + + a) A new Kconfig option for something that used to always be built + should be "default y". + + b) A new gatekeeping Kconfig option that hides/shows other Kconfig + options (but does not generate any code of its own), should be + "default y" so people will see those other options. + + c) Sub-driver behavior or similar options for a driver that is + "default n". This allows you to provide sane defaults. + + d) Hardware or infrastructure that everybody expects, such as CONFIG_NET + or CONFIG_BLOCK. These are rare exceptions. + +- type definition + default value:: + + "def_bool"/"def_tristate" ["if" ] + + This is a shorthand notation for a type definition plus a value. + Optionally dependencies for this default value can be added with "if". + +- dependencies: "depends on" + + This defines a dependency for this menu entry. If multiple + dependencies are defined, they are connected with '&&'. Dependencies + are applied to all other options within this menu entry (which also + accept an "if" expression), so these two examples are equivalent:: + + bool "foo" if BAR + default y if BAR + + and:: + + depends on BAR + bool "foo" + default y + +- reverse dependencies: "select" ["if" ] + + While normal dependencies reduce the upper limit of a symbol (see + below), reverse dependencies can be used to force a lower limit of + another symbol. The value of the current menu symbol is used as the + minimal value can be set to. If is selected multiple + times, the limit is set to the largest selection. + Reverse dependencies can only be used with boolean or tristate + symbols. + + Note: + select should be used with care. select will force + a symbol to a value without visiting the dependencies. + By abusing select you are able to select a symbol FOO even + if FOO depends on BAR that is not set. + In general use select only for non-visible symbols + (no prompts anywhere) and for symbols with no dependencies. + That will limit the usefulness but on the other hand avoid + the illegal configurations all over. + +- weak reverse dependencies: "imply" ["if" ] + + This is similar to "select" as it enforces a lower limit on another + symbol except that the "implied" symbol's value may still be set to n + from a direct dependency or with a visible prompt. + + Given the following example:: + + config FOO + tristate + imply BAZ + + config BAZ + tristate + depends on BAR + + The following values are possible: + + === === ============= ============== + FOO BAR BAZ's default choice for BAZ + === === ============= ============== + n y n N/m/y + m y m M/y/n + y y y Y/n + y n * N + === === ============= ============== + + This is useful e.g. with multiple drivers that want to indicate their + ability to hook into a secondary subsystem while allowing the user to + configure that subsystem out without also having to unset these drivers. + +- limiting menu display: "visible if" + + This attribute is only applicable to menu blocks, if the condition is + false, the menu block is not displayed to the user (the symbols + contained there can still be selected by other symbols, though). It is + similar to a conditional "prompt" attribute for individual menu + entries. Default value of "visible" is true. + +- numerical ranges: "range" ["if" ] + + This allows to limit the range of possible input values for int + and hex symbols. The user can only input a value which is larger than + or equal to the first symbol and smaller than or equal to the second + symbol. + +- help text: "help" or "---help---" + + This defines a help text. The end of the help text is determined by + the indentation level, this means it ends at the first line which has + a smaller indentation than the first line of the help text. + "---help---" and "help" do not differ in behaviour, "---help---" is + used to help visually separate configuration logic from help within + the file as an aid to developers. + +- misc options: "option" [=] + + Various less common options can be defined via this option syntax, + which can modify the behaviour of the menu entry and its config + symbol. These options are currently possible: + + - "defconfig_list" + This declares a list of default entries which can be used when + looking for the default configuration (which is used when the main + .config doesn't exists yet.) + + - "modules" + This declares the symbol to be used as the MODULES symbol, which + enables the third modular state for all config symbols. + At most one symbol may have the "modules" option set. + + - "allnoconfig_y" + This declares the symbol as one that should have the value y when + using "allnoconfig". Used for symbols that hide other symbols. + +Menu dependencies +----------------- + +Dependencies define the visibility of a menu entry and can also reduce +the input range of tristate symbols. The tristate logic used in the +expressions uses one more state than normal boolean logic to express the +module state. Dependency expressions have the following syntax:: + + ::= (1) + '=' (2) + '!=' (3) + '<' (4) + '>' (4) + '<=' (4) + '>=' (4) + '(' ')' (5) + '!' (6) + '&&' (7) + '||' (8) + +Expressions are listed in decreasing order of precedence. + +(1) Convert the symbol into an expression. Boolean and tristate symbols + are simply converted into the respective expression values. All + other symbol types result in 'n'. +(2) If the values of both symbols are equal, it returns 'y', + otherwise 'n'. +(3) If the values of both symbols are equal, it returns 'n', + otherwise 'y'. +(4) If value of is respectively lower, greater, lower-or-equal, + or greater-or-equal than value of , it returns 'y', + otherwise 'n'. +(5) Returns the value of the expression. Used to override precedence. +(6) Returns the result of (2-/expr/). +(7) Returns the result of min(/expr/, /expr/). +(8) Returns the result of max(/expr/, /expr/). + +An expression can have a value of 'n', 'm' or 'y' (or 0, 1, 2 +respectively for calculations). A menu entry becomes visible when its +expression evaluates to 'm' or 'y'. + +There are two types of symbols: constant and non-constant symbols. +Non-constant symbols are the most common ones and are defined with the +'config' statement. Non-constant symbols consist entirely of alphanumeric +characters or underscores. +Constant symbols are only part of expressions. Constant symbols are +always surrounded by single or double quotes. Within the quote, any +other character is allowed and the quotes can be escaped using '\'. + +Menu structure +-------------- + +The position of a menu entry in the tree is determined in two ways. First +it can be specified explicitly:: + + menu "Network device support" + depends on NET + + config NETDEVICES + ... + + endmenu + +All entries within the "menu" ... "endmenu" block become a submenu of +"Network device support". All subentries inherit the dependencies from +the menu entry, e.g. this means the dependency "NET" is added to the +dependency list of the config option NETDEVICES. + +The other way to generate the menu structure is done by analyzing the +dependencies. If a menu entry somehow depends on the previous entry, it +can be made a submenu of it. First, the previous (parent) symbol must +be part of the dependency list and then one of these two conditions +must be true: + +- the child entry must become invisible, if the parent is set to 'n' +- the child entry must only be visible, if the parent is visible:: + + config MODULES + bool "Enable loadable module support" + + config MODVERSIONS + bool "Set version information on all module symbols" + depends on MODULES + + comment "module support disabled" + depends on !MODULES + +MODVERSIONS directly depends on MODULES, this means it's only visible if +MODULES is different from 'n'. The comment on the other hand is only +visible when MODULES is set to 'n'. + + +Kconfig syntax +-------------- + +The configuration file describes a series of menu entries, where every +line starts with a keyword (except help texts). The following keywords +end a menu entry: + +- config +- menuconfig +- choice/endchoice +- comment +- menu/endmenu +- if/endif +- source + +The first five also start the definition of a menu entry. + +config:: + + "config" + + +This defines a config symbol and accepts any of above +attributes as options. + +menuconfig:: + + "menuconfig" + + +This is similar to the simple config entry above, but it also gives a +hint to front ends, that all suboptions should be displayed as a +separate list of options. To make sure all the suboptions will really +show up under the menuconfig entry and not outside of it, every item +from the list must depend on the menuconfig symbol. +In practice, this is achieved by using one of the next two constructs:: + + (1): + menuconfig M + if M + config C1 + config C2 + endif + + (2): + menuconfig M + config C1 + depends on M + config C2 + depends on M + +In the following examples (3) and (4), C1 and C2 still have the M +dependency, but will not appear under menuconfig M anymore, because +of C0, which doesn't depend on M:: + + (3): + menuconfig M + config C0 + if M + config C1 + config C2 + endif + + (4): + menuconfig M + config C0 + config C1 + depends on M + config C2 + depends on M + +choices:: + + "choice" [symbol] + + + "endchoice" + +This defines a choice group and accepts any of the above attributes as +options. A choice can only be of type bool or tristate. If no type is +specified for a choice, its type will be determined by the type of +the first choice element in the group or remain unknown if none of the +choice elements have a type specified, as well. + +While a boolean choice only allows a single config entry to be +selected, a tristate choice also allows any number of config entries +to be set to 'm'. This can be used if multiple drivers for a single +hardware exists and only a single driver can be compiled/loaded into +the kernel, but all drivers can be compiled as modules. + +A choice accepts another option "optional", which allows to set the +choice to 'n' and no entry needs to be selected. +If no [symbol] is associated with a choice, then you can not have multiple +definitions of that choice. If a [symbol] is associated to the choice, +then you may define the same choice (i.e. with the same entries) in another +place. + +comment:: + + "comment" + + +This defines a comment which is displayed to the user during the +configuration process and is also echoed to the output files. The only +possible options are dependencies. + +menu:: + + "menu" + + + "endmenu" + +This defines a menu block, see "Menu structure" above for more +information. The only possible options are dependencies and "visible" +attributes. + +if:: + + "if" + + "endif" + +This defines an if block. The dependency expression is appended +to all enclosed menu entries. + +source:: + + "source" + +This reads the specified configuration file. This file is always parsed. + +mainmenu:: + + "mainmenu" + +This sets the config program's title bar if the config program chooses +to use it. It should be placed at the top of the configuration, before any +other statement. + +'#' Kconfig source file comment: + +An unquoted '#' character anywhere in a source file line indicates +the beginning of a source file comment. The remainder of that line +is a comment. + + +Kconfig hints +------------- +This is a collection of Kconfig tips, most of which aren't obvious at +first glance and most of which have become idioms in several Kconfig +files. + +Adding common features and make the usage configurable +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +It is a common idiom to implement a feature/functionality that are +relevant for some architectures but not all. +The recommended way to do so is to use a config variable named HAVE_* +that is defined in a common Kconfig file and selected by the relevant +architectures. +An example is the generic IOMAP functionality. + +We would in lib/Kconfig see:: + + # Generic IOMAP is used to ... + config HAVE_GENERIC_IOMAP + + config GENERIC_IOMAP + depends on HAVE_GENERIC_IOMAP && FOO + +And in lib/Makefile we would see:: + + obj-$(CONFIG_GENERIC_IOMAP) += iomap.o + +For each architecture using the generic IOMAP functionality we would see:: + + config X86 + select ... + select HAVE_GENERIC_IOMAP + select ... + +Note: we use the existing config option and avoid creating a new +config variable to select HAVE_GENERIC_IOMAP. + +Note: the use of the internal config variable HAVE_GENERIC_IOMAP, it is +introduced to overcome the limitation of select which will force a +config option to 'y' no matter the dependencies. +The dependencies are moved to the symbol GENERIC_IOMAP and we avoid the +situation where select forces a symbol equals to 'y'. + +Adding features that need compiler support +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +There are several features that need compiler support. The recommended way +to describe the dependency on the compiler feature is to use "depends on" +followed by a test macro:: + + config STACKPROTECTOR + bool "Stack Protector buffer overflow detection" + depends on $(cc-option,-fstack-protector) + ... + +If you need to expose a compiler capability to makefiles and/or C source files, +`CC_HAS_` is the recommended prefix for the config option:: + + config CC_HAS_STACKPROTECTOR_NONE + def_bool $(cc-option,-fno-stack-protector) + +Build as module only +~~~~~~~~~~~~~~~~~~~~ +To restrict a component build to module-only, qualify its config symbol +with "depends on m". E.g.:: + + config FOO + depends on BAR && m + +limits FOO to module (=m) or disabled (=n). + +Kconfig recursive dependency limitations +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +If you've hit the Kconfig error: "recursive dependency detected" you've run +into a recursive dependency issue with Kconfig, a recursive dependency can be +summarized as a circular dependency. The kconfig tools need to ensure that +Kconfig files comply with specified configuration requirements. In order to do +that kconfig must determine the values that are possible for all Kconfig +symbols, this is currently not possible if there is a circular relation +between two or more Kconfig symbols. For more details refer to the "Simple +Kconfig recursive issue" subsection below. Kconfig does not do recursive +dependency resolution; this has a few implications for Kconfig file writers. +We'll first explain why this issues exists and then provide an example +technical limitation which this brings upon Kconfig developers. Eager +developers wishing to try to address this limitation should read the next +subsections. + +Simple Kconfig recursive issue +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Read: Documentation/kbuild/Kconfig.recursion-issue-01 + +Test with:: + + make KBUILD_KCONFIG=Documentation/kbuild/Kconfig.recursion-issue-01 allnoconfig + +Cumulative Kconfig recursive issue +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Read: Documentation/kbuild/Kconfig.recursion-issue-02 + +Test with:: + + make KBUILD_KCONFIG=Documentation/kbuild/Kconfig.recursion-issue-02 allnoconfig + +Practical solutions to kconfig recursive issue +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Developers who run into the recursive Kconfig issue have two options +at their disposal. We document them below and also provide a list of +historical issues resolved through these different solutions. + + a) Remove any superfluous "select FOO" or "depends on FOO" + b) Match dependency semantics: + + b1) Swap all "select FOO" to "depends on FOO" or, + + b2) Swap all "depends on FOO" to "select FOO" + +The resolution to a) can be tested with the sample Kconfig file +Documentation/kbuild/Kconfig.recursion-issue-01 through the removal +of the "select CORE" from CORE_BELL_A_ADVANCED as that is implicit already +since CORE_BELL_A depends on CORE. At times it may not be possible to remove +some dependency criteria, for such cases you can work with solution b). + +The two different resolutions for b) can be tested in the sample Kconfig file +Documentation/kbuild/Kconfig.recursion-issue-02. + +Below is a list of examples of prior fixes for these types of recursive issues; +all errors appear to involve one or more select's and one or more "depends on". + +============ =================================== +commit fix +============ =================================== +06b718c01208 select A -> depends on A +c22eacfe82f9 depends on A -> depends on B +6a91e854442c select A -> depends on A +118c565a8f2e select A -> select B +f004e5594705 select A -> depends on A +c7861f37b4c6 depends on A -> (null) +80c69915e5fb select A -> (null) (1) +c2218e26c0d0 select A -> depends on A (1) +d6ae99d04e1c select A -> depends on A +95ca19cf8cbf select A -> depends on A +8f057d7bca54 depends on A -> (null) +8f057d7bca54 depends on A -> select A +a0701f04846e select A -> depends on A +0c8b92f7f259 depends on A -> (null) +e4e9e0540928 select A -> depends on A (2) +7453ea886e87 depends on A > (null) (1) +7b1fff7e4fdf select A -> depends on A +86c747d2a4f0 select A -> depends on A +d9f9ab51e55e select A -> depends on A +0c51a4d8abd6 depends on A -> select A (3) +e98062ed6dc4 select A -> depends on A (3) +91e5d284a7f1 select A -> (null) +============ =================================== + +(1) Partial (or no) quote of error. +(2) That seems to be the gist of that fix. +(3) Same error. + +Future kconfig work +~~~~~~~~~~~~~~~~~~~ + +Work on kconfig is welcomed on both areas of clarifying semantics and on +evaluating the use of a full SAT solver for it. A full SAT solver can be +desirable to enable more complex dependency mappings and / or queries, +for instance on possible use case for a SAT solver could be that of handling +the current known recursive dependency issues. It is not known if this would +address such issues but such evaluation is desirable. If support for a full SAT +solver proves too complex or that it cannot address recursive dependency issues +Kconfig should have at least clear and well defined semantics which also +addresses and documents limitations or requirements such as the ones dealing +with recursive dependencies. + +Further work on both of these areas is welcomed on Kconfig. We elaborate +on both of these in the next two subsections. + +Semantics of Kconfig +~~~~~~~~~~~~~~~~~~~~ + +The use of Kconfig is broad, Linux is now only one of Kconfig's users: +one study has completed a broad analysis of Kconfig use in 12 projects [0]_. +Despite its widespread use, and although this document does a reasonable job +in documenting basic Kconfig syntax a more precise definition of Kconfig +semantics is welcomed. One project deduced Kconfig semantics through +the use of the xconfig configurator [1]_. Work should be done to confirm if +the deduced semantics matches our intended Kconfig design goals. + +Having well defined semantics can be useful for tools for practical +evaluation of depenencies, for instance one such use known case was work to +express in boolean abstraction of the inferred semantics of Kconfig to +translate Kconfig logic into boolean formulas and run a SAT solver on this to +find dead code / features (always inactive), 114 dead features were found in +Linux using this methodology [1]_ (Section 8: Threats to validity). + +Confirming this could prove useful as Kconfig stands as one of the the leading +industrial variability modeling languages [1]_ [2]_. Its study would help +evaluate practical uses of such languages, their use was only theoretical +and real world requirements were not well understood. As it stands though +only reverse engineering techniques have been used to deduce semantics from +variability modeling languages such as Kconfig [3]_. + +.. [0] http://www.eng.uwaterloo.ca/~shshe/kconfig_semantics.pdf +.. [1] http://gsd.uwaterloo.ca/sites/default/files/vm-2013-berger.pdf +.. [2] http://gsd.uwaterloo.ca/sites/default/files/ase241-berger_0.pdf +.. [3] http://gsd.uwaterloo.ca/sites/default/files/icse2011.pdf + +Full SAT solver for Kconfig +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Although SAT solvers [4]_ haven't yet been used by Kconfig directly, as noted +in the previous subsection, work has been done however to express in boolean +abstraction the inferred semantics of Kconfig to translate Kconfig logic into +boolean formulas and run a SAT solver on it [5]_. Another known related project +is CADOS [6]_ (former VAMOS [7]_) and the tools, mainly undertaker [8]_, which +has been introduced first with [9]_. The basic concept of undertaker is to +exract variability models from Kconfig, and put them together with a +propositional formula extracted from CPP #ifdefs and build-rules into a SAT +solver in order to find dead code, dead files, and dead symbols. If using a SAT +solver is desirable on Kconfig one approach would be to evaluate repurposing +such efforts somehow on Kconfig. There is enough interest from mentors of +existing projects to not only help advise how to integrate this work upstream +but also help maintain it long term. Interested developers should visit: + +http://kernelnewbies.org/KernelProjects/kconfig-sat + +.. [4] http://www.cs.cornell.edu/~sabhar/chapters/SATSolvers-KR-Handbook.pdf +.. [5] http://gsd.uwaterloo.ca/sites/default/files/vm-2013-berger.pdf +.. [6] https://cados.cs.fau.de +.. [7] https://vamos.cs.fau.de +.. [8] https://undertaker.cs.fau.de +.. [9] https://www4.cs.fau.de/Publications/2011/tartler_11_eurosys.pdf diff --git a/docs/misc/kconfig-language.txt b/docs/misc/kconfig-language.txt deleted file mode 100644 index 350f733bf2c7..000000000000 --- a/docs/misc/kconfig-language.txt +++ /dev/null @@ -1,395 +0,0 @@ -Introduction ------------- - -The configuration database is a collection of configuration options -organized in a tree structure: - - +- Code maturity level options - | +- Prompt for development and/or incomplete code/drivers - +- General setup - | +- Networking support - | +- System V IPC - | +- BSD Process Accounting - | +- Sysctl support - +- Loadable module support - | +- Enable loadable module support - | +- Set version information on all module symbols - | +- Kernel module loader - +- ... - -Every entry has its own dependencies. These dependencies are used -to determine the visibility of an entry. Any child entry is only -visible if its parent entry is also visible. - -Menu entries ------------- - -Most entries define a config option; all other entries help to organize -them. A single configuration option is defined like this: - -config MODVERSIONS - bool "Set version information on all module symbols" - depends on MODULES - help - Usually, modules have to be recompiled whenever you switch to a new - kernel. ... - -Every line starts with a key word and can be followed by multiple -arguments. "config" starts a new config entry. The following lines -define attributes for this config option. Attributes can be the type of -the config option, input prompt, dependencies, help text and default -values. A config option can be defined multiple times with the same -name, but every definition can have only a single input prompt and the -type must not conflict. - -Menu attributes ---------------- - -A menu entry can have a number of attributes. Not all of them are -applicable everywhere (see syntax). - -- type definition: "bool"/"tristate"/"string"/"hex"/"int" - Every config option must have a type. There are only two basic types: - tristate and string; the other types are based on these two. The type - definition optionally accepts an input prompt, so these two examples - are equivalent: - - bool "Networking support" - and - bool - prompt "Networking support" - -- input prompt: "prompt" ["if" ] - Every menu entry can have at most one prompt, which is used to display - to the user. Optionally dependencies only for this prompt can be added - with "if". - -- default value: "default" ["if" ] - A config option can have any number of default values. If multiple - default values are visible, only the first defined one is active. - Default values are not limited to the menu entry where they are - defined. This means the default can be defined somewhere else or be - overridden by an earlier definition. - The default value is only assigned to the config symbol if no other - value was set by the user (via the input prompt above). If an input - prompt is visible the default value is presented to the user and can - be overridden by him. - Optionally, dependencies only for this default value can be added with - "if". - -- type definition + default value: - "def_bool"/"def_tristate" ["if" ] - This is a shorthand notation for a type definition plus a value. - Optionally dependencies for this default value can be added with "if". - -- dependencies: "depends on" - This defines a dependency for this menu entry. If multiple - dependencies are defined, they are connected with '&&'. Dependencies - are applied to all other options within this menu entry (which also - accept an "if" expression), so these two examples are equivalent: - - bool "foo" if BAR - default y if BAR - and - depends on BAR - bool "foo" - default y - -- reverse dependencies: "select" ["if" ] - While normal dependencies reduce the upper limit of a symbol (see - below), reverse dependencies can be used to force a lower limit of - another symbol. The value of the current menu symbol is used as the - minimal value can be set to. If is selected multiple - times, the limit is set to the largest selection. - Reverse dependencies can only be used with boolean or tristate - symbols. - Note: - select should be used with care. select will force - a symbol to a value without visiting the dependencies. - By abusing select you are able to select a symbol FOO even - if FOO depends on BAR that is not set. - In general use select only for non-visible symbols - (no prompts anywhere) and for symbols with no dependencies. - That will limit the usefulness but on the other hand avoid - the illegal configurations all over. - -- limiting menu display: "visible if" - This attribute is only applicable to menu blocks, if the condition is - false, the menu block is not displayed to the user (the symbols - contained there can still be selected by other symbols, though). It is - similar to a conditional "prompt" attribute for individual menu - entries. Default value of "visible" is true. - -- numerical ranges: "range" ["if" ] - This allows to limit the range of possible input values for int - and hex symbols. The user can only input a value which is larger than - or equal to the first symbol and smaller than or equal to the second - symbol. - -- help text: "help" or "---help---" - This defines a help text. The end of the help text is determined by - the indentation level, this means it ends at the first line which has - a smaller indentation than the first line of the help text. - "---help---" and "help" do not differ in behaviour, "---help---" is - used to help visually separate configuration logic from help within - the file as an aid to developers. - -- misc options: "option" [=] - Various less common options can be defined via this option syntax, - which can modify the behaviour of the menu entry and its config - symbol. These options are currently possible: - - - "defconfig_list" - This declares a list of default entries which can be used when - looking for the default configuration (which is used when the main - .config doesn't exists yet.) - - - "modules" - This declares the symbol to be used as the MODULES symbol, which - enables the third modular state for all config symbols. - At most one symbol may have the "modules" option set. - - - "env"= - This imports the environment variable into Kconfig. It behaves like - a default, except that the value comes from the environment, this - also means that the behaviour when mixing it with normal defaults is - undefined at this point. The symbol is currently not exported back - to the build environment (if this is desired, it can be done via - another symbol). - - - "allnoconfig_y" - This declares the symbol as one that should have the value y when - using "allnoconfig". Used for symbols that hide other symbols. - -Menu dependencies ------------------ - -Dependencies define the visibility of a menu entry and can also reduce -the input range of tristate symbols. The tristate logic used in the -expressions uses one more state than normal boolean logic to express the -module state. Dependency expressions have the following syntax: - - ::= (1) - '=' (2) - '!=' (3) - '(' ')' (4) - '!' (5) - '&&' (6) - '||' (7) - -Expressions are listed in decreasing order of precedence. - -(1) Convert the symbol into an expression. Boolean and tristate symbols - are simply converted into the respective expression values. All - other symbol types result in 'n'. -(2) If the values of both symbols are equal, it returns 'y', - otherwise 'n'. -(3) If the values of both symbols are equal, it returns 'n', - otherwise 'y'. -(4) Returns the value of the expression. Used to override precedence. -(5) Returns the result of (2-/expr/). -(6) Returns the result of min(/expr/, /expr/). -(7) Returns the result of max(/expr/, /expr/). - -An expression can have a value of 'n', 'm' or 'y' (or 0, 1, 2 -respectively for calculations). A menu entry becomes visible when its -expression evaluates to 'm' or 'y'. - -There are two types of symbols: constant and non-constant symbols. -Non-constant symbols are the most common ones and are defined with the -'config' statement. Non-constant symbols consist entirely of alphanumeric -characters or underscores. -Constant symbols are only part of expressions. Constant symbols are -always surrounded by single or double quotes. Within the quote, any -other character is allowed and the quotes can be escaped using '\'. - -Menu structure --------------- - -The position of a menu entry in the tree is determined in two ways. First -it can be specified explicitly: - -menu "Network device support" - depends on NET - -config NETDEVICES - ... - -endmenu - -All entries within the "menu" ... "endmenu" block become a submenu of -"Network device support". All subentries inherit the dependencies from -the menu entry, e.g. this means the dependency "NET" is added to the -dependency list of the config option NETDEVICES. - -The other way to generate the menu structure is done by analyzing the -dependencies. If a menu entry somehow depends on the previous entry, it -can be made a submenu of it. First, the previous (parent) symbol must -be part of the dependency list and then one of these two conditions -must be true: -- the child entry must become invisible, if the parent is set to 'n' -- the child entry must only be visible, if the parent is visible - -config MODULES - bool "Enable loadable module support" - -config MODVERSIONS - bool "Set version information on all module symbols" - depends on MODULES - -comment "module support disabled" - depends on !MODULES - -MODVERSIONS directly depends on MODULES, this means it's only visible if -MODULES is different from 'n'. The comment on the other hand is always -visible when MODULES is visible (the (empty) dependency of MODULES is -also part of the comment dependencies). - - -Kconfig syntax --------------- - -The configuration file describes a series of menu entries, where every -line starts with a keyword (except help texts). The following keywords -end a menu entry: -- config -- menuconfig -- choice/endchoice -- comment -- menu/endmenu -- if/endif -- source -The first five also start the definition of a menu entry. - -config: - - "config" - - -This defines a config symbol and accepts any of above -attributes as options. - -menuconfig: - "menuconfig" - - -This is similar to the simple config entry above, but it also gives a -hint to front ends, that all suboptions should be displayed as a -separate list of options. - -choices: - - "choice" [symbol] - - - "endchoice" - -This defines a choice group and accepts any of the above attributes as -options. A choice can only be of type bool or tristate, while a boolean -choice only allows a single config entry to be selected, a tristate -choice also allows any number of config entries to be set to 'm'. This -can be used if multiple drivers for a single hardware exists and only a -single driver can be compiled/loaded into the kernel, but all drivers -can be compiled as modules. -A choice accepts another option "optional", which allows to set the -choice to 'n' and no entry needs to be selected. -If no [symbol] is associated with a choice, then you can not have multiple -definitions of that choice. If a [symbol] is associated to the choice, -then you may define the same choice (ie. with the same entries) in another -place. - -comment: - - "comment" - - -This defines a comment which is displayed to the user during the -configuration process and is also echoed to the output files. The only -possible options are dependencies. - -menu: - - "menu" - - - "endmenu" - -This defines a menu block, see "Menu structure" above for more -information. The only possible options are dependencies and "visible" -attributes. - -if: - - "if" - - "endif" - -This defines an if block. The dependency expression is appended -to all enclosed menu entries. - -source: - - "source" - -This reads the specified configuration file. This file is always parsed. - -mainmenu: - - "mainmenu" - -This sets the config program's title bar if the config program chooses -to use it. It should be placed at the top of the configuration, before any -other statement. - - -Kconfig hints -------------- -This is a collection of Kconfig tips, most of which aren't obvious at -first glance and most of which have become idioms in several Kconfig -files. - -Adding common features and make the usage configurable -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -It is a common idiom to implement a feature/functionality that are -relevant for some architectures but not all. -The recommended way to do so is to use a config variable named HAVE_* -that is defined in a common Kconfig file and selected by the relevant -architectures. -An example is the generic IOMAP functionality. - -We would in lib/Kconfig see: - -# Generic IOMAP is used to ... -config HAVE_GENERIC_IOMAP - -config GENERIC_IOMAP - depends on HAVE_GENERIC_IOMAP && FOO - -And in lib/Makefile we would see: -obj-$(CONFIG_GENERIC_IOMAP) += iomap.o - -For each architecture using the generic IOMAP functionality we would see: - -config X86 - select ... - select HAVE_GENERIC_IOMAP - select ... - -Note: we use the existing config option and avoid creating a new -config variable to select HAVE_GENERIC_IOMAP. - -Note: the use of the internal config variable HAVE_GENERIC_IOMAP, it is -introduced to overcome the limitation of select which will force a -config option to 'y' no matter the dependencies. -The dependencies are moved to the symbol GENERIC_IOMAP and we avoid the -situation where select forces a symbol equals to 'y'. - -Build as module only -~~~~~~~~~~~~~~~~~~~~ -To restrict a component build to module-only, qualify its config symbol -with "depends on m". E.g.: - -config FOO - depends on BAR && m - -limits FOO to module (=m) or disabled (=n). diff --git a/docs/misc/kconfig-macro-language.rst b/docs/misc/kconfig-macro-language.rst new file mode 100644 index 000000000000..35b3263b7e40 --- /dev/null +++ b/docs/misc/kconfig-macro-language.rst @@ -0,0 +1,247 @@ +====================== +Kconfig macro language +====================== + +Concept +------- + +The basic idea was inspired by Make. When we look at Make, we notice sort of +two languages in one. One language describes dependency graphs consisting of +targets and prerequisites. The other is a macro language for performing textual +substitution. + +There is clear distinction between the two language stages. For example, you +can write a makefile like follows:: + + APP := foo + SRC := foo.c + CC := gcc + + $(APP): $(SRC) + $(CC) -o $(APP) $(SRC) + +The macro language replaces the variable references with their expanded form, +and handles as if the source file were input like follows:: + + foo: foo.c + gcc -o foo foo.c + +Then, Make analyzes the dependency graph and determines the targets to be +updated. + +The idea is quite similar in Kconfig - it is possible to describe a Kconfig +file like this:: + + CC := gcc + + config CC_HAS_FOO + def_bool $(shell, $(srctree)/scripts/gcc-check-foo.sh $(CC)) + +The macro language in Kconfig processes the source file into the following +intermediate:: + + config CC_HAS_FOO + def_bool y + +Then, Kconfig moves onto the evaluation stage to resolve inter-symbol +dependency as explained in kconfig-language.txt. + + +Variables +--------- + +Like in Make, a variable in Kconfig works as a macro variable. A macro +variable is expanded "in place" to yield a text string that may then be +expanded further. To get the value of a variable, enclose the variable name in +$( ). The parentheses are required even for single-letter variable names; $X is +a syntax error. The curly brace form as in ${CC} is not supported either. + +There are two types of variables: simply expanded variables and recursively +expanded variables. + +A simply expanded variable is defined using the := assignment operator. Its +righthand side is expanded immediately upon reading the line from the Kconfig +file. + +A recursively expanded variable is defined using the = assignment operator. +Its righthand side is simply stored as the value of the variable without +expanding it in any way. Instead, the expansion is performed when the variable +is used. + +There is another type of assignment operator; += is used to append text to a +variable. The righthand side of += is expanded immediately if the lefthand +side was originally defined as a simple variable. Otherwise, its evaluation is +deferred. + +The variable reference can take parameters, in the following form:: + + $(name,arg1,arg2,arg3) + +You can consider the parameterized reference as a function. (more precisely, +"user-defined function" in contrast to "built-in function" listed below). + +Useful functions must be expanded when they are used since the same function is +expanded differently if different parameters are passed. Hence, a user-defined +function is defined using the = assignment operator. The parameters are +referenced within the body definition with $(1), $(2), etc. + +In fact, recursively expanded variables and user-defined functions are the same +internally. (In other words, "variable" is "function with zero argument".) +When we say "variable" in a broad sense, it includes "user-defined function". + + +Built-in functions +------------------ + +Like Make, Kconfig provides several built-in functions. Every function takes a +particular number of arguments. + +In Make, every built-in function takes at least one argument. Kconfig allows +zero argument for built-in functions, such as $(fileno), $(lineno). You could +consider those as "built-in variable", but it is just a matter of how we call +it after all. Let's say "built-in function" here to refer to natively supported +functionality. + +Kconfig currently supports the following built-in functions. + + - $(shell,command) + + The "shell" function accepts a single argument that is expanded and passed + to a subshell for execution. The standard output of the command is then read + and returned as the value of the function. Every newline in the output is + replaced with a space. Any trailing newlines are deleted. The standard error + is not returned, nor is any program exit status. + + - $(info,text) + + The "info" function takes a single argument and prints it to stdout. + It evaluates to an empty string. + + - $(warning-if,condition,text) + + The "warning-if" function takes two arguments. If the condition part is "y", + the text part is sent to stderr. The text is prefixed with the name of the + current Kconfig file and the current line number. + + - $(error-if,condition,text) + + The "error-if" function is similar to "warning-if", but it terminates the + parsing immediately if the condition part is "y". + + - $(filename) + + The 'filename' takes no argument, and $(filename) is expanded to the file + name being parsed. + + - $(lineno) + + The 'lineno' takes no argument, and $(lineno) is expanded to the line number + being parsed. + + +Make vs Kconfig +--------------- + +Kconfig adopts Make-like macro language, but the function call syntax is +slightly different. + +A function call in Make looks like this:: + + $(func-name arg1,arg2,arg3) + +The function name and the first argument are separated by at least one +whitespace. Then, leading whitespaces are trimmed from the first argument, +while whitespaces in the other arguments are kept. You need to use a kind of +trick to start the first parameter with spaces. For example, if you want +to make "info" function print " hello", you can write like follows:: + + empty := + space := $(empty) $(empty) + $(info $(space)$(space)hello) + +Kconfig uses only commas for delimiters, and keeps all whitespaces in the +function call. Some people prefer putting a space after each comma delimiter:: + + $(func-name, arg1, arg2, arg3) + +In this case, "func-name" will receive " arg1", " arg2", " arg3". The presence +of leading spaces may matter depending on the function. The same applies to +Make - for example, $(subst .c, .o, $(sources)) is a typical mistake; it +replaces ".c" with " .o". + +In Make, a user-defined function is referenced by using a built-in function, +'call', like this:: + + $(call my-func,arg1,arg2,arg3) + +Kconfig invokes user-defined functions and built-in functions in the same way. +The omission of 'call' makes the syntax shorter. + +In Make, some functions treat commas verbatim instead of argument separators. +For example, $(shell echo hello, world) runs the command "echo hello, world". +Likewise, $(info hello, world) prints "hello, world" to stdout. You could say +this is _useful_ inconsistency. + +In Kconfig, for simpler implementation and grammatical consistency, commas that +appear in the $( ) context are always delimiters. It means:: + + $(shell, echo hello, world) + +is an error because it is passing two parameters where the 'shell' function +accepts only one. To pass commas in arguments, you can use the following trick:: + + comma := , + $(shell, echo hello$(comma) world) + + +Caveats +------- + +A variable (or function) cannot be expanded across tokens. So, you cannot use +a variable as a shorthand for an expression that consists of multiple tokens. +The following works:: + + RANGE_MIN := 1 + RANGE_MAX := 3 + + config FOO + int "foo" + range $(RANGE_MIN) $(RANGE_MAX) + +But, the following does not work:: + + RANGES := 1 3 + + config FOO + int "foo" + range $(RANGES) + +A variable cannot be expanded to any keyword in Kconfig. The following does +not work:: + + MY_TYPE := tristate + + config FOO + $(MY_TYPE) "foo" + default y + +Obviously from the design, $(shell command) is expanded in the textual +substitution phase. You cannot pass symbols to the 'shell' function. + +The following does not work as expected:: + + config ENDIAN_FLAG + string + default "-mbig-endian" if CPU_BIG_ENDIAN + default "-mlittle-endian" if CPU_LITTLE_ENDIAN + + config CC_HAS_ENDIAN_FLAG + def_bool $(shell $(srctree)/scripts/gcc-check-flag ENDIAN_FLAG) + +Instead, you can do like follows so that any function call is statically +expanded:: + + config CC_HAS_ENDIAN_FLAG + bool + default $(shell $(srctree)/scripts/gcc-check-flag -mbig-endian) if CPU_BIG_ENDIAN + default $(shell $(srctree)/scripts/gcc-check-flag -mlittle-endian) if CPU_LITTLE_ENDIAN diff --git a/docs/misc/kconfig.txt b/docs/misc/kconfig.rst similarity index 70% rename from docs/misc/kconfig.txt rename to docs/misc/kconfig.rst index bbc99c0c1094..a9a855f894b3 100644 --- a/docs/misc/kconfig.txt +++ b/docs/misc/kconfig.rst @@ -1,14 +1,17 @@ -This file contains some assistance for using "make *config". +=================== +Kconfig make config +=================== + +This file contains some assistance for using `make *config`. Use "make help" to list all of the possible configuration targets. -The xconfig ('qconf') and menuconfig ('mconf') programs also -have embedded help text. Be sure to check it for navigation, -search, and other general help text. +The xconfig ('qconf'), menuconfig ('mconf'), and nconfig ('nconf') +programs also have embedded help text. Be sure to check that for +navigation, search, and other general help text. -====================================================================== General --------------------------------------------------- +------- New kernel releases often introduce new config symbols. Often more important, new kernel releases may rename config symbols. When @@ -17,48 +20,55 @@ this happens, using a previously working .config file and running for you, so you may find that you need to see what NEW kernel symbols have been introduced. -To see a list of new config symbols when using "make oldconfig", use +To see a list of new config symbols, use:: cp user/some/old.config .config make listnewconfig and the config program will list any new symbols, one per line. +Alternatively, you can use the brute force method:: + + make oldconfig scripts/diffconfig .config.old .config | less -______________________________________________________________________ -Environment variables for '*config' +---------------------------------------------------------------------- + +Environment variables for `*config` KCONFIG_CONFIG --------------------------------------------------- +-------------- This environment variable can be used to specify a default kernel config file name to override the default name of ".config". KCONFIG_OVERWRITECONFIG --------------------------------------------------- +----------------------- If you set KCONFIG_OVERWRITECONFIG in the environment, Kconfig will not break symlinks when .config is a symlink to somewhere else. -CONFIG_ --------------------------------------------------- -If you set CONFIG_ in the environment, Kconfig will prefix all symbols +`CONFIG_` +--------- +If you set `CONFIG_` in the environment, Kconfig will prefix all symbols with its value when saving the configuration, instead of using the default, -"CONFIG_". +`CONFIG_`. + +---------------------------------------------------------------------- -______________________________________________________________________ Environment variables for '{allyes/allmod/allno/rand}config' KCONFIG_ALLCONFIG --------------------------------------------------- +----------------- (partially based on lkml email from/by Rob Landley, re: miniconfig) + -------------------------------------------------- + The allyesconfig/allmodconfig/allnoconfig/randconfig variants can also use the environment variable KCONFIG_ALLCONFIG as a flag or a filename that contains config symbols that the user requires to be set to a specific value. If KCONFIG_ALLCONFIG is used without a filename where -KCONFIG_ALLCONFIG == "" or KCONFIG_ALLCONFIG == "1", "make *config" +KCONFIG_ALLCONFIG == "" or KCONFIG_ALLCONFIG == "1", `make *config` checks for a file named "all{yes/mod/no/def/random}.config" -(corresponding to the *config command that was used) for symbol values +(corresponding to the `*config` command that was used) for symbol values that are to be forced. If this file is not found, it checks for a file named "all.config" to contain forced values. @@ -71,43 +81,55 @@ This 'KCONFIG_ALLCONFIG' file is a config file which contains (usually a subset of all) preset config symbols. These variable settings are still subject to normal dependency checks. -Examples: +Examples:: + KCONFIG_ALLCONFIG=custom-notebook.config make allnoconfig -or + +or:: + KCONFIG_ALLCONFIG=mini.config make allnoconfig -or + +or:: + make KCONFIG_ALLCONFIG=mini.config allnoconfig These examples will disable most options (allnoconfig) but enable or disable the options that are explicitly listed in the specified mini-config files. -______________________________________________________________________ +---------------------------------------------------------------------- + Environment variables for 'randconfig' KCONFIG_SEED --------------------------------------------------- +------------ You can set this to the integer value used to seed the RNG, if you want to somehow debug the behaviour of the kconfig parser/frontends. If not set, the current time will be used. KCONFIG_PROBABILITY --------------------------------------------------- +------------------- This variable can be used to skew the probabilities. This variable can be unset or empty, or set to three different formats: + + ======================= ================== ===================== KCONFIG_PROBABILITY y:n split y:m:n split - ----------------------------------------------------------------- + ======================= ================== ===================== unset or empty 50 : 50 33 : 33 : 34 N N : 100-N N/2 : N/2 : 100-N [1] N:M N+M : 100-(N+M) N : M : 100-(N+M) [2] N:M:L N : 100-N M : L : 100-(M+L) + ======================= ================== ===================== where N, M and L are integers (in base 10) in the range [0,100], and so that: + [1] N+M is in the range [0,100] + [2] M+L is in the range [0,100] -Examples: +Examples:: + KCONFIG_PROBABILITY=10 10% of booleans will be set to 'y', 90% to 'n' 5% of tristates will be set to 'y', 5% to 'm', 90% to 'n' @@ -118,34 +140,36 @@ Examples: 10% of booleans will be set to 'y', 90% to 'n' 15% of tristates will be set to 'y', 15% to 'm', 70% to 'n' -______________________________________________________________________ -Environment variables for 'silentoldconfig' +---------------------------------------------------------------------- + +Environment variables for 'syncconfig' KCONFIG_NOSILENTUPDATE --------------------------------------------------- +---------------------- If this variable has a non-blank value, it prevents silent kernel config updates (requires explicit updates). KCONFIG_AUTOCONFIG --------------------------------------------------- +------------------ This environment variable can be set to specify the path & name of the "auto.conf" file. Its default value is "include/config/auto.conf". KCONFIG_TRISTATE --------------------------------------------------- +---------------- This environment variable can be set to specify the path & name of the "tristate.conf" file. Its default value is "include/config/tristate.conf". KCONFIG_AUTOHEADER --------------------------------------------------- +------------------ This environment variable can be set to specify the path & name of the "autoconf.h" (header) file. Its default value is "include/generated/autoconf.h". -====================================================================== +---------------------------------------------------------------------- + menuconfig --------------------------------------------------- +---------- SEARCHING for CONFIG symbols @@ -155,56 +179,98 @@ Searching in menuconfig: names, so you have to know something close to what you are looking for. - Example: + Example:: + /hotplug This lists all config symbols that contain "hotplug", e.g., HOTPLUG_CPU, MEMORY_HOTPLUG. - For search help, enter / followed TAB-TAB-TAB (to highlight + For search help, enter / followed by TAB-TAB (to highlight ) and Enter. This will tell you that you can also use regular expressions (regexes) in the search string, so if you - are not interested in MEMORY_HOTPLUG, you could try + are not interested in MEMORY_HOTPLUG, you could try:: /^hotplug When searching, symbols are sorted thus: + - first, exact matches, sorted alphabetically (an exact match is when the search matches the complete symbol name); - then, other matches, sorted alphabetically. + For example: ^ATH.K matches: + ATH5K ATH9K ATH5K_AHB ATH5K_DEBUG [...] ATH6KL ATH6KL_DEBUG [...] ATH9K_AHB ATH9K_BTCOEX_SUPPORT ATH9K_COMMON [...] + of which only ATH5K and ATH9K match exactly and so are sorted first (and in alphabetical order), then come all other symbols, sorted in alphabetical order. -______________________________________________________________________ +---------------------------------------------------------------------- + User interface options for 'menuconfig' MENUCONFIG_COLOR --------------------------------------------------- +---------------- It is possible to select different color themes using the variable -MENUCONFIG_COLOR. To select a theme use: +MENUCONFIG_COLOR. To select a theme use:: make MENUCONFIG_COLOR= menuconfig -Available themes are: - mono => selects colors suitable for monochrome displays - blackbg => selects a color scheme with black background - classic => theme with blue background. The classic look - bluetitle => a LCD friendly version of classic. (default) +Available themes are:: + + - mono => selects colors suitable for monochrome displays + - blackbg => selects a color scheme with black background + - classic => theme with blue background. The classic look + - bluetitle => a LCD friendly version of classic. (default) MENUCONFIG_MODE --------------------------------------------------- +--------------- This mode shows all sub-menus in one large tree. -Example: +Example:: + make MENUCONFIG_MODE=single_menu menuconfig +---------------------------------------------------------------------- + +nconfig +------- + +nconfig is an alternate text-based configurator. It lists function +keys across the bottom of the terminal (window) that execute commands. +You can also just use the corresponding numeric key to execute the +commands unless you are in a data entry window. E.g., instead of F6 +for Save, you can just press 6. + +Use F1 for Global help or F3 for the Short help menu. + +Searching in nconfig: + + You can search either in the menu entry "prompt" strings + or in the configuration symbols. + + Use / to begin a search through the menu entries. This does + not support regular expressions. Use or for + Next hit and Previous hit, respectively. Use to + terminate the search mode. + + F8 (SymSearch) searches the configuration symbols for the + given string or regular expression (regex). + +NCONFIG_MODE +------------ +This mode shows all sub-menus in one large tree. + +Example:: + + make NCONFIG_MODE=single_menu nconfig + +---------------------------------------------------------------------- -====================================================================== xconfig --------------------------------------------------- +------- Searching in xconfig: @@ -212,9 +278,12 @@ Searching in xconfig: names, so you have to know something close to what you are looking for. - Example: + Example:: + Ctrl-F hotplug - or + + or:: + Menu: File, Search, hotplug lists all config symbol entries that contain "hotplug" in @@ -224,14 +293,12 @@ Searching in xconfig: to return to the main menu. -====================================================================== +---------------------------------------------------------------------- + gconfig --------------------------------------------------- +------- Searching in gconfig: - None (gconfig isn't maintained as well as xconfig or menuconfig); - however, gconfig does have a few more viewing choices than - xconfig does. - -### + There is no search command in gconfig. However, gconfig does + have several different viewing choices, modes, and options. diff --git a/xen/.gitignore b/xen/.gitignore new file mode 100644 index 000000000000..9fef41a09b47 --- /dev/null +++ b/xen/.gitignore @@ -0,0 +1,2 @@ +*.lex.c +*.tab.[ch] diff --git a/xen/Kconfig b/xen/Kconfig index 4a207e4553aa..01067326b4e7 100644 --- a/xen/Kconfig +++ b/xen/Kconfig @@ -2,24 +2,12 @@ # For a description of the syntax of this configuration file, # see docs/misc/kconfig-language.txt # -mainmenu "Xen/$SRCARCH $XEN_FULLVERSION Configuration" - -config SRCARCH - string - option env="SRCARCH" - -config ARCH - string - option env="ARCH" +mainmenu "Xen/$(SRCARCH) $(XEN_FULLVERSION) Configuration" config BROKEN bool -source "arch/$SRCARCH/Kconfig" - -config XEN_FULLVERSION - string - option env="XEN_FULLVERSION" +source "arch/$(SRCARCH)/Kconfig" config DEFCONFIG_LIST string @@ -28,7 +16,7 @@ config DEFCONFIG_LIST config EXPERT string - option env="XEN_CONFIG_EXPERT" + default y if "$(XEN_CONFIG_EXPERT)" = "y" config LTO bool "Link Time Optimisation" diff --git a/xen/Makefile b/xen/Makefile index 805543790bc3..b1b60e679082 100644 --- a/xen/Makefile +++ b/xen/Makefile @@ -262,7 +262,7 @@ $(foreach base,arch/x86/mm/guest_walk_% \ arch/x86/mm/shadow/guest_%, \ $(foreach ext,o i s,$(call build-intermediate,$(base).$(ext)))) -kconfig := silentoldconfig oldconfig config menuconfig defconfig \ +kconfig := oldconfig config menuconfig defconfig \ nconfig xconfig gconfig savedefconfig listnewconfig olddefconfig \ randconfig $(notdir $(wildcard arch/$(SRCARCH)/configs/*_defconfig)) .PHONY: $(kconfig) @@ -270,7 +270,7 @@ $(kconfig): $(MAKE) -f $(BASEDIR)/tools/kconfig/Makefile.kconfig ARCH=$(ARCH) SRCARCH=$(SRCARCH) HOSTCC="$(HOSTCC)" HOSTCXX="$(HOSTCXX)" $@ include/config/%.conf: include/config/auto.conf.cmd $(KCONFIG_CONFIG) - $(MAKE) -f $(BASEDIR)/tools/kconfig/Makefile.kconfig ARCH=$(ARCH) SRCARCH=$(SRCARCH) HOSTCC="$(HOSTCC)" HOSTCXX="$(HOSTCXX)" silentoldconfig + $(MAKE) -f $(BASEDIR)/tools/kconfig/Makefile.kconfig ARCH=$(ARCH) SRCARCH=$(SRCARCH) HOSTCC="$(HOSTCC)" HOSTCXX="$(HOSTCXX)" syncconfig # Allow people to just run `make` as before and not force them to configure $(KCONFIG_CONFIG): diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig index a51aa7bfa8fc..d51f66072e2e 100644 --- a/xen/arch/arm/Kconfig +++ b/xen/arch/arm/Kconfig @@ -1,6 +1,6 @@ config 64BIT bool - default ARCH != "arm32" + default "$(ARCH)" != "arm32" help Say yes to build a 64-bit Xen Say no to build a 32-bit Xen diff --git a/xen/common/Kconfig b/xen/common/Kconfig index 5c0f8d30c709..8c95d25a9e09 100644 --- a/xen/common/Kconfig +++ b/xen/common/Kconfig @@ -72,14 +72,6 @@ config NEEDS_LIBELF config NEEDS_LIST_SORT bool -config HAS_BUILD_ID - string - option env="XEN_HAS_BUILD_ID" - -config HAS_CHECKPOLICY - string - option env="XEN_HAS_CHECKPOLICY" - menu "Speculative hardening" config SPECULATIVE_HARDEN_ARRAY @@ -165,7 +157,7 @@ config XSM_FLASK_AVC_STATS config XSM_FLASK_POLICY bool "Compile Xen with a built-in FLASK security policy" - default y if HAS_CHECKPOLICY = "y" + default y if "$(XEN_HAS_CHECKPOLICY)" = "y" depends on XSM_FLASK ---help--- This includes a default XSM policy in the hypervisor so that the @@ -317,7 +309,7 @@ config CRYPTO config LIVEPATCH bool "Live patching support" default X86 - depends on HAS_BUILD_ID = "y" + depends on "$(XEN_HAS_BUILD_ID)" = "y" ---help--- Allows a running Xen hypervisor to be dynamically patched using binary patches without rebooting. This is primarily used to binarily diff --git a/xen/tools/kconfig/.gitignore b/xen/tools/kconfig/.gitignore index ca38e983d698..b5bf92f66d11 100644 --- a/xen/tools/kconfig/.gitignore +++ b/xen/tools/kconfig/.gitignore @@ -1,12 +1,8 @@ # # Generated files # -config* -*.lex.c -*.tab.c -*.tab.h -zconf.hash.c *.moc +*conf-cfg # # configuration programs diff --git a/xen/tools/kconfig/Makefile b/xen/tools/kconfig/Makefile index c8ad69501c06..7656e1137b6b 100644 --- a/xen/tools/kconfig/Makefile +++ b/xen/tools/kconfig/Makefile @@ -1,9 +1,10 @@ +# SPDX-License-Identifier: GPL-2.0 # =========================================================================== # Kernel configuration targets # These targets are used from top-level makefile -PHONY += xconfig gconfig menuconfig config silentoldconfig \ - localmodconfig localyesconfig +PHONY += xconfig gconfig menuconfig config localmodconfig localyesconfig \ + build_menuconfig build_nconfig build_gconfig build_xconfig ifdef KBUILD_KCONFIG Kconfig := $(KBUILD_KCONFIG) @@ -11,6 +12,10 @@ else Kconfig := Kconfig endif +ifndef KBUILD_DEFCONFIG +KBUILD_DEFCONFIG := defconfig +endif + ifeq ($(quiet),silent_) silent := -s endif @@ -33,49 +38,52 @@ config: $(obj)/conf nconfig: $(obj)/nconf $< $(silent) $(Kconfig) -silentoldconfig: $(obj)/conf - $(Q)mkdir -p include/config include/generated - $< $(silent) --$@ $(Kconfig) +build_menuconfig: $(obj)/mconf + +build_nconfig: $(obj)/nconf -localyesconfig localmodconfig: $(obj)/streamline_config.pl $(obj)/conf - $(Q)mkdir -p include/config include/generated - $(Q)perl $< --$@ $(srctree) $(Kconfig) > .tmp.config +build_gconfig: $(obj)/gconf + +build_xconfig: $(obj)/qconf + +localyesconfig localmodconfig: $(obj)/conf + $(Q)perl $(srctree)/$(src)/streamline_config.pl --$@ $(srctree) $(Kconfig) > .tmp.config $(Q)if [ -f .config ]; then \ cmp -s .tmp.config .config || \ (mv -f .config .config.old.1; \ mv -f .tmp.config .config; \ - $(obj)/conf $(silent) --silentoldconfig $(Kconfig); \ + $< $(silent) --oldconfig $(Kconfig); \ mv -f .config.old.1 .config.old) \ else \ mv -f .tmp.config .config; \ - $(obj)/conf $(silent) --silentoldconfig $(Kconfig); \ + $< $(silent) --oldconfig $(Kconfig); \ fi $(Q)rm -f .tmp.config # These targets map 1:1 to the commandline options of 'conf' +# +# Note: +# syncconfig has become an internal implementation detail and is now +# deprecated for external use simple-targets := oldconfig allnoconfig allyesconfig allmodconfig \ - alldefconfig randconfig listnewconfig olddefconfig + alldefconfig randconfig listnewconfig olddefconfig syncconfig PHONY += $(simple-targets) $(simple-targets): $(obj)/conf $< $(silent) --$@ $(Kconfig) -PHONY += oldnoconfig savedefconfig defconfig - -# oldnoconfig is an alias of olddefconfig, because people already are dependent -# on its behavior (sets new symbols to their default value but not 'n') with the -# counter-intuitive name. -oldnoconfig: olddefconfig +PHONY += savedefconfig defconfig savedefconfig: $(obj)/conf $< $(silent) --$@=defconfig $(Kconfig) defconfig: $(obj)/conf -ifeq ($(KBUILD_DEFCONFIG),) - $< $(silent) --defconfig $(Kconfig) -else +ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG)),) @$(kecho) "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'" $(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig) +else + @$(kecho) "*** Default configuration is based on target '$(KBUILD_DEFCONFIG)'" + $(Q)$(MAKE) -f $(srctree)/Makefile $(KBUILD_DEFCONFIG) endif %_defconfig: $(obj)/conf @@ -86,7 +94,7 @@ configfiles=$(wildcard $(srctree)/kernel/configs/$@ $(srctree)/arch/$(SRCARCH)/c %.config: $(obj)/conf $(if $(call configfiles),, $(error No configuration exists for this target on this architecture)) $(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh -m .config $(configfiles) - +$(Q)yes "" | $(MAKE) -f $(srctree)/Makefile oldconfig + $(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig PHONY += kvmconfig kvmconfig: kvm_guest.config @@ -100,18 +108,24 @@ PHONY += tinyconfig tinyconfig: $(Q)$(MAKE) -f $(srctree)/Makefile allnoconfig tiny.config +# CHECK: -o cache_dir= working? +PHONY += testconfig +testconfig: $(obj)/conf + $(PYTHON3) -B -m pytest $(srctree)/$(src)/tests \ + -o cache_dir=$(abspath $(obj)/tests/.cache) \ + $(if $(findstring 1,$(KBUILD_VERBOSE)),--capture=no) +clean-dirs += tests/.cache + # Help text used by make help help: @echo ' config - Update current config utilising a line-oriented program' - @echo ' nconfig - Update current config utilising a ncurses menu based' - @echo ' program' + @echo ' nconfig - Update current config utilising a ncurses menu based program' @echo ' menuconfig - Update current config utilising a menu based program' @echo ' xconfig - Update current config utilising a Qt based front-end' @echo ' gconfig - Update current config utilising a GTK+ based front-end' @echo ' oldconfig - Update current config utilising a provided .config as base' @echo ' localmodconfig - Update current config disabling modules not loaded' @echo ' localyesconfig - Update current config converting local mods to core' - @echo ' silentoldconfig - Same as oldconfig, but quietly, additionally update deps' @echo ' defconfig - New config with default from ARCH supplied defconfig' @echo ' savedefconfig - Save current config as ./defconfig (minimal config)' @echo ' allnoconfig - New config where all options are answered with no' @@ -120,165 +134,77 @@ help: @echo ' alldefconfig - New config with all symbols set to default' @echo ' randconfig - New config with random answer to all options' @echo ' listnewconfig - List new options' - @echo ' olddefconfig - Same as silentoldconfig but sets new symbols to their' - @echo ' default value' + @echo ' olddefconfig - Same as oldconfig but sets new symbols to their' + @echo ' default value without prompting' @echo ' kvmconfig - Enable additional options for kvm guest kernel support' @echo ' xenconfig - Enable additional options for xen dom0 and guest kernel support' @echo ' tinyconfig - Configure the tiniest possible kernel' - -# lxdialog stuff -check-lxdialog := $(srctree)/$(src)/lxdialog/check-lxdialog.sh - -# Use recursively expanded variables so we do not call gcc unless -# we really need to do so. (Do not call gcc as part of make mrproper) -HOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags) \ - -DLOCALE + @echo ' testconfig - Run Kconfig unit tests (requires python3 and pytest)' # =========================================================================== -# Shared Makefile for the various kconfig executables: -# conf: Used for defconfig, oldconfig and related targets -# nconf: Used for the nconfig target. -# Utilizes ncurses -# mconf: Used for the menuconfig target -# Utilizes the lxdialog package -# qconf: Used for the xconfig target -# Based on Qt which needs to be installed to compile it -# gconf: Used for the gconfig target -# Based on GTK+ which needs to be installed to compile it # object files used by all kconfig flavours +common-objs := confdata.o expr.o lexer.lex.o parser.tab.o preprocess.o \ + symbol.o -lxdialog := lxdialog/checklist.o lxdialog/util.o lxdialog/inputbox.o -lxdialog += lxdialog/textbox.o lxdialog/yesno.o lxdialog/menubox.o +$(obj)/lexer.lex.o: $(obj)/parser.tab.h +HOSTCFLAGS_lexer.lex.o := -I $(srctree)/$(src) +HOSTCFLAGS_parser.tab.o := -I $(srctree)/$(src) -conf-objs := conf.o zconf.tab.o -mconf-objs := mconf.o zconf.tab.o $(lxdialog) -nconf-objs := nconf.o zconf.tab.o nconf.gui.o -qconf-cxxobjs := qconf.o -qconf-objs := zconf.tab.o -gconf-objs := gconf.o zconf.tab.o - -hostprogs-y := conf nconf mconf qconf gconf - -clean-files := qconf.moc .tmp_qtcheck .tmp_gtkcheck -clean-files += zconf.tab.c zconf.lex.c zconf.hash.c - -# Check that we have the required ncurses stuff installed for lxdialog (menuconfig) -PHONY += $(obj)/dochecklxdialog -$(addprefix $(obj)/,$(lxdialog)): $(obj)/dochecklxdialog -$(obj)/dochecklxdialog: - $(Q)$(CONFIG_SHELL) $(check-lxdialog) -check $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTLOADLIBES_mconf) - -always := dochecklxdialog - -# generated files seem to need this to find local include files -HOSTCFLAGS_zconf.lex.o := -I$(src) -HOSTCFLAGS_zconf.tab.o := -I$(src) - -LEX_PREFIX_zconf := zconf -YACC_PREFIX_zconf := zconf - -HOSTLOADLIBES_qconf = $(KC_QT_LIBS) -HOSTCXXFLAGS_qconf.o = $(KC_QT_CFLAGS) - -HOSTLOADLIBES_gconf = `pkg-config --libs gtk+-2.0 gmodule-2.0 libglade-2.0` -HOSTCFLAGS_gconf.o = `pkg-config --cflags gtk+-2.0 gmodule-2.0 libglade-2.0` \ - -Wno-missing-prototypes - -HOSTLOADLIBES_mconf = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC)) - -HOSTLOADLIBES_nconf = $(shell \ - pkg-config --libs menuw panelw ncursesw 2>/dev/null \ - || pkg-config --libs menu panel ncurses 2>/dev/null \ - || echo "-lmenu -lpanel -lncurses" ) -$(obj)/qconf.o: $(obj)/.tmp_qtcheck - -ifeq ($(MAKECMDGOALS),xconfig) -$(obj)/.tmp_qtcheck: $(src)/Makefile --include $(obj)/.tmp_qtcheck - -# Qt needs some extra effort... -$(obj)/.tmp_qtcheck: - @set -e; $(kecho) " CHECK qt"; dir=""; pkg=""; \ - if ! pkg-config --exists QtCore 2> /dev/null; then \ - echo "* Unable to find the Qt4 tool qmake. Trying to use Qt3"; \ - pkg-config --exists qt 2> /dev/null && pkg=qt; \ - pkg-config --exists qt-mt 2> /dev/null && pkg=qt-mt; \ - if [ -n "$$pkg" ]; then \ - cflags="\$$(shell pkg-config $$pkg --cflags)"; \ - libs="\$$(shell pkg-config $$pkg --libs)"; \ - moc="\$$(shell pkg-config $$pkg --variable=prefix)/bin/moc"; \ - dir="$$(pkg-config $$pkg --variable=prefix)"; \ - else \ - for d in $$QTDIR /usr/share/qt* /usr/lib/qt*; do \ - if [ -f $$d/include/qconfig.h ]; then dir=$$d; break; fi; \ - done; \ - if [ -z "$$dir" ]; then \ - echo >&2 "*"; \ - echo >&2 "* Unable to find any Qt installation. Please make sure that"; \ - echo >&2 "* the Qt4 or Qt3 development package is correctly installed and"; \ - echo >&2 "* either qmake can be found or install pkg-config or set"; \ - echo >&2 "* the QTDIR environment variable to the correct location."; \ - echo >&2 "*"; \ - false; \ - fi; \ - libpath=$$dir/lib; lib=qt; osdir=""; \ - $(HOSTCXX) -print-multi-os-directory > /dev/null 2>&1 && \ - osdir=x$$($(HOSTCXX) -print-multi-os-directory); \ - test -d $$libpath/$$osdir && libpath=$$libpath/$$osdir; \ - test -f $$libpath/libqt-mt.so && lib=qt-mt; \ - cflags="-I$$dir/include"; \ - libs="-L$$libpath -Wl,-rpath,$$libpath -l$$lib"; \ - moc="$$dir/bin/moc"; \ - fi; \ - if [ ! -x $$dir/bin/moc -a -x /usr/bin/moc ]; then \ - echo "*"; \ - echo "* Unable to find $$dir/bin/moc, using /usr/bin/moc instead."; \ - echo "*"; \ - moc="/usr/bin/moc"; \ - fi; \ - else \ - cflags="\$$(shell pkg-config QtCore QtGui Qt3Support --cflags)"; \ - libs="\$$(shell pkg-config QtCore QtGui Qt3Support --libs)"; \ - moc="\$$(shell pkg-config QtCore --variable=moc_location)"; \ - [ -n "$$moc" ] || moc="\$$(shell pkg-config QtCore --variable=prefix)/bin/moc"; \ - fi; \ - echo "KC_QT_CFLAGS=$$cflags" > $@; \ - echo "KC_QT_LIBS=$$libs" >> $@; \ - echo "KC_QT_MOC=$$moc" >> $@ -endif +# conf: Used for defconfig, oldconfig and related targets +hostprogs-y += conf +conf-objs := conf.o $(common-objs) -$(obj)/gconf.o: $(obj)/.tmp_gtkcheck - -ifeq ($(MAKECMDGOALS),gconfig) --include $(obj)/.tmp_gtkcheck - -# GTK+ needs some extra effort, too... -$(obj)/.tmp_gtkcheck: - @if `pkg-config --exists gtk+-2.0 gmodule-2.0 libglade-2.0`; then \ - if `pkg-config --atleast-version=2.0.0 gtk+-2.0`; then \ - touch $@; \ - else \ - echo >&2 "*"; \ - echo >&2 "* GTK+ is present but version >= 2.0.0 is required."; \ - echo >&2 "*"; \ - false; \ - fi \ - else \ - echo >&2 "*"; \ - echo >&2 "* Unable to find the GTK+ installation. Please make sure that"; \ - echo >&2 "* the GTK+ 2.0 development package is correctly installed..."; \ - echo >&2 "* You need gtk+-2.0, glib-2.0 and libglade-2.0."; \ - echo >&2 "*"; \ - false; \ - fi -endif +# nconf: Used for the nconfig target based on ncurses +hostprogs-y += nconf +nconf-objs := nconf.o nconf.gui.o $(common-objs) + +HOSTLDLIBS_nconf = $(shell . $(obj)/nconf-cfg && echo $$libs) +HOSTCFLAGS_nconf.o = $(shell . $(obj)/nconf-cfg && echo $$cflags) +HOSTCFLAGS_nconf.gui.o = $(shell . $(obj)/nconf-cfg && echo $$cflags) + +$(obj)/nconf.o $(obj)/nconf.gui.o: $(obj)/nconf-cfg + +# mconf: Used for the menuconfig target based on lxdialog +hostprogs-y += mconf +lxdialog := checklist.o inputbox.o menubox.o textbox.o util.o yesno.o +mconf-objs := mconf.o $(addprefix lxdialog/, $(lxdialog)) $(common-objs) + +HOSTLDLIBS_mconf = $(shell . $(obj)/mconf-cfg && echo $$libs) +$(foreach f, mconf.o $(lxdialog), \ + $(eval HOSTCFLAGS_$f = $$(shell . $(obj)/mconf-cfg && echo $$$$cflags))) + +$(obj)/mconf.o: $(obj)/mconf-cfg +$(addprefix $(obj)/lxdialog/, $(lxdialog)): $(obj)/mconf-cfg + +# qconf: Used for the xconfig target based on Qt +hostprogs-y += qconf +qconf-cxxobjs := qconf.o +qconf-objs := images.o $(common-objs) -$(obj)/zconf.tab.o: $(obj)/zconf.lex.c $(obj)/zconf.hash.c +HOSTLDLIBS_qconf = $(shell . $(obj)/qconf-cfg && echo $$libs) +HOSTCXXFLAGS_qconf.o = $(shell . $(obj)/qconf-cfg && echo $$cflags) -$(obj)/qconf.o: $(obj)/qconf.moc +$(obj)/qconf.o: $(obj)/qconf-cfg $(obj)/qconf.moc quiet_cmd_moc = MOC $@ - cmd_moc = $(KC_QT_MOC) -i $< -o $@ + cmd_moc = $(shell . $(obj)/qconf-cfg && echo $$moc) -i $< -o $@ -$(obj)/%.moc: $(src)/%.h $(obj)/.tmp_qtcheck +$(obj)/%.moc: $(src)/%.h $(obj)/qconf-cfg $(call cmd,moc) + +# gconf: Used for the gconfig target based on GTK+ +hostprogs-y += gconf +gconf-objs := gconf.o images.o $(common-objs) + +HOSTLDLIBS_gconf = $(shell . $(obj)/gconf-cfg && echo $$libs) +HOSTCFLAGS_gconf.o = $(shell . $(obj)/gconf-cfg && echo $$cflags) + +$(obj)/gconf.o: $(obj)/gconf-cfg + +# check if necessary packages are available, and configure build flags +filechk_conf_cfg = $(CONFIG_SHELL) $< + +$(obj)/%conf-cfg: $(src)/%conf-cfg.sh FORCE + $(call filechk,conf_cfg) + +clean-files += *conf-cfg diff --git a/xen/tools/kconfig/Makefile.host b/xen/tools/kconfig/Makefile.host index 133edfae5b8a..2208ebbd8c4c 100644 --- a/xen/tools/kconfig/Makefile.host +++ b/xen/tools/kconfig/Makefile.host @@ -1,3 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0 # ========================================================================== # Building binaries on the host system # Binaries are used during the compilation of the kernel, for example @@ -5,7 +6,7 @@ # # Both C and C++ are supported, but preferred language is C for such utilities. # -# Sample syntax (see Documentation/kbuild/makefiles.txt for reference) +# Sample syntax (see Documentation/kbuild/makefiles.rst for reference) # hostprogs-y := bin2hex # Will compile bin2hex.c and create an executable named bin2hex # @@ -21,6 +22,8 @@ # They are linked as C++ code to the executable qconf __hostprogs := $(sort $(hostprogs-y) $(hostprogs-m)) +host-cshlib := $(sort $(hostlibs-y) $(hostlibs-m)) +host-cxxshlib := $(sort $(hostcxxlibs-y) $(hostcxxlibs-m)) # C code # Executables compiled from a single .c file @@ -42,42 +45,38 @@ host-cxxmulti := $(foreach m,$(__hostprogs),$(if $($(m)-cxxobjs),$(m))) # C++ Object (.o) files compiled from .cc files host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs))) -# output directory for programs/.o files -# hostprogs-y := tools/build may have been specified. -# Retrieve also directory of .o files from prog-objs or prog-cxxobjs notation -host-objdirs := $(dir $(__hostprogs) $(host-cobjs) $(host-cxxobjs)) +# Object (.o) files used by the shared libaries +host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs)))) +host-cxxshobjs := $(sort $(foreach m,$(host-cxxshlib),$($(m:.so=-objs)))) -host-objdirs := $(strip $(sort $(filter-out ./,$(host-objdirs)))) - - -__hostprogs := $(addprefix $(obj)/,$(__hostprogs)) host-csingle := $(addprefix $(obj)/,$(host-csingle)) host-cmulti := $(addprefix $(obj)/,$(host-cmulti)) host-cobjs := $(addprefix $(obj)/,$(host-cobjs)) host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti)) host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs)) -host-objdirs := $(addprefix $(obj)/,$(host-objdirs)) - -obj-dirs += $(host-objdirs) +host-cshlib := $(addprefix $(obj)/,$(host-cshlib)) +host-cxxshlib := $(addprefix $(obj)/,$(host-cxxshlib)) +host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs)) +host-cxxshobjs := $(addprefix $(obj)/,$(host-cxxshobjs)) ##### # Handle options to gcc. Support building with separate output directory -_hostc_flags = $(HOSTCFLAGS) $(HOST_EXTRACFLAGS) \ +_hostc_flags = $(KBUILD_HOSTCFLAGS) $(HOST_EXTRACFLAGS) \ $(HOSTCFLAGS_$(basetarget).o) -_hostcxx_flags = $(HOSTCXXFLAGS) $(HOST_EXTRACXXFLAGS) \ +_hostcxx_flags = $(KBUILD_HOSTCXXFLAGS) $(HOST_EXTRACXXFLAGS) \ $(HOSTCXXFLAGS_$(basetarget).o) -ifeq ($(KBUILD_SRC),) -__hostc_flags = $(_hostc_flags) -__hostcxx_flags = $(_hostcxx_flags) -else -__hostc_flags = -I$(obj) $(call flags,_hostc_flags) -__hostcxx_flags = -I$(obj) $(call flags,_hostcxx_flags) +# $(objtree)/$(obj) for including generated headers from checkin source files +ifeq ($(KBUILD_EXTMOD),) +ifdef building_out_of_srctree +_hostc_flags += -I $(objtree)/$(obj) +_hostcxx_flags += -I $(objtree)/$(obj) +endif endif -hostc_flags = -Wp,-MD,$(depfile) $(__hostc_flags) -hostcxx_flags = -Wp,-MD,$(depfile) $(__hostcxx_flags) +hostc_flags = -Wp,-MD,$(depfile) $(_hostc_flags) +hostcxx_flags = -Wp,-MD,$(depfile) $(_hostcxx_flags) ##### # Compile programs on the host @@ -85,17 +84,17 @@ hostcxx_flags = -Wp,-MD,$(depfile) $(__hostcxx_flags) # Create executable from a single .c file # host-csingle -> Executable quiet_cmd_host-csingle = HOSTCC $@ - cmd_host-csingle = $(HOSTCC) $(hostc_flags) -o $@ $< \ - $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F)) + cmd_host-csingle = $(HOSTCC) $(hostc_flags) $(KBUILD_HOSTLDFLAGS) -o $@ $< \ + $(KBUILD_HOSTLDLIBS) $(HOSTLDLIBS_$(@F)) $(host-csingle): $(obj)/%: $(src)/%.c FORCE $(call if_changed_dep,host-csingle) # Link an executable based on list of .o files, all plain c # host-cmulti -> executable quiet_cmd_host-cmulti = HOSTLD $@ - cmd_host-cmulti = $(HOSTCC) $(HOSTLDFLAGS) -o $@ \ + cmd_host-cmulti = $(HOSTCC) $(KBUILD_HOSTLDFLAGS) -o $@ \ $(addprefix $(obj)/,$($(@F)-objs)) \ - $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F)) + $(KBUILD_HOSTLDLIBS) $(HOSTLDLIBS_$(@F)) $(host-cmulti): FORCE $(call if_changed,host-cmulti) $(call multi_depend, $(host-cmulti), , -objs) @@ -110,10 +109,10 @@ $(host-cobjs): $(obj)/%.o: $(src)/%.c FORCE # Link an executable based on list of .o files, a mixture of .c and .cc # host-cxxmulti -> executable quiet_cmd_host-cxxmulti = HOSTLD $@ - cmd_host-cxxmulti = $(HOSTCXX) $(HOSTLDFLAGS) -o $@ \ + cmd_host-cxxmulti = $(HOSTCXX) $(KBUILD_HOSTLDFLAGS) -o $@ \ $(foreach o,objs cxxobjs,\ $(addprefix $(obj)/,$($(@F)-$(o)))) \ - $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F)) + $(KBUILD_HOSTLDLIBS) $(HOSTLDLIBS_$(@F)) $(host-cxxmulti): FORCE $(call if_changed,host-cxxmulti) $(call multi_depend, $(host-cxxmulti), , -objs -cxxobjs) @@ -124,5 +123,42 @@ quiet_cmd_host-cxxobjs = HOSTCXX $@ $(host-cxxobjs): $(obj)/%.o: $(src)/%.cc FORCE $(call if_changed_dep,host-cxxobjs) +# Compile .c file, create position independent .o file +# host-cshobjs -> .o +quiet_cmd_host-cshobjs = HOSTCC -fPIC $@ + cmd_host-cshobjs = $(HOSTCC) $(hostc_flags) -fPIC -c -o $@ $< +$(host-cshobjs): $(obj)/%.o: $(src)/%.c FORCE + $(call if_changed_dep,host-cshobjs) + +# Compile .c file, create position independent .o file +# Note that plugin capable gcc versions can be either C or C++ based +# therefore plugin source files have to be compilable in both C and C++ mode. +# This is why a C++ compiler is invoked on a .c file. +# host-cxxshobjs -> .o +quiet_cmd_host-cxxshobjs = HOSTCXX -fPIC $@ + cmd_host-cxxshobjs = $(HOSTCXX) $(hostcxx_flags) -fPIC -c -o $@ $< +$(host-cxxshobjs): $(obj)/%.o: $(src)/%.c FORCE + $(call if_changed_dep,host-cxxshobjs) + +# Link a shared library, based on position independent .o files +# *.o -> .so shared library (host-cshlib) +quiet_cmd_host-cshlib = HOSTLLD -shared $@ + cmd_host-cshlib = $(HOSTCC) $(KBUILD_HOSTLDFLAGS) -shared -o $@ \ + $(addprefix $(obj)/,$($(@F:.so=-objs))) \ + $(KBUILD_HOSTLDLIBS) $(HOSTLDLIBS_$(@F)) +$(host-cshlib): FORCE + $(call if_changed,host-cshlib) +$(call multi_depend, $(host-cshlib), .so, -objs) + +# Link a shared library, based on position independent .o files +# *.o -> .so shared library (host-cxxshlib) +quiet_cmd_host-cxxshlib = HOSTLLD -shared $@ + cmd_host-cxxshlib = $(HOSTCXX) $(KBUILD_HOSTLDFLAGS) -shared -o $@ \ + $(addprefix $(obj)/,$($(@F:.so=-objs))) \ + $(KBUILD_HOSTLDLIBS) $(HOSTLDLIBS_$(@F)) +$(host-cxxshlib): FORCE + $(call if_changed,host-cxxshlib) +$(call multi_depend, $(host-cxxshlib), .so, -objs) + targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\ - $(host-cxxmulti) $(host-cxxobjs) + $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs) $(host-cxxshlib) $(host-cxxshobjs) diff --git a/xen/tools/kconfig/Makefile.kconfig b/xen/tools/kconfig/Makefile.kconfig index dbd89120154d..6d2df760ff28 100644 --- a/xen/tools/kconfig/Makefile.kconfig +++ b/xen/tools/kconfig/Makefile.kconfig @@ -4,8 +4,8 @@ all: # Xen doesn't have a silent build flag -quiet := silent_ -Q := @ +quiet := +Q := kecho := : # eventually you'll want to do out of tree builds @@ -13,7 +13,6 @@ srctree := $(XEN_ROOT)/xen objtree := $(srctree) src := tools/kconfig obj := $(src) -KBUILD_SRC := # handle functions (most of these lifted from different Linux makefiles dot-target = $(dir $@).$(notdir $@) @@ -23,12 +22,61 @@ cmd = $(cmd_$(1)) if_changed = $(cmd_$(1)) if_changed_dep = $(cmd_$(1)) +### +# filechk is used to check if the content of a generated file is updated. +# Sample usage: +# +# filechk_sample = echo $(KERNELRELEASE) +# version.h: FORCE +# $(call filechk,sample) +# +# The rule defined shall write to stdout the content of the new file. +# The existing file will be compared with the new one. +# - If no file exist it is created +# - If the content differ the new file is used +# - If they are equal no change, and no timestamp update +# - stdin is piped in from the first prerequisite ($<) so one has +# to specify a valid file as first prerequisite (often the kbuild file) +define filechk + $(Q)set -e; \ + mkdir -p $(dir $@); \ + { $(filechk_$(1)); } > $@.tmp; \ + if [ -r $@ ] && cmp -s $@ $@.tmp; then \ + rm -f $@.tmp; \ + else \ + $(kecho) ' UPD $@'; \ + mv -f $@.tmp $@; \ + fi +endef + define multi_depend $(foreach m, $(notdir $1), \ $(eval $(obj)/$m: \ $(addprefix $(obj)/, $(foreach s, $3, $($(m:%$(strip $2)=%$(s))))))) endef +# LEX +# --------------------------------------------------------------------------- +quiet_cmd_flex = LEX $@ + cmd_flex = $(LEX) -o$@ -L $< + +$(obj)/%.lex.c: $(src)/%.l FORCE + $(call if_changed,flex) + +# YACC +# --------------------------------------------------------------------------- +quiet_cmd_bison = YACC $@ + cmd_bison = $(YACC) -o$@ -t -l $< + +$(obj)/%.tab.c: $(src)/%.y FORCE + $(call if_changed,bison) + +quiet_cmd_bison_h = YACC $@ + cmd_bison_h = $(YACC) -o/dev/null --defines=$@ -t -l $< + +$(obj)/%.tab.h: $(src)/%.y FORCE + $(call if_changed,bison_h) + # Set our default defconfig file KBUILD_DEFCONFIG := $(ARCH)_defconfig @@ -38,6 +86,8 @@ CONFIG_SHELL := $(SHELL) # provide the host compiler HOSTCC ?= gcc HOSTCXX ?= g++ +YACC = $(if $(BISON),$(BISON),bison) +LEX = $(if $(FLEX),$(FLEX),flex) # force target PHONY += FORCE @@ -48,6 +98,18 @@ FORCE: include $(src)/Makefile include $(src)/Makefile.host +# Add intermediate targets: +# When building objects with specific suffix patterns, add intermediate +# targets that the final targets are derived from. +intermediate_targets = $(foreach sfx, $(2), \ + $(patsubst %$(strip $(1)),%$(sfx), \ + $(filter %$(strip $(1)), $(targets)))) + +# %.lex.o <- %.lex.c <- %.l +# %.tab.o <- %.tab.[ch] <- %.y +targets += $(call intermediate_targets, .lex.o, .lex.c) \ + $(call intermediate_targets, .tab.o, .tab.c .tab.h) + # clean up rule clean-deps = $(foreach f,$(host-cobjs) $(host-cxxobjs),$(dir $f).$(notdir $f).d) clean-shipped = $(patsubst %_shipped,%,$(wildcard $(obj)/*_shipped)) @@ -59,4 +121,6 @@ clean: rm -rf $(clean-shipped) $(obj)/zconf%: $(src)/zconf%_shipped - @cp -f $< $@ + cp -f $< $@ + +.PHONY: $(PHONY) diff --git a/xen/tools/kconfig/conf.c b/xen/tools/kconfig/conf.c index d986f44098f9..40e16e871ae2 100644 --- a/xen/tools/kconfig/conf.c +++ b/xen/tools/kconfig/conf.c @@ -1,9 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) 2002 Roman Zippel - * Released under the terms of the GNU GPL v2.0. */ #include +#include #include #include #include @@ -18,11 +19,10 @@ static void conf(struct menu *menu); static void check_conf(struct menu *menu); -static void xfgets(char *str, int size, FILE *in); enum input_mode { oldaskconfig, - silentoldconfig, + syncconfig, oldconfig, allnoconfig, allyesconfig, @@ -33,14 +33,14 @@ enum input_mode { savedefconfig, listnewconfig, olddefconfig, -} input_mode = oldaskconfig; +}; +static enum input_mode input_mode = oldaskconfig; static int indent = 1; static int tty_stdio; -static int valid_stdin = 1; static int sync_kconfig; static int conf_cnt; -static char line[128]; +static char line[PATH_MAX]; static struct menu *rootEntry; static void print_help(struct menu *menu) @@ -70,14 +70,14 @@ static void strip(char *str) *p-- = 0; } -static void check_stdin(void) +/* Helper function to facilitate fgets() by Jean Sacren. */ +static void xfgets(char *str, int size, FILE *in) { - if (!valid_stdin) { - printf("aborted!\n\n"); - printf("Console input/output is redirected. "); - printf("Run 'make oldconfig' to update configuration.\n\n"); - exit(1); - } + if (!fgets(str, size, in)) + fprintf(stderr, "\nError in reading or end of file.\n"); + + if (!tty_stdio) + printf("%s", str); } static int conf_askvalue(struct symbol *sym, const char *def) @@ -90,7 +90,7 @@ static int conf_askvalue(struct symbol *sym, const char *def) line[0] = '\n'; line[1] = 0; - if (!sym_is_changable(sym)) { + if (!sym_is_changeable(sym)) { printf("%s\n", def); line[0] = '\n'; line[1] = 0; @@ -99,18 +99,15 @@ static int conf_askvalue(struct symbol *sym, const char *def) switch (input_mode) { case oldconfig: - case silentoldconfig: + case syncconfig: if (sym_has_value(sym)) { printf("%s\n", def); return 0; } - check_stdin(); /* fall through */ case oldaskconfig: fflush(stdout); - xfgets(line, 128, stdin); - if (!tty_stdio) - printf("\n"); + xfgets(line, sizeof(line), stdin); return 1; default: break; @@ -190,9 +187,7 @@ static int conf_sym(struct menu *menu) printf("/m"); if (oldval != yes && sym_tristate_within_range(sym, yes)) printf("/y"); - if (menu_has_help(menu)) - printf("/?"); - printf("] "); + printf("/?] "); if (!conf_askvalue(sym, sym_get_string_value(sym))) return 0; strip(line); @@ -239,7 +234,7 @@ static int conf_choice(struct menu *menu) sym = menu->sym; is_new = !sym_has_value(sym); - if (sym_is_changable(sym)) { + if (sym_is_changeable(sym)) { conf_sym(menu); sym_calc_value(sym); switch (sym_get_tristate_value(sym)) { @@ -294,23 +289,19 @@ static int conf_choice(struct menu *menu) printf("[1]: 1\n"); goto conf_childs; } - printf("[1-%d", cnt); - if (menu_has_help(menu)) - printf("?"); - printf("]: "); + printf("[1-%d?]: ", cnt); switch (input_mode) { case oldconfig: - case silentoldconfig: + case syncconfig: if (!is_new) { cnt = def; printf("%d\n", cnt); break; } - check_stdin(); /* fall through */ case oldaskconfig: fflush(stdout); - xfgets(line, 128, stdin); + xfgets(line, sizeof(line), stdin); strip(line); if (line[0] == '?') { print_help(menu); @@ -366,10 +357,11 @@ static void conf(struct menu *menu) switch (prop->type) { case P_MENU: - if ((input_mode == silentoldconfig || - input_mode == listnewconfig || - input_mode == olddefconfig) && - rootEntry != menu) { + /* + * Except in oldaskconfig mode, we show only menus that + * contain new symbols. + */ + if (input_mode != oldaskconfig && rootEntry != menu) { check_conf(menu); return; } @@ -426,13 +418,23 @@ static void check_conf(struct menu *menu) sym = menu->sym; if (sym && !sym_has_value(sym)) { - if (sym_is_changable(sym) || + if (sym_is_changeable(sym) || (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes)) { if (input_mode == listnewconfig) { - if (sym->name && !sym_is_choice_value(sym)) { - printf("%s%s\n", CONFIG_, sym->name); + if (sym->name) { + const char *str; + + if (sym->type == S_STRING) { + str = sym_get_string_value(sym); + str = sym_escape_string_value(str); + printf("%s%s=%s\n", CONFIG_, sym->name, str); + free((void *)str); + } else { + str = sym_get_string_value(sym); + printf("%s%s=%s\n", CONFIG_, sym->name, str); + } } - } else if (input_mode != olddefconfig) { + } else { if (!conf_cnt++) printf("*\n* Restart config...\n*\n"); rootEntry = menu_get_parent_menu(menu); @@ -448,8 +450,8 @@ static void check_conf(struct menu *menu) static struct option long_opts[] = { {"oldaskconfig", no_argument, NULL, oldaskconfig}, {"oldconfig", no_argument, NULL, oldconfig}, - {"silentoldconfig", no_argument, NULL, silentoldconfig}, - {"defconfig", optional_argument, NULL, defconfig}, + {"syncconfig", no_argument, NULL, syncconfig}, + {"defconfig", required_argument, NULL, defconfig}, {"savedefconfig", required_argument, NULL, savedefconfig}, {"allnoconfig", no_argument, NULL, allnoconfig}, {"allyesconfig", no_argument, NULL, allyesconfig}, @@ -458,12 +460,6 @@ static struct option long_opts[] = { {"randconfig", no_argument, NULL, randconfig}, {"listnewconfig", no_argument, NULL, listnewconfig}, {"olddefconfig", no_argument, NULL, olddefconfig}, - /* - * oldnoconfig is an alias of olddefconfig, because people already - * are dependent on its behavior(sets new symbols to their default - * value but not 'n') with the counter-intuitive name. - */ - {"oldnoconfig", no_argument, NULL, olddefconfig}, {NULL, 0, NULL, 0} }; @@ -475,9 +471,9 @@ static void conf_usage(const char *progname) printf(" --listnewconfig List new options\n"); printf(" --oldaskconfig Start a new configuration using a line-oriented program\n"); printf(" --oldconfig Update a configuration using a provided .config as base\n"); - printf(" --silentoldconfig Same as oldconfig, but quietly, additionally update deps\n"); - printf(" --olddefconfig Same as silentoldconfig but sets new symbols to their default value\n"); - printf(" --oldnoconfig An alias of olddefconfig\n"); + printf(" --syncconfig Similar to oldconfig but generates configuration in\n" + " include/{generated/,config/}\n"); + printf(" --olddefconfig Same as oldconfig but sets new symbols to their default value\n"); printf(" --defconfig New config with default defined in \n"); printf(" --savedefconfig Save the minimal current configuration to \n"); printf(" --allnoconfig New config where all options are answered with no\n"); @@ -492,9 +488,9 @@ int main(int ac, char **av) const char *progname = av[0]; int opt; const char *name, *defconfig_file = NULL /* gcc uninit */; - struct stat tmpstat; + int no_conf_write = 0; - tty_stdio = isatty(0) && isatty(1) && isatty(2); + tty_stdio = isatty(0) && isatty(1); while ((opt = getopt_long(ac, av, "s", long_opts, NULL)) != -1) { if (opt == 's') { @@ -503,7 +499,12 @@ int main(int ac, char **av) } input_mode = (enum input_mode)opt; switch (opt) { - case silentoldconfig: + case syncconfig: + /* + * syncconfig is invoked during the build stage. + * Suppress distracting "configuration written to ..." + */ + conf_set_message_callback(NULL); sync_kconfig = 1; break; case defconfig: @@ -551,39 +552,27 @@ int main(int ac, char **av) } } if (ac == optind) { - printf("%s: Kconfig file missing\n", av[0]); + fprintf(stderr, "%s: Kconfig file missing\n", av[0]); conf_usage(progname); exit(1); } name = av[optind]; conf_parse(name); //zconfdump(stdout); - if (sync_kconfig) { - name = conf_get_configname(); - if (stat(name, &tmpstat)) { - fprintf(stderr, "***\n" - "*** Configuration file \"%s\" not found!\n" - "***\n" - "*** Please run some configurator (e.g. \"make oldconfig\" or\n" - "*** \"make menuconfig\" or \"make xconfig\").\n" - "***\n", name); - exit(1); - } - } switch (input_mode) { case defconfig: - if (!defconfig_file) - defconfig_file = conf_get_default_confname(); if (conf_read(defconfig_file)) { - printf("***\n" - "*** Can't find default configuration \"%s\"!\n" - "***\n", defconfig_file); + fprintf(stderr, + "***\n" + "*** Can't find default configuration \"%s\"!\n" + "***\n", + defconfig_file); exit(1); } break; case savedefconfig: - case silentoldconfig: + case syncconfig: case oldaskconfig: case oldconfig: case listnewconfig: @@ -628,15 +617,15 @@ int main(int ac, char **av) } if (sync_kconfig) { - if (conf_get_changed()) { - name = getenv("KCONFIG_NOSILENTUPDATE"); - if (name && *name) { + name = getenv("KCONFIG_NOSILENTUPDATE"); + if (name && *name) { + if (conf_get_changed()) { fprintf(stderr, "\n*** The configuration requires explicit update.\n\n"); return 1; } + no_conf_write = 1; } - valid_stdin = tty_stdio; } switch (input_mode) { @@ -664,54 +653,48 @@ int main(int ac, char **av) case oldaskconfig: rootEntry = &rootmenu; conf(&rootmenu); - input_mode = silentoldconfig; + input_mode = oldconfig; /* fall through */ case oldconfig: case listnewconfig: - case olddefconfig: - case silentoldconfig: + case syncconfig: /* Update until a loop caused no more changes */ do { conf_cnt = 0; check_conf(&rootmenu); - } while (conf_cnt && - (input_mode != listnewconfig && - input_mode != olddefconfig)); + } while (conf_cnt); + break; + case olddefconfig: + default: break; } - if (sync_kconfig) { - /* silentoldconfig is used during the build so we shall update autoconf. - * All other commands are only used to generate a config. - */ - if (conf_get_changed() && conf_write(NULL)) { - fprintf(stderr, "\n*** Error during writing of the configuration.\n\n"); - exit(1); - } - if (conf_write_autoconf()) { - fprintf(stderr, "\n*** Error during update of the configuration.\n\n"); - return 1; - } - } else if (input_mode == savedefconfig) { + if (input_mode == savedefconfig) { if (conf_write_defconfig(defconfig_file)) { fprintf(stderr, "n*** Error while saving defconfig to: %s\n\n", defconfig_file); return 1; } } else if (input_mode != listnewconfig) { - if (conf_write(NULL)) { + if (!no_conf_write && conf_write(NULL)) { fprintf(stderr, "\n*** Error during writing of the configuration.\n\n"); exit(1); } + + /* + * Create auto.conf if it does not exist. + * This prevents GNU Make 4.1 or older from emitting + * "include/config/auto.conf: No such file or directory" + * in the top-level Makefile + * + * syncconfig always creates or updates auto.conf because it is + * used during the build. + */ + if (conf_write_autoconf(sync_kconfig) && sync_kconfig) { + fprintf(stderr, + "\n*** Error during sync of the configuration.\n\n"); + return 1; + } } return 0; } - -/* - * Helper function to facilitate fgets() by Jean Sacren. - */ -void xfgets(char *str, int size, FILE *in) -{ - if (fgets(str, size, in) == NULL) - fprintf(stderr, "\nError in reading or end of file.\n"); -} diff --git a/xen/tools/kconfig/confdata.c b/xen/tools/kconfig/confdata.c index 7d38d87a2e97..3569d2dec37c 100644 --- a/xen/tools/kconfig/confdata.c +++ b/xen/tools/kconfig/confdata.c @@ -1,12 +1,14 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) 2002 Roman Zippel - * Released under the terms of the GNU GPL v2.0. */ +#include #include #include #include #include +#include #include #include #include @@ -16,6 +18,151 @@ #include "lkc.h" +/* return true if 'path' exists, false otherwise */ +static bool is_present(const char *path) +{ + struct stat st; + + return !stat(path, &st); +} + +/* return true if 'path' exists and it is a directory, false otherwise */ +static bool is_dir(const char *path) +{ + struct stat st; + + if (stat(path, &st)) + return 0; + + return S_ISDIR(st.st_mode); +} + +/* return true if the given two files are the same, false otherwise */ +static bool is_same(const char *file1, const char *file2) +{ + int fd1, fd2; + struct stat st1, st2; + void *map1, *map2; + bool ret = false; + + fd1 = open(file1, O_RDONLY); + if (fd1 < 0) + return ret; + + fd2 = open(file2, O_RDONLY); + if (fd2 < 0) + goto close1; + + ret = fstat(fd1, &st1); + if (ret) + goto close2; + ret = fstat(fd2, &st2); + if (ret) + goto close2; + + if (st1.st_size != st2.st_size) + goto close2; + + map1 = mmap(NULL, st1.st_size, PROT_READ, MAP_PRIVATE, fd1, 0); + if (map1 == MAP_FAILED) + goto close2; + + map2 = mmap(NULL, st2.st_size, PROT_READ, MAP_PRIVATE, fd2, 0); + if (map2 == MAP_FAILED) + goto close2; + + if (bcmp(map1, map2, st1.st_size)) + goto close2; + + ret = true; +close2: + close(fd2); +close1: + close(fd1); + + return ret; +} + +/* + * Create the parent directory of the given path. + * + * For example, if 'include/config/auto.conf' is given, create 'include/config'. + */ +static int make_parent_dir(const char *path) +{ + char tmp[PATH_MAX + 1]; + char *p; + + strncpy(tmp, path, sizeof(tmp)); + tmp[sizeof(tmp) - 1] = 0; + + /* Remove the base name. Just return if nothing is left */ + p = strrchr(tmp, '/'); + if (!p) + return 0; + *(p + 1) = 0; + + /* Just in case it is an absolute path */ + p = tmp; + while (*p == '/') + p++; + + while ((p = strchr(p, '/'))) { + *p = 0; + + /* skip if the directory exists */ + if (!is_dir(tmp) && mkdir(tmp, 0755)) + return -1; + + *p = '/'; + while (*p == '/') + p++; + } + + return 0; +} + +static char depfile_path[PATH_MAX]; +static size_t depfile_prefix_len; + +/* touch depfile for symbol 'name' */ +static int conf_touch_dep(const char *name) +{ + int fd, ret; + const char *s; + char *d, c; + + /* check overflow: prefix + name + ".h" + '\0' must fit in buffer. */ + if (depfile_prefix_len + strlen(name) + 3 > sizeof(depfile_path)) + return -1; + + d = depfile_path + depfile_prefix_len; + s = name; + + while ((c = *s++)) + *d++ = (c == '_') ? '/' : tolower(c); + strcpy(d, ".h"); + + /* Assume directory path already exists. */ + fd = open(depfile_path, O_WRONLY | O_CREAT | O_TRUNC, 0644); + if (fd == -1) { + if (errno != ENOENT) + return -1; + + ret = make_parent_dir(depfile_path); + if (ret) + return ret; + + /* Try it again. */ + fd = open(depfile_path, O_WRONLY | O_CREAT | O_TRUNC, 0644); + if (fd == -1) + return -1; + } + close(fd); + + return 0; +} + struct conf_printer { void (*print_symbol)(FILE *, struct symbol *, const char *, void *); void (*print_comment)(FILE *, const char *, void *); @@ -28,9 +175,7 @@ static void conf_message(const char *fmt, ...) __attribute__ ((format (printf, 1, 2))); static const char *conf_filename; -static int conf_lineno, conf_warnings, conf_unsaved; - -const char conf_defname[] = "arch/$ARCH/defconfig"; +static int conf_lineno, conf_warnings; static void conf_warning(const char *fmt, ...) { @@ -43,16 +188,16 @@ static void conf_warning(const char *fmt, ...) conf_warnings++; } -static void conf_default_message_callback(const char *fmt, va_list ap) +static void conf_default_message_callback(const char *s) { printf("#\n# "); - vprintf(fmt, ap); + printf("%s", s); printf("\n#\n"); } -static void (*conf_message_callback) (const char *fmt, va_list ap) = +static void (*conf_message_callback)(const char *s) = conf_default_message_callback; -void conf_set_message_callback(void (*fn) (const char *fmt, va_list ap)) +void conf_set_message_callback(void (*fn)(const char *s)) { conf_message_callback = fn; } @@ -60,10 +205,15 @@ void conf_set_message_callback(void (*fn) (const char *fmt, va_list ap)) static void conf_message(const char *fmt, ...) { va_list ap; + char buf[4096]; + + if (!conf_message_callback) + return; va_start(ap, fmt); - if (conf_message_callback) - conf_message_callback(fmt, ap); + + vsnprintf(buf, sizeof(buf), fmt, ap); + conf_message_callback(buf); va_end(ap); } @@ -74,55 +224,13 @@ const char *conf_get_configname(void) return name ? name : ".config"; } -const char *conf_get_autoconfig_name(void) +static const char *conf_get_autoconfig_name(void) { char *name = getenv("KCONFIG_AUTOCONFIG"); return name ? name : "include/config/auto.conf"; } -static char *conf_expand_value(const char *in) -{ - struct symbol *sym; - const char *src; - static char res_value[SYMBOL_MAXLENGTH]; - char *dst, name[SYMBOL_MAXLENGTH]; - - res_value[0] = 0; - dst = name; - while ((src = strchr(in, '$'))) { - strncat(res_value, in, src - in); - src++; - dst = name; - while (isalnum(*src) || *src == '_') - *dst++ = *src++; - *dst = 0; - sym = sym_lookup(name, 0); - sym_calc_value(sym); - strcat(res_value, sym_get_string_value(sym)); - in = src; - } - strcat(res_value, in); - - return res_value; -} - -char *conf_get_default_confname(void) -{ - struct stat buf; - static char fullname[PATH_MAX+1]; - char *env, *name; - - name = conf_expand_value(conf_defname); - env = getenv(SRCTREE); - if (env) { - sprintf(fullname, "%s/%s", env, name); - if (!stat(fullname, &buf)) - return fullname; - } - return name; -} - static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p) { char *p2; @@ -150,14 +258,6 @@ static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p) conf_warning("symbol value '%s' invalid for %s", p, sym->name); return 1; - case S_OTHER: - if (*p != '"') { - for (p2 = p; *p2 && !isspace(*p2); p2++) - ; - sym->type = S_STRING; - goto done; - } - /* fall through */ case S_STRING: if (*p++ != '"') break; @@ -176,9 +276,8 @@ static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p) /* fall through */ case S_INT: case S_HEX: - done: if (sym_string_valid(sym, p)) { - sym->def[def].val = strdup(p); + sym->def[def].val = xstrdup(p); sym->flags |= def_flags; } else { if (def != S_DEF_AUTO) @@ -201,7 +300,7 @@ static int add_byte(int c, char **lineptr, size_t slen, size_t *n) if (new_size > *n) { new_size += LINE_GROWTH - 1; new_size *= 2; - nline = realloc(*lineptr, new_size); + nline = xrealloc(*lineptr, new_size); if (!nline) return -1; @@ -267,16 +366,15 @@ int conf_read_simple(const char *name, int def) if (in) goto load; sym_add_change_count(1); - if (!sym_defconfig_list) { - sym_calc_value(modules_sym); + if (!sym_defconfig_list) return 1; - } for_all_defaults(sym_defconfig_list, prop) { if (expr_calc_value(prop->visible.expr) == no || prop->expr->type != E_SYMBOL) continue; - name = conf_expand_value(prop->expr->left.sym->name); + sym_calc_value(prop->expr->left.sym); + name = sym_get_string_value(prop->expr->left.sym); in = zconf_fopen(name); if (in) { conf_message("using defaults found in %s", @@ -292,7 +390,6 @@ int conf_read_simple(const char *name, int def) conf_filename = name; conf_lineno = 0; conf_warnings = 0; - conf_unsaved = 0; def_flags = SYMBOL_DEF << def; for_all_symbols(i, sym) { @@ -329,7 +426,7 @@ int conf_read_simple(const char *name, int def) sym = sym_find(line + 2 + strlen(CONFIG_)); if (!sym) { sym_add_change_count(1); - goto setsym; + continue; } } else { sym = sym_lookup(line + 2 + strlen(CONFIG_), 0); @@ -359,17 +456,22 @@ int conf_read_simple(const char *name, int def) if (*p2 == '\r') *p2 = 0; } - if (def == S_DEF_USER) { - sym = sym_find(line + strlen(CONFIG_)); - if (!sym) { + + sym = sym_find(line + strlen(CONFIG_)); + if (!sym) { + if (def == S_DEF_AUTO) + /* + * Reading from include/config/auto.conf + * If CONFIG_FOO previously existed in + * auto.conf but it is missing now, + * include/config/foo.h must be touched. + */ + conf_touch_dep(line + strlen(CONFIG_)); + else sym_add_change_count(1); - goto setsym; - } - } else { - sym = sym_lookup(line + strlen(CONFIG_), 0); - if (sym->type == S_UNKNOWN) - sym->type = S_OTHER; + continue; } + if (sym->flags & def_flags) { conf_warning("override: reassigning to symbol %s", sym->name); } @@ -377,10 +479,12 @@ int conf_read_simple(const char *name, int def) continue; } else { if (line[0] != '\r' && line[0] != '\n') - conf_warning("unexpected data"); + conf_warning("unexpected data: %.*s", + (int)strcspn(line, "\r\n"), line); + continue; } -setsym: + if (sym && sym_is_choice_value(sym)) { struct symbol *cs = prop_get_symbol(sym_get_choice_prop(sym)); switch (sym->def[def].tri) { @@ -403,34 +507,36 @@ int conf_read_simple(const char *name, int def) } free(line); fclose(in); - sym_calc_value(modules_sym); return 0; } int conf_read(const char *name) { struct symbol *sym; + int conf_unsaved = 0; int i; sym_set_change_count(0); - if (conf_read_simple(name, S_DEF_USER)) + if (conf_read_simple(name, S_DEF_USER)) { + sym_calc_value(modules_sym); return 1; + } + + sym_calc_value(modules_sym); for_all_symbols(i, sym) { sym_calc_value(sym); - if (sym_is_choice(sym) || (sym->flags & SYMBOL_AUTO)) + if (sym_is_choice(sym) || (sym->flags & SYMBOL_NO_WRITE)) continue; if (sym_has_value(sym) && (sym->flags & SYMBOL_WRITE)) { /* check that calculated value agrees with saved value */ switch (sym->type) { case S_BOOLEAN: case S_TRISTATE: - if (sym->def[S_DEF_USER].tri != sym_get_tristate_value(sym)) - break; - if (!sym_is_choice(sym)) + if (sym->def[S_DEF_USER].tri == sym_get_tristate_value(sym)) continue; - /* fall through */ + break; default: if (!strcmp(sym->curr.val, sym->def[S_DEF_USER].val)) continue; @@ -629,7 +735,6 @@ static void conf_write_symbol(FILE *fp, struct symbol *sym, const char *str; switch (sym->type) { - case S_OTHER: case S_UNKNOWN: break; case S_STRING: @@ -689,7 +794,7 @@ int conf_write_defconfig(const char *filename) goto next_menu; sym->flags &= ~SYMBOL_WRITE; /* If we cannot change the symbol - skip */ - if (!sym_is_changable(sym)) + if (!sym_is_changeable(sym)) goto next_menu; /* If symbol equals to default value - skip */ if (strcmp(sym_get_string_value(sym), sym_get_string_default(sym)) == 0) @@ -740,41 +845,36 @@ int conf_write(const char *name) FILE *out; struct symbol *sym; struct menu *menu; - const char *basename; const char *str; - char dirname[PATH_MAX+1], tmpname[PATH_MAX+1], newname[PATH_MAX+1]; + char tmpname[PATH_MAX + 1], oldname[PATH_MAX + 1]; char *env; + int i; + bool need_newline = false; + + if (!name) + name = conf_get_configname(); + + if (!*name) { + fprintf(stderr, "config name is empty\n"); + return -1; + } + + if (is_dir(name)) { + fprintf(stderr, "%s: Is a directory\n", name); + return -1; + } + + if (make_parent_dir(name)) + return -1; - dirname[0] = 0; - if (name && name[0]) { - struct stat st; - char *slash; - - if (!stat(name, &st) && S_ISDIR(st.st_mode)) { - strcpy(dirname, name); - strcat(dirname, "/"); - basename = conf_get_configname(); - } else if ((slash = strrchr(name, '/'))) { - int size = slash - name + 1; - memcpy(dirname, name, size); - dirname[size] = 0; - if (slash[1]) - basename = slash + 1; - else - basename = conf_get_configname(); - } else - basename = name; - } else - basename = conf_get_configname(); - - sprintf(newname, "%s%s", dirname, basename); env = getenv("KCONFIG_OVERWRITECONFIG"); - if (!env || !*env) { - sprintf(tmpname, "%s.tmpconfig.%d", dirname, (int)getpid()); - out = fopen(tmpname, "w"); - } else { + if (env && *env) { *tmpname = 0; - out = fopen(newname, "w"); + out = fopen(name, "w"); + } else { + snprintf(tmpname, sizeof(tmpname), "%s.%d.tmp", + name, (int)getpid()); + out = fopen(tmpname, "w"); } if (!out) return 1; @@ -795,12 +895,17 @@ int conf_write(const char *name) "#\n" "# %s\n" "#\n", str); - } else if (!(sym->flags & SYMBOL_CHOICE)) { + need_newline = false; + } else if (!(sym->flags & SYMBOL_CHOICE) && + !(sym->flags & SYMBOL_WRITTEN)) { sym_calc_value(sym); if (!(sym->flags & SYMBOL_WRITE)) goto next; - sym->flags &= ~SYMBOL_WRITE; - + if (need_newline) { + fprintf(out, "\n"); + need_newline = false; + } + sym->flags |= SYMBOL_WRITTEN; conf_write_symbol(out, sym, &kconfig_printer_cb, NULL); } @@ -812,6 +917,12 @@ int conf_write(const char *name) if (menu->next) menu = menu->next; else while ((menu = menu->parent)) { + if (!menu->sym && menu_is_visible(menu) && + menu != &rootmenu) { + str = menu_get_prompt(menu); + fprintf(out, "# end of %s\n", str); + need_newline = true; + } if (menu->next) { menu = menu->next; break; @@ -820,40 +931,76 @@ int conf_write(const char *name) } fclose(out); + for_all_symbols(i, sym) + sym->flags &= ~SYMBOL_WRITTEN; + if (*tmpname) { - strcat(dirname, basename); - strcat(dirname, ".old"); - rename(newname, dirname); - if (rename(tmpname, newname)) + if (is_same(name, tmpname)) { + conf_message("No change to %s", name); + unlink(tmpname); + sym_set_change_count(0); + return 0; + } + + snprintf(oldname, sizeof(oldname), "%s.old", name); + rename(name, oldname); + if (rename(tmpname, name)) return 1; } - conf_message("configuration written to %s", newname); + conf_message("configuration written to %s", name); sym_set_change_count(0); return 0; } -static int conf_split_config(void) +/* write a dependency file as used by kbuild to track dependencies */ +static int conf_write_dep(const char *name) +{ + struct file *file; + FILE *out; + + out = fopen("..config.tmp", "w"); + if (!out) + return 1; + fprintf(out, "deps_config := \\\n"); + for (file = file_list; file; file = file->next) { + if (file->next) + fprintf(out, "\t%s \\\n", file->name); + else + fprintf(out, "\t%s\n", file->name); + } + fprintf(out, "\n%s: \\\n" + "\t$(deps_config)\n\n", conf_get_autoconfig_name()); + + env_write_dep(out, conf_get_autoconfig_name()); + + fprintf(out, "\n$(deps_config): ;\n"); + fclose(out); + + if (make_parent_dir(name)) + return 1; + rename("..config.tmp", name); + return 0; +} + +static int conf_touch_deps(void) { const char *name; - char path[PATH_MAX+1]; - char *s, *d, c; struct symbol *sym; - struct stat sb; - int res, i, fd; + int res, i; + + strcpy(depfile_path, "include/config/"); + depfile_prefix_len = strlen(depfile_path); name = conf_get_autoconfig_name(); conf_read_simple(name, S_DEF_AUTO); + sym_calc_value(modules_sym); - if (chdir("include/config")) - return 1; - - res = 0; for_all_symbols(i, sym) { sym_calc_value(sym); - if ((sym->flags & SYMBOL_AUTO) || !sym->name) + if ((sym->flags & SYMBOL_NO_WRITE) || !sym->name) continue; if (sym->flags & SYMBOL_WRITE) { if (sym->flags & SYMBOL_DEF_AUTO) { @@ -902,63 +1049,28 @@ static int conf_split_config(void) * different from 'no'). */ - /* Replace all '_' and append ".h" */ - s = sym->name; - d = path; - while ((c = *s++)) { - c = tolower(c); - *d++ = (c == '_') ? '/' : c; - } - strcpy(d, ".h"); - - /* Assume directory path already exists. */ - fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0644); - if (fd == -1) { - if (errno != ENOENT) { - res = 1; - break; - } - /* - * Create directory components, - * unless they exist already. - */ - d = path; - while ((d = strchr(d, '/'))) { - *d = 0; - if (stat(path, &sb) && mkdir(path, 0755)) { - res = 1; - goto out; - } - *d++ = '/'; - } - /* Try it again. */ - fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0644); - if (fd == -1) { - res = 1; - break; - } - } - close(fd); + res = conf_touch_dep(sym->name); + if (res) + return res; } -out: - if (chdir("../..")) - return 1; - return res; + return 0; } -int conf_write_autoconf(void) +int conf_write_autoconf(int overwrite) { struct symbol *sym; const char *name; + const char *autoconf_name = conf_get_autoconfig_name(); FILE *out, *tristate, *out_h; int i; - sym_clear_all_valid(); + if (!overwrite && is_present(autoconf_name)) + return 0; - file_write_dep("include/config/auto.conf.cmd"); + conf_write_dep("include/config/auto.conf.cmd"); - if (conf_split_config()) + if (conf_touch_deps()) return 1; out = fopen(".tmpconfig", "w"); @@ -1003,19 +1115,26 @@ int conf_write_autoconf(void) name = getenv("KCONFIG_AUTOHEADER"); if (!name) name = "include/generated/autoconf.h"; + if (make_parent_dir(name)) + return 1; if (rename(".tmpconfig.h", name)) return 1; + name = getenv("KCONFIG_TRISTATE"); if (!name) name = "include/config/tristate.conf"; + if (make_parent_dir(name)) + return 1; if (rename(".tmpconfig_tristate", name)) return 1; - name = conf_get_autoconfig_name(); + + if (make_parent_dir(autoconf_name)) + return 1; /* * This must be the last step, kbuild has a dependency on auto.conf * and this marks the successful completion of the previous steps. */ - if (rename(".tmpconfig", name)) + if (rename(".tmpconfig", autoconf_name)) return 1; return 0; @@ -1119,7 +1238,7 @@ void set_all_choice_values(struct symbol *csym) bool conf_set_all_new_symbols(enum conf_def_mode mode) { struct symbol *sym, *csym; - int i, cnt, pby, pty, ptm; /* pby: probability of boolean = y + int i, cnt, pby, pty, ptm; /* pby: probability of bool = y * pty: probability of tristate = y * ptm: probability of tristate = m */ diff --git a/xen/tools/kconfig/expr.c b/xen/tools/kconfig/expr.c index 667d1aa23711..77ffff3a053c 100644 --- a/xen/tools/kconfig/expr.c +++ b/xen/tools/kconfig/expr.c @@ -1,8 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) 2002 Roman Zippel - * Released under the terms of the GNU GPL v2.0. */ +#include +#include #include #include #include @@ -94,7 +96,7 @@ struct expr *expr_copy(const struct expr *org) e->right.expr = expr_copy(org->right.expr); break; default: - printf("can't copy type %d\n", e->type); + fprintf(stderr, "can't copy type %d\n", e->type); free(e); e = NULL; break; @@ -113,7 +115,7 @@ void expr_free(struct expr *e) break; case E_NOT: expr_free(e->left.expr); - return; + break; case E_EQUAL: case E_GEQ: case E_GTH: @@ -127,7 +129,7 @@ void expr_free(struct expr *e) expr_free(e->right.expr); break; default: - printf("how to free type %d?\n", e->type); + fprintf(stderr, "how to free type %d?\n", e->type); break; } free(e); @@ -138,8 +140,18 @@ static int trans_count; #define e1 (*ep1) #define e2 (*ep2) +/* + * expr_eliminate_eq() helper. + * + * Walks the two expression trees given in 'ep1' and 'ep2'. Any node that does + * not have type 'type' (E_OR/E_AND) is considered a leaf, and is compared + * against all other leaves. Two equal leaves are both replaced with either 'y' + * or 'n' as appropriate for 'type', to be eliminated later. + */ static void __expr_eliminate_eq(enum expr_type type, struct expr **ep1, struct expr **ep2) { + /* Recurse down to leaves */ + if (e1->type == type) { __expr_eliminate_eq(type, &e1->left.expr, &e2); __expr_eliminate_eq(type, &e1->right.expr, &e2); @@ -150,12 +162,18 @@ static void __expr_eliminate_eq(enum expr_type type, struct expr **ep1, struct e __expr_eliminate_eq(type, &e1, &e2->right.expr); return; } + + /* e1 and e2 are leaves. Compare them. */ + if (e1->type == E_SYMBOL && e2->type == E_SYMBOL && e1->left.sym == e2->left.sym && (e1->left.sym == &symbol_yes || e1->left.sym == &symbol_no)) return; if (!expr_eq(e1, e2)) return; + + /* e1 and e2 are equal leaves. Prepare them for elimination. */ + trans_count++; expr_free(e1); expr_free(e2); switch (type) { @@ -172,6 +190,35 @@ static void __expr_eliminate_eq(enum expr_type type, struct expr **ep1, struct e } } +/* + * Rewrites the expressions 'ep1' and 'ep2' to remove operands common to both. + * Example reductions: + * + * ep1: A && B -> ep1: y + * ep2: A && B && C -> ep2: C + * + * ep1: A || B -> ep1: n + * ep2: A || B || C -> ep2: C + * + * ep1: A && (B && FOO) -> ep1: FOO + * ep2: (BAR && B) && A -> ep2: BAR + * + * ep1: A && (B || C) -> ep1: y + * ep2: (C || B) && A -> ep2: y + * + * Comparisons are done between all operands at the same "level" of && or ||. + * For example, in the expression 'e1 && (e2 || e3) && (e4 || e5)', the + * following operands will be compared: + * + * - 'e1', 'e2 || e3', and 'e4 || e5', against each other + * - e2 against e3 + * - e4 against e5 + * + * Parentheses are irrelevant within a single level. 'e1 && (e2 && e3)' and + * '(e1 && e2) && e3' are both a single level. + * + * See __expr_eliminate_eq() as well. + */ void expr_eliminate_eq(struct expr **ep1, struct expr **ep2) { if (!e1 || !e2) @@ -197,6 +244,12 @@ void expr_eliminate_eq(struct expr **ep1, struct expr **ep2) #undef e1 #undef e2 +/* + * Returns true if 'e1' and 'e2' are equal, after minor simplification. Two + * &&/|| expressions are considered equal if every operand in one expression + * equals some operand in the other (operands do not need to appear in the same + * order), recursively. + */ static int expr_eq(struct expr *e1, struct expr *e2) { int res, old_count; @@ -243,6 +296,17 @@ static int expr_eq(struct expr *e1, struct expr *e2) return 0; } +/* + * Recursively performs the following simplifications in-place (as well as the + * corresponding simplifications with swapped operands): + * + * expr && n -> n + * expr && y -> expr + * expr || n -> expr + * expr || y -> y + * + * Returns the optimized expression. + */ static struct expr *expr_eliminate_yn(struct expr *e) { struct expr *tmp; @@ -516,12 +580,21 @@ static struct expr *expr_join_and(struct expr *e1, struct expr *e2) return NULL; } +/* + * expr_eliminate_dups() helper. + * + * Walks the two expression trees given in 'ep1' and 'ep2'. Any node that does + * not have type 'type' (E_OR/E_AND) is considered a leaf, and is compared + * against all other leaves to look for simplifications. + */ static void expr_eliminate_dups1(enum expr_type type, struct expr **ep1, struct expr **ep2) { #define e1 (*ep1) #define e2 (*ep2) struct expr *tmp; + /* Recurse down to leaves */ + if (e1->type == type) { expr_eliminate_dups1(type, &e1->left.expr, &e2); expr_eliminate_dups1(type, &e1->right.expr, &e2); @@ -532,6 +605,9 @@ static void expr_eliminate_dups1(enum expr_type type, struct expr **ep1, struct expr_eliminate_dups1(type, &e1, &e2->right.expr); return; } + + /* e1 and e2 are leaves. Compare and process them. */ + if (e1 == e2) return; @@ -568,6 +644,17 @@ static void expr_eliminate_dups1(enum expr_type type, struct expr **ep1, struct #undef e2 } +/* + * Rewrites 'e' in-place to remove ("join") duplicate and other redundant + * operands. + * + * Example simplifications: + * + * A || B || A -> A || B + * A && B && A=y -> A=y && B + * + * Returns the deduplicated expression. + */ struct expr *expr_eliminate_dups(struct expr *e) { int oldcount; @@ -584,6 +671,7 @@ struct expr *expr_eliminate_dups(struct expr *e) ; } if (!trans_count) + /* No simplifications done in this pass. We're done */ break; e = expr_eliminate_yn(e); } @@ -591,6 +679,12 @@ struct expr *expr_eliminate_dups(struct expr *e) return e; } +/* + * Performs various simplifications involving logical operators and + * comparisons. + * + * Allocates and returns a new expression. + */ struct expr *expr_transform(struct expr *e) { struct expr *tmp; @@ -805,6 +899,20 @@ bool expr_depends_symbol(struct expr *dep, struct symbol *sym) return false; } +/* + * Inserts explicit comparisons of type 'type' to symbol 'sym' into the + * expression 'e'. + * + * Examples transformations for type == E_UNEQUAL, sym == &symbol_no: + * + * A -> A!=n + * !A -> A=n + * A && B -> !(A=n || B=n) + * A || B -> !(A=n && B=n) + * A && (B || C) -> !(A=n || (B=n && C=n)) + * + * Allocates and returns a new expression. + */ struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym) { struct expr *e1, *e2; @@ -874,7 +982,6 @@ enum string_value_kind { k_string, k_signed, k_unsigned, - k_invalid }; union string_value { @@ -893,7 +1000,10 @@ static enum string_value_kind expr_parse_string(const char *str, switch (type) { case S_BOOLEAN: case S_TRISTATE: - return k_string; + val->s = !strcmp(str, "n") ? 0 : + !strcmp(str, "m") ? 1 : + !strcmp(str, "y") ? 2 : -1; + return k_signed; case S_INT: val->s = strtoll(str, &tail, 10); kind = k_signed; @@ -902,13 +1012,10 @@ static enum string_value_kind expr_parse_string(const char *str, val->u = strtoull(str, &tail, 16); kind = k_unsigned; break; - case S_STRING: - case S_UNKNOWN: + default: val->s = strtoll(str, &tail, 0); kind = k_signed; break; - default: - return k_invalid; } return !errno && !*tail && tail > str && isxdigit(tail[-1]) ? kind : k_string; @@ -964,13 +1071,7 @@ tristate expr_calc_value(struct expr *e) if (k1 == k_string || k2 == k_string) res = strcmp(str1, str2); - else if (k1 == k_invalid || k2 == k_invalid) { - if (e->type != E_EQUAL && e->type != E_UNEQUAL) { - printf("Cannot compare \"%s\" and \"%s\"\n", str1, str2); - return no; - } - res = strcmp(str1, str2); - } else if (k1 == k_unsigned || k2 == k_unsigned) + else if (k1 == k_unsigned || k2 == k_unsigned) res = (lval.u > rval.u) - (lval.u < rval.u); else /* if (k1 == k_signed && k2 == k_signed) */ res = (lval.s > rval.s) - (lval.s < rval.s); @@ -1028,49 +1129,9 @@ static int expr_compare_type(enum expr_type t1, enum expr_type t2) return 0; } -static inline struct expr * -expr_get_leftmost_symbol(const struct expr *e) -{ - - if (e == NULL) - return NULL; - - while (e->type != E_SYMBOL) - e = e->left.expr; - - return expr_copy(e); -} - -/* - * Given expression `e1' and `e2', returns the leaf of the longest - * sub-expression of `e1' not containing 'e2. - */ -struct expr *expr_simplify_unmet_dep(struct expr *e1, struct expr *e2) -{ - struct expr *ret; - - switch (e1->type) { - case E_OR: - return expr_alloc_and( - expr_simplify_unmet_dep(e1->left.expr, e2), - expr_simplify_unmet_dep(e1->right.expr, e2)); - case E_AND: { - struct expr *e; - e = expr_alloc_and(expr_copy(e1), expr_copy(e2)); - e = expr_eliminate_dups(e); - ret = (!expr_eq(e, e1)) ? e1 : NULL; - expr_free(e); - break; - } - default: - ret = e1; - break; - } - - return expr_get_leftmost_symbol(ret); -} - -void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken) +void expr_print(struct expr *e, + void (*fn)(void *, struct symbol *, const char *), + void *data, int prevtoken) { if (!e) { fn(data, NULL, "y"); @@ -1113,7 +1174,7 @@ void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char * fn(data, e->left.sym, e->left.sym->name); else fn(data, NULL, ""); - fn(data, NULL, e->type == E_LEQ ? ">=" : ">"); + fn(data, NULL, e->type == E_GEQ ? ">=" : ">"); fn(data, e->right.sym, e->right.sym->name); break; case E_UNEQUAL: @@ -1204,3 +1265,33 @@ void expr_gstr_print(struct expr *e, struct gstr *gs) { expr_print(e, expr_print_gstr_helper, gs, E_NONE); } + +/* + * Transform the top level "||" tokens into newlines and prepend each + * line with a minus. This makes expressions much easier to read. + * Suitable for reverse dependency expressions. + */ +static void expr_print_revdep(struct expr *e, + void (*fn)(void *, struct symbol *, const char *), + void *data, tristate pr_type, const char **title) +{ + if (e->type == E_OR) { + expr_print_revdep(e->left.expr, fn, data, pr_type, title); + expr_print_revdep(e->right.expr, fn, data, pr_type, title); + } else if (expr_calc_value(e) == pr_type) { + if (*title) { + fn(data, NULL, *title); + *title = NULL; + } + + fn(data, NULL, " - "); + expr_print(e, fn, data, E_NONE); + fn(data, NULL, "\n"); + } +} + +void expr_gstr_print_revdep(struct expr *e, struct gstr *gs, + tristate pr_type, const char *title) +{ + expr_print_revdep(e, expr_print_gstr_helper, gs, pr_type, &title); +} diff --git a/xen/tools/kconfig/expr.h b/xen/tools/kconfig/expr.h index 973b6f733368..017843c9a4f4 100644 --- a/xen/tools/kconfig/expr.h +++ b/xen/tools/kconfig/expr.h @@ -1,6 +1,6 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* * Copyright (C) 2002 Roman Zippel - * Released under the terms of the GNU GPL v2.0. */ #ifndef EXPR_H @@ -62,7 +62,7 @@ struct symbol_value { }; enum symbol_type { - S_UNKNOWN, S_BOOLEAN, S_TRISTATE, S_INT, S_HEX, S_STRING, S_OTHER + S_UNKNOWN, S_BOOLEAN, S_TRISTATE, S_INT, S_HEX, S_STRING }; /* enum values are used as index to symbol.def[] */ @@ -74,20 +74,64 @@ enum { S_DEF_COUNT }; +/* + * Represents a configuration symbol. + * + * Choices are represented as a special kind of symbol and have the + * SYMBOL_CHOICE bit set in 'flags'. + */ struct symbol { + /* The next symbol in the same bucket in the symbol hash table */ struct symbol *next; + + /* The name of the symbol, e.g. "FOO" for 'config FOO' */ char *name; + + /* S_BOOLEAN, S_TRISTATE, ... */ enum symbol_type type; + + /* + * The calculated value of the symbol. The SYMBOL_VALID bit is set in + * 'flags' when this is up to date. Note that this value might differ + * from the user value set in e.g. a .config file, due to visibility. + */ struct symbol_value curr; + + /* + * Values for the symbol provided from outside. def[S_DEF_USER] holds + * the .config value. + */ struct symbol_value def[S_DEF_COUNT]; + + /* + * An upper bound on the tristate value the user can set for the symbol + * if it is a boolean or tristate. Calculated from prompt dependencies, + * which also inherit dependencies from enclosing menus, choices, and + * ifs. If 'n', the user value will be ignored. + * + * Symbols lacking prompts always have visibility 'n'. + */ tristate visible; + + /* SYMBOL_* flags */ int flags; + + /* List of properties. See prop_type. */ struct property *prop; + + /* Dependencies from enclosing menus, choices, and ifs */ struct expr_value dir_dep; + + /* Reverse dependencies through being selected by other symbols */ struct expr_value rev_dep; + + /* + * "Weak" reverse dependencies through being implied by other symbols + */ + struct expr_value implied; }; -#define for_all_symbols(i, sym) for (i = 0; i < SYMBOL_HASHSIZE; i++) for (sym = symbol_hash[i]; sym; sym = sym->next) if (sym->type != S_OTHER) +#define for_all_symbols(i, sym) for (i = 0; i < SYMBOL_HASHSIZE; i++) for (sym = symbol_hash[i]; sym; sym = sym->next) #define SYMBOL_CONST 0x0001 /* symbol is const */ #define SYMBOL_CHECK 0x0008 /* used during dependency checking */ @@ -97,7 +141,8 @@ struct symbol { #define SYMBOL_OPTIONAL 0x0100 /* choice is optional - values can be 'n' */ #define SYMBOL_WRITE 0x0200 /* write symbol to file (KCONFIG_CONFIG) */ #define SYMBOL_CHANGED 0x0400 /* ? */ -#define SYMBOL_AUTO 0x1000 /* value from environment variable */ +#define SYMBOL_WRITTEN 0x0800 /* track info to avoid double-write to .config */ +#define SYMBOL_NO_WRITE 0x1000 /* Symbol for internal use only; it will not be written */ #define SYMBOL_CHECKED 0x2000 /* used during dependency checking */ #define SYMBOL_WARNED 0x8000 /* warning has been issued */ @@ -127,17 +172,20 @@ struct symbol { * config BAZ * int "BAZ Value" * range 1..255 + * + * Please, also check parser.y:print_symbol() when modifying the + * list of property types! */ enum prop_type { P_UNKNOWN, P_PROMPT, /* prompt "foo prompt" or "BAZ Value" */ P_COMMENT, /* text associated with a comment */ - P_MENU, /* prompt associated with a menuconfig option */ + P_MENU, /* prompt associated with a menu or menuconfig symbol */ P_DEFAULT, /* default y */ P_CHOICE, /* choice value */ P_SELECT, /* select BAR */ + P_IMPLY, /* imply BAR */ P_RANGE, /* range 7..100 (for a symbol) */ - P_ENV, /* value from environment variable */ P_SYMBOL, /* where a symbol is defined */ }; @@ -164,22 +212,67 @@ struct property { for (st = sym->prop; st; st = st->next) \ if (st->text) +/* + * Represents a node in the menu tree, as seen in e.g. menuconfig (though used + * for all front ends). Each symbol, menu, etc. defined in the Kconfig files + * gets a node. A symbol defined in multiple locations gets one node at each + * location. + */ struct menu { + /* The next menu node at the same level */ struct menu *next; + + /* The parent menu node, corresponding to e.g. a menu or choice */ struct menu *parent; + + /* The first child menu node, for e.g. menus and choices */ struct menu *list; + + /* + * The symbol associated with the menu node. Choices are implemented as + * a special kind of symbol. NULL for menus, comments, and ifs. + */ struct symbol *sym; + + /* + * The prompt associated with the node. This holds the prompt for a + * symbol as well as the text for a menu or comment, along with the + * type (P_PROMPT, P_MENU, etc.) + */ struct property *prompt; + + /* + * 'visible if' dependencies. If more than one is given, they will be + * ANDed together. + */ struct expr *visibility; + + /* + * Ordinary dependencies from e.g. 'depends on' and 'if', ANDed + * together + */ struct expr *dep; + + /* MENU_* flags */ unsigned int flags; + + /* Any help text associated with the node */ char *help; + + /* The location where the menu node appears in the Kconfig files */ struct file *file; int lineno; + + /* For use by front ends that need to store auxiliary data */ void *data; }; +/* + * Set on a menu node when the corresponding symbol changes state in some way. + * Can be checked by front ends. + */ #define MENU_CHANGED 0x0001 + #define MENU_ROOT 0x0002 struct jump_key { @@ -215,11 +308,12 @@ struct expr *expr_transform(struct expr *e); int expr_contains_symbol(struct expr *dep, struct symbol *sym); bool expr_depends_symbol(struct expr *dep, struct symbol *sym); struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym); -struct expr *expr_simplify_unmet_dep(struct expr *e1, struct expr *e2); void expr_fprint(struct expr *e, FILE *out); struct gstr; /* forward */ void expr_gstr_print(struct expr *e, struct gstr *gs); +void expr_gstr_print_revdep(struct expr *e, struct gstr *gs, + tristate pr_type, const char *title); static inline int expr_is_yes(struct expr *e) { diff --git a/xen/tools/kconfig/gconf-cfg.sh b/xen/tools/kconfig/gconf-cfg.sh new file mode 100755 index 000000000000..480ecd8b9f41 --- /dev/null +++ b/xen/tools/kconfig/gconf-cfg.sh @@ -0,0 +1,30 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 + +PKG="gtk+-2.0 gmodule-2.0 libglade-2.0" + +if [ -z "$(command -v pkg-config)" ]; then + echo >&2 "*" + echo >&2 "* 'make gconfig' requires 'pkg-config'. Please install it." + echo >&2 "*" + exit 1 +fi + +if ! pkg-config --exists $PKG; then + echo >&2 "*" + echo >&2 "* Unable to find the GTK+ installation. Please make sure that" + echo >&2 "* the GTK+ 2.0 development package is correctly installed." + echo >&2 "* You need $PKG" + echo >&2 "*" + exit 1 +fi + +if ! pkg-config --atleast-version=2.0.0 gtk+-2.0; then + echo >&2 "*" + echo >&2 "* GTK+ is present but version >= 2.0.0 is required." + echo >&2 "*" + exit 1 +fi + +echo cflags=\"$(pkg-config --cflags $PKG)\" +echo libs=\"$(pkg-config --libs $PKG)\" diff --git a/xen/tools/kconfig/gconf.c b/xen/tools/kconfig/gconf.c index 405178769103..e36b342f1065 100644 --- a/xen/tools/kconfig/gconf.c +++ b/xen/tools/kconfig/gconf.c @@ -1,9 +1,6 @@ -/* Hey EMACS -*- linux-c -*- */ +// SPDX-License-Identifier: GPL-2.0 /* - * * Copyright (C) 2002-2003 Romain Lievin - * Released under the terms of the GNU GPL v2.0. - * */ #ifdef HAVE_CONFIG_H @@ -12,7 +9,7 @@ #include #include "lkc.h" -#include "images.c" +#include "images.h" #include #include @@ -78,8 +75,8 @@ static gchar **fill_row(struct menu *menu); static void conf_changed(void); /* Helping/Debugging Functions */ - -const char *dbg_sym_flags(int val) +#ifdef DEBUG +static const char *dbg_sym_flags(int val) { static char buf[256]; @@ -101,16 +98,17 @@ const char *dbg_sym_flags(int val) strcat(buf, "write/"); if (val & SYMBOL_CHANGED) strcat(buf, "changed/"); - if (val & SYMBOL_AUTO) - strcat(buf, "auto/"); + if (val & SYMBOL_NO_WRITE) + strcat(buf, "no_write/"); buf[strlen(buf) - 1] = '\0'; return buf; } +#endif -void replace_button_icon(GladeXML * xml, GdkDrawable * window, - GtkStyle * style, gchar * btn_name, gchar ** xpm) +static void replace_button_icon(GladeXML *xml, GdkDrawable *window, + GtkStyle *style, gchar *btn_name, gchar **xpm) { GdkPixmap *pixmap; GdkBitmap *mask; @@ -128,7 +126,7 @@ void replace_button_icon(GladeXML * xml, GdkDrawable * window, } /* Main Window Initialization */ -void init_main_window(const gchar * glade_file) +static void init_main_window(const gchar *glade_file) { GladeXML *xml; GtkWidget *widget; @@ -190,7 +188,7 @@ void init_main_window(const gchar * glade_file) gtk_widget_show(main_wnd); } -void init_tree_model(void) +static void init_tree_model(void) { gint i; @@ -220,7 +218,7 @@ void init_tree_model(void) model1 = GTK_TREE_MODEL(tree1); } -void init_left_tree(void) +static void init_left_tree(void) { GtkTreeView *view = GTK_TREE_VIEW(tree1_w); GtkCellRenderer *renderer; @@ -262,7 +260,7 @@ static void renderer_edited(GtkCellRendererText * cell, const gchar * path_string, const gchar * new_text, gpointer user_data); -void init_right_tree(void) +static void init_right_tree(void) { GtkTreeView *view = GTK_TREE_VIEW(tree2_w); GtkCellRenderer *renderer; @@ -525,6 +523,7 @@ void on_save_activate(GtkMenuItem * menuitem, gpointer user_data) { if (conf_write(NULL)) text_insert_msg("Error", "Unable to save configuration !"); + conf_write_autoconf(0); } @@ -639,7 +638,7 @@ on_set_option_mode3_activate(GtkMenuItem *menuitem, gpointer user_data) void on_introduction1_activate(GtkMenuItem * menuitem, gpointer user_data) { GtkWidget *dialog; - const gchar *intro_text = + const gchar *intro_text = "Welcome to gkc, the GTK+ graphical configuration tool\n" "For each option, a blank box indicates the feature is disabled, a\n" "check indicates it is enabled, and a dot indicates that it is to\n" @@ -914,7 +913,7 @@ on_treeview2_button_press_event(GtkWidget * widget, current = menu; display_tree_part(); gtk_widget_set_sensitive(back_btn, TRUE); - } else if ((col == COL_OPTION)) { + } else if (col == COL_OPTION) { toggle_sym_value(menu); gtk_tree_view_expand_row(view, path, TRUE); } @@ -1211,8 +1210,8 @@ static GtkTreeIter found; /* * Find a menu in the GtkTree starting at parent. */ -GtkTreeIter *gtktree_iter_find_node(GtkTreeIter * parent, - struct menu *tofind) +static GtkTreeIter *gtktree_iter_find_node(GtkTreeIter *parent, + struct menu *tofind) { GtkTreeIter iter; GtkTreeIter *child = &iter; @@ -1423,7 +1422,7 @@ static void display_list(void) tree = tree2; } -void fixup_rootmenu(struct menu *menu) +static void fixup_rootmenu(struct menu *menu) { struct menu *child; static int menu_cnt = 0; diff --git a/xen/tools/kconfig/images.c b/xen/tools/kconfig/images.c index d4f84bd4a96b..b4fa0e4a63a5 100644 --- a/xen/tools/kconfig/images.c +++ b/xen/tools/kconfig/images.c @@ -1,9 +1,11 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) 2002 Roman Zippel - * Released under the terms of the GNU GPL v2.0. */ -static const char *xpm_load[] = { +#include "images.h" + +const char *xpm_load[] = { "22 22 5 1", ". c None", "# c #000000", @@ -33,7 +35,7 @@ static const char *xpm_load[] = { "###############.......", "......................"}; -static const char *xpm_save[] = { +const char *xpm_save[] = { "22 22 5 1", ". c None", "# c #000000", @@ -63,7 +65,7 @@ static const char *xpm_save[] = { "..##################..", "......................"}; -static const char *xpm_back[] = { +const char *xpm_back[] = { "22 22 3 1", ". c None", "# c #000083", @@ -91,7 +93,7 @@ static const char *xpm_back[] = { "......................", "......................"}; -static const char *xpm_tree_view[] = { +const char *xpm_tree_view[] = { "22 22 2 1", ". c None", "# c #000000", @@ -118,7 +120,7 @@ static const char *xpm_tree_view[] = { "......................", "......................"}; -static const char *xpm_single_view[] = { +const char *xpm_single_view[] = { "22 22 2 1", ". c None", "# c #000000", @@ -145,7 +147,7 @@ static const char *xpm_single_view[] = { "......................", "......................"}; -static const char *xpm_split_view[] = { +const char *xpm_split_view[] = { "22 22 2 1", ". c None", "# c #000000", @@ -172,7 +174,7 @@ static const char *xpm_split_view[] = { "......................", "......................"}; -static const char *xpm_symbol_no[] = { +const char *xpm_symbol_no[] = { "12 12 2 1", " c white", ". c black", @@ -189,7 +191,7 @@ static const char *xpm_symbol_no[] = { " .......... ", " "}; -static const char *xpm_symbol_mod[] = { +const char *xpm_symbol_mod[] = { "12 12 2 1", " c white", ". c black", @@ -206,7 +208,7 @@ static const char *xpm_symbol_mod[] = { " .......... ", " "}; -static const char *xpm_symbol_yes[] = { +const char *xpm_symbol_yes[] = { "12 12 2 1", " c white", ". c black", @@ -223,7 +225,7 @@ static const char *xpm_symbol_yes[] = { " .......... ", " "}; -static const char *xpm_choice_no[] = { +const char *xpm_choice_no[] = { "12 12 2 1", " c white", ". c black", @@ -240,7 +242,7 @@ static const char *xpm_choice_no[] = { " .... ", " "}; -static const char *xpm_choice_yes[] = { +const char *xpm_choice_yes[] = { "12 12 2 1", " c white", ". c black", @@ -257,7 +259,7 @@ static const char *xpm_choice_yes[] = { " .... ", " "}; -static const char *xpm_menu[] = { +const char *xpm_menu[] = { "12 12 2 1", " c white", ". c black", @@ -274,7 +276,7 @@ static const char *xpm_menu[] = { " .......... ", " "}; -static const char *xpm_menu_inv[] = { +const char *xpm_menu_inv[] = { "12 12 2 1", " c white", ". c black", @@ -291,7 +293,7 @@ static const char *xpm_menu_inv[] = { " .......... ", " "}; -static const char *xpm_menuback[] = { +const char *xpm_menuback[] = { "12 12 2 1", " c white", ". c black", @@ -308,7 +310,7 @@ static const char *xpm_menuback[] = { " .......... ", " "}; -static const char *xpm_void[] = { +const char *xpm_void[] = { "12 12 2 1", " c white", ". c black", diff --git a/xen/tools/kconfig/images.h b/xen/tools/kconfig/images.h new file mode 100644 index 000000000000..d8ff614bd087 --- /dev/null +++ b/xen/tools/kconfig/images.h @@ -0,0 +1,33 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2002 Roman Zippel + */ + +#ifndef IMAGES_H +#define IMAGES_H + +#ifdef __cplusplus +extern "C" { +#endif + +extern const char *xpm_load[]; +extern const char *xpm_save[]; +extern const char *xpm_back[]; +extern const char *xpm_tree_view[]; +extern const char *xpm_single_view[]; +extern const char *xpm_split_view[]; +extern const char *xpm_symbol_no[]; +extern const char *xpm_symbol_mod[]; +extern const char *xpm_symbol_yes[]; +extern const char *xpm_choice_no[]; +extern const char *xpm_choice_yes[]; +extern const char *xpm_menu[]; +extern const char *xpm_menu_inv[]; +extern const char *xpm_menuback[]; +extern const char *xpm_void[]; + +#ifdef __cplusplus +} +#endif + +#endif /* IMAGES_H */ diff --git a/xen/tools/kconfig/lexer.l b/xen/tools/kconfig/lexer.l new file mode 100644 index 000000000000..6354c905b006 --- /dev/null +++ b/xen/tools/kconfig/lexer.l @@ -0,0 +1,471 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2002 Roman Zippel + */ +%option nostdinit noyywrap never-interactive full ecs +%option 8bit nodefault yylineno +%x ASSIGN_VAL HELP STRING +%{ + +#include +#include +#include +#include +#include +#include + +#include "lkc.h" +#include "parser.tab.h" + +#define YY_DECL static int yylex1(void) + +#define START_STRSIZE 16 + +static struct { + struct file *file; + int lineno; +} current_pos; + +static int prev_prev_token = T_EOL; +static int prev_token = T_EOL; +static char *text; +static int text_size, text_asize; + +struct buffer { + struct buffer *parent; + YY_BUFFER_STATE state; +}; + +struct buffer *current_buf; + +static int last_ts, first_ts; + +static char *expand_token(const char *in, size_t n); +static void append_expanded_string(const char *in); +static void zconf_endhelp(void); +static void zconf_endfile(void); + +static void new_string(void) +{ + text = xmalloc(START_STRSIZE); + text_asize = START_STRSIZE; + text_size = 0; + *text = 0; +} + +static void append_string(const char *str, int size) +{ + int new_size = text_size + size + 1; + if (new_size > text_asize) { + new_size += START_STRSIZE - 1; + new_size &= -START_STRSIZE; + text = xrealloc(text, new_size); + text_asize = new_size; + } + memcpy(text + text_size, str, size); + text_size += size; + text[text_size] = 0; +} + +static void alloc_string(const char *str, int size) +{ + text = xmalloc(size + 1); + memcpy(text, str, size); + text[size] = 0; +} + +static void warn_ignored_character(char chr) +{ + fprintf(stderr, + "%s:%d:warning: ignoring unsupported character '%c'\n", + current_file->name, yylineno, chr); +} +%} + +n [A-Za-z0-9_-] + +%% + int str = 0; + int ts, i; + +#.* /* ignore comment */ +[ \t]* /* whitespaces */ +\\\n /* escaped new line */ +\n return T_EOL; +"allnoconfig_y" return T_ALLNOCONFIG_Y; +"bool" return T_BOOL; +"choice" return T_CHOICE; +"comment" return T_COMMENT; +"config" return T_CONFIG; +"def_bool" return T_DEF_BOOL; +"def_tristate" return T_DEF_TRISTATE; +"default" return T_DEFAULT; +"defconfig_list" return T_DEFCONFIG_LIST; +"depends" return T_DEPENDS; +"endchoice" return T_ENDCHOICE; +"endif" return T_ENDIF; +"endmenu" return T_ENDMENU; +"help"|"---help---" return T_HELP; +"hex" return T_HEX; +"if" return T_IF; +"imply" return T_IMPLY; +"int" return T_INT; +"mainmenu" return T_MAINMENU; +"menu" return T_MENU; +"menuconfig" return T_MENUCONFIG; +"modules" return T_MODULES; +"on" return T_ON; +"option" return T_OPTION; +"optional" return T_OPTIONAL; +"prompt" return T_PROMPT; +"range" return T_RANGE; +"select" return T_SELECT; +"source" return T_SOURCE; +"string" return T_STRING; +"tristate" return T_TRISTATE; +"visible" return T_VISIBLE; +"||" return T_OR; +"&&" return T_AND; +"=" return T_EQUAL; +"!=" return T_UNEQUAL; +"<" return T_LESS; +"<=" return T_LESS_EQUAL; +">" return T_GREATER; +">=" return T_GREATER_EQUAL; +"!" return T_NOT; +"(" return T_OPEN_PAREN; +")" return T_CLOSE_PAREN; +":=" return T_COLON_EQUAL; +"+=" return T_PLUS_EQUAL; +\"|\' { + str = yytext[0]; + new_string(); + BEGIN(STRING); + } +{n}+ { + alloc_string(yytext, yyleng); + yylval.string = text; + return T_WORD; + } +({n}|$)+ { + /* this token includes at least one '$' */ + yylval.string = expand_token(yytext, yyleng); + if (strlen(yylval.string)) + return T_WORD; + free(yylval.string); + } +. warn_ignored_character(*yytext); + +{ + [^[:blank:]\n]+.* { + alloc_string(yytext, yyleng); + yylval.string = text; + return T_ASSIGN_VAL; + } + \n { BEGIN(INITIAL); return T_EOL; } + . +} + +{ + "$".* append_expanded_string(yytext); + [^$'"\\\n]+ { + append_string(yytext, yyleng); + } + \\.? { + append_string(yytext + 1, yyleng - 1); + } + \'|\" { + if (str == yytext[0]) { + BEGIN(INITIAL); + yylval.string = text; + return T_WORD_QUOTE; + } else + append_string(yytext, 1); + } + \n { + fprintf(stderr, + "%s:%d:warning: multi-line strings not supported\n", + zconf_curname(), zconf_lineno()); + unput('\n'); + BEGIN(INITIAL); + yylval.string = text; + return T_WORD_QUOTE; + } + <> { + BEGIN(INITIAL); + yylval.string = text; + return T_WORD_QUOTE; + } +} + +{ + [ \t]+ { + ts = 0; + for (i = 0; i < yyleng; i++) { + if (yytext[i] == '\t') + ts = (ts & ~7) + 8; + else + ts++; + } + last_ts = ts; + if (first_ts) { + if (ts < first_ts) { + zconf_endhelp(); + return T_HELPTEXT; + } + ts -= first_ts; + while (ts > 8) { + append_string(" ", 8); + ts -= 8; + } + append_string(" ", ts); + } + } + [ \t]*\n/[^ \t\n] { + zconf_endhelp(); + return T_HELPTEXT; + } + [ \t]*\n { + append_string("\n", 1); + } + [^ \t\n].* { + while (yyleng) { + if ((yytext[yyleng-1] != ' ') && (yytext[yyleng-1] != '\t')) + break; + yyleng--; + } + append_string(yytext, yyleng); + if (!first_ts) + first_ts = last_ts; + } + <> { + zconf_endhelp(); + return T_HELPTEXT; + } +} + +<> { + BEGIN(INITIAL); + + if (prev_token != T_EOL && prev_token != T_HELPTEXT) + fprintf(stderr, "%s:%d:warning: no new line at end of file\n", + current_file->name, yylineno); + + if (current_file) { + zconf_endfile(); + return T_EOL; + } + fclose(yyin); + yyterminate(); +} + +%% + +/* second stage lexer */ +int yylex(void) +{ + int token; + +repeat: + token = yylex1(); + + if (prev_token == T_EOL || prev_token == T_HELPTEXT) { + if (token == T_EOL) { + /* Do not pass unneeded T_EOL to the parser. */ + goto repeat; + } else { + /* + * For the parser, update file/lineno at the first token + * of each statement. Generally, \n is a statement + * terminator in Kconfig, but it is not always true + * because \n could be escaped by a backslash. + */ + current_pos.file = current_file; + current_pos.lineno = yylineno; + } + } + + if (prev_prev_token == T_EOL && prev_token == T_WORD && + (token == T_EQUAL || token == T_COLON_EQUAL || token == T_PLUS_EQUAL)) + BEGIN(ASSIGN_VAL); + + prev_prev_token = prev_token; + prev_token = token; + + return token; +} + +static char *expand_token(const char *in, size_t n) +{ + char *out; + int c; + char c2; + const char *rest, *end; + + new_string(); + append_string(in, n); + + /* get the whole line because we do not know the end of token. */ + while ((c = input()) != EOF) { + if (c == '\n') { + unput(c); + break; + } + c2 = c; + append_string(&c2, 1); + } + + rest = text; + out = expand_one_token(&rest); + + /* push back unused characters to the input stream */ + end = rest + strlen(rest); + while (end > rest) + unput(*--end); + + free(text); + + return out; +} + +static void append_expanded_string(const char *str) +{ + const char *end; + char *res; + + str++; + + res = expand_dollar(&str); + + /* push back unused characters to the input stream */ + end = str + strlen(str); + while (end > str) + unput(*--end); + + append_string(res, strlen(res)); + + free(res); +} + +void zconf_starthelp(void) +{ + new_string(); + last_ts = first_ts = 0; + BEGIN(HELP); +} + +static void zconf_endhelp(void) +{ + yylval.string = text; + BEGIN(INITIAL); +} + + +/* + * Try to open specified file with following names: + * ./name + * $(srctree)/name + * The latter is used when srctree is separate from objtree + * when compiling the kernel. + * Return NULL if file is not found. + */ +FILE *zconf_fopen(const char *name) +{ + char *env, fullname[PATH_MAX+1]; + FILE *f; + + f = fopen(name, "r"); + if (!f && name != NULL && name[0] != '/') { + env = getenv(SRCTREE); + if (env) { + snprintf(fullname, sizeof(fullname), + "%s/%s", env, name); + f = fopen(fullname, "r"); + } + } + return f; +} + +void zconf_initscan(const char *name) +{ + yyin = zconf_fopen(name); + if (!yyin) { + fprintf(stderr, "can't find file %s\n", name); + exit(1); + } + + current_buf = xmalloc(sizeof(*current_buf)); + memset(current_buf, 0, sizeof(*current_buf)); + + current_file = file_lookup(name); + yylineno = 1; +} + +void zconf_nextfile(const char *name) +{ + struct file *iter; + struct file *file = file_lookup(name); + struct buffer *buf = xmalloc(sizeof(*buf)); + memset(buf, 0, sizeof(*buf)); + + current_buf->state = YY_CURRENT_BUFFER; + yyin = zconf_fopen(file->name); + if (!yyin) { + fprintf(stderr, "%s:%d: can't open file \"%s\"\n", + zconf_curname(), zconf_lineno(), file->name); + exit(1); + } + yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE)); + buf->parent = current_buf; + current_buf = buf; + + current_file->lineno = yylineno; + file->parent = current_file; + + for (iter = current_file; iter; iter = iter->parent) { + if (!strcmp(iter->name, file->name)) { + fprintf(stderr, + "Recursive inclusion detected.\n" + "Inclusion path:\n" + " current file : %s\n", file->name); + iter = file; + do { + iter = iter->parent; + fprintf(stderr, " included from: %s:%d\n", + iter->name, iter->lineno - 1); + } while (strcmp(iter->name, file->name)); + exit(1); + } + } + + yylineno = 1; + current_file = file; +} + +static void zconf_endfile(void) +{ + struct buffer *parent; + + current_file = current_file->parent; + if (current_file) + yylineno = current_file->lineno; + + parent = current_buf->parent; + if (parent) { + fclose(yyin); + yy_delete_buffer(YY_CURRENT_BUFFER); + yy_switch_to_buffer(parent->state); + } + free(current_buf); + current_buf = parent; +} + +int zconf_lineno(void) +{ + return current_pos.lineno; +} + +const char *zconf_curname(void) +{ + return current_pos.file ? current_pos.file->name : ""; +} diff --git a/xen/tools/kconfig/list.h b/xen/tools/kconfig/list.h index 2cf23f002d3f..45cb237ab7ef 100644 --- a/xen/tools/kconfig/list.h +++ b/xen/tools/kconfig/list.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef LIST_H #define LIST_H diff --git a/xen/tools/kconfig/lkc.h b/xen/tools/kconfig/lkc.h index bbc850cee12e..4fb16f316626 100644 --- a/xen/tools/kconfig/lkc.h +++ b/xen/tools/kconfig/lkc.h @@ -1,6 +1,6 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* * Copyright (C) 2002 Roman Zippel - * Released under the terms of the GNU GPL v2.0. */ #ifndef LKC_H @@ -30,10 +30,6 @@ static inline const char *CONFIG_prefix(void) #undef CONFIG_ #define CONFIG_ CONFIG_prefix() -#define TF_COMMAND 0x0001 -#define TF_PARAM 0x0002 -#define TF_OPTION 0x0004 - enum conf_def_mode { def_default, def_yes, @@ -42,18 +38,7 @@ enum conf_def_mode { def_random }; -#define T_OPT_MODULES 1 -#define T_OPT_DEFCONFIG_LIST 2 -#define T_OPT_ENV 3 -#define T_OPT_ALLNOCONFIG_Y 4 - -struct kconf_id { - int name; - int token; - unsigned int flags; - enum symbol_type stype; -}; - +extern int yylineno; void zconfdump(FILE *out); void zconf_starthelp(void); FILE *zconf_fopen(const char *name); @@ -64,8 +49,6 @@ const char *zconf_curname(void); /* confdata.c */ const char *conf_get_configname(void); -const char *conf_get_autoconfig_name(void); -char *conf_get_default_confname(void); void sym_set_change_count(int count); void sym_add_change_count(int count); bool conf_set_all_new_symbols(enum conf_def_mode mode); @@ -86,21 +69,27 @@ void menu_warn(struct menu *menu, const char *fmt, ...); struct menu *menu_add_menu(void); void menu_end_menu(void); void menu_add_entry(struct symbol *sym); -void menu_end_entry(void); void menu_add_dep(struct expr *dep); void menu_add_visibility(struct expr *dep); struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep); void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep); void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep); -void menu_add_option(int token, char *arg); +void menu_add_option_modules(void); +void menu_add_option_defconfig_list(void); +void menu_add_option_allnoconfig_y(void); void menu_finalize(struct menu *parent); void menu_set_type(int type); /* util.c */ struct file *file_lookup(const char *name); -int file_write_dep(const char *name); void *xmalloc(size_t size); void *xcalloc(size_t nmemb, size_t size); +void *xrealloc(void *p, size_t size); +char *xstrdup(const char *s); +char *xstrndup(const char *s, size_t n); + +/* lexer.l */ +int yylex(void); struct gstr { size_t len; @@ -118,16 +107,13 @@ void str_printf(struct gstr *gs, const char *fmt, ...); const char *str_get(struct gstr *gs); /* symbol.c */ -extern struct expr *sym_env_list; - -void sym_init(void); void sym_clear_all_valid(void); struct symbol *sym_choice_default(struct symbol *sym); +struct property *sym_get_range_prop(struct symbol *sym); const char *sym_get_string_default(struct symbol *sym); struct symbol *sym_check_deps(struct symbol *sym); struct property *prop_alloc(enum prop_type type, struct symbol *sym); struct symbol *prop_get_symbol(struct property *prop); -struct property *sym_get_env_prop(struct symbol *sym); static inline tristate sym_get_tristate_value(struct symbol *sym) { diff --git a/xen/tools/kconfig/lkc_proto.h b/xen/tools/kconfig/lkc_proto.h index d5398718ec2a..f9ab98238aef 100644 --- a/xen/tools/kconfig/lkc_proto.h +++ b/xen/tools/kconfig/lkc_proto.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */ #include /* confdata.c */ @@ -6,10 +7,10 @@ int conf_read(const char *name); int conf_read_simple(const char *name, int); int conf_write_defconfig(const char *name); int conf_write(const char *name); -int conf_write_autoconf(void); +int conf_write_autoconf(int overwrite); bool conf_get_changed(void); void conf_set_changed_callback(void (*fn)(void)); -void conf_set_message_callback(void (*fn)(const char *fmt, va_list ap)); +void conf_set_message_callback(void (*fn)(const char *s)); /* menu.c */ extern struct menu rootmenu; @@ -30,7 +31,6 @@ extern struct symbol * symbol_hash[SYMBOL_HASHSIZE]; struct symbol * sym_lookup(const char *name, int flags); struct symbol * sym_find(const char *name); -const char * sym_expand_string_value(const char *in); const char * sym_escape_string_value(const char *in); struct symbol ** sym_re_search(const char *pattern); const char * sym_type_name(enum symbol_type type); @@ -42,11 +42,24 @@ tristate sym_toggle_tristate_value(struct symbol *sym); bool sym_string_valid(struct symbol *sym, const char *newval); bool sym_string_within_range(struct symbol *sym, const char *str); bool sym_set_string_value(struct symbol *sym, const char *newval); -bool sym_is_changable(struct symbol *sym); +bool sym_is_changeable(struct symbol *sym); struct property * sym_get_choice_prop(struct symbol *sym); const char * sym_get_string_value(struct symbol *sym); const char * prop_get_type_name(enum prop_type type); +/* preprocess.c */ +enum variable_flavor { + VAR_SIMPLE, + VAR_RECURSIVE, + VAR_APPEND, +}; +void env_write_dep(FILE *f, const char *auto_conf_name); +void variable_add(const char *name, const char *value, + enum variable_flavor flavor); +void variable_all_del(void); +char *expand_dollar(const char **str); +char *expand_one_token(const char **str); + /* expr.c */ void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken); diff --git a/xen/tools/kconfig/lxdialog/.gitignore b/xen/tools/kconfig/lxdialog/.gitignore deleted file mode 100644 index 90b08ff025a6..000000000000 --- a/xen/tools/kconfig/lxdialog/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -# -# Generated files -# -lxdialog diff --git a/xen/tools/kconfig/lxdialog/BIG.FAT.WARNING b/xen/tools/kconfig/lxdialog/BIG.FAT.WARNING index a8999d82bdb3..7cb5a7ec93d2 100644 --- a/xen/tools/kconfig/lxdialog/BIG.FAT.WARNING +++ b/xen/tools/kconfig/lxdialog/BIG.FAT.WARNING @@ -1,4 +1,4 @@ This is NOT the official version of dialog. This version has been significantly modified from the original. It is for use by the Linux -kernel configuration script. Please do not bother Savio Lam with +kernel configuration script. Please do not bother Savio Lam with questions about this program. diff --git a/xen/tools/kconfig/lxdialog/check-lxdialog.sh b/xen/tools/kconfig/lxdialog/check-lxdialog.sh deleted file mode 100755 index 5075ebf2d3b9..000000000000 --- a/xen/tools/kconfig/lxdialog/check-lxdialog.sh +++ /dev/null @@ -1,91 +0,0 @@ -#!/bin/sh -# Check ncurses compatibility - -# What library to link -ldflags() -{ - pkg-config --libs ncursesw 2>/dev/null && exit - pkg-config --libs ncurses 2>/dev/null && exit - for ext in so a dll.a dylib ; do - for lib in ncursesw ncurses curses ; do - $cc -print-file-name=lib${lib}.${ext} | grep -q / - if [ $? -eq 0 ]; then - echo "-l${lib}" - exit - fi - done - done - exit 1 -} - -# Where is ncurses.h? -ccflags() -{ - if pkg-config --cflags ncursesw 2>/dev/null; then - echo '-DCURSES_LOC="" -DNCURSES_WIDECHAR=1' - elif pkg-config --cflags ncurses 2>/dev/null; then - echo '-DCURSES_LOC=""' - elif [ -f /usr/include/ncursesw/curses.h ]; then - echo '-I/usr/include/ncursesw -DCURSES_LOC=""' - echo ' -DNCURSES_WIDECHAR=1' - elif [ -f /usr/include/ncurses/ncurses.h ]; then - echo '-I/usr/include/ncurses -DCURSES_LOC=""' - elif [ -f /usr/include/ncurses/curses.h ]; then - echo '-I/usr/include/ncurses -DCURSES_LOC=""' - elif [ -f /usr/include/ncurses.h ]; then - echo '-DCURSES_LOC=""' - else - echo '-DCURSES_LOC=""' - fi -} - -# Temp file, try to clean up after us -tmp=.lxdialog.tmp -trap "rm -f $tmp" 0 1 2 3 15 - -# Check if we can link to ncurses -check() { - $cc -x c - -o $tmp 2>/dev/null <<'EOF' -#include CURSES_LOC -main() {} -EOF - if [ $? != 0 ]; then - echo " *** Unable to find the ncurses libraries or the" 1>&2 - echo " *** required header files." 1>&2 - echo " *** 'make menuconfig' requires the ncurses libraries." 1>&2 - echo " *** " 1>&2 - echo " *** Install ncurses (ncurses-devel) and try again." 1>&2 - echo " *** " 1>&2 - exit 1 - fi -} - -usage() { - printf "Usage: $0 [-check compiler options|-ccflags|-ldflags compiler options]\n" -} - -if [ $# -eq 0 ]; then - usage - exit 1 -fi - -cc="" -case "$1" in - "-check") - shift - cc="$@" - check - ;; - "-ccflags") - ccflags - ;; - "-ldflags") - shift - cc="$@" - ldflags - ;; - "*") - usage - exit 1 - ;; -esac diff --git a/xen/tools/kconfig/lxdialog/checklist.c b/xen/tools/kconfig/lxdialog/checklist.c index 2e96323ad11b..fd161cfff121 100644 --- a/xen/tools/kconfig/lxdialog/checklist.c +++ b/xen/tools/kconfig/lxdialog/checklist.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * checklist.c -- implements the checklist box * @@ -5,20 +6,6 @@ * Stuart Herbert - S.Herbert@sheffield.ac.uk: radiolist extension * Alessandro Rubini - rubini@ipvvis.unipv.it: merged the two * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "dialog.h" diff --git a/xen/tools/kconfig/lxdialog/dialog.h b/xen/tools/kconfig/lxdialog/dialog.h index cc22e5a90e7e..68b565e3c495 100644 --- a/xen/tools/kconfig/lxdialog/dialog.h +++ b/xen/tools/kconfig/lxdialog/dialog.h @@ -1,21 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ /* * dialog.h -- common declarations for all dialog modules * * AUTHOR: Savio Lam (lam836@cs.cuhk.hk) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include @@ -29,7 +16,7 @@ #ifdef __sun__ #define CURS_MACROS #endif -#include CURSES_LOC +#include /* * Colors in ncurses 1.9.9e do not work properly since foreground and diff --git a/xen/tools/kconfig/lxdialog/inputbox.c b/xen/tools/kconfig/lxdialog/inputbox.c index fe82ff6d744e..1dcfb288ee63 100644 --- a/xen/tools/kconfig/lxdialog/inputbox.c +++ b/xen/tools/kconfig/lxdialog/inputbox.c @@ -1,22 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * inputbox.c -- implements the input box * * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "dialog.h" @@ -126,7 +113,8 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width case KEY_DOWN: break; case KEY_BACKSPACE: - case 127: + case 8: /* ^H */ + case 127: /* ^? */ if (pos) { wattrset(dialog, dlg.inputbox.atr); if (input_x == 0) { diff --git a/xen/tools/kconfig/lxdialog/menubox.c b/xen/tools/kconfig/lxdialog/menubox.c index d70cab36137e..58c2f8afe59b 100644 --- a/xen/tools/kconfig/lxdialog/menubox.c +++ b/xen/tools/kconfig/lxdialog/menubox.c @@ -1,22 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * menubox.c -- implements the menu box * * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcapw@cfw.com) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* diff --git a/xen/tools/kconfig/lxdialog/textbox.c b/xen/tools/kconfig/lxdialog/textbox.c index 88d2818ed956..4e339b12664e 100644 --- a/xen/tools/kconfig/lxdialog/textbox.c +++ b/xen/tools/kconfig/lxdialog/textbox.c @@ -1,22 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * textbox.c -- implements the text box * * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "dialog.h" diff --git a/xen/tools/kconfig/lxdialog/util.c b/xen/tools/kconfig/lxdialog/util.c index f7abdeb92af0..1b490d4af0d3 100644 --- a/xen/tools/kconfig/lxdialog/util.c +++ b/xen/tools/kconfig/lxdialog/util.c @@ -1,22 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * util.c * * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include diff --git a/xen/tools/kconfig/lxdialog/yesno.c b/xen/tools/kconfig/lxdialog/yesno.c index cd1223c903d1..bcaac9b7bab2 100644 --- a/xen/tools/kconfig/lxdialog/yesno.c +++ b/xen/tools/kconfig/lxdialog/yesno.c @@ -1,22 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * yesno.c -- implements the yes/no box * * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "dialog.h" diff --git a/xen/tools/kconfig/mconf-cfg.sh b/xen/tools/kconfig/mconf-cfg.sh new file mode 100755 index 000000000000..c812872d7f9d --- /dev/null +++ b/xen/tools/kconfig/mconf-cfg.sh @@ -0,0 +1,47 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 + +PKG="ncursesw" +PKG2="ncurses" + +if [ -n "$(command -v pkg-config)" ]; then + if pkg-config --exists $PKG; then + echo cflags=\"$(pkg-config --cflags $PKG)\" + echo libs=\"$(pkg-config --libs $PKG)\" + exit 0 + fi + + if pkg-config --exists $PKG2; then + echo cflags=\"$(pkg-config --cflags $PKG2)\" + echo libs=\"$(pkg-config --libs $PKG2)\" + exit 0 + fi +fi + +# Check the default paths in case pkg-config is not installed. +# (Even if it is installed, some distributions such as openSUSE cannot +# find ncurses by pkg-config.) +if [ -f /usr/include/ncursesw/ncurses.h ]; then + echo cflags=\"-D_GNU_SOURCE -I/usr/include/ncursesw\" + echo libs=\"-lncursesw\" + exit 0 +fi + +if [ -f /usr/include/ncurses/ncurses.h ]; then + echo cflags=\"-D_GNU_SOURCE -I/usr/include/ncurses\" + echo libs=\"-lncurses\" + exit 0 +fi + +if [ -f /usr/include/ncurses.h ]; then + echo cflags=\"-D_GNU_SOURCE\" + echo libs=\"-lncurses\" + exit 0 +fi + +echo >&2 "*" +echo >&2 "* Unable to find the ncurses package." +echo >&2 "* Install ncurses (ncurses-devel or libncurses-dev" +echo >&2 "* depending on your distribution)." +echo >&2 "*" +exit 1 diff --git a/xen/tools/kconfig/mconf.c b/xen/tools/kconfig/mconf.c index 2489af60b929..49c26ea9dd98 100644 --- a/xen/tools/kconfig/mconf.c +++ b/xen/tools/kconfig/mconf.c @@ -1,6 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) 2002 Roman Zippel - * Released under the terms of the GNU GPL v2.0. * * Introduced single menu mode (show all sub-menus in one large tree). * 2002-11-06 Petr Baudis @@ -245,7 +245,7 @@ search_help[] = " Selected by: BAR [=n]\n" "-----------------------------------------------------------------\n" "o The line 'Type:' shows the type of the configuration option for\n" - " this symbol (boolean, tristate, string, ...)\n" + " this symbol (bool, tristate, string, ...)\n" "o The line 'Prompt:' shows the text used in the menu structure for\n" " this symbol\n" "o The 'Defined at' line tells at what file / line number the symbol\n" @@ -490,7 +490,6 @@ static void build_conf(struct menu *menu) switch (prop->type) { case P_MENU: child_count++; - prompt = prompt; if (single_menu_mode) { item_make("%s%*c%s", menu->data ? "-->" : "++>", @@ -537,7 +536,7 @@ static void build_conf(struct menu *menu) } val = sym_get_tristate_value(sym); - if (sym_is_changable(sym)) { + if (sym_is_changeable(sym)) { switch (type) { case S_BOOLEAN: item_make("[%c]", val == no ? ' ' : '*'); @@ -588,7 +587,7 @@ static void build_conf(struct menu *menu) } else { switch (type) { case S_BOOLEAN: - if (sym_is_changable(sym)) + if (sym_is_changeable(sym)) item_make("[%c]", val == no ? ' ' : '*'); else item_make("-%c-", val == no ? ' ' : '*'); @@ -601,7 +600,7 @@ static void build_conf(struct menu *menu) case mod: ch = 'M'; break; default: ch = ' '; break; } - if (sym_is_changable(sym)) { + if (sym_is_changeable(sym)) { if (sym->rev_dep.tri == mod) item_make("{%c}", ch); else @@ -618,7 +617,7 @@ static void build_conf(struct menu *menu) if (tmp < 0) tmp = 0; item_add_str("%*c%s%s", tmp, ' ', menu_get_prompt(menu), - (sym_has_value(sym) || !sym_is_changable(sym)) ? + (sym_has_value(sym) || !sym_is_changeable(sym)) ? "" : " (NEW)"); item_set_tag('s'); item_set_data(menu); @@ -626,7 +625,7 @@ static void build_conf(struct menu *menu) } } item_add_str("%*c%s%s", indent + 1, ' ', menu_get_prompt(menu), - (sym_has_value(sym) || !sym_is_changable(sym)) ? + (sym_has_value(sym) || !sym_is_changeable(sym)) ? "" : " (NEW)"); if (menu->prompt->type == P_MENU) { item_add_str(" %s", menu_is_empty(menu) ? "----" : "--->"); @@ -772,16 +771,13 @@ static void show_helptext(const char *title, const char *text) show_textbox(title, text, 0, 0); } -static void conf_message_callback(const char *fmt, va_list ap) +static void conf_message_callback(const char *s) { - char buf[PATH_MAX+1]; - - vsnprintf(buf, sizeof(buf), fmt, ap); if (save_and_exit) { if (!silent) - printf("%s", buf); + printf("%s", s); } else { - show_textbox(NULL, buf, 6, 60); + show_textbox(NULL, s, 6, 60); } } @@ -940,7 +936,7 @@ static void conf_save(void) set_config_filename(dialog_input_result); return; } - show_textbox(NULL, "Can't create file! Probably a nonexistent directory.", 5, 60); + show_textbox(NULL, "Can't create file!", 5, 60); break; case 1: show_helptext("Save Alternate Configuration", save_config_help); @@ -977,6 +973,7 @@ static int handle_exit(void) "\n\n"); return 1; } + conf_write_autoconf(0); /* fall through */ case -1: if (!silent) diff --git a/xen/tools/kconfig/menu.c b/xen/tools/kconfig/menu.c index 71d31f2bf619..d9d16469859a 100644 --- a/xen/tools/kconfig/menu.c +++ b/xen/tools/kconfig/menu.c @@ -1,6 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) 2002 Roman Zippel - * Released under the terms of the GNU GPL v2.0. */ #include @@ -62,13 +62,8 @@ void menu_add_entry(struct symbol *sym) menu_add_symbol(P_SYMBOL, sym, NULL); } -void menu_end_entry(void) -{ -} - struct menu *menu_add_menu(void) { - menu_end_entry(); last_entry_ptr = ¤t_entry->list; return current_menu = current_entry; } @@ -79,19 +74,23 @@ void menu_end_menu(void) current_menu = current_menu->parent; } -static struct expr *menu_check_dep(struct expr *e) +/* + * Rewrites 'm' to 'm' && MODULES, so that it evaluates to 'n' when running + * without modules + */ +static struct expr *rewrite_m(struct expr *e) { if (!e) return e; switch (e->type) { case E_NOT: - e->left.expr = menu_check_dep(e->left.expr); + e->left.expr = rewrite_m(e->left.expr); break; case E_OR: case E_AND: - e->left.expr = menu_check_dep(e->left.expr); - e->right.expr = menu_check_dep(e->right.expr); + e->left.expr = rewrite_m(e->left.expr); + e->right.expr = rewrite_m(e->right.expr); break; case E_SYMBOL: /* change 'm' into 'm' && MODULES */ @@ -106,7 +105,7 @@ static struct expr *menu_check_dep(struct expr *e) void menu_add_dep(struct expr *dep) { - current_entry->dep = expr_alloc_and(current_entry->dep, menu_check_dep(dep)); + current_entry->dep = expr_alloc_and(current_entry->dep, dep); } void menu_set_type(int type) @@ -131,7 +130,7 @@ static struct property *menu_add_prop(enum prop_type type, char *prompt, struct prop->menu = current_entry; prop->expr = expr; - prop->visible.expr = menu_check_dep(dep); + prop->visible.expr = dep; if (prompt) { if (isspace(*prompt)) { @@ -196,31 +195,26 @@ void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep) menu_add_prop(type, NULL, expr_alloc_symbol(sym), dep); } -void menu_add_option(int token, char *arg) +void menu_add_option_modules(void) { - switch (token) { - case T_OPT_MODULES: - if (modules_sym) - zconf_error("symbol '%s' redefines option 'modules'" - " already defined by symbol '%s'", - current_entry->sym->name, - modules_sym->name - ); - modules_sym = current_entry->sym; - break; - case T_OPT_DEFCONFIG_LIST: - if (!sym_defconfig_list) - sym_defconfig_list = current_entry->sym; - else if (sym_defconfig_list != current_entry->sym) - zconf_error("trying to redefine defconfig symbol"); - break; - case T_OPT_ENV: - prop_add_env(arg); - break; - case T_OPT_ALLNOCONFIG_Y: - current_entry->sym->flags |= SYMBOL_ALLNOCONFIG_Y; - break; - } + if (modules_sym) + zconf_error("symbol '%s' redefines option 'modules' already defined by symbol '%s'", + current_entry->sym->name, modules_sym->name); + modules_sym = current_entry->sym; +} + +void menu_add_option_defconfig_list(void) +{ + if (!sym_defconfig_list) + sym_defconfig_list = current_entry->sym; + else if (sym_defconfig_list != current_entry->sym) + zconf_error("trying to redefine defconfig symbol"); + sym_defconfig_list->flags |= SYMBOL_NO_WRITE; +} + +void menu_add_option_allnoconfig_y(void) +{ + current_entry->sym->flags |= SYMBOL_ALLNOCONFIG_Y; } static int menu_validate_number(struct symbol *sym, struct symbol *sym2) @@ -233,6 +227,8 @@ static void sym_check_prop(struct symbol *sym) { struct property *prop; struct symbol *sym2; + char *use; + for (prop = sym->prop; prop; prop = prop->next) { switch (prop->type) { case P_DEFAULT: @@ -250,20 +246,32 @@ static void sym_check_prop(struct symbol *sym) "'%s': number is invalid", sym->name); } + if (sym_is_choice(sym)) { + struct property *choice_prop = + sym_get_choice_prop(sym2); + + if (!choice_prop || + prop_get_symbol(choice_prop) != sym) + prop_warn(prop, + "choice default symbol '%s' is not contained in the choice", + sym2->name); + } break; case P_SELECT: + case P_IMPLY: + use = prop->type == P_SELECT ? "select" : "imply"; sym2 = prop_get_symbol(prop); if (sym->type != S_BOOLEAN && sym->type != S_TRISTATE) prop_warn(prop, - "config symbol '%s' uses select, but is " - "not boolean or tristate", sym->name); + "config symbol '%s' uses %s, but is " + "not bool or tristate", sym->name, use); else if (sym2->type != S_UNKNOWN && sym2->type != S_BOOLEAN && sym2->type != S_TRISTATE) prop_warn(prop, - "'%s' has wrong type. 'select' only " - "accept arguments of boolean and " - "tristate type", sym2->name); + "'%s' has wrong type. '%s' only " + "accept arguments of bool and " + "tristate type", sym2->name, use); break; case P_RANGE: if (sym->type != S_INT && sym->type != S_HEX) @@ -288,6 +296,11 @@ void menu_finalize(struct menu *parent) sym = parent->sym; if (parent->list) { + /* + * This menu node has children. We (recursively) process them + * and propagate parent dependencies before moving on. + */ + if (sym && sym_is_choice(sym)) { if (sym->type == S_UNKNOWN) { /* find the first choice value to find out choice type */ @@ -305,65 +318,169 @@ void menu_finalize(struct menu *parent) if (menu->sym && menu->sym->type == S_UNKNOWN) menu_set_type(sym->type); } + + /* + * Use the choice itself as the parent dependency of + * the contained items. This turns the mode of the + * choice into an upper bound on the visibility of the + * choice value symbols. + */ parentdep = expr_alloc_symbol(sym); } else if (parent->prompt) + /* Menu node for 'menu' */ parentdep = parent->prompt->visible.expr; else + /* Menu node for 'if' */ parentdep = parent->dep; + /* For each child menu node... */ for (menu = parent->list; menu; menu = menu->next) { - basedep = expr_transform(menu->dep); + /* + * Propagate parent dependencies to the child menu + * node, also rewriting and simplifying expressions + */ + basedep = rewrite_m(menu->dep); + basedep = expr_transform(basedep); basedep = expr_alloc_and(expr_copy(parentdep), basedep); basedep = expr_eliminate_dups(basedep); menu->dep = basedep; + if (menu->sym) + /* + * Note: For symbols, all prompts are included + * too in the symbol's own property list + */ prop = menu->sym->prop; else + /* + * For non-symbol menu nodes, we just need to + * handle the prompt + */ prop = menu->prompt; + + /* For each property... */ for (; prop; prop = prop->next) { if (prop->menu != menu) + /* + * Two possibilities: + * + * 1. The property lacks dependencies + * and so isn't location-specific, + * e.g. an 'option' + * + * 2. The property belongs to a symbol + * defined in multiple locations and + * is from some other location. It + * will be handled there in that + * case. + * + * Skip the property. + */ continue; - dep = expr_transform(prop->visible.expr); + + /* + * Propagate parent dependencies to the + * property's condition, rewriting and + * simplifying expressions at the same time + */ + dep = rewrite_m(prop->visible.expr); + dep = expr_transform(dep); dep = expr_alloc_and(expr_copy(basedep), dep); dep = expr_eliminate_dups(dep); if (menu->sym && menu->sym->type != S_TRISTATE) dep = expr_trans_bool(dep); prop->visible.expr = dep; + + /* + * Handle selects and implies, which modify the + * dependencies of the selected/implied symbol + */ if (prop->type == P_SELECT) { struct symbol *es = prop_get_symbol(prop); es->rev_dep.expr = expr_alloc_or(es->rev_dep.expr, expr_alloc_and(expr_alloc_symbol(menu->sym), expr_copy(dep))); + } else if (prop->type == P_IMPLY) { + struct symbol *es = prop_get_symbol(prop); + es->implied.expr = expr_alloc_or(es->implied.expr, + expr_alloc_and(expr_alloc_symbol(menu->sym), expr_copy(dep))); } } } + + if (sym && sym_is_choice(sym)) + expr_free(parentdep); + + /* + * Recursively process children in the same fashion before + * moving on + */ for (menu = parent->list; menu; menu = menu->next) menu_finalize(menu); } else if (sym) { + /* + * Automatic submenu creation. If sym is a symbol and A, B, C, + * ... are consecutive items (symbols, menus, ifs, etc.) that + * all depend on sym, then the following menu structure is + * created: + * + * sym + * +-A + * +-B + * +-C + * ... + * + * This also works recursively, giving the following structure + * if A is a symbol and B depends on A: + * + * sym + * +-A + * | +-B + * +-C + * ... + */ + basedep = parent->prompt ? parent->prompt->visible.expr : NULL; basedep = expr_trans_compare(basedep, E_UNEQUAL, &symbol_no); basedep = expr_eliminate_dups(expr_transform(basedep)); + + /* Examine consecutive elements after sym */ last_menu = NULL; for (menu = parent->next; menu; menu = menu->next) { dep = menu->prompt ? menu->prompt->visible.expr : menu->dep; if (!expr_contains_symbol(dep, sym)) + /* No dependency, quit */ break; if (expr_depends_symbol(dep, sym)) + /* Absolute dependency, put in submenu */ goto next; + + /* + * Also consider it a dependency on sym if our + * dependencies contain sym and are a "superset" of + * sym's dependencies, e.g. '(sym || Q) && R' when sym + * depends on R. + * + * Note that 'R' might be from an enclosing menu or if, + * making this a more common case than it might seem. + */ dep = expr_trans_compare(dep, E_UNEQUAL, &symbol_no); dep = expr_eliminate_dups(expr_transform(dep)); dep2 = expr_copy(basedep); expr_eliminate_eq(&dep, &dep2); expr_free(dep); if (!expr_is_yes(dep2)) { + /* Not superset, quit */ expr_free(dep2); break; } + /* Superset, put in submenu */ expr_free(dep2); next: menu_finalize(menu); menu->parent = parent; last_menu = menu; } + expr_free(basedep); if (last_menu) { parent->list = parent->next; parent->next = last_menu->next; @@ -412,6 +529,35 @@ void menu_finalize(struct menu *parent) *ep = expr_alloc_one(E_LIST, NULL); (*ep)->right.sym = menu->sym; } + + /* + * This code serves two purposes: + * + * (1) Flattening 'if' blocks, which do not specify a submenu + * and only add dependencies. + * + * (Automatic submenu creation might still create a submenu + * from an 'if' before this code runs.) + * + * (2) "Undoing" any automatic submenus created earlier below + * promptless symbols. + * + * Before: + * + * A + * if ... (or promptless symbol) + * +-B + * +-C + * D + * + * After: + * + * A + * if ... (or promptless symbol) + * B + * C + * D + */ if (menu->list && (!menu->prompt || !menu->prompt->text)) { for (last_menu = menu->list; ; last_menu = last_menu->next) { last_menu->parent = parent; @@ -436,6 +582,15 @@ void menu_finalize(struct menu *parent) sym->flags |= SYMBOL_WARNED; } + /* + * For non-optional choices, add a reverse dependency (corresponding to + * a select) of ' && m'. This prevents the user from + * setting the choice mode to 'n' when the choice is visible. + * + * This would also work for non-choice symbols, but only non-optional + * choices clear SYMBOL_OPTIONAL as of writing. Choices are implemented + * as a type of symbol. + */ if (sym && !sym_is_optional(sym) && parent->prompt) { sym->rev_dep.expr = expr_alloc_or(sym->rev_dep.expr, expr_alloc_and(parent->prompt->visible.expr, @@ -477,7 +632,7 @@ bool menu_is_visible(struct menu *menu) if (menu->visibility) { if (expr_calc_value(menu->visibility) == no) - return no; + return false; } sym = menu->sym; @@ -612,13 +767,30 @@ static struct property *get_symbol_prop(struct symbol *sym) return prop; } +static void get_symbol_props_str(struct gstr *r, struct symbol *sym, + enum prop_type tok, const char *prefix) +{ + bool hit = false; + struct property *prop; + + for_all_properties(sym, prop, tok) { + if (!hit) { + str_append(r, prefix); + hit = true; + } else + str_printf(r, " && "); + expr_gstr_print(prop->expr, r); + } + if (hit) + str_append(r, "\n"); +} + /* * head is optional and may be NULL */ static void get_symbol_str(struct gstr *r, struct symbol *sym, struct list_head *head) { - bool hit; struct property *prop; if (sym && sym->name) { @@ -648,22 +820,20 @@ static void get_symbol_str(struct gstr *r, struct symbol *sym, } } - hit = false; - for_all_properties(sym, prop, P_SELECT) { - if (!hit) { - str_append(r, " Selects: "); - hit = true; - } else - str_printf(r, " && "); - expr_gstr_print(prop->expr, r); - } - if (hit) - str_append(r, "\n"); + get_symbol_props_str(r, sym, P_SELECT, " Selects: "); if (sym->rev_dep.expr) { - str_append(r, " Selected by: "); - expr_gstr_print(sym->rev_dep.expr, r); - str_append(r, "\n"); + expr_gstr_print_revdep(sym->rev_dep.expr, r, yes, " Selected by [y]:\n"); + expr_gstr_print_revdep(sym->rev_dep.expr, r, mod, " Selected by [m]:\n"); + expr_gstr_print_revdep(sym->rev_dep.expr, r, no, " Selected by [n]:\n"); + } + + get_symbol_props_str(r, sym, P_IMPLY, " Implies: "); + if (sym->implied.expr) { + expr_gstr_print_revdep(sym->implied.expr, r, yes, " Implied by [y]:\n"); + expr_gstr_print_revdep(sym->implied.expr, r, mod, " Implied by [m]:\n"); + expr_gstr_print_revdep(sym->implied.expr, r, no, " Implied by [n]:\n"); } + str_append(r, "\n\n"); } diff --git a/xen/tools/kconfig/merge_config.sh b/xen/tools/kconfig/merge_config.sh index 0d883b37882a..d924c51d28b7 100755 --- a/xen/tools/kconfig/merge_config.sh +++ b/xen/tools/kconfig/merge_config.sh @@ -1,4 +1,6 @@ #!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# # merge_config.sh - Takes a list of config fragment values, and merges # them one by one. Provides warnings on overridden values, and specified # values that did not make it to the resulting .config file (due to missed @@ -10,18 +12,10 @@ # # Copyright (c) 2009-2010 Wind River Systems, Inc. # Copyright 2011 Linaro -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 2 as -# published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the GNU General Public License for more details. clean_up() { rm -f $TMP_FILE + rm -f $MERGE_FILE exit } trap clean_up HUP INT TERM @@ -32,13 +26,18 @@ usage() { echo " -m only merge the fragments, do not execute the make command" echo " -n use allnoconfig instead of alldefconfig" echo " -r list redundant entries when merging fragments" - echo " -O dir to put generated output files" + echo " -y make builtin have precedence over modules" + echo " -O dir to put generated output files. Consider setting \$KCONFIG_CONFIG instead." + echo + echo "Used prefix: '$CONFIG_PREFIX'. You can redefine it with \$CONFIG_ environment variable." } RUNMAKE=true ALLTARGET=alldefconfig WARNREDUN=false +BUILTIN=false OUTPUT=. +CONFIG_PREFIX=${CONFIG_-CONFIG_} while true; do case $1 in @@ -61,6 +60,11 @@ while true; do shift continue ;; + "-y") + BUILTIN=true + shift + continue + ;; "-O") if [ -d $2 ];then OUTPUT=$(echo $2 | sed 's/\/*$//') @@ -77,11 +81,19 @@ while true; do esac done -if [ "$#" -lt 2 ] ; then +if [ "$#" -lt 1 ] ; then usage exit fi +if [ -z "$KCONFIG_CONFIG" ]; then + if [ "$OUTPUT" != . ]; then + KCONFIG_CONFIG=$(readlink -m -- "$OUTPUT/.config") + else + KCONFIG_CONFIG=.config + fi +fi + INITFILE=$1 shift; @@ -91,42 +103,57 @@ if [ ! -r "$INITFILE" ]; then fi MERGE_LIST=$* -SED_CONFIG_EXP="s/^\(# \)\{0,1\}\(CONFIG_[a-zA-Z0-9_]*\)[= ].*/\2/p" +SED_CONFIG_EXP1="s/^\(${CONFIG_PREFIX}[a-zA-Z0-9_]*\)=.*/\1/p" +SED_CONFIG_EXP2="s/^# \(${CONFIG_PREFIX}[a-zA-Z0-9_]*\) is not set$/\1/p" + TMP_FILE=$(mktemp ./.tmp.config.XXXXXXXXXX) +MERGE_FILE=$(mktemp ./.merge_tmp.config.XXXXXXXXXX) echo "Using $INITFILE as base" cat $INITFILE > $TMP_FILE # Merge files, printing warnings on overridden values -for MERGE_FILE in $MERGE_LIST ; do - echo "Merging $MERGE_FILE" - if [ ! -r "$MERGE_FILE" ]; then - echo "The merge file '$MERGE_FILE' does not exist. Exit." >&2 +for ORIG_MERGE_FILE in $MERGE_LIST ; do + echo "Merging $ORIG_MERGE_FILE" + if [ ! -r "$ORIG_MERGE_FILE" ]; then + echo "The merge file '$ORIG_MERGE_FILE' does not exist. Exit." >&2 exit 1 fi - CFG_LIST=$(sed -n "$SED_CONFIG_EXP" $MERGE_FILE) + cat $ORIG_MERGE_FILE > $MERGE_FILE + CFG_LIST=$(sed -n -e "$SED_CONFIG_EXP1" -e "$SED_CONFIG_EXP2" $MERGE_FILE) for CFG in $CFG_LIST ; do grep -q -w $CFG $TMP_FILE || continue PREV_VAL=$(grep -w $CFG $TMP_FILE) NEW_VAL=$(grep -w $CFG $MERGE_FILE) - if [ "x$PREV_VAL" != "x$NEW_VAL" ] ; then - echo Value of $CFG is redefined by fragment $MERGE_FILE: + BUILTIN_FLAG=false + if [ "$BUILTIN" = "true" ] && [ "${NEW_VAL#CONFIG_*=}" = "m" ] && [ "${PREV_VAL#CONFIG_*=}" = "y" ]; then + echo Previous value: $PREV_VAL + echo New value: $NEW_VAL + echo -y passed, will not demote y to m + echo + BUILTIN_FLAG=true + elif [ "x$PREV_VAL" != "x$NEW_VAL" ] ; then + echo Value of $CFG is redefined by fragment $ORIG_MERGE_FILE: echo Previous value: $PREV_VAL echo New value: $NEW_VAL echo elif [ "$WARNREDUN" = "true" ]; then - echo Value of $CFG is redundant by fragment $MERGE_FILE: + echo Value of $CFG is redundant by fragment $ORIG_MERGE_FILE: + fi + if [ "$BUILTIN_FLAG" = "false" ]; then + sed -i "/$CFG[ =]/d" $TMP_FILE + else + sed -i "/$CFG[ =]/d" $MERGE_FILE fi - sed -i "/$CFG[ =]/d" $TMP_FILE done cat $MERGE_FILE >> $TMP_FILE done if [ "$RUNMAKE" = "false" ]; then - cp $TMP_FILE $OUTPUT/.config + cp -T -- "$TMP_FILE" "$KCONFIG_CONFIG" echo "#" - echo "# merged configuration written to $OUTPUT/.config (needs make)" + echo "# merged configuration written to $KCONFIG_CONFIG (needs make)" echo "#" clean_up exit @@ -147,10 +174,10 @@ make KCONFIG_ALLCONFIG=$TMP_FILE $OUTPUT_ARG $ALLTARGET # Check all specified config values took (might have missed-dependency issues) -for CFG in $(sed -n "$SED_CONFIG_EXP" $TMP_FILE); do +for CFG in $(sed -n -e "$SED_CONFIG_EXP1" -e "$SED_CONFIG_EXP2" $TMP_FILE); do REQUESTED_VAL=$(grep -w -e "$CFG" $TMP_FILE) - ACTUAL_VAL=$(grep -w -e "$CFG" $OUTPUT/.config) + ACTUAL_VAL=$(grep -w -e "$CFG" "$KCONFIG_CONFIG") if [ "x$REQUESTED_VAL" != "x$ACTUAL_VAL" ] ; then echo "Value requested for $CFG not in final .config" echo "Requested value: $REQUESTED_VAL" diff --git a/xen/tools/kconfig/nconf-cfg.sh b/xen/tools/kconfig/nconf-cfg.sh new file mode 100755 index 000000000000..001559ef0a60 --- /dev/null +++ b/xen/tools/kconfig/nconf-cfg.sh @@ -0,0 +1,47 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 + +PKG="ncursesw menuw panelw" +PKG2="ncurses menu panel" + +if [ -n "$(command -v pkg-config)" ]; then + if pkg-config --exists $PKG; then + echo cflags=\"$(pkg-config --cflags $PKG)\" + echo libs=\"$(pkg-config --libs $PKG)\" + exit 0 + fi + + if pkg-config --exists $PKG2; then + echo cflags=\"$(pkg-config --cflags $PKG2)\" + echo libs=\"$(pkg-config --libs $PKG2)\" + exit 0 + fi +fi + +# Check the default paths in case pkg-config is not installed. +# (Even if it is installed, some distributions such as openSUSE cannot +# find ncurses by pkg-config.) +if [ -f /usr/include/ncursesw/ncurses.h ]; then + echo cflags=\"-D_GNU_SOURCE -I/usr/include/ncursesw\" + echo libs=\"-lncursesw -lmenuw -lpanelw\" + exit 0 +fi + +if [ -f /usr/include/ncurses/ncurses.h ]; then + echo cflags=\"-D_GNU_SOURCE -I/usr/include/ncurses\" + echo libs=\"-lncurses -lmenu -lpanel\" + exit 0 +fi + +if [ -f /usr/include/ncurses.h ]; then + echo cflags=\"-D_GNU_SOURCE\" + echo libs=\"-lncurses -lmenu -lpanel\" + exit 0 +fi + +echo >&2 "*" +echo >&2 "* Unable to find the ncurses package." +echo >&2 "* Install ncurses (ncurses-devel or libncurses-dev" +echo >&2 "* depending on your distribution)." +echo >&2 "*" +exit 1 diff --git a/xen/tools/kconfig/nconf.c b/xen/tools/kconfig/nconf.c index b6e44cbe5929..b7c1ef757178 100644 --- a/xen/tools/kconfig/nconf.c +++ b/xen/tools/kconfig/nconf.c @@ -1,11 +1,12 @@ +// SPDX-License-Identifier: GPL-2.0 /* - * Copyright (C) 2008 Nir Tzachar * * Derived from menuconfig. - * */ +#ifndef _GNU_SOURCE #define _GNU_SOURCE +#endif #include #include @@ -269,7 +270,7 @@ static struct mitem k_menu_items[MAX_MENU_ITEMS]; static int items_num; static int global_exit; /* the currently selected button */ -const char *current_instructions = menu_instructions; +static const char *current_instructions = menu_instructions; static char *dialog_input_result; static int dialog_input_result_len; @@ -303,7 +304,7 @@ struct function_keys { }; static const int function_keys_num = 9; -struct function_keys function_keys[] = { +static struct function_keys function_keys[] = { { .key_str = "F1", .func = "Help", @@ -506,7 +507,7 @@ static int get_mext_match(const char *match_str, match_f flag) index = (index + items_num) % items_num; while (true) { char *str = k_menu_items[index].str; - if (strcasestr(str, match_str) != 0) + if (strcasestr(str, match_str) != NULL) return index; if (flag == FIND_NEXT_MATCH_UP || flag == MATCH_TINKER_PATTERN_UP) @@ -672,6 +673,7 @@ static int do_exit(void) "Your configuration changes were NOT saved.", 1, ""); + conf_write_autoconf(0); break; default: btn_dialog( @@ -801,7 +803,7 @@ static void build_conf(struct menu *menu) } val = sym_get_tristate_value(sym); - if (sym_is_changable(sym)) { + if (sym_is_changeable(sym)) { switch (type) { case S_BOOLEAN: item_make(menu, 't', "[%c]", @@ -855,7 +857,7 @@ static void build_conf(struct menu *menu) } else { switch (type) { case S_BOOLEAN: - if (sym_is_changable(sym)) + if (sym_is_changeable(sym)) item_make(menu, 't', "[%c]", val == no ? ' ' : '*'); else @@ -874,7 +876,7 @@ static void build_conf(struct menu *menu) ch = ' '; break; } - if (sym_is_changable(sym)) { + if (sym_is_changeable(sym)) { if (sym->rev_dep.tri == mod) item_make(menu, 't', "{%c}", ch); @@ -894,14 +896,14 @@ static void build_conf(struct menu *menu) item_add_str("%*c%s%s", tmp, ' ', menu_get_prompt(menu), (sym_has_value(sym) || - !sym_is_changable(sym)) ? "" : + !sym_is_changeable(sym)) ? "" : " (NEW)"); goto conf_childs; } } item_add_str("%*c%s%s", indent + 1, ' ', menu_get_prompt(menu), - (sym_has_value(sym) || !sym_is_changable(sym)) ? + (sym_has_value(sym) || !sym_is_changeable(sym)) ? "" : " (NEW)"); if (menu->prompt && menu->prompt->type == P_MENU) { item_add_str(" %s", menu_is_empty(menu) ? "----" : "--->"); @@ -1046,7 +1048,7 @@ static int do_match(int key, struct match_state *state, int *ans) state->match_direction = FIND_NEXT_MATCH_UP; *ans = get_mext_match(state->pattern, state->match_direction); - } else if (key == KEY_BACKSPACE || key == 127) { + } else if (key == KEY_BACKSPACE || key == 8 || key == 127) { state->pattern[strlen(state->pattern)-1] = '\0'; adj_match_dir(&state->match_direction); } else @@ -1065,7 +1067,7 @@ static int do_match(int key, struct match_state *state, int *ans) static void conf(struct menu *menu) { - struct menu *submenu = 0; + struct menu *submenu = NULL; const char *prompt = menu_get_prompt(menu); struct symbol *sym; int res; @@ -1208,12 +1210,9 @@ static void conf(struct menu *menu) } } -static void conf_message_callback(const char *fmt, va_list ap) +static void conf_message_callback(const char *s) { - char buf[1024]; - - vsnprintf(buf, sizeof(buf), fmt, ap); - btn_dialog(main_window, buf, 1, ""); + btn_dialog(main_window, s, 1, ""); } static void show_help(struct menu *menu) @@ -1232,7 +1231,7 @@ static void show_help(struct menu *menu) static void conf_choice(struct menu *menu) { const char *prompt = menu_get_prompt(menu); - struct menu *child = 0; + struct menu *child = NULL; struct symbol *active; int selected_index = 0; int last_top_row = 0; @@ -1439,8 +1438,7 @@ static void conf_save(void) set_config_filename(dialog_input_result); return; } - btn_dialog(main_window, "Can't create file! " - "Probably a nonexistent directory.", + btn_dialog(main_window, "Can't create file!", 1, ""); break; case 1: @@ -1454,7 +1452,7 @@ static void conf_save(void) } } -void setup_windows(void) +static void setup_windows(void) { int lines, columns; diff --git a/xen/tools/kconfig/nconf.gui.c b/xen/tools/kconfig/nconf.gui.c index 8275f0e55106..77f525a8617c 100644 --- a/xen/tools/kconfig/nconf.gui.c +++ b/xen/tools/kconfig/nconf.gui.c @@ -1,11 +1,11 @@ +// SPDX-License-Identifier: GPL-2.0 /* - * Copyright (C) 2008 Nir Tzachar * * Derived from menuconfig. - * */ #include "nconf.h" +#include "lkc.h" /* a list of all the different widgets we use */ attributes_t attributes[ATTR_MAX+1] = {0}; @@ -129,7 +129,7 @@ static void no_colors_theme(void) mkattrn(FUNCTION_TEXT, A_REVERSE); } -void set_colors() +void set_colors(void) { start_color(); use_default_colors(); @@ -192,7 +192,7 @@ const char *get_line(const char *text, int line_no) int lines = 0; if (!text) - return 0; + return NULL; for (i = 0; text[i] != '\0' && lines < line_no; i++) if (text[i] == '\n') @@ -364,15 +364,17 @@ int dialog_inputbox(WINDOW *main_window, WINDOW *prompt_win; WINDOW *form_win; PANEL *panel; - int i, x, y; + int i, x, y, lines, columns, win_lines, win_cols; int res = -1; int cursor_position = strlen(init); int cursor_form_win; char *result = *resultp; + getmaxyx(stdscr, lines, columns); + if (strlen(init)+1 > *result_len) { *result_len = strlen(init)+1; - *resultp = result = realloc(result, *result_len); + *resultp = result = xrealloc(result, *result_len); } /* find the widest line of msg: */ @@ -386,14 +388,19 @@ int dialog_inputbox(WINDOW *main_window, if (title) prompt_width = max(prompt_width, strlen(title)); + win_lines = min(prompt_lines+6, lines-2); + win_cols = min(prompt_width+7, columns-2); + prompt_lines = max(win_lines-6, 0); + prompt_width = max(win_cols-7, 0); + /* place dialog in middle of screen */ - y = (getmaxy(stdscr)-(prompt_lines+4))/2; - x = (getmaxx(stdscr)-(prompt_width+4))/2; + y = (lines-win_lines)/2; + x = (columns-win_cols)/2; strncpy(result, init, *result_len); /* create the windows */ - win = newwin(prompt_lines+6, prompt_width+7, y, x); + win = newwin(win_lines, win_cols, y, x); prompt_win = derwin(win, prompt_lines+1, prompt_width, 2, 2); form_win = derwin(win, 1, prompt_width, prompt_lines+3, 2); keypad(form_win, TRUE); @@ -432,7 +439,8 @@ int dialog_inputbox(WINDOW *main_window, case KEY_F(F_EXIT): case KEY_F(F_BACK): break; - case 127: + case 8: /* ^H */ + case 127: /* ^? */ case KEY_BACKSPACE: if (cursor_position > 0) { memmove(&result[cursor_position-1], diff --git a/xen/tools/kconfig/nconf.h b/xen/tools/kconfig/nconf.h index 5e968163a41c..fa5245eb93a7 100644 --- a/xen/tools/kconfig/nconf.h +++ b/xen/tools/kconfig/nconf.h @@ -1,9 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* - * Copyright (C) 2008 Nir Tzachar * * Derived from menuconfig. - * */ #include @@ -14,7 +13,7 @@ #include #include #include -#include +#include #include #include #include @@ -23,8 +22,6 @@ #include #include -#include "ncurses.h" - #define max(a, b) ({\ typeof(a) _a = a;\ typeof(b) _b = b;\ diff --git a/xen/tools/kconfig/zconf.y b/xen/tools/kconfig/parser.y similarity index 66% rename from xen/tools/kconfig/zconf.y rename to xen/tools/kconfig/parser.y index 6efcd5a36309..60936c76865b 100644 --- a/xen/tools/kconfig/zconf.y +++ b/xen/tools/kconfig/parser.y @@ -1,8 +1,8 @@ -%{ +/* SPDX-License-Identifier: GPL-2.0 */ /* * Copyright (C) 2002 Roman Zippel - * Released under the terms of the GNU GPL v2.0. */ +%{ #include #include @@ -20,62 +20,69 @@ int cdebug = PRINTD; -extern int zconflex(void); +static void yyerror(const char *err); static void zconfprint(const char *err, ...); static void zconf_error(const char *err, ...); -static void zconferror(const char *err); -static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtoken); +static bool zconf_endtoken(const char *tokenname, + const char *expected_tokenname); struct symbol *symbol_hash[SYMBOL_HASHSIZE]; static struct menu *current_menu, *current_entry; %} -%expect 30 %union { char *string; - struct file *file; struct symbol *symbol; struct expr *expr; struct menu *menu; - const struct kconf_id *id; + enum symbol_type type; + enum variable_flavor flavor; } -%token T_MAINMENU -%token T_MENU -%token T_ENDMENU -%token T_SOURCE -%token T_CHOICE -%token T_ENDCHOICE -%token T_COMMENT -%token T_CONFIG -%token T_MENUCONFIG -%token T_HELP %token T_HELPTEXT -%token T_IF -%token T_ENDIF -%token T_DEPENDS -%token T_OPTIONAL -%token T_PROMPT -%token T_TYPE -%token T_DEFAULT -%token T_SELECT -%token T_RANGE -%token T_VISIBLE -%token T_OPTION -%token T_ON %token T_WORD %token T_WORD_QUOTE -%token T_UNEQUAL -%token T_LESS -%token T_LESS_EQUAL -%token T_GREATER -%token T_GREATER_EQUAL +%token T_ALLNOCONFIG_Y +%token T_BOOL +%token T_CHOICE %token T_CLOSE_PAREN +%token T_COLON_EQUAL +%token T_COMMENT +%token T_CONFIG +%token T_DEFAULT +%token T_DEFCONFIG_LIST +%token T_DEF_BOOL +%token T_DEF_TRISTATE +%token T_DEPENDS +%token T_ENDCHOICE +%token T_ENDIF +%token T_ENDMENU +%token T_HELP +%token T_HEX +%token T_IF +%token T_IMPLY +%token T_INT +%token T_MAINMENU +%token T_MENU +%token T_MENUCONFIG +%token T_MODULES +%token T_ON %token T_OPEN_PAREN +%token T_OPTION +%token T_OPTIONAL +%token T_PLUS_EQUAL +%token T_PROMPT +%token T_RANGE +%token T_SELECT +%token T_SOURCE +%token T_STRING +%token T_TRISTATE +%token T_VISIBLE %token T_EOL +%token T_ASSIGN_VAL %left T_OR %left T_AND @@ -84,13 +91,15 @@ static struct menu *current_menu, *current_entry; %nonassoc T_NOT %type prompt +%type nonconst_symbol %type symbol +%type type logic_type default %type expr %type if_expr -%type end -%type option_name +%type end %type if_entry menu_entry choice_entry -%type symbol_option_arg word_opt +%type word_opt assign_val +%type assign_op %destructor { fprintf(stderr, "%s:%d: missing end statement for this entry\n", @@ -99,71 +108,53 @@ static struct menu *current_menu, *current_entry; menu_end_menu(); } if_entry menu_entry choice_entry -%{ -/* Include zconf.hash.c here so it can see the token constants. */ -#include "zconf.hash.c" -%} - %% -input: nl start | start; +input: mainmenu_stmt stmt_list | stmt_list; -start: mainmenu_stmt stmt_list | stmt_list; +/* mainmenu entry */ + +mainmenu_stmt: T_MAINMENU prompt T_EOL +{ + menu_add_prompt(P_MENU, $2, NULL); +}; stmt_list: /* empty */ | stmt_list common_stmt | stmt_list choice_stmt | stmt_list menu_stmt - | stmt_list end { zconf_error("unexpected end statement"); } | stmt_list T_WORD error T_EOL { zconf_error("unknown statement \"%s\"", $2); } - | stmt_list option_name error T_EOL -{ - zconf_error("unexpected option \"%s\"", kconf_id_strings + $2->name); -} | stmt_list error T_EOL { zconf_error("invalid statement"); } ; -option_name: - T_DEPENDS | T_PROMPT | T_TYPE | T_SELECT | T_OPTIONAL | T_RANGE | T_DEFAULT | T_VISIBLE -; - common_stmt: - T_EOL - | if_stmt + if_stmt | comment_stmt | config_stmt | menuconfig_stmt | source_stmt + | assignment_stmt ; -option_error: - T_WORD error T_EOL { zconf_error("unknown option \"%s\"", $1); } - | error T_EOL { zconf_error("invalid option"); } -; - - /* config/menuconfig entry */ -config_entry_start: T_CONFIG T_WORD T_EOL +config_entry_start: T_CONFIG nonconst_symbol T_EOL { - struct symbol *sym = sym_lookup($2, 0); - sym->flags |= SYMBOL_OPTIONAL; - menu_add_entry(sym); - printd(DEBUG_PARSE, "%s:%d:config %s\n", zconf_curname(), zconf_lineno(), $2); + $2->flags |= SYMBOL_OPTIONAL; + menu_add_entry($2); + printd(DEBUG_PARSE, "%s:%d:config %s\n", zconf_curname(), zconf_lineno(), $2->name); }; config_stmt: config_entry_start config_option_list { - menu_end_entry(); printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno()); }; -menuconfig_entry_start: T_MENUCONFIG T_WORD T_EOL +menuconfig_entry_start: T_MENUCONFIG nonconst_symbol T_EOL { - struct symbol *sym = sym_lookup($2, 0); - sym->flags |= SYMBOL_OPTIONAL; - menu_add_entry(sym); - printd(DEBUG_PARSE, "%s:%d:menuconfig %s\n", zconf_curname(), zconf_lineno(), $2); + $2->flags |= SYMBOL_OPTIONAL; + menu_add_entry($2); + printd(DEBUG_PARSE, "%s:%d:menuconfig %s\n", zconf_curname(), zconf_lineno(), $2->name); }; menuconfig_stmt: menuconfig_entry_start config_option_list @@ -172,26 +163,22 @@ menuconfig_stmt: menuconfig_entry_start config_option_list current_entry->prompt->type = P_MENU; else zconfprint("warning: menuconfig statement without prompt"); - menu_end_entry(); printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno()); }; config_option_list: /* empty */ | config_option_list config_option - | config_option_list symbol_option | config_option_list depends | config_option_list help - | config_option_list option_error - | config_option_list T_EOL ; -config_option: T_TYPE prompt_stmt_opt T_EOL +config_option: type prompt_stmt_opt T_EOL { - menu_set_type($1->stype); + menu_set_type($1); printd(DEBUG_PARSE, "%s:%d:type(%u)\n", zconf_curname(), zconf_lineno(), - $1->stype); + $1); }; config_option: T_PROMPT prompt if_expr T_EOL @@ -200,56 +187,58 @@ config_option: T_PROMPT prompt if_expr T_EOL printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno()); }; -config_option: T_DEFAULT expr if_expr T_EOL +config_option: default expr if_expr T_EOL { menu_add_expr(P_DEFAULT, $2, $3); - if ($1->stype != S_UNKNOWN) - menu_set_type($1->stype); + if ($1 != S_UNKNOWN) + menu_set_type($1); printd(DEBUG_PARSE, "%s:%d:default(%u)\n", zconf_curname(), zconf_lineno(), - $1->stype); + $1); }; -config_option: T_SELECT T_WORD if_expr T_EOL +config_option: T_SELECT nonconst_symbol if_expr T_EOL { - menu_add_symbol(P_SELECT, sym_lookup($2, 0), $3); + menu_add_symbol(P_SELECT, $2, $3); printd(DEBUG_PARSE, "%s:%d:select\n", zconf_curname(), zconf_lineno()); }; +config_option: T_IMPLY nonconst_symbol if_expr T_EOL +{ + menu_add_symbol(P_IMPLY, $2, $3); + printd(DEBUG_PARSE, "%s:%d:imply\n", zconf_curname(), zconf_lineno()); +}; + config_option: T_RANGE symbol symbol if_expr T_EOL { menu_add_expr(P_RANGE, expr_alloc_comp(E_RANGE,$2, $3), $4); printd(DEBUG_PARSE, "%s:%d:range\n", zconf_curname(), zconf_lineno()); }; -symbol_option: T_OPTION symbol_option_list T_EOL -; +config_option: T_OPTION T_MODULES T_EOL +{ + menu_add_option_modules(); +}; -symbol_option_list: - /* empty */ - | symbol_option_list T_WORD symbol_option_arg +config_option: T_OPTION T_DEFCONFIG_LIST T_EOL { - const struct kconf_id *id = kconf_id_lookup($2, strlen($2)); - if (id && id->flags & TF_OPTION) - menu_add_option(id->token, $3); - else - zconfprint("warning: ignoring unknown option %s", $2); - free($2); + menu_add_option_defconfig_list(); }; -symbol_option_arg: - /* empty */ { $$ = NULL; } - | T_EQUAL prompt { $$ = $2; } -; +config_option: T_OPTION T_ALLNOCONFIG_Y T_EOL +{ + menu_add_option_allnoconfig_y(); +}; /* choice entry */ choice: T_CHOICE word_opt T_EOL { struct symbol *sym = sym_lookup($2, SYMBOL_CHOICE); - sym->flags |= SYMBOL_AUTO; + sym->flags |= SYMBOL_NO_WRITE; menu_add_entry(sym); menu_add_expr(P_CHOICE, NULL, NULL); + free($2); printd(DEBUG_PARSE, "%s:%d:choice\n", zconf_curname(), zconf_lineno()); }; @@ -260,7 +249,7 @@ choice_entry: choice choice_option_list choice_end: end { - if (zconf_endtoken($1, T_CHOICE, T_ENDCHOICE)) { + if (zconf_endtoken($1, "choice")) { menu_end_menu(); printd(DEBUG_PARSE, "%s:%d:endchoice\n", zconf_curname(), zconf_lineno()); } @@ -274,8 +263,6 @@ choice_option_list: | choice_option_list choice_option | choice_option_list depends | choice_option_list help - | choice_option_list T_EOL - | choice_option_list option_error ; choice_option: T_PROMPT prompt if_expr T_EOL @@ -284,15 +271,11 @@ choice_option: T_PROMPT prompt if_expr T_EOL printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno()); }; -choice_option: T_TYPE prompt_stmt_opt T_EOL +choice_option: logic_type prompt_stmt_opt T_EOL { - if ($1->stype == S_BOOLEAN || $1->stype == S_TRISTATE) { - menu_set_type($1->stype); - printd(DEBUG_PARSE, "%s:%d:type(%u)\n", - zconf_curname(), zconf_lineno(), - $1->stype); - } else - YYERROR; + menu_set_type($1); + printd(DEBUG_PARSE, "%s:%d:type(%u)\n", + zconf_curname(), zconf_lineno(), $1); }; choice_option: T_OPTIONAL T_EOL @@ -301,16 +284,28 @@ choice_option: T_OPTIONAL T_EOL printd(DEBUG_PARSE, "%s:%d:optional\n", zconf_curname(), zconf_lineno()); }; -choice_option: T_DEFAULT T_WORD if_expr T_EOL +choice_option: T_DEFAULT nonconst_symbol if_expr T_EOL { - if ($1->stype == S_UNKNOWN) { - menu_add_symbol(P_DEFAULT, sym_lookup($2, 0), $3); - printd(DEBUG_PARSE, "%s:%d:default\n", - zconf_curname(), zconf_lineno()); - } else - YYERROR; + menu_add_symbol(P_DEFAULT, $2, $3); + printd(DEBUG_PARSE, "%s:%d:default\n", + zconf_curname(), zconf_lineno()); }; +type: + logic_type + | T_INT { $$ = S_INT; } + | T_HEX { $$ = S_HEX; } + | T_STRING { $$ = S_STRING; } + +logic_type: + T_BOOL { $$ = S_BOOLEAN; } + | T_TRISTATE { $$ = S_TRISTATE; } + +default: + T_DEFAULT { $$ = S_UNKNOWN; } + | T_DEF_BOOL { $$ = S_BOOLEAN; } + | T_DEF_TRISTATE { $$ = S_TRISTATE; } + choice_block: /* empty */ | choice_block common_stmt @@ -318,7 +313,7 @@ choice_block: /* if entry */ -if_entry: T_IF expr nl +if_entry: T_IF expr T_EOL { printd(DEBUG_PARSE, "%s:%d:if\n", zconf_curname(), zconf_lineno()); menu_add_entry(NULL); @@ -328,29 +323,15 @@ if_entry: T_IF expr nl if_end: end { - if (zconf_endtoken($1, T_IF, T_ENDIF)) { + if (zconf_endtoken($1, "if")) { menu_end_menu(); printd(DEBUG_PARSE, "%s:%d:endif\n", zconf_curname(), zconf_lineno()); } }; -if_stmt: if_entry if_block if_end +if_stmt: if_entry stmt_list if_end ; -if_block: - /* empty */ - | if_block common_stmt - | if_block menu_stmt - | if_block choice_stmt -; - -/* mainmenu entry */ - -mainmenu_stmt: T_MAINMENU prompt nl -{ - menu_add_prompt(P_MENU, $2, NULL); -}; - /* menu entry */ menu: T_MENU prompt T_EOL @@ -360,33 +341,33 @@ menu: T_MENU prompt T_EOL printd(DEBUG_PARSE, "%s:%d:menu\n", zconf_curname(), zconf_lineno()); }; -menu_entry: menu visibility_list depends_list +menu_entry: menu menu_option_list { $$ = menu_add_menu(); }; menu_end: end { - if (zconf_endtoken($1, T_MENU, T_ENDMENU)) { + if (zconf_endtoken($1, "menu")) { menu_end_menu(); printd(DEBUG_PARSE, "%s:%d:endmenu\n", zconf_curname(), zconf_lineno()); } }; -menu_stmt: menu_entry menu_block menu_end +menu_stmt: menu_entry stmt_list menu_end ; -menu_block: +menu_option_list: /* empty */ - | menu_block common_stmt - | menu_block menu_stmt - | menu_block choice_stmt + | menu_option_list visible + | menu_option_list depends ; source_stmt: T_SOURCE prompt T_EOL { printd(DEBUG_PARSE, "%s:%d:source %s\n", zconf_curname(), zconf_lineno(), $2); zconf_nextfile($2); + free($2); }; /* comment entry */ @@ -398,10 +379,13 @@ comment: T_COMMENT prompt T_EOL printd(DEBUG_PARSE, "%s:%d:comment\n", zconf_curname(), zconf_lineno()); }; -comment_stmt: comment depends_list -{ - menu_end_entry(); -}; +comment_stmt: comment comment_option_list +; + +comment_option_list: + /* empty */ + | comment_option_list depends +; /* help option */ @@ -413,18 +397,22 @@ help_start: T_HELP T_EOL help: help_start T_HELPTEXT { + if (current_entry->help) { + free(current_entry->help); + zconfprint("warning: '%s' defined with more than one help text -- only the last one will be used", + current_entry->sym->name ?: ""); + } + + /* Is the help text empty or all whitespace? */ + if ($2[strspn($2, " \f\n\r\t\v")] == '\0') + zconfprint("warning: '%s' defined with blank help text", + current_entry->sym->name ?: ""); + current_entry->help = $2; }; /* depends option */ -depends_list: - /* empty */ - | depends_list depends - | depends_list T_EOL - | depends_list option_error -; - depends: T_DEPENDS T_ON expr T_EOL { menu_add_dep($3); @@ -432,14 +420,7 @@ depends: T_DEPENDS T_ON expr T_EOL }; /* visibility option */ - -visibility_list: - /* empty */ - | visibility_list visible - | visibility_list T_EOL -; - -visible: T_VISIBLE if_expr +visible: T_VISIBLE if_expr T_EOL { menu_add_visibility($2); }; @@ -457,14 +438,9 @@ prompt: T_WORD | T_WORD_QUOTE ; -end: T_ENDMENU T_EOL { $$ = $1; } - | T_ENDCHOICE T_EOL { $$ = $1; } - | T_ENDIF T_EOL { $$ = $1; } -; - -nl: - T_EOL - | nl T_EOL +end: T_ENDMENU T_EOL { $$ = "menu"; } + | T_ENDCHOICE T_EOL { $$ = "choice"; } + | T_ENDIF T_EOL { $$ = "if"; } ; if_expr: /* empty */ { $$ = NULL; } @@ -484,13 +460,31 @@ expr: symbol { $$ = expr_alloc_symbol($1); } | expr T_AND expr { $$ = expr_alloc_two(E_AND, $1, $3); } ; -symbol: T_WORD { $$ = sym_lookup($1, 0); free($1); } +/* For symbol definitions, selects, etc., where quotes are not accepted */ +nonconst_symbol: T_WORD { $$ = sym_lookup($1, 0); free($1); }; + +symbol: nonconst_symbol | T_WORD_QUOTE { $$ = sym_lookup($1, SYMBOL_CONST); free($1); } ; word_opt: /* empty */ { $$ = NULL; } | T_WORD +/* assignment statement */ + +assignment_stmt: T_WORD assign_op assign_val T_EOL { variable_add($1, $3, $2); free($1); free($3); } + +assign_op: + T_EQUAL { $$ = VAR_RECURSIVE; } + | T_COLON_EQUAL { $$ = VAR_SIMPLE; } + | T_PLUS_EQUAL { $$ = VAR_APPEND; } +; + +assign_val: + /* empty */ { $$ = xstrdup(""); }; + | T_ASSIGN_VAL +; + %% void conf_parse(const char *name) @@ -500,61 +494,51 @@ void conf_parse(const char *name) zconf_initscan(name); - sym_init(); _menu_init(); - rootmenu.prompt = menu_add_prompt(P_MENU, "Linux Kernel Configuration", NULL); if (getenv("ZCONF_DEBUG")) - zconfdebug = 1; - zconfparse(); - if (zconfnerrs) + yydebug = 1; + yyparse(); + + /* Variables are expanded in the parse phase. We can free them here. */ + variable_all_del(); + + if (yynerrs) exit(1); if (!modules_sym) modules_sym = sym_find( "n" ); - rootmenu.prompt->text = rootmenu.prompt->text; - rootmenu.prompt->text = sym_expand_string_value(rootmenu.prompt->text); + if (!menu_has_prompt(&rootmenu)) { + current_entry = &rootmenu; + menu_add_prompt(P_MENU, "Main menu", NULL); + } menu_finalize(&rootmenu); for_all_symbols(i, sym) { if (sym_check_deps(sym)) - zconfnerrs++; + yynerrs++; } - if (zconfnerrs) + if (yynerrs) exit(1); sym_set_change_count(1); } -static const char *zconf_tokenname(int token) -{ - switch (token) { - case T_MENU: return "menu"; - case T_ENDMENU: return "endmenu"; - case T_CHOICE: return "choice"; - case T_ENDCHOICE: return "endchoice"; - case T_IF: return "if"; - case T_ENDIF: return "endif"; - case T_DEPENDS: return "depends"; - case T_VISIBLE: return "visible"; - } - return ""; -} - -static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtoken) +static bool zconf_endtoken(const char *tokenname, + const char *expected_tokenname) { - if (id->token != endtoken) { + if (strcmp(tokenname, expected_tokenname)) { zconf_error("unexpected '%s' within %s block", - kconf_id_strings + id->name, zconf_tokenname(starttoken)); - zconfnerrs++; + tokenname, expected_tokenname); + yynerrs++; return false; } if (current_menu->file != current_file) { zconf_error("'%s' in different file than '%s'", - kconf_id_strings + id->name, zconf_tokenname(starttoken)); + tokenname, expected_tokenname); fprintf(stderr, "%s:%d: location of the '%s'\n", current_menu->file->name, current_menu->lineno, - zconf_tokenname(starttoken)); - zconfnerrs++; + expected_tokenname); + yynerrs++; return false; } return true; @@ -575,7 +559,7 @@ static void zconf_error(const char *err, ...) { va_list ap; - zconfnerrs++; + yynerrs++; fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno()); va_start(ap, err); vfprintf(stderr, err, ap); @@ -583,7 +567,7 @@ static void zconf_error(const char *err, ...) fprintf(stderr, "\n"); } -static void zconferror(const char *err) +static void yyerror(const char *err) { fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno() + 1, err); } @@ -616,7 +600,7 @@ static void print_symbol(FILE *out, struct menu *menu) fprintf(out, "\nconfig %s\n", sym->name); switch (sym->type) { case S_BOOLEAN: - fputs(" boolean\n", out); + fputs(" bool\n", out); break; case S_TRISTATE: fputs(" tristate\n", out); @@ -664,6 +648,11 @@ static void print_symbol(FILE *out, struct menu *menu) expr_fprint(prop->expr, out); fputc('\n', out); break; + case P_IMPLY: + fputs( " imply ", out); + expr_fprint(prop->expr, out); + fputc('\n', out); + break; case P_RANGE: fputs( " range ", out); expr_fprint(prop->expr, out); @@ -674,6 +663,10 @@ static void print_symbol(FILE *out, struct menu *menu) print_quoted_string(out, prop->text); fputc('\n', out); break; + case P_SYMBOL: + fputs( " symbol ", out); + fprintf(out, "%s\n", prop->sym->name); + break; default: fprintf(out, " unknown prop %d!\n", prop->type); break; @@ -734,9 +727,5 @@ void zconfdump(FILE *out) } } -#include "zconf.lex.c" #include "util.c" -#include "confdata.c" -#include "expr.c" -#include "symbol.c" #include "menu.c" diff --git a/xen/tools/kconfig/preprocess.c b/xen/tools/kconfig/preprocess.c new file mode 100644 index 000000000000..0243086fb168 --- /dev/null +++ b/xen/tools/kconfig/preprocess.c @@ -0,0 +1,574 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// Copyright (C) 2018 Masahiro Yamada + +#include +#include +#include +#include +#include +#include + +#include "list.h" +#include "lkc.h" + +#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) + +static char *expand_string_with_args(const char *in, int argc, char *argv[]); +static char *expand_string(const char *in); + +static void __attribute__((noreturn)) pperror(const char *format, ...) +{ + va_list ap; + + fprintf(stderr, "%s:%d: ", current_file->name, yylineno); + va_start(ap, format); + vfprintf(stderr, format, ap); + va_end(ap); + fprintf(stderr, "\n"); + + exit(1); +} + +/* + * Environment variables + */ +static LIST_HEAD(env_list); + +struct env { + char *name; + char *value; + struct list_head node; +}; + +static void env_add(const char *name, const char *value) +{ + struct env *e; + + e = xmalloc(sizeof(*e)); + e->name = xstrdup(name); + e->value = xstrdup(value); + + list_add_tail(&e->node, &env_list); +} + +static void env_del(struct env *e) +{ + list_del(&e->node); + free(e->name); + free(e->value); + free(e); +} + +/* The returned pointer must be freed when done */ +static char *env_expand(const char *name) +{ + struct env *e; + const char *value; + + if (!*name) + return NULL; + + list_for_each_entry(e, &env_list, node) { + if (!strcmp(name, e->name)) + return xstrdup(e->value); + } + + value = getenv(name); + if (!value) + return NULL; + + /* + * We need to remember all referenced environment variables. + * They will be written out to include/config/auto.conf.cmd + */ + env_add(name, value); + + return xstrdup(value); +} + +void env_write_dep(FILE *f, const char *autoconfig_name) +{ + struct env *e, *tmp; + + list_for_each_entry_safe(e, tmp, &env_list, node) { + fprintf(f, "ifneq \"$(%s)\" \"%s\"\n", e->name, e->value); + fprintf(f, "%s: FORCE\n", autoconfig_name); + fprintf(f, "endif\n"); + env_del(e); + } +} + +/* + * Built-in functions + */ +struct function { + const char *name; + unsigned int min_args; + unsigned int max_args; + char *(*func)(int argc, char *argv[]); +}; + +static char *do_error_if(int argc, char *argv[]) +{ + if (!strcmp(argv[0], "y")) + pperror("%s", argv[1]); + + return NULL; +} + +static char *do_filename(int argc, char *argv[]) +{ + return xstrdup(current_file->name); +} + +static char *do_info(int argc, char *argv[]) +{ + printf("%s\n", argv[0]); + + return xstrdup(""); +} + +static char *do_lineno(int argc, char *argv[]) +{ + char buf[16]; + + sprintf(buf, "%d", yylineno); + + return xstrdup(buf); +} + +static char *do_shell(int argc, char *argv[]) +{ + FILE *p; + char buf[256]; + char *cmd; + size_t nread; + int i; + + cmd = argv[0]; + + p = popen(cmd, "r"); + if (!p) { + perror(cmd); + exit(1); + } + + nread = fread(buf, 1, sizeof(buf), p); + if (nread == sizeof(buf)) + nread--; + + /* remove trailing new lines */ + while (nread > 0 && buf[nread - 1] == '\n') + nread--; + + buf[nread] = 0; + + /* replace a new line with a space */ + for (i = 0; i < nread; i++) { + if (buf[i] == '\n') + buf[i] = ' '; + } + + if (pclose(p) == -1) { + perror(cmd); + exit(1); + } + + return xstrdup(buf); +} + +static char *do_warning_if(int argc, char *argv[]) +{ + if (!strcmp(argv[0], "y")) + fprintf(stderr, "%s:%d: %s\n", + current_file->name, yylineno, argv[1]); + + return xstrdup(""); +} + +static const struct function function_table[] = { + /* Name MIN MAX Function */ + { "error-if", 2, 2, do_error_if }, + { "filename", 0, 0, do_filename }, + { "info", 1, 1, do_info }, + { "lineno", 0, 0, do_lineno }, + { "shell", 1, 1, do_shell }, + { "warning-if", 2, 2, do_warning_if }, +}; + +#define FUNCTION_MAX_ARGS 16 + +static char *function_expand(const char *name, int argc, char *argv[]) +{ + const struct function *f; + int i; + + for (i = 0; i < ARRAY_SIZE(function_table); i++) { + f = &function_table[i]; + if (strcmp(f->name, name)) + continue; + + if (argc < f->min_args) + pperror("too few function arguments passed to '%s'", + name); + + if (argc > f->max_args) + pperror("too many function arguments passed to '%s'", + name); + + return f->func(argc, argv); + } + + return NULL; +} + +/* + * Variables (and user-defined functions) + */ +static LIST_HEAD(variable_list); + +struct variable { + char *name; + char *value; + enum variable_flavor flavor; + int exp_count; + struct list_head node; +}; + +static struct variable *variable_lookup(const char *name) +{ + struct variable *v; + + list_for_each_entry(v, &variable_list, node) { + if (!strcmp(name, v->name)) + return v; + } + + return NULL; +} + +static char *variable_expand(const char *name, int argc, char *argv[]) +{ + struct variable *v; + char *res; + + v = variable_lookup(name); + if (!v) + return NULL; + + if (argc == 0 && v->exp_count) + pperror("Recursive variable '%s' references itself (eventually)", + name); + + if (v->exp_count > 1000) + pperror("Too deep recursive expansion"); + + v->exp_count++; + + if (v->flavor == VAR_RECURSIVE) + res = expand_string_with_args(v->value, argc, argv); + else + res = xstrdup(v->value); + + v->exp_count--; + + return res; +} + +void variable_add(const char *name, const char *value, + enum variable_flavor flavor) +{ + struct variable *v; + char *new_value; + bool append = false; + + v = variable_lookup(name); + if (v) { + /* For defined variables, += inherits the existing flavor */ + if (flavor == VAR_APPEND) { + flavor = v->flavor; + append = true; + } else { + free(v->value); + } + } else { + /* For undefined variables, += assumes the recursive flavor */ + if (flavor == VAR_APPEND) + flavor = VAR_RECURSIVE; + + v = xmalloc(sizeof(*v)); + v->name = xstrdup(name); + v->exp_count = 0; + list_add_tail(&v->node, &variable_list); + } + + v->flavor = flavor; + + if (flavor == VAR_SIMPLE) + new_value = expand_string(value); + else + new_value = xstrdup(value); + + if (append) { + v->value = xrealloc(v->value, + strlen(v->value) + strlen(new_value) + 2); + strcat(v->value, " "); + strcat(v->value, new_value); + free(new_value); + } else { + v->value = new_value; + } +} + +static void variable_del(struct variable *v) +{ + list_del(&v->node); + free(v->name); + free(v->value); + free(v); +} + +void variable_all_del(void) +{ + struct variable *v, *tmp; + + list_for_each_entry_safe(v, tmp, &variable_list, node) + variable_del(v); +} + +/* + * Evaluate a clause with arguments. argc/argv are arguments from the upper + * function call. + * + * Returned string must be freed when done + */ +static char *eval_clause(const char *str, size_t len, int argc, char *argv[]) +{ + char *tmp, *name, *res, *endptr, *prev, *p; + int new_argc = 0; + char *new_argv[FUNCTION_MAX_ARGS]; + int nest = 0; + int i; + unsigned long n; + + tmp = xstrndup(str, len); + + /* + * If variable name is '1', '2', etc. It is generally an argument + * from a user-function call (i.e. local-scope variable). If not + * available, then look-up global-scope variables. + */ + n = strtoul(tmp, &endptr, 10); + if (!*endptr && n > 0 && n <= argc) { + res = xstrdup(argv[n - 1]); + goto free_tmp; + } + + prev = p = tmp; + + /* + * Split into tokens + * The function name and arguments are separated by a comma. + * For example, if the function call is like this: + * $(foo,$(x),$(y)) + * + * The input string for this helper should be: + * foo,$(x),$(y) + * + * and split into: + * new_argv[0] = 'foo' + * new_argv[1] = '$(x)' + * new_argv[2] = '$(y)' + */ + while (*p) { + if (nest == 0 && *p == ',') { + *p = 0; + if (new_argc >= FUNCTION_MAX_ARGS) + pperror("too many function arguments"); + new_argv[new_argc++] = prev; + prev = p + 1; + } else if (*p == '(') { + nest++; + } else if (*p == ')') { + nest--; + } + + p++; + } + new_argv[new_argc++] = prev; + + /* + * Shift arguments + * new_argv[0] represents a function name or a variable name. Put it + * into 'name', then shift the rest of the arguments. This simplifies + * 'const' handling. + */ + name = expand_string_with_args(new_argv[0], argc, argv); + new_argc--; + for (i = 0; i < new_argc; i++) + new_argv[i] = expand_string_with_args(new_argv[i + 1], + argc, argv); + + /* Search for variables */ + res = variable_expand(name, new_argc, new_argv); + if (res) + goto free; + + /* Look for built-in functions */ + res = function_expand(name, new_argc, new_argv); + if (res) + goto free; + + /* Last, try environment variable */ + if (new_argc == 0) { + res = env_expand(name); + if (res) + goto free; + } + + res = xstrdup(""); +free: + for (i = 0; i < new_argc; i++) + free(new_argv[i]); + free(name); +free_tmp: + free(tmp); + + return res; +} + +/* + * Expand a string that follows '$' + * + * For example, if the input string is + * ($(FOO)$($(BAR)))$(BAZ) + * this helper evaluates + * $($(FOO)$($(BAR))) + * and returns a new string containing the expansion (note that the string is + * recursively expanded), also advancing 'str' to point to the next character + * after the corresponding closing parenthesis, in this case, *str will be + * $(BAR) + */ +static char *expand_dollar_with_args(const char **str, int argc, char *argv[]) +{ + const char *p = *str; + const char *q; + int nest = 0; + + /* + * In Kconfig, variable/function references always start with "$(". + * Neither single-letter variables as in $A nor curly braces as in ${CC} + * are supported. '$' not followed by '(' loses its special meaning. + */ + if (*p != '(') { + *str = p; + return xstrdup("$"); + } + + p++; + q = p; + while (*q) { + if (*q == '(') { + nest++; + } else if (*q == ')') { + if (nest-- == 0) + break; + } + q++; + } + + if (!*q) + pperror("unterminated reference to '%s': missing ')'", p); + + /* Advance 'str' to after the expanded initial portion of the string */ + *str = q + 1; + + return eval_clause(p, q - p, argc, argv); +} + +char *expand_dollar(const char **str) +{ + return expand_dollar_with_args(str, 0, NULL); +} + +static char *__expand_string(const char **str, bool (*is_end)(char c), + int argc, char *argv[]) +{ + const char *in, *p; + char *expansion, *out; + size_t in_len, out_len; + + out = xmalloc(1); + *out = 0; + out_len = 1; + + p = in = *str; + + while (1) { + if (*p == '$') { + in_len = p - in; + p++; + expansion = expand_dollar_with_args(&p, argc, argv); + out_len += in_len + strlen(expansion); + out = xrealloc(out, out_len); + strncat(out, in, in_len); + strcat(out, expansion); + free(expansion); + in = p; + continue; + } + + if (is_end(*p)) + break; + + p++; + } + + in_len = p - in; + out_len += in_len; + out = xrealloc(out, out_len); + strncat(out, in, in_len); + + /* Advance 'str' to the end character */ + *str = p; + + return out; +} + +static bool is_end_of_str(char c) +{ + return !c; +} + +/* + * Expand variables and functions in the given string. Undefined variables + * expand to an empty string. + * The returned string must be freed when done. + */ +static char *expand_string_with_args(const char *in, int argc, char *argv[]) +{ + return __expand_string(&in, is_end_of_str, argc, argv); +} + +static char *expand_string(const char *in) +{ + return expand_string_with_args(in, 0, NULL); +} + +static bool is_end_of_token(char c) +{ + return !(isalnum(c) || c == '_' || c == '-'); +} + +/* + * Expand variables in a token. The parsing stops when a token separater + * (in most cases, it is a whitespace) is encountered. 'str' is updated to + * point to the next character. + * + * The returned string must be freed when done. + */ +char *expand_one_token(const char **str) +{ + return __expand_string(str, is_end_of_token, 0, NULL); +} diff --git a/xen/tools/kconfig/qconf-cfg.sh b/xen/tools/kconfig/qconf-cfg.sh new file mode 100755 index 000000000000..02ccc0ae1031 --- /dev/null +++ b/xen/tools/kconfig/qconf-cfg.sh @@ -0,0 +1,32 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 + +PKG="Qt5Core Qt5Gui Qt5Widgets" +PKG2="QtCore QtGui" + +if [ -z "$(command -v pkg-config)" ]; then + echo >&2 "*" + echo >&2 "* 'make xconfig' requires 'pkg-config'. Please install it." + echo >&2 "*" + exit 1 +fi + +if pkg-config --exists $PKG; then + echo cflags=\"-std=c++11 -fPIC $(pkg-config --cflags Qt5Core Qt5Gui Qt5Widgets)\" + echo libs=\"$(pkg-config --libs $PKG)\" + echo moc=\"$(pkg-config --variable=host_bins Qt5Core)/moc\" + exit 0 +fi + +if pkg-config --exists $PKG2; then + echo cflags=\"$(pkg-config --cflags $PKG2)\" + echo libs=\"$(pkg-config --libs $PKG2)\" + echo moc=\"$(pkg-config --variable=moc_location QtCore)\" + exit 0 +fi + +echo >&2 "*" +echo >&2 "* Could not find Qt via pkg-config." +echo >&2 "* Please install either Qt 4.8 or 5.x. and make sure it's in PKG_CONFIG_PATH" +echo >&2 "*" +exit 1 diff --git a/xen/tools/kconfig/qconf.cc b/xen/tools/kconfig/qconf.cc index e140ab00abcf..82773cc35d35 100644 --- a/xen/tools/kconfig/qconf.cc +++ b/xen/tools/kconfig/qconf.cc @@ -1,32 +1,17 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) 2002 Roman Zippel - * Released under the terms of the GNU GPL v2.0. + * Copyright (C) 2015 Boris Barbulovski */ #include -#if QT_VERSION < 0x040000 -#include -#include -#include -#include +#include +#include #include -#include -#include -#include -#include -#include -#else -#include -#include -#include -#include -#include -#include -#include -#include -#include -#endif +#include +#include +#include #include #include @@ -47,13 +32,13 @@ #include "qconf.h" #include "qconf.moc" -#include "images.c" +#include "images.h" static QApplication *configApp; static ConfigSettings *configSettings; -Q3Action *ConfigMainWindow::saveAction; +QAction *ConfigMainWindow::saveAction; static inline QString qgettext(const char* str) { @@ -68,14 +53,22 @@ ConfigSettings::ConfigSettings() /** * Reads a list of integer values from the application settings. */ -Q3ValueList ConfigSettings::readSizes(const QString& key, bool *ok) +QList ConfigSettings::readSizes(const QString& key, bool *ok) { - Q3ValueList result; - QStringList entryList = readListEntry(key, ok); - QStringList::Iterator it; + QList result; - for (it = entryList.begin(); it != entryList.end(); ++it) - result.push_back((*it).toInt()); + if (contains(key)) + { + QStringList entryList = value(key).toStringList(); + QStringList::Iterator it; + + for (it = entryList.begin(); it != entryList.end(); ++it) + result.push_back((*it).toInt()); + + *ok = true; + } + else + *ok = false; return result; } @@ -83,14 +76,16 @@ Q3ValueList ConfigSettings::readSizes(const QString& key, bool *ok) /** * Writes a list of integer values to the application settings. */ -bool ConfigSettings::writeSizes(const QString& key, const Q3ValueList& value) +bool ConfigSettings::writeSizes(const QString& key, const QList& value) { QStringList stringList; - Q3ValueList::ConstIterator it; + QList::ConstIterator it; for (it = value.begin(); it != value.end(); ++it) stringList.push_back(QString::number(*it)); - return writeEntry(key, stringList); + setValue(key, stringList); + + return true; } @@ -100,9 +95,6 @@ bool ConfigSettings::writeSizes(const QString& key, const Q3ValueList& valu */ void ConfigItem::okRename(int col) { - Parent::okRename(col); - sym_set_string_value(menu->sym, text(dataColIdx).latin1()); - listView()->updateList(this); } /* @@ -140,11 +132,11 @@ void ConfigItem::updateMenu(void) } else { if (sym) break; - setPixmap(promptColIdx, 0); + setPixmap(promptColIdx, QIcon()); } goto set_prompt; case P_COMMENT: - setPixmap(promptColIdx, 0); + setPixmap(promptColIdx, QIcon()); goto set_prompt; default: ; @@ -160,8 +152,8 @@ void ConfigItem::updateMenu(void) case S_TRISTATE: char ch; - if (!sym_is_changable(sym) && list->optMode == normalOpt) { - setPixmap(promptColIdx, 0); + if (!sym_is_changeable(sym) && list->optMode == normalOpt) { + setPixmap(promptColIdx, QIcon()); setText(noColIdx, QString::null); setText(modColIdx, QString::null); setText(yesColIdx, QString::null); @@ -207,9 +199,6 @@ void ConfigItem::updateMenu(void) data = sym_get_string_value(sym); - int i = list->mapIdx(dataColIdx); - if (i >= 0) - setRenameEnabled(i, TRUE); setText(dataColIdx, data); if (type == S_STRING) prompt = QString("%1: %2").arg(prompt).arg(data); @@ -241,18 +230,6 @@ void ConfigItem::testUpdateMenu(bool v) updateMenu(); } -void ConfigItem::paintCell(QPainter* p, const QColorGroup& cg, int column, int width, int align) -{ - ConfigList* list = listView(); - - if (visible) { - if (isSelected() && !list->hasFocus() && list->mode == menuMode) - Parent::paintCell(p, list->inactivedColorGroup, column, width, align); - else - Parent::paintCell(p, cg, column, width, align); - } else - Parent::paintCell(p, list->disabledColorGroup, column, width, align); -} /* * construct a menu entry @@ -265,7 +242,7 @@ void ConfigItem::init(void) menu->data = this; if (list->mode != fullMode) - setOpen(TRUE); + setExpanded(true); sym_calc_value(menu->sym); } updateMenu(); @@ -290,7 +267,7 @@ ConfigItem::~ConfigItem(void) ConfigLineEdit::ConfigLineEdit(ConfigView* parent) : Parent(parent) { - connect(this, SIGNAL(lostFocus()), SLOT(hide())); + connect(this, SIGNAL(editingFinished()), SLOT(hide())); } void ConfigLineEdit::show(ConfigItem* i) @@ -311,7 +288,7 @@ void ConfigLineEdit::keyPressEvent(QKeyEvent* e) break; case Qt::Key_Return: case Qt::Key_Enter: - sym_set_string_value(item->menu->sym, text().latin1()); + sym_set_string_value(item->menu->sym, text().toLatin1()); parent()->updateList(item); break; default: @@ -324,39 +301,39 @@ void ConfigLineEdit::keyPressEvent(QKeyEvent* e) } ConfigList::ConfigList(ConfigView* p, const char *name) - : Parent(p, name), + : Parent(p), updateAll(false), symbolYesPix(xpm_symbol_yes), symbolModPix(xpm_symbol_mod), symbolNoPix(xpm_symbol_no), choiceYesPix(xpm_choice_yes), choiceNoPix(xpm_choice_no), menuPix(xpm_menu), menuInvPix(xpm_menu_inv), menuBackPix(xpm_menuback), voidPix(xpm_void), - showName(false), showRange(false), showData(false), optMode(normalOpt), + showName(false), showRange(false), showData(false), mode(singleMode), optMode(normalOpt), rootEntry(0), headerPopup(0) { int i; - setSorting(-1); - setRootIsDecorated(TRUE); - disabledColorGroup = palette().active(); - disabledColorGroup.setColor(QColorGroup::Text, palette().disabled().text()); - inactivedColorGroup = palette().active(); - inactivedColorGroup.setColor(QColorGroup::Highlight, palette().disabled().highlight()); + setObjectName(name); + setSortingEnabled(false); + setRootIsDecorated(true); + + setVerticalScrollMode(ScrollPerPixel); + setHorizontalScrollMode(ScrollPerPixel); - connect(this, SIGNAL(selectionChanged(void)), + setHeaderLabels(QStringList() << "Option" << "Name" << "N" << "M" << "Y" << "Value"); + + connect(this, SIGNAL(itemSelectionChanged(void)), SLOT(updateSelection(void))); if (name) { configSettings->beginGroup(name); - showName = configSettings->readBoolEntry("/showName", false); - showRange = configSettings->readBoolEntry("/showRange", false); - showData = configSettings->readBoolEntry("/showData", false); - optMode = (enum optionMode)configSettings->readNumEntry("/optionMode", false); + showName = configSettings->value("/showName", false).toBool(); + showRange = configSettings->value("/showRange", false).toBool(); + showData = configSettings->value("/showData", false).toBool(); + optMode = (enum optionMode)configSettings->value("/optionMode", 0).toInt(); configSettings->endGroup(); connect(configApp, SIGNAL(aboutToQuit()), SLOT(saveSettings())); } - for (i = 0; i < colNr; i++) - colMap[i] = colRevMap[i] = -1; - addColumn(promptColIdx, "Option"); + addColumn(promptColIdx); reinit(); } @@ -381,26 +358,26 @@ void ConfigList::reinit(void) removeColumn(nameColIdx); if (showName) - addColumn(nameColIdx, "Name"); + addColumn(nameColIdx); if (showRange) { - addColumn(noColIdx, "N"); - addColumn(modColIdx, "M"); - addColumn(yesColIdx, "Y"); + addColumn(noColIdx); + addColumn(modColIdx); + addColumn(yesColIdx); } if (showData) - addColumn(dataColIdx, "Value"); + addColumn(dataColIdx); updateListAll(); } void ConfigList::saveSettings(void) { - if (name()) { - configSettings->beginGroup(name()); - configSettings->writeEntry("/showName", showName); - configSettings->writeEntry("/showRange", showRange); - configSettings->writeEntry("/showData", showData); - configSettings->writeEntry("/optionMode", (int)optMode); + if (!objectName().isEmpty()) { + configSettings->beginGroup(objectName()); + configSettings->setValue("/showName", showName); + configSettings->setValue("/showRange", showRange); + configSettings->setValue("/showData", showData); + configSettings->setValue("/optionMode", (int)optMode); configSettings->endGroup(); } } @@ -422,7 +399,10 @@ void ConfigList::updateSelection(void) struct menu *menu; enum prop_type type; - ConfigItem* item = (ConfigItem*)selectedItem(); + if (selectedItems().count() == 0) + return; + + ConfigItem* item = (ConfigItem*)selectedItems().first(); if (!item) return; @@ -442,21 +422,23 @@ void ConfigList::updateList(ConfigItem* item) if (!rootEntry) { if (mode != listMode) goto update; - Q3ListViewItemIterator it(this); + QTreeWidgetItemIterator it(this); ConfigItem* item; - for (; it.current(); ++it) { - item = (ConfigItem*)it.current(); + while (*it) { + item = (ConfigItem*)(*it); if (!item->menu) continue; item->testUpdateMenu(menu_is_visible(item->menu)); + + ++it; } return; } if (rootEntry != &rootmenu && (mode == singleMode || (mode == symbolMode && rootEntry->parent != &rootmenu))) { - item = firstChild(); + item = (ConfigItem *)topLevelItem(0); if (!item) item = new ConfigItem(this, 0, true); last = item; @@ -470,12 +452,14 @@ void ConfigList::updateList(ConfigItem* item) item->testUpdateMenu(true); updateMenuList(item, rootEntry); - triggerUpdate(); + update(); + resizeColumnToContents(0); return; } update: updateMenuList(this, rootEntry); - triggerUpdate(); + update(); + resizeColumnToContents(0); } void ConfigList::setValue(ConfigItem* item, tristate val) @@ -497,7 +481,7 @@ void ConfigList::setValue(ConfigItem* item, tristate val) if (!sym_set_tristate_value(sym, val)) return; if (oldval == no && item->menu->list) - item->setOpen(TRUE); + item->setExpanded(true); parent()->updateList(item); break; } @@ -515,7 +499,7 @@ void ConfigList::changeValue(ConfigItem* item) sym = menu->sym; if (!sym) { if (item->menu->list) - item->setOpen(!item->isOpen()); + item->setExpanded(!item->isExpanded()); return; } @@ -527,9 +511,9 @@ void ConfigList::changeValue(ConfigItem* item) newexpr = sym_toggle_tristate_value(sym); if (item->menu->list) { if (oldexpr == newexpr) - item->setOpen(!item->isOpen()); + item->setExpanded(!item->isExpanded()); else if (oldexpr == no) - item->setOpen(TRUE); + item->setExpanded(true); } if (oldexpr != newexpr) parent()->updateList(item); @@ -537,10 +521,7 @@ void ConfigList::changeValue(ConfigItem* item) case S_INT: case S_HEX: case S_STRING: - if (colMap[dataColIdx] >= 0) - item->startRename(colMap[dataColIdx]); - else - parent()->lineEdit->show(item); + parent()->lineEdit->show(item); break; } } @@ -557,8 +538,10 @@ void ConfigList::setRootMenu(struct menu *menu) updateMenuList(this, 0); rootEntry = menu; updateListAll(); - setSelected(currentItem(), hasFocus()); - ensureItemVisible(currentItem()); + if (currentItem()) { + currentItem()->setSelected(hasFocus()); + scrollToItem(currentItem()); + } } void ConfigList::setParentMenu(void) @@ -571,13 +554,16 @@ void ConfigList::setParentMenu(void) return; setRootMenu(menu_get_parent_menu(rootEntry->parent)); - Q3ListViewItemIterator it(this); - for (; (item = (ConfigItem*)it.current()); it++) { + QTreeWidgetItemIterator it(this); + while (*it) { + item = (ConfigItem *)(*it); if (item->menu == oldroot) { setCurrentItem(item); - ensureItemVisible(item); + scrollToItem(item); break; } + + ++it; } } @@ -588,8 +574,7 @@ void ConfigList::setParentMenu(void) * parent: either the menu list widget or a menu entry widget * menu: entry to be updated */ -template -void ConfigList::updateMenuList(P* parent, struct menu* menu) +void ConfigList::updateMenuList(ConfigItem *parent, struct menu* menu) { struct menu* child; ConfigItem* item; @@ -598,8 +583,11 @@ void ConfigList::updateMenuList(P* parent, struct menu* menu) enum prop_type type; if (!menu) { - while ((item = parent->firstChild())) - delete item; + while (parent->childCount() > 0) + { + delete parent->takeChild(0); + } + return; } @@ -651,9 +639,74 @@ void ConfigList::updateMenuList(P* parent, struct menu* menu) } } +void ConfigList::updateMenuList(ConfigList *parent, struct menu* menu) +{ + struct menu* child; + ConfigItem* item; + ConfigItem* last; + bool visible; + enum prop_type type; + + if (!menu) { + while (parent->topLevelItemCount() > 0) + { + delete parent->takeTopLevelItem(0); + } + + return; + } + + last = (ConfigItem*)parent->topLevelItem(0); + if (last && !last->goParent) + last = 0; + for (child = menu->list; child; child = child->next) { + item = last ? last->nextSibling() : (ConfigItem*)parent->topLevelItem(0); + type = child->prompt ? child->prompt->type : P_UNKNOWN; + + switch (mode) { + case menuMode: + if (!(child->flags & MENU_ROOT)) + goto hide; + break; + case symbolMode: + if (child->flags & MENU_ROOT) + goto hide; + break; + default: + break; + } + + visible = menu_is_visible(child); + if (!menuSkip(child)) { + if (!child->sym && !child->list && !child->prompt) + continue; + if (!item || item->menu != child) + item = new ConfigItem(parent, last, child, visible); + else + item->testUpdateMenu(visible); + + if (mode == fullMode || mode == menuMode || type != P_MENU) + updateMenuList(item, child); + else + updateMenuList(item, 0); + last = item; + continue; + } + hide: + if (item && item->menu == child) { + last = (ConfigItem*)parent->topLevelItem(0); + if (last == item) + last = 0; + else while (last->nextSibling() != item) + last = last->nextSibling(); + delete item; + } + } +} + void ConfigList::keyPressEvent(QKeyEvent* ev) { - Q3ListViewItem* i = currentItem(); + QTreeWidgetItem* i = currentItem(); ConfigItem* item; struct menu *menu; enum prop_type type; @@ -705,20 +758,20 @@ void ConfigList::keyPressEvent(QKeyEvent* ev) ev->accept(); } -void ConfigList::contentsMousePressEvent(QMouseEvent* e) +void ConfigList::mousePressEvent(QMouseEvent* e) { //QPoint p(contentsToViewport(e->pos())); //printf("contentsMousePressEvent: %d,%d\n", p.x(), p.y()); - Parent::contentsMousePressEvent(e); + Parent::mousePressEvent(e); } -void ConfigList::contentsMouseReleaseEvent(QMouseEvent* e) +void ConfigList::mouseReleaseEvent(QMouseEvent* e) { - QPoint p(contentsToViewport(e->pos())); + QPoint p = e->pos(); ConfigItem* item = (ConfigItem*)itemAt(p); struct menu *menu; enum prop_type ptype; - const QPixmap* pm; + QIcon icon; int idx, x; if (!item) @@ -726,14 +779,13 @@ void ConfigList::contentsMouseReleaseEvent(QMouseEvent* e) menu = item->menu; x = header()->offset() + p.x(); - idx = colRevMap[header()->sectionAt(x)]; + idx = header()->logicalIndexAt(x); switch (idx) { case promptColIdx: - pm = item->pixmap(promptColIdx); - if (pm) { - int off = header()->sectionPos(0) + itemMargin() + - treeStepSize() * (item->depth() + (rootIsDecorated() ? 1 : 0)); - if (x >= off && x < off + pm->width()) { + icon = item->pixmap(promptColIdx); + if (!icon.isNull()) { + int off = header()->sectionPosition(0) + visualRect(indexAt(p)).x() + 4; // 4 is Hardcoded image offset. There might be a way to do it properly. + if (x >= off && x < off + icon.availableSizes().first().width()) { if (item->goParent) { emit parentSelected(); break; @@ -764,19 +816,19 @@ void ConfigList::contentsMouseReleaseEvent(QMouseEvent* e) skip: //printf("contentsMouseReleaseEvent: %d,%d\n", p.x(), p.y()); - Parent::contentsMouseReleaseEvent(e); + Parent::mouseReleaseEvent(e); } -void ConfigList::contentsMouseMoveEvent(QMouseEvent* e) +void ConfigList::mouseMoveEvent(QMouseEvent* e) { //QPoint p(contentsToViewport(e->pos())); //printf("contentsMouseMoveEvent: %d,%d\n", p.x(), p.y()); - Parent::contentsMouseMoveEvent(e); + Parent::mouseMoveEvent(e); } -void ConfigList::contentsMouseDoubleClickEvent(QMouseEvent* e) +void ConfigList::mouseDoubleClickEvent(QMouseEvent* e) { - QPoint p(contentsToViewport(e->pos())); + QPoint p = e->pos(); // TODO: Check if this works(was contentsToViewport). ConfigItem* item = (ConfigItem*)itemAt(p); struct menu *menu; enum prop_type ptype; @@ -798,7 +850,7 @@ void ConfigList::contentsMouseDoubleClickEvent(QMouseEvent* e) skip: //printf("contentsMouseDoubleClickEvent: %d,%d\n", p.x(), p.y()); - Parent::contentsMouseDoubleClickEvent(e); + Parent::mouseDoubleClickEvent(e); } void ConfigList::focusInEvent(QFocusEvent *e) @@ -809,7 +861,7 @@ void ConfigList::focusInEvent(QFocusEvent *e) ConfigItem* item = (ConfigItem *)currentItem(); if (item) { - setSelected(item, TRUE); + item->setSelected(true); menu = item->menu; } emit gotFocus(menu); @@ -819,33 +871,33 @@ void ConfigList::contextMenuEvent(QContextMenuEvent *e) { if (e->y() <= header()->geometry().bottom()) { if (!headerPopup) { - Q3Action *action; + QAction *action; - headerPopup = new Q3PopupMenu(this); - action = new Q3Action(NULL, "Show Name", 0, this); - action->setToggleAction(TRUE); + headerPopup = new QMenu(this); + action = new QAction("Show Name", this); + action->setCheckable(true); connect(action, SIGNAL(toggled(bool)), parent(), SLOT(setShowName(bool))); connect(parent(), SIGNAL(showNameChanged(bool)), action, SLOT(setOn(bool))); - action->setOn(showName); - action->addTo(headerPopup); - action = new Q3Action(NULL, "Show Range", 0, this); - action->setToggleAction(TRUE); + action->setChecked(showName); + headerPopup->addAction(action); + action = new QAction("Show Range", this); + action->setCheckable(true); connect(action, SIGNAL(toggled(bool)), parent(), SLOT(setShowRange(bool))); connect(parent(), SIGNAL(showRangeChanged(bool)), action, SLOT(setOn(bool))); - action->setOn(showRange); - action->addTo(headerPopup); - action = new Q3Action(NULL, "Show Data", 0, this); - action->setToggleAction(TRUE); + action->setChecked(showRange); + headerPopup->addAction(action); + action = new QAction("Show Data", this); + action->setCheckable(true); connect(action, SIGNAL(toggled(bool)), parent(), SLOT(setShowData(bool))); connect(parent(), SIGNAL(showDataChanged(bool)), action, SLOT(setOn(bool))); - action->setOn(showData); - action->addTo(headerPopup); + action->setChecked(showData); + headerPopup->addAction(action); } headerPopup->exec(e->globalPos()); e->accept(); @@ -859,11 +911,17 @@ QAction *ConfigView::showAllAction; QAction *ConfigView::showPromptAction; ConfigView::ConfigView(QWidget* parent, const char *name) - : Parent(parent, name) + : Parent(parent) { - list = new ConfigList(this, name); + setObjectName(name); + QVBoxLayout *verticalLayout = new QVBoxLayout(this); + verticalLayout->setContentsMargins(0, 0, 0, 0); + + list = new ConfigList(this); + verticalLayout->addWidget(list); lineEdit = new ConfigLineEdit(this); lineEdit->hide(); + verticalLayout->addWidget(lineEdit); this->nextView = viewList; viewList = this; @@ -922,10 +980,13 @@ void ConfigView::setShowData(bool b) void ConfigList::setAllOpen(bool open) { - Q3ListViewItemIterator it(this); + QTreeWidgetItemIterator it(this); - for (; it.current(); it++) - it.current()->setOpen(open); + while (*it) { + (*it)->setExpanded(open); + + ++it; + } } void ConfigView::updateList(ConfigItem* item) @@ -945,11 +1006,14 @@ void ConfigView::updateListAll(void) } ConfigInfoView::ConfigInfoView(QWidget* parent, const char *name) - : Parent(parent, name), sym(0), _menu(0) + : Parent(parent), sym(0), _menu(0) { - if (name) { - configSettings->beginGroup(name); - _showDebug = configSettings->readBoolEntry("/showDebug", false); + setObjectName(name); + + + if (!objectName().isEmpty()) { + configSettings->beginGroup(objectName()); + setShowDebug(configSettings->value("/showDebug", false).toBool()); configSettings->endGroup(); connect(configApp, SIGNAL(aboutToQuit()), SLOT(saveSettings())); } @@ -957,9 +1021,9 @@ ConfigInfoView::ConfigInfoView(QWidget* parent, const char *name) void ConfigInfoView::saveSettings(void) { - if (name()) { - configSettings->beginGroup(name()); - configSettings->writeEntry("/showDebug", showDebug()); + if (!objectName().isEmpty()) { + configSettings->beginGroup(objectName()); + configSettings->setValue("/showDebug", showDebug()); configSettings->endGroup(); } } @@ -1085,7 +1149,6 @@ QString ConfigInfoView::debug_info(struct symbol *sym) case P_DEFAULT: case P_SELECT: case P_RANGE: - case P_ENV: debug += prop_get_type_name(prop->type); debug += ": "; expr_print(prop->expr, expr_print_help, &debug, E_NONE); @@ -1118,8 +1181,8 @@ QString ConfigInfoView::print_filter(const QString &str) { QRegExp re("[<>&\"\\n]"); QString res = str; - for (int i = 0; (i = res.find(re, i)) >= 0;) { - switch (res[i].latin1()) { + for (int i = 0; (i = res.indexOf(re, i)) >= 0;) { + switch (res[i].toLatin1()) { case '<': res.replace(i, 1, "<"); i += 4; @@ -1158,37 +1221,42 @@ void ConfigInfoView::expr_print_help(void *data, struct symbol *sym, const char *text += str2; } -Q3PopupMenu* ConfigInfoView::createPopupMenu(const QPoint& pos) +QMenu* ConfigInfoView::createStandardContextMenu(const QPoint & pos) { - Q3PopupMenu* popup = Parent::createPopupMenu(pos); - Q3Action* action = new Q3Action(NULL, "Show Debug Info", 0, popup); - action->setToggleAction(TRUE); + QMenu* popup = Parent::createStandardContextMenu(pos); + QAction* action = new QAction("Show Debug Info", popup); + action->setCheckable(true); connect(action, SIGNAL(toggled(bool)), SLOT(setShowDebug(bool))); connect(this, SIGNAL(showDebugChanged(bool)), action, SLOT(setOn(bool))); - action->setOn(showDebug()); - popup->insertSeparator(); - action->addTo(popup); + action->setChecked(showDebug()); + popup->addSeparator(); + popup->addAction(action); return popup; } -void ConfigInfoView::contentsContextMenuEvent(QContextMenuEvent *e) +void ConfigInfoView::contextMenuEvent(QContextMenuEvent *e) { - Parent::contentsContextMenuEvent(e); + Parent::contextMenuEvent(e); } ConfigSearchWindow::ConfigSearchWindow(ConfigMainWindow* parent, const char *name) - : Parent(parent, name), result(NULL) + : Parent(parent), result(NULL) { - setCaption("Search Config"); + setObjectName(name); + setWindowTitle("Search Config"); - QVBoxLayout* layout1 = new QVBoxLayout(this, 11, 6); - QHBoxLayout* layout2 = new QHBoxLayout(0, 0, 6); + QVBoxLayout* layout1 = new QVBoxLayout(this); + layout1->setContentsMargins(11, 11, 11, 11); + layout1->setSpacing(6); + QHBoxLayout* layout2 = new QHBoxLayout(0); + layout2->setContentsMargins(0, 0, 0, 0); + layout2->setSpacing(6); layout2->addWidget(new QLabel("Find:", this)); editField = new QLineEdit(this); connect(editField, SIGNAL(returnPressed()), SLOT(search())); layout2->addWidget(editField); searchButton = new QPushButton("Search", this); - searchButton->setAutoDefault(FALSE); + searchButton->setAutoDefault(false); connect(searchButton, SIGNAL(clicked()), SLOT(search())); layout2->addWidget(searchButton); layout1->addLayout(layout2); @@ -1206,19 +1274,19 @@ ConfigSearchWindow::ConfigSearchWindow(ConfigMainWindow* parent, const char *nam layout1->addWidget(split); if (name) { - int x, y, width, height; + QVariant x, y; + int width, height; bool ok; configSettings->beginGroup(name); - width = configSettings->readNumEntry("/window width", parent->width() / 2); - height = configSettings->readNumEntry("/window height", parent->height() / 2); + width = configSettings->value("/window width", parent->width() / 2).toInt(); + height = configSettings->value("/window height", parent->height() / 2).toInt(); resize(width, height); - x = configSettings->readNumEntry("/window x", 0, &ok); - if (ok) - y = configSettings->readNumEntry("/window y", 0, &ok); - if (ok) - move(x, y); - Q3ValueList sizes = configSettings->readSizes("/split", &ok); + x = configSettings->value("/window x"); + y = configSettings->value("/window y"); + if ((x.isValid())&&(y.isValid())) + move(x.toInt(), y.toInt()); + QList sizes = configSettings->readSizes("/split", &ok); if (ok) split->setSizes(sizes); configSettings->endGroup(); @@ -1228,12 +1296,12 @@ ConfigSearchWindow::ConfigSearchWindow(ConfigMainWindow* parent, const char *nam void ConfigSearchWindow::saveSettings(void) { - if (name()) { - configSettings->beginGroup(name()); - configSettings->writeEntry("/window x", pos().x()); - configSettings->writeEntry("/window y", pos().y()); - configSettings->writeEntry("/window width", size().width()); - configSettings->writeEntry("/window height", size().height()); + if (!objectName().isEmpty()) { + configSettings->beginGroup(objectName()); + configSettings->setValue("/window x", pos().x()); + configSettings->setValue("/window y", pos().y()); + configSettings->setValue("/window width", size().width()); + configSettings->setValue("/window height", size().height()); configSettings->writeSizes("/split", split->sizes()); configSettings->endGroup(); } @@ -1249,7 +1317,7 @@ void ConfigSearchWindow::search(void) list->list->clear(); info->clear(); - result = sym_re_search(editField->text().latin1()); + result = sym_re_search(editField->text().toLatin1()); if (!result) return; for (p = result; *p; p++) { @@ -1266,29 +1334,25 @@ ConfigMainWindow::ConfigMainWindow(void) : searchWindow(0) { QMenuBar* menu; - bool ok; - int x, y, width, height; + bool ok = true; + QVariant x, y; + int width, height; char title[256]; QDesktopWidget *d = configApp->desktop(); snprintf(title, sizeof(title), "%s%s", rootmenu.prompt->text, -#if QT_VERSION < 0x040000 - " (Qt3)" -#else "" -#endif ); - setCaption(title); + setWindowTitle(title); - width = configSettings->readNumEntry("/window width", d->width() - 64); - height = configSettings->readNumEntry("/window height", d->height() - 64); + width = configSettings->value("/window width", d->width() - 64).toInt(); + height = configSettings->value("/window height", d->height() - 64).toInt(); resize(width, height); - x = configSettings->readNumEntry("/window x", 0, &ok); - if (ok) - y = configSettings->readNumEntry("/window y", 0, &ok); - if (ok) - move(x, y); + x = configSettings->value("/window x"); + y = configSettings->value("/window y"); + if ((x.isValid())&&(y.isValid())) + move(x.toInt(), y.toInt()); split1 = new QSplitter(this); split1->setOrientation(Qt::Horizontal); @@ -1305,127 +1369,118 @@ ConfigMainWindow::ConfigMainWindow(void) configList = configView->list; helpText = new ConfigInfoView(split2, "help"); - helpText->setTextFormat(Qt::RichText); setTabOrder(configList, helpText); configList->setFocus(); menu = menuBar(); - toolBar = new Q3ToolBar("Tools", this); - - backAction = new Q3Action("Back", QPixmap(xpm_back), "Back", 0, this); - connect(backAction, SIGNAL(activated()), SLOT(goBack())); - backAction->setEnabled(FALSE); - Q3Action *quitAction = new Q3Action("Quit", "&Quit", Qt::CTRL + Qt::Key_Q, this); - connect(quitAction, SIGNAL(activated()), SLOT(close())); - Q3Action *loadAction = new Q3Action("Load", QPixmap(xpm_load), "&Load", Qt::CTRL + Qt::Key_L, this); - connect(loadAction, SIGNAL(activated()), SLOT(loadConfig())); - saveAction = new Q3Action("Save", QPixmap(xpm_save), "&Save", Qt::CTRL + Qt::Key_S, this); - connect(saveAction, SIGNAL(activated()), SLOT(saveConfig())); + toolBar = new QToolBar("Tools", this); + addToolBar(toolBar); + + backAction = new QAction(QPixmap(xpm_back), "Back", this); + connect(backAction, SIGNAL(triggered(bool)), SLOT(goBack())); + backAction->setEnabled(false); + QAction *quitAction = new QAction("&Quit", this); + quitAction->setShortcut(Qt::CTRL + Qt::Key_Q); + connect(quitAction, SIGNAL(triggered(bool)), SLOT(close())); + QAction *loadAction = new QAction(QPixmap(xpm_load), "&Load", this); + loadAction->setShortcut(Qt::CTRL + Qt::Key_L); + connect(loadAction, SIGNAL(triggered(bool)), SLOT(loadConfig())); + saveAction = new QAction(QPixmap(xpm_save), "&Save", this); + saveAction->setShortcut(Qt::CTRL + Qt::Key_S); + connect(saveAction, SIGNAL(triggered(bool)), SLOT(saveConfig())); conf_set_changed_callback(conf_changed); // Set saveAction's initial state conf_changed(); - Q3Action *saveAsAction = new Q3Action("Save As...", "Save &As...", 0, this); - connect(saveAsAction, SIGNAL(activated()), SLOT(saveConfigAs())); - Q3Action *searchAction = new Q3Action("Find", "&Find", Qt::CTRL + Qt::Key_F, this); - connect(searchAction, SIGNAL(activated()), SLOT(searchConfig())); - Q3Action *singleViewAction = new Q3Action("Single View", QPixmap(xpm_single_view), "Single View", 0, this); - connect(singleViewAction, SIGNAL(activated()), SLOT(showSingleView())); - Q3Action *splitViewAction = new Q3Action("Split View", QPixmap(xpm_split_view), "Split View", 0, this); - connect(splitViewAction, SIGNAL(activated()), SLOT(showSplitView())); - Q3Action *fullViewAction = new Q3Action("Full View", QPixmap(xpm_tree_view), "Full View", 0, this); - connect(fullViewAction, SIGNAL(activated()), SLOT(showFullView())); - - Q3Action *showNameAction = new Q3Action(NULL, "Show Name", 0, this); - showNameAction->setToggleAction(TRUE); + configname = xstrdup(conf_get_configname()); + + QAction *saveAsAction = new QAction("Save &As...", this); + connect(saveAsAction, SIGNAL(triggered(bool)), SLOT(saveConfigAs())); + QAction *searchAction = new QAction("&Find", this); + searchAction->setShortcut(Qt::CTRL + Qt::Key_F); + connect(searchAction, SIGNAL(triggered(bool)), SLOT(searchConfig())); + singleViewAction = new QAction(QPixmap(xpm_single_view), "Single View", this); + singleViewAction->setCheckable(true); + connect(singleViewAction, SIGNAL(triggered(bool)), SLOT(showSingleView())); + splitViewAction = new QAction(QPixmap(xpm_split_view), "Split View", this); + splitViewAction->setCheckable(true); + connect(splitViewAction, SIGNAL(triggered(bool)), SLOT(showSplitView())); + fullViewAction = new QAction(QPixmap(xpm_tree_view), "Full View", this); + fullViewAction->setCheckable(true); + connect(fullViewAction, SIGNAL(triggered(bool)), SLOT(showFullView())); + + QAction *showNameAction = new QAction("Show Name", this); + showNameAction->setCheckable(true); connect(showNameAction, SIGNAL(toggled(bool)), configView, SLOT(setShowName(bool))); - connect(configView, SIGNAL(showNameChanged(bool)), showNameAction, SLOT(setOn(bool))); - showNameAction->setOn(configView->showName()); - Q3Action *showRangeAction = new Q3Action(NULL, "Show Range", 0, this); - showRangeAction->setToggleAction(TRUE); + showNameAction->setChecked(configView->showName()); + QAction *showRangeAction = new QAction("Show Range", this); + showRangeAction->setCheckable(true); connect(showRangeAction, SIGNAL(toggled(bool)), configView, SLOT(setShowRange(bool))); - connect(configView, SIGNAL(showRangeChanged(bool)), showRangeAction, SLOT(setOn(bool))); - showRangeAction->setOn(configList->showRange); - Q3Action *showDataAction = new Q3Action(NULL, "Show Data", 0, this); - showDataAction->setToggleAction(TRUE); + QAction *showDataAction = new QAction("Show Data", this); + showDataAction->setCheckable(true); connect(showDataAction, SIGNAL(toggled(bool)), configView, SLOT(setShowData(bool))); - connect(configView, SIGNAL(showDataChanged(bool)), showDataAction, SLOT(setOn(bool))); - showDataAction->setOn(configList->showData); QActionGroup *optGroup = new QActionGroup(this); - optGroup->setExclusive(TRUE); - connect(optGroup, SIGNAL(selected(QAction *)), configView, + optGroup->setExclusive(true); + connect(optGroup, SIGNAL(triggered(QAction*)), configView, SLOT(setOptionMode(QAction *))); - connect(optGroup, SIGNAL(selected(QAction *)), menuView, + connect(optGroup, SIGNAL(triggered(QAction *)), menuView, SLOT(setOptionMode(QAction *))); -#if QT_VERSION >= 0x040000 configView->showNormalAction = new QAction("Show Normal Options", optGroup); configView->showAllAction = new QAction("Show All Options", optGroup); configView->showPromptAction = new QAction("Show Prompt Options", optGroup); -#else - configView->showNormalAction = new QAction("Show Normal Options", 0, optGroup); - configView->showAllAction = new QAction("Show All Options", 0, optGroup); - configView->showPromptAction = new QAction("Show Prompt Options", 0, optGroup); -#endif - configView->showNormalAction->setToggleAction(TRUE); - configView->showNormalAction->setOn(configList->optMode == normalOpt); - configView->showAllAction->setToggleAction(TRUE); - configView->showAllAction->setOn(configList->optMode == allOpt); - configView->showPromptAction->setToggleAction(TRUE); - configView->showPromptAction->setOn(configList->optMode == promptOpt); - - Q3Action *showDebugAction = new Q3Action(NULL, "Show Debug Info", 0, this); - showDebugAction->setToggleAction(TRUE); + configView->showNormalAction->setCheckable(true); + configView->showAllAction->setCheckable(true); + configView->showPromptAction->setCheckable(true); + + QAction *showDebugAction = new QAction("Show Debug Info", this); + showDebugAction->setCheckable(true); connect(showDebugAction, SIGNAL(toggled(bool)), helpText, SLOT(setShowDebug(bool))); - connect(helpText, SIGNAL(showDebugChanged(bool)), showDebugAction, SLOT(setOn(bool))); - showDebugAction->setOn(helpText->showDebug()); + showDebugAction->setChecked(helpText->showDebug()); - Q3Action *showIntroAction = new Q3Action(NULL, "Introduction", 0, this); - connect(showIntroAction, SIGNAL(activated()), SLOT(showIntro())); - Q3Action *showAboutAction = new Q3Action(NULL, "About", 0, this); - connect(showAboutAction, SIGNAL(activated()), SLOT(showAbout())); + QAction *showIntroAction = new QAction("Introduction", this); + connect(showIntroAction, SIGNAL(triggered(bool)), SLOT(showIntro())); + QAction *showAboutAction = new QAction("About", this); + connect(showAboutAction, SIGNAL(triggered(bool)), SLOT(showAbout())); // init tool bar - backAction->addTo(toolBar); + toolBar->addAction(backAction); toolBar->addSeparator(); - loadAction->addTo(toolBar); - saveAction->addTo(toolBar); + toolBar->addAction(loadAction); + toolBar->addAction(saveAction); toolBar->addSeparator(); - singleViewAction->addTo(toolBar); - splitViewAction->addTo(toolBar); - fullViewAction->addTo(toolBar); + toolBar->addAction(singleViewAction); + toolBar->addAction(splitViewAction); + toolBar->addAction(fullViewAction); // create config menu - Q3PopupMenu* config = new Q3PopupMenu(this); - menu->insertItem("&File", config); - loadAction->addTo(config); - saveAction->addTo(config); - saveAsAction->addTo(config); - config->insertSeparator(); - quitAction->addTo(config); + QMenu* config = menu->addMenu("&File"); + config->addAction(loadAction); + config->addAction(saveAction); + config->addAction(saveAsAction); + config->addSeparator(); + config->addAction(quitAction); // create edit menu - Q3PopupMenu* editMenu = new Q3PopupMenu(this); - menu->insertItem("&Edit", editMenu); - searchAction->addTo(editMenu); + QMenu* editMenu = menu->addMenu("&Edit"); + editMenu->addAction(searchAction); // create options menu - Q3PopupMenu* optionMenu = new Q3PopupMenu(this); - menu->insertItem("&Option", optionMenu); - showNameAction->addTo(optionMenu); - showRangeAction->addTo(optionMenu); - showDataAction->addTo(optionMenu); - optionMenu->insertSeparator(); - optGroup->addTo(optionMenu); - optionMenu->insertSeparator(); + QMenu* optionMenu = menu->addMenu("&Option"); + optionMenu->addAction(showNameAction); + optionMenu->addAction(showRangeAction); + optionMenu->addAction(showDataAction); + optionMenu->addSeparator(); + optionMenu->addActions(optGroup->actions()); + optionMenu->addSeparator(); + optionMenu->addAction(showDebugAction); // create help menu - Q3PopupMenu* helpMenu = new Q3PopupMenu(this); - menu->insertSeparator(); - menu->insertItem("&Help", helpMenu); - showIntroAction->addTo(helpMenu); - showAboutAction->addTo(helpMenu); + menu->addSeparator(); + QMenu* helpMenu = menu->addMenu("&Help"); + helpMenu->addAction(showIntroAction); + helpMenu->addAction(showAboutAction); connect(configList, SIGNAL(menuChanged(struct menu *)), helpText, SLOT(setInfo(struct menu *))); @@ -1447,7 +1502,7 @@ ConfigMainWindow::ConfigMainWindow(void) connect(helpText, SIGNAL(menuSelected(struct menu *)), SLOT(setMenuLink(struct menu *))); - QString listMode = configSettings->readEntry("/listMode", "symbol"); + QString listMode = configSettings->value("/listMode", "symbol").toString(); if (listMode == "single") showSingleView(); else if (listMode == "full") @@ -1456,7 +1511,7 @@ ConfigMainWindow::ConfigMainWindow(void) showSplitView(); // UI setup done, restore splitter positions - Q3ValueList sizes = configSettings->readSizes("/split1", &ok); + QList sizes = configSettings->readSizes("/split1", &ok); if (ok) split1->setSizes(sizes); @@ -1467,29 +1522,57 @@ ConfigMainWindow::ConfigMainWindow(void) void ConfigMainWindow::loadConfig(void) { - QString s = Q3FileDialog::getOpenFileName(conf_get_configname(), NULL, this); - if (s.isNull()) + QString str; + QByteArray ba; + const char *name; + + str = QFileDialog::getOpenFileName(this, "", configname); + if (str.isNull()) return; - if (conf_read(QFile::encodeName(s))) + + ba = str.toLocal8Bit(); + name = ba.data(); + + if (conf_read(name)) QMessageBox::information(this, "qconf", "Unable to load configuration!"); + + free(configname); + configname = xstrdup(name); + ConfigView::updateListAll(); } bool ConfigMainWindow::saveConfig(void) { - if (conf_write(NULL)) { + if (conf_write(configname)) { QMessageBox::information(this, "qconf", "Unable to save configuration!"); return false; } + conf_write_autoconf(0); + return true; } void ConfigMainWindow::saveConfigAs(void) { - QString s = Q3FileDialog::getSaveFileName(conf_get_configname(), NULL, this); - if (s.isNull()) + QString str; + QByteArray ba; + const char *name; + + str = QFileDialog::getSaveFileName(this, "", configname); + if (str.isNull()) return; - saveConfig(); + + ba = str.toLocal8Bit(); + name = ba.data(); + + if (conf_write(name)) { + QMessageBox::information(this, "qconf", "Unable to save configuration!"); + } + conf_write_autoconf(0); + + free(configname); + configname = xstrdup(name); } void ConfigMainWindow::searchConfig(void) @@ -1503,9 +1586,9 @@ void ConfigMainWindow::changeMenu(struct menu *menu) { configList->setRootMenu(menu); if (configList->rootEntry->parent == &rootmenu) - backAction->setEnabled(FALSE); + backAction->setEnabled(false); else - backAction->setEnabled(TRUE); + backAction->setEnabled(true); } void ConfigMainWindow::setMenuLink(struct menu *menu) @@ -1537,8 +1620,8 @@ void ConfigMainWindow::setMenuLink(struct menu *menu) return; item = menuList->findConfigItem(parent); if (item) { - menuList->setSelected(item, TRUE); - menuList->ensureItemVisible(item); + item->setSelected(true); + menuList->scrollToItem(item); } list->setRootMenu(parent); } @@ -1553,8 +1636,8 @@ void ConfigMainWindow::setMenuLink(struct menu *menu) if (list) { item = list->findConfigItem(menu); if (item) { - list->setSelected(item, TRUE); - list->ensureItemVisible(item); + item->setSelected(true); + list->scrollToItem(item); list->setFocus(); } } @@ -1568,15 +1651,21 @@ void ConfigMainWindow::listFocusChanged(void) void ConfigMainWindow::goBack(void) { - ConfigItem* item; + ConfigItem* item, *oldSelection; configList->setParentMenu(); if (configList->rootEntry == &rootmenu) - backAction->setEnabled(FALSE); - item = (ConfigItem*)menuList->selectedItem(); + backAction->setEnabled(false); + + if (menuList->selectedItems().count() == 0) + return; + + item = (ConfigItem*)menuList->selectedItems().first(); + oldSelection = item; while (item) { if (item->menu == configList->rootEntry) { - menuList->setSelected(item, TRUE); + oldSelection->setSelected(false); + item->setSelected(true); break; } item = (ConfigItem*)item->parent(); @@ -1585,6 +1674,13 @@ void ConfigMainWindow::goBack(void) void ConfigMainWindow::showSingleView(void) { + singleViewAction->setEnabled(false); + singleViewAction->setChecked(true); + splitViewAction->setEnabled(true); + splitViewAction->setChecked(false); + fullViewAction->setEnabled(true); + fullViewAction->setChecked(false); + menuView->hide(); menuList->setRootMenu(0); configList->mode = singleMode; @@ -1592,28 +1688,41 @@ void ConfigMainWindow::showSingleView(void) configList->updateListAll(); else configList->setRootMenu(&rootmenu); - configList->setAllOpen(TRUE); configList->setFocus(); } void ConfigMainWindow::showSplitView(void) { + singleViewAction->setEnabled(true); + singleViewAction->setChecked(false); + splitViewAction->setEnabled(false); + splitViewAction->setChecked(true); + fullViewAction->setEnabled(true); + fullViewAction->setChecked(false); + configList->mode = symbolMode; if (configList->rootEntry == &rootmenu) configList->updateListAll(); else configList->setRootMenu(&rootmenu); - configList->setAllOpen(TRUE); + configList->setAllOpen(true); configApp->processEvents(); menuList->mode = menuMode; menuList->setRootMenu(&rootmenu); - menuList->setAllOpen(TRUE); + menuList->setAllOpen(true); menuView->show(); menuList->setFocus(); } void ConfigMainWindow::showFullView(void) { + singleViewAction->setEnabled(true); + singleViewAction->setChecked(false); + splitViewAction->setEnabled(true); + splitViewAction->setChecked(false); + fullViewAction->setEnabled(false); + fullViewAction->setChecked(true); + menuView->hide(); menuList->setRootMenu(0); configList->mode = fullMode; @@ -1621,7 +1730,6 @@ void ConfigMainWindow::showFullView(void) configList->updateListAll(); else configList->setRootMenu(&rootmenu); - configList->setAllOpen(FALSE); configList->setFocus(); } @@ -1668,14 +1776,15 @@ void ConfigMainWindow::showIntro(void) "options must be enabled to support the option you are interested in, you can\n" "still view the help of a grayed-out option.\n\n" "Toggling Show Debug Info under the Options menu will show the dependencies,\n" - "which you can then match by examining other options.\n\n"); + "which you can then match by examining other options.\n\n"; QMessageBox::information(this, "qconf", str); } void ConfigMainWindow::showAbout(void) { - static const QString str = "qconf is Copyright (C) 2002 Roman Zippel .\n\n" + static const QString str = "qconf is Copyright (C) 2002 Roman Zippel .\n" + "Copyright (C) 2015 Boris Barbulovski .\n\n" "Bug reports and feature request can also be entered at http://bugzilla.kernel.org/\n"; QMessageBox::information(this, "qconf", str); @@ -1683,10 +1792,10 @@ void ConfigMainWindow::showAbout(void) void ConfigMainWindow::saveSettings(void) { - configSettings->writeEntry("/window x", pos().x()); - configSettings->writeEntry("/window y", pos().y()); - configSettings->writeEntry("/window width", size().width()); - configSettings->writeEntry("/window height", size().height()); + configSettings->setValue("/window x", pos().x()); + configSettings->setValue("/window y", pos().y()); + configSettings->setValue("/window width", size().width()); + configSettings->setValue("/window height", size().height()); QString entry; switch(configList->mode) { @@ -1705,7 +1814,7 @@ void ConfigMainWindow::saveSettings(void) default: break; } - configSettings->writeEntry("/listMode", entry); + configSettings->setValue("/listMode", entry); configSettings->writeSizes("/split1", split1->sizes()); configSettings->writeSizes("/split2", split2->sizes()); @@ -1773,7 +1882,6 @@ int main(int ac, char** av) v = new ConfigMainWindow(); //zconfdump(stdout); - configApp->setMainWidget(v); configApp->connect(configApp, SIGNAL(lastWindowClosed()), SLOT(quit())); configApp->connect(configApp, SIGNAL(aboutToQuit()), v, SLOT(saveSettings())); v->show(); @@ -1781,6 +1889,8 @@ int main(int ac, char** av) configSettings->endGroup(); delete configSettings; + delete v; + delete configApp; return 0; } diff --git a/xen/tools/kconfig/qconf.h b/xen/tools/kconfig/qconf.h index bde0c6b6f9e8..45bfe9b2b966 100644 --- a/xen/tools/kconfig/qconf.h +++ b/xen/tools/kconfig/qconf.h @@ -1,28 +1,20 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* * Copyright (C) 2002 Roman Zippel - * Released under the terms of the GNU GPL v2.0. */ -#if QT_VERSION < 0x040000 -#include -#else -#include -#endif +#include +#include +#include +#include #include - -#if QT_VERSION < 0x040000 -#define Q3ValueList QValueList -#define Q3PopupMenu QPopupMenu -#define Q3ListView QListView -#define Q3ListViewItem QListViewItem -#define Q3VBox QVBox -#define Q3TextBrowser QTextBrowser -#define Q3MainWindow QMainWindow -#define Q3Action QAction -#define Q3ToolBar QToolBar -#define Q3ListViewItemIterator QListViewItemIterator -#define Q3FileDialog QFileDialog -#endif +#include +#include +#include +#include +#include +#include +#include "expr.h" class ConfigView; class ConfigList; @@ -33,8 +25,8 @@ class ConfigMainWindow; class ConfigSettings : public QSettings { public: ConfigSettings(); - Q3ValueList readSizes(const QString& key, bool *ok); - bool writeSizes(const QString& key, const Q3ValueList& value); + QList readSizes(const QString& key, bool *ok); + bool writeSizes(const QString& key, const QList& value); }; enum colIdx { @@ -47,9 +39,9 @@ enum optionMode { normalOpt = 0, allOpt, promptOpt }; -class ConfigList : public Q3ListView { +class ConfigList : public QTreeWidget { Q_OBJECT - typedef class Q3ListView Parent; + typedef class QTreeWidget Parent; public: ConfigList(ConfigView* p, const char *name = 0); void reinit(void); @@ -61,10 +53,10 @@ class ConfigList : public Q3ListView { protected: void keyPressEvent(QKeyEvent *e); - void contentsMousePressEvent(QMouseEvent *e); - void contentsMouseReleaseEvent(QMouseEvent *e); - void contentsMouseMoveEvent(QMouseEvent *e); - void contentsMouseDoubleClickEvent(QMouseEvent *e); + void mousePressEvent(QMouseEvent *e); + void mouseReleaseEvent(QMouseEvent *e); + void mouseMoveEvent(QMouseEvent *e); + void mouseDoubleClickEvent(QMouseEvent *e); void focusInEvent(QFocusEvent *e); void contextMenuEvent(QContextMenuEvent *e); @@ -95,32 +87,23 @@ public slots: } ConfigItem* firstChild() const { - return (ConfigItem *)Parent::firstChild(); - } - int mapIdx(colIdx idx) - { - return colMap[idx]; + return (ConfigItem *)children().first(); } - void addColumn(colIdx idx, const QString& label) + void addColumn(colIdx idx) { - colMap[idx] = Parent::addColumn(label); - colRevMap[colMap[idx]] = idx; + showColumn(idx); } void removeColumn(colIdx idx) { - int col = colMap[idx]; - if (col >= 0) { - Parent::removeColumn(col); - colRevMap[col] = colMap[idx] = -1; - } + hideColumn(idx); } void setAllOpen(bool open); void setParentMenu(void); bool menuSkip(struct menu *); - template - void updateMenuList(P*, struct menu*); + void updateMenuList(ConfigItem *parent, struct menu*); + void updateMenuList(ConfigList *parent, struct menu*); bool updateAll; @@ -132,30 +115,26 @@ public slots: enum listMode mode; enum optionMode optMode; struct menu *rootEntry; - QColorGroup disabledColorGroup; - QColorGroup inactivedColorGroup; - Q3PopupMenu* headerPopup; - -private: - int colMap[colNr]; - int colRevMap[colNr]; + QPalette disabledColorGroup; + QPalette inactivedColorGroup; + QMenu* headerPopup; }; -class ConfigItem : public Q3ListViewItem { - typedef class Q3ListViewItem Parent; +class ConfigItem : public QTreeWidgetItem { + typedef class QTreeWidgetItem Parent; public: - ConfigItem(Q3ListView *parent, ConfigItem *after, struct menu *m, bool v) - : Parent(parent, after), menu(m), visible(v), goParent(false) + ConfigItem(ConfigList *parent, ConfigItem *after, struct menu *m, bool v) + : Parent(parent, after), nextItem(0), menu(m), visible(v), goParent(false) { init(); } ConfigItem(ConfigItem *parent, ConfigItem *after, struct menu *m, bool v) - : Parent(parent, after), menu(m), visible(v), goParent(false) + : Parent(parent, after), nextItem(0), menu(m), visible(v), goParent(false) { init(); } - ConfigItem(Q3ListView *parent, ConfigItem *after, bool v) - : Parent(parent, after), menu(0), visible(v), goParent(true) + ConfigItem(ConfigList *parent, ConfigItem *after, bool v) + : Parent(parent, after), nextItem(0), menu(0), visible(v), goParent(true) { init(); } @@ -166,33 +145,43 @@ class ConfigItem : public Q3ListViewItem { void testUpdateMenu(bool v); ConfigList* listView() const { - return (ConfigList*)Parent::listView(); + return (ConfigList*)Parent::treeWidget(); } ConfigItem* firstChild() const { - return (ConfigItem *)Parent::firstChild(); + return (ConfigItem *)Parent::child(0); } - ConfigItem* nextSibling() const + ConfigItem* nextSibling() { - return (ConfigItem *)Parent::nextSibling(); + ConfigItem *ret = NULL; + ConfigItem *_parent = (ConfigItem *)parent(); + + if(_parent) { + ret = (ConfigItem *)_parent->child(_parent->indexOfChild(this)+1); + } else { + QTreeWidget *_treeWidget = treeWidget(); + ret = (ConfigItem *)_treeWidget->topLevelItem(_treeWidget->indexOfTopLevelItem(this)+1); + } + + return ret; } void setText(colIdx idx, const QString& text) { - Parent::setText(listView()->mapIdx(idx), text); + Parent::setText(idx, text); } QString text(colIdx idx) const { - return Parent::text(listView()->mapIdx(idx)); + return Parent::text(idx); } - void setPixmap(colIdx idx, const QPixmap& pm) + void setPixmap(colIdx idx, const QIcon &icon) { - Parent::setPixmap(listView()->mapIdx(idx), pm); + Parent::setIcon(idx, icon); } - const QPixmap* pixmap(colIdx idx) const + const QIcon pixmap(colIdx idx) const { - return Parent::pixmap(listView()->mapIdx(idx)); + return icon(idx); } - void paintCell(QPainter* p, const QColorGroup& cg, int column, int width, int align); + // TODO: Implement paintCell ConfigItem* nextItem; struct menu *menu; @@ -216,9 +205,9 @@ class ConfigLineEdit : public QLineEdit { ConfigItem *item; }; -class ConfigView : public Q3VBox { +class ConfigView : public QWidget { Q_OBJECT - typedef class Q3VBox Parent; + typedef class QWidget Parent; public: ConfigView(QWidget* parent, const char *name = 0); ~ConfigView(void); @@ -249,9 +238,9 @@ public slots: static QAction *showPromptAction; }; -class ConfigInfoView : public Q3TextBrowser { +class ConfigInfoView : public QTextBrowser { Q_OBJECT - typedef class Q3TextBrowser Parent; + typedef class QTextBrowser Parent; public: ConfigInfoView(QWidget* parent, const char *name = 0); bool showDebug(void) const { return _showDebug; } @@ -271,8 +260,8 @@ public slots: QString debug_info(struct symbol *sym); static QString print_filter(const QString &str); static void expr_print_help(void *data, struct symbol *sym, const char *str); - Q3PopupMenu* createPopupMenu(const QPoint& pos); - void contentsContextMenuEvent(QContextMenuEvent *e); + QMenu *createStandardContextMenu(const QPoint & pos); + void contextMenuEvent(QContextMenuEvent *e); struct symbol *sym; struct menu *_menu; @@ -299,10 +288,11 @@ public slots: struct symbol **result; }; -class ConfigMainWindow : public Q3MainWindow { +class ConfigMainWindow : public QMainWindow { Q_OBJECT - static Q3Action *saveAction; + char *configname; + static QAction *saveAction; static void conf_changed(void); public: ConfigMainWindow(void); @@ -331,8 +321,11 @@ public slots: ConfigView *configView; ConfigList *configList; ConfigInfoView *helpText; - Q3ToolBar *toolBar; - Q3Action *backAction; - QSplitter* split1; - QSplitter* split2; + QToolBar *toolBar; + QAction *backAction; + QAction *singleViewAction; + QAction *splitViewAction; + QAction *fullViewAction; + QSplitter *split1; + QSplitter *split2; }; diff --git a/xen/tools/kconfig/streamline_config.pl b/xen/tools/kconfig/streamline_config.pl index f3d3fb42b873..08d76d7b3b81 100755 --- a/xen/tools/kconfig/streamline_config.pl +++ b/xen/tools/kconfig/streamline_config.pl @@ -1,7 +1,7 @@ -#!/usr/bin/perl -w +#!/usr/bin/env perl +# SPDX-License-Identifier: GPL-2.0 # # Copyright 2005-2009 - Steven Rostedt -# Licensed under the terms of the GNU GPL License version 2 # # It's simple enough to figure out how this works. # If not, then you can ask me at stripconfig@goodmis.org @@ -42,6 +42,7 @@ # mv config_strip .config # make oldconfig # +use warnings; use strict; use Getopt::Long; @@ -164,10 +165,10 @@ sub read_kconfig { my $last_source = ""; # Check for any environment variables used - while ($source =~ /\$(\w+)/ && $last_source ne $source) { + while ($source =~ /\$\((\w+)\)/ && $last_source ne $source) { my $env = $1; $last_source = $source; - $source =~ s/\$$env/$ENV{$env}/; + $source =~ s/\$\($env\)/$ENV{$env}/; } open(my $kinfile, '<', $source) || die "Can't open $kconfig"; @@ -188,7 +189,7 @@ sub read_kconfig { $cont = 0; # collect any Kconfig sources - if (/^source\s*"(.*)"/) { + if (/^source\s+"?([^"]+)/) { my $kconfig = $1; # prevent reading twice. if (!defined($read_kconfigs{$kconfig})) { @@ -237,7 +238,7 @@ sub read_kconfig { } # configs without prompts must be selected - } elsif ($state ne "NONE" && /^\s*tristate\s\S/) { + } elsif ($state ne "NONE" && /^\s*(tristate\s+\S|prompt\b)/) { # note if the config has a prompt $prompts{$config} = 1; @@ -256,8 +257,8 @@ sub read_kconfig { $iflevel-- if ($iflevel); - # stop on "help" - } elsif (/^\s*help\s*$/) { + # stop on "help" and keywords that end a menu entry + } elsif (/^\s*(---)?help(---)?\s*$/ || /^(comment|choice|menu)\b/) { $state = "NONE"; } } @@ -454,7 +455,7 @@ sub parse_config_depends $p =~ s/^[^$valid]*[$valid]+//; # We only need to process if the depend config is a module - if (!defined($orig_configs{$conf}) || !$orig_configs{conf} eq "m") { + if (!defined($orig_configs{$conf}) || $orig_configs{$conf} eq "y") { next; } @@ -610,6 +611,40 @@ foreach my $line (@config_file) { next; } + if (/CONFIG_MODULE_SIG_KEY="(.+)"/) { + my $orig_cert = $1; + my $default_cert = "certs/signing_key.pem"; + + # Check that the logic in this script still matches the one in Kconfig + if (!defined($depends{"MODULE_SIG_KEY"}) || + $depends{"MODULE_SIG_KEY"} !~ /"\Q$default_cert\E"/) { + print STDERR "WARNING: MODULE_SIG_KEY assertion failure, ", + "update needed to ", __FILE__, " line ", __LINE__, "\n"; + print; + } elsif ($orig_cert ne $default_cert && ! -f $orig_cert) { + print STDERR "Module signature verification enabled but ", + "module signing key \"$orig_cert\" not found. Resetting ", + "signing key to default value.\n"; + print "CONFIG_MODULE_SIG_KEY=\"$default_cert\"\n"; + } else { + print; + } + next; + } + + if (/CONFIG_SYSTEM_TRUSTED_KEYS="(.+)"/) { + my $orig_keys = $1; + + if (! -f $orig_keys) { + print STDERR "System keyring enabled but keys \"$orig_keys\" ", + "not found. Resetting keys to default value.\n"; + print "CONFIG_SYSTEM_TRUSTED_KEYS=\"\"\n"; + } else { + print; + } + next; + } + if (/^(CONFIG.*)=(m|y)/) { if (defined($configs{$1})) { if ($localyesconfig) { diff --git a/xen/tools/kconfig/symbol.c b/xen/tools/kconfig/symbol.c index 50878dc025a5..f56eec5ea4c7 100644 --- a/xen/tools/kconfig/symbol.c +++ b/xen/tools/kconfig/symbol.c @@ -1,6 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) 2002 Roman Zippel - * Released under the terms of the GNU GPL v2.0. */ #include @@ -33,33 +33,6 @@ struct symbol *sym_defconfig_list; struct symbol *modules_sym; tristate modules_val; -struct expr *sym_env_list; - -static void sym_add_default(struct symbol *sym, const char *def) -{ - struct property *prop = prop_alloc(P_DEFAULT, sym); - - prop->expr = expr_alloc_symbol(sym_lookup(def, SYMBOL_CONST)); -} - -void sym_init(void) -{ - struct symbol *sym; - struct utsname uts; - static bool inited = false; - - if (inited) - return; - inited = true; - - uname(&uts); - - sym = sym_lookup("UNAME_RELEASE", 0); - sym->type = S_STRING; - sym->flags |= SYMBOL_AUTO; - sym_add_default(sym, uts.release); -} - enum symbol_type sym_get_type(struct symbol *sym) { enum symbol_type type = sym->type; @@ -77,7 +50,7 @@ const char *sym_type_name(enum symbol_type type) { switch (type) { case S_BOOLEAN: - return "boolean"; + return "bool"; case S_TRISTATE: return "tristate"; case S_INT: @@ -88,8 +61,6 @@ const char *sym_type_name(enum symbol_type type) return "string"; case S_UNKNOWN: return "unknown"; - case S_OTHER: - break; } return "???"; } @@ -103,15 +74,6 @@ struct property *sym_get_choice_prop(struct symbol *sym) return NULL; } -struct property *sym_get_env_prop(struct symbol *sym) -{ - struct property *prop; - - for_all_properties(sym, prop, P_ENV) - return prop; - return NULL; -} - static struct property *sym_get_default_prop(struct symbol *sym) { struct property *prop; @@ -124,7 +86,7 @@ static struct property *sym_get_default_prop(struct symbol *sym) return NULL; } -static struct property *sym_get_range_prop(struct symbol *sym) +struct property *sym_get_range_prop(struct symbol *sym) { struct property *prop; @@ -183,7 +145,7 @@ static void sym_validate_range(struct symbol *sym) sprintf(str, "%lld", val2); else sprintf(str, "0x%llx", val2); - sym->curr.val = strdup(str); + sym->curr.val = xstrdup(str); } static void sym_set_changed(struct symbol *sym) @@ -209,12 +171,26 @@ static void sym_set_all_changed(void) static void sym_calc_visibility(struct symbol *sym) { struct property *prop; + struct symbol *choice_sym = NULL; tristate tri; /* any prompt visible? */ tri = no; + + if (sym_is_choice_value(sym)) + choice_sym = prop_get_symbol(sym_get_choice_prop(sym)); + for_all_prompts(sym, prop) { prop->visible.tri = expr_calc_value(prop->visible.expr); + /* + * Tristate choice_values with visibility 'mod' are + * not visible if the corresponding choice's value is + * 'yes'. + */ + if (choice_sym && sym->type == S_TRISTATE && + prop->visible.tri == mod && choice_sym->curr.tri == yes) + prop->visible.tri = no; + tri = EXPR_OR(tri, prop->visible.tri); } if (tri == mod && (sym->type != S_TRISTATE || modules_val == no)) @@ -229,7 +205,7 @@ static void sym_calc_visibility(struct symbol *sym) tri = yes; if (sym->dir_dep.expr) tri = expr_calc_value(sym->dir_dep.expr); - if (tri == mod) + if (tri == mod && sym_get_type(sym) == S_BOOLEAN) tri = yes; if (sym->dir_dep.tri != tri) { sym->dir_dep.tri = tri; @@ -244,6 +220,15 @@ static void sym_calc_visibility(struct symbol *sym) sym->rev_dep.tri = tri; sym_set_changed(sym); } + tri = no; + if (sym->implied.expr && sym->dir_dep.tri != no) + tri = expr_calc_value(sym->implied.expr); + if (tri == mod && sym_get_type(sym) == S_BOOLEAN) + tri = yes; + if (sym->implied.tri != tri) { + sym->implied.tri = tri; + sym_set_changed(sym); + } } /* @@ -310,6 +295,27 @@ static struct symbol *sym_calc_choice(struct symbol *sym) return def_sym; } +static void sym_warn_unmet_dep(struct symbol *sym) +{ + struct gstr gs = str_new(); + + str_printf(&gs, + "\nWARNING: unmet direct dependencies detected for %s\n", + sym->name); + str_printf(&gs, + " Depends on [%c]: ", + sym->dir_dep.tri == mod ? 'm' : 'n'); + expr_gstr_print(sym->dir_dep.expr, &gs); + str_printf(&gs, "\n"); + + expr_gstr_print_revdep(sym->rev_dep.expr, &gs, yes, + " Selected by [y]:\n"); + expr_gstr_print_revdep(sym->rev_dep.expr, &gs, mod, + " Selected by [m]:\n"); + + fputs(str_get(&gs), stderr); +} + void sym_calc_value(struct symbol *sym) { struct symbol_value newval, oldval; @@ -348,11 +354,13 @@ void sym_calc_value(struct symbol *sym) sym->curr.tri = no; return; } - if (!sym_is_choice_value(sym)) - sym->flags &= ~SYMBOL_WRITE; + sym->flags &= ~SYMBOL_WRITE; sym_calc_visibility(sym); + if (sym->visible != no) + sym->flags |= SYMBOL_WRITE; + /* set default if recursively called */ sym->curr = newval; @@ -367,7 +375,6 @@ void sym_calc_value(struct symbol *sym) /* if the symbol is visible use the user value * if available, otherwise try the default value */ - sym->flags |= SYMBOL_WRITE; if (sym_has_value(sym)) { newval.tri = EXPR_AND(sym->def[S_DEF_USER].tri, sym->visible); @@ -379,38 +386,31 @@ void sym_calc_value(struct symbol *sym) if (!sym_is_choice(sym)) { prop = sym_get_default_prop(sym); if (prop) { - sym->flags |= SYMBOL_WRITE; newval.tri = EXPR_AND(expr_calc_value(prop->expr), prop->visible.tri); + if (newval.tri != no) + sym->flags |= SYMBOL_WRITE; + } + if (sym->implied.tri != no) { + sym->flags |= SYMBOL_WRITE; + newval.tri = EXPR_OR(newval.tri, sym->implied.tri); } } calc_newval: - if (sym->dir_dep.tri == no && sym->rev_dep.tri != no) { - struct expr *e; - e = expr_simplify_unmet_dep(sym->rev_dep.expr, - sym->dir_dep.expr); - fprintf(stderr, "warning: ("); - expr_fprint(e, stderr); - fprintf(stderr, ") selects %s which has unmet direct dependencies (", - sym->name); - expr_fprint(sym->dir_dep.expr, stderr); - fprintf(stderr, ")\n"); - expr_free(e); - } + if (sym->dir_dep.tri < sym->rev_dep.tri) + sym_warn_unmet_dep(sym); newval.tri = EXPR_OR(newval.tri, sym->rev_dep.tri); } - if (newval.tri == mod && sym_get_type(sym) == S_BOOLEAN) + if (newval.tri == mod && + (sym_get_type(sym) == S_BOOLEAN || sym->implied.tri == yes)) newval.tri = yes; break; case S_STRING: case S_HEX: case S_INT: - if (sym->visible != no) { - sym->flags |= SYMBOL_WRITE; - if (sym_has_value(sym)) { - newval.val = sym->def[S_DEF_USER].val; - break; - } + if (sym->visible != no && sym_has_value(sym)) { + newval.val = sym->def[S_DEF_USER].val; + break; } prop = sym_get_default_prop(sym); if (prop) { @@ -452,7 +452,7 @@ void sym_calc_value(struct symbol *sym) } } - if (sym->flags & SYMBOL_AUTO) + if (sym->flags & SYMBOL_NO_WRITE) sym->flags &= ~SYMBOL_WRITE; if (sym->flags & SYMBOL_NEED_SET_CHOICE_VALUES) @@ -484,6 +484,8 @@ bool sym_tristate_within_range(struct symbol *sym, tristate val) return false; if (sym->visible <= sym->rev_dep.tri) return false; + if (sym->implied.tri == yes && val == mod) + return false; if (sym_is_choice_value(sym) && sym->visible == yes) return val == yes; return val >= sym->rev_dep.tri && val <= sym->visible; @@ -736,6 +738,10 @@ const char *sym_get_string_default(struct symbol *sym) if (sym->type == S_BOOLEAN && val == mod) val = yes; + /* adjust the default value if this symbol is implied by another */ + if (val < sym->implied.tri) + val = sym->implied.tri; + switch (sym->type) { case S_BOOLEAN: case S_TRISTATE: @@ -749,7 +755,6 @@ const char *sym_get_string_default(struct symbol *sym) return str; case S_STRING: return str; - case S_OTHER: case S_UNKNOWN: break; } @@ -780,7 +785,7 @@ const char *sym_get_string_value(struct symbol *sym) return (const char *)sym->curr.val; } -bool sym_is_changable(struct symbol *sym) +bool sym_is_changeable(struct symbol *sym) { return sym->visible > sym->rev_dep.tri; } @@ -817,7 +822,7 @@ struct symbol *sym_lookup(const char *name, int flags) : !(symbol->flags & (SYMBOL_CONST|SYMBOL_CHOICE)))) return symbol; } - new_name = strdup(name); + new_name = xstrdup(name); } else { new_name = NULL; hash = 0; @@ -862,55 +867,6 @@ struct symbol *sym_find(const char *name) return symbol; } -/* - * Expand symbol's names embedded in the string given in argument. Symbols' - * name to be expanded shall be prefixed by a '$'. Unknown symbol expands to - * the empty string. - */ -const char *sym_expand_string_value(const char *in) -{ - const char *src; - char *res; - size_t reslen; - - reslen = strlen(in) + 1; - res = xmalloc(reslen); - res[0] = '\0'; - - while ((src = strchr(in, '$'))) { - char *p, name[SYMBOL_MAXLENGTH]; - const char *symval = ""; - struct symbol *sym; - size_t newlen; - - strncat(res, in, src - in); - src++; - - p = name; - while (isalnum(*src) || *src == '_') - *p++ = *src++; - *p = '\0'; - - sym = sym_find(name); - if (sym != NULL) { - sym_calc_value(sym); - symval = sym_get_string_value(sym); - } - - newlen = strlen(res) + strlen(symval) + strlen(src) + 1; - if (newlen > reslen) { - reslen = newlen; - res = realloc(res, reslen); - } - - strcat(res, symval); - in = src; - } - strcat(res, in); - - return res; -} - const char *sym_escape_string_value(const char *in) { const char *p; @@ -1027,7 +983,7 @@ struct symbol **sym_re_search(const char *pattern) } if (sym_match_arr) { qsort(sym_match_arr, cnt, sizeof(struct sym_match), sym_rel_comp); - sym_arr = malloc((cnt+1) * sizeof(struct symbol)); + sym_arr = malloc((cnt+1) * sizeof(struct symbol *)); if (!sym_arr) goto sym_re_search_free; for (i = 0; i < cnt; i++) @@ -1052,7 +1008,7 @@ static struct dep_stack { struct dep_stack *prev, *next; struct symbol *sym; struct property *prop; - struct expr *expr; + struct expr **expr; } *check_top; static void dep_stack_insert(struct dep_stack *stack, struct symbol *sym) @@ -1116,35 +1072,52 @@ static void sym_check_print_recursive(struct symbol *last_sym) if (stack->sym == last_sym) fprintf(stderr, "%s:%d:error: recursive dependency detected!\n", prop->file->name, prop->lineno); - if (stack->expr) { - fprintf(stderr, "%s:%d:\tsymbol %s %s value contains %s\n", - prop->file->name, prop->lineno, + + if (sym_is_choice(sym)) { + fprintf(stderr, "%s:%d:\tchoice %s contains symbol %s\n", + menu->file->name, menu->lineno, + sym->name ? sym->name : "", + next_sym->name ? next_sym->name : ""); + } else if (sym_is_choice_value(sym)) { + fprintf(stderr, "%s:%d:\tsymbol %s is part of choice %s\n", + menu->file->name, menu->lineno, sym->name ? sym->name : "", - prop_get_type_name(prop->type), next_sym->name ? next_sym->name : ""); - } else if (stack->prop) { + } else if (stack->expr == &sym->dir_dep.expr) { fprintf(stderr, "%s:%d:\tsymbol %s depends on %s\n", prop->file->name, prop->lineno, sym->name ? sym->name : "", next_sym->name ? next_sym->name : ""); - } else if (sym_is_choice(sym)) { - fprintf(stderr, "%s:%d:\tchoice %s contains symbol %s\n", - menu->file->name, menu->lineno, + } else if (stack->expr == &sym->rev_dep.expr) { + fprintf(stderr, "%s:%d:\tsymbol %s is selected by %s\n", + prop->file->name, prop->lineno, sym->name ? sym->name : "", next_sym->name ? next_sym->name : ""); - } else if (sym_is_choice_value(sym)) { - fprintf(stderr, "%s:%d:\tsymbol %s is part of choice %s\n", - menu->file->name, menu->lineno, + } else if (stack->expr == &sym->implied.expr) { + fprintf(stderr, "%s:%d:\tsymbol %s is implied by %s\n", + prop->file->name, prop->lineno, sym->name ? sym->name : "", next_sym->name ? next_sym->name : ""); + } else if (stack->expr) { + fprintf(stderr, "%s:%d:\tsymbol %s %s value contains %s\n", + prop->file->name, prop->lineno, + sym->name ? sym->name : "", + prop_get_type_name(prop->type), + next_sym->name ? next_sym->name : ""); } else { - fprintf(stderr, "%s:%d:\tsymbol %s is selected by %s\n", + fprintf(stderr, "%s:%d:\tsymbol %s %s is visible depending on %s\n", prop->file->name, prop->lineno, sym->name ? sym->name : "", + prop_get_type_name(prop->type), next_sym->name ? next_sym->name : ""); } } + fprintf(stderr, + "For a resolution refer to Documentation/kbuild/kconfig-language.rst\n" + "subsection \"Kconfig recursive dependency limitations\"\n" + "\n"); + if (check_top == &cv_stack) dep_stack_remove(); } @@ -1179,7 +1152,7 @@ static struct symbol *sym_check_expr_deps(struct expr *e) default: break; } - printf("Oops! How to check %d?\n", e->type); + fprintf(stderr, "Oops! How to check %d?\n", e->type); return NULL; } @@ -1192,12 +1165,26 @@ static struct symbol *sym_check_sym_deps(struct symbol *sym) dep_stack_insert(&stack, sym); + stack.expr = &sym->dir_dep.expr; + sym2 = sym_check_expr_deps(sym->dir_dep.expr); + if (sym2) + goto out; + + stack.expr = &sym->rev_dep.expr; sym2 = sym_check_expr_deps(sym->rev_dep.expr); if (sym2) goto out; + stack.expr = &sym->implied.expr; + sym2 = sym_check_expr_deps(sym->implied.expr); + if (sym2) + goto out; + + stack.expr = NULL; + for (prop = sym->prop; prop; prop = prop->next) { - if (prop->type == P_CHOICE || prop->type == P_SELECT) + if (prop->type == P_CHOICE || prop->type == P_SELECT || + prop->type == P_IMPLY) continue; stack.prop = prop; sym2 = sym_check_expr_deps(prop->visible.expr); @@ -1205,7 +1192,7 @@ static struct symbol *sym_check_sym_deps(struct symbol *sym) break; if (prop->type != P_DEFAULT || sym_is_choice(sym)) continue; - stack.expr = prop->expr; + stack.expr = &prop->expr; sym2 = sym_check_expr_deps(prop->expr); if (sym2) break; @@ -1283,9 +1270,6 @@ struct symbol *sym_check_deps(struct symbol *sym) sym->flags &= ~SYMBOL_CHECK; } - if (sym2 && sym2 == sym) - sym2 = NULL; - return sym2; } @@ -1324,8 +1308,6 @@ const char *prop_get_type_name(enum prop_type type) switch (type) { case P_PROMPT: return "prompt"; - case P_ENV: - return "env"; case P_COMMENT: return "comment"; case P_MENU: @@ -1336,6 +1318,8 @@ const char *prop_get_type_name(enum prop_type type) return "choice"; case P_SELECT: return "select"; + case P_IMPLY: + return "imply"; case P_RANGE: return "range"; case P_SYMBOL: @@ -1345,32 +1329,3 @@ const char *prop_get_type_name(enum prop_type type) } return "unknown"; } - -static void prop_add_env(const char *env) -{ - struct symbol *sym, *sym2; - struct property *prop; - char *p; - - sym = current_entry->sym; - sym->flags |= SYMBOL_AUTO; - for_all_properties(sym, prop, P_ENV) { - sym2 = prop_get_symbol(prop); - if (strcmp(sym2->name, env)) - menu_warn(current_entry, "redefining environment symbol from %s", - sym2->name); - return; - } - - prop = prop_alloc(P_ENV, sym); - prop->expr = expr_alloc_symbol(sym_lookup(env, SYMBOL_CONST)); - - sym_env_list = expr_alloc_one(E_LIST, sym_env_list); - sym_env_list->right.sym = sym; - - p = getenv(env); - if (p) - sym_add_default(sym, p); - else - menu_warn(current_entry, "environment variable %s undefined", env); -} diff --git a/xen/tools/kconfig/tests/auto_submenu/Kconfig b/xen/tools/kconfig/tests/auto_submenu/Kconfig new file mode 100644 index 000000000000..b20761edc2f4 --- /dev/null +++ b/xen/tools/kconfig/tests/auto_submenu/Kconfig @@ -0,0 +1,52 @@ +# SPDX-License-Identifier: GPL-2.0 + +config A + bool "A" + default y + +config A0 + bool "A0" + depends on A + default y + help + This depends on A, so should be a submenu of A. + +config A0_0 + bool "A1_0" + depends on A0 + help + Submenus are created recursively. + This should be a submenu of A0. + +config A1 + bool "A1" + depends on A + default y + help + This should line up with A0. + +choice + prompt "choice" + depends on A1 + help + Choice should become a submenu as well. + +config A1_0 + bool "A1_0" + +config A1_1 + bool "A1_1" + +endchoice + +config B + bool "B" + help + This is independent of A. + +config C + bool "C" + depends on A + help + This depends on A, but not a consecutive item, so can/should not + be a submenu. diff --git a/xen/tools/kconfig/tests/auto_submenu/__init__.py b/xen/tools/kconfig/tests/auto_submenu/__init__.py new file mode 100644 index 000000000000..25abd927fd0a --- /dev/null +++ b/xen/tools/kconfig/tests/auto_submenu/__init__.py @@ -0,0 +1,13 @@ +# SPDX-License-Identifier: GPL-2.0 +""" +Create submenu for symbols that depend on the preceding one. + +If a symbols has dependency on the preceding symbol, the menu entry +should become the submenu of the preceding one, and displayed with +deeper indentation. +""" + + +def test(conf): + assert conf.oldaskconfig() == 0 + assert conf.stdout_contains('expected_stdout') diff --git a/xen/tools/kconfig/tests/auto_submenu/expected_stdout b/xen/tools/kconfig/tests/auto_submenu/expected_stdout new file mode 100644 index 000000000000..bf5236f39a56 --- /dev/null +++ b/xen/tools/kconfig/tests/auto_submenu/expected_stdout @@ -0,0 +1,10 @@ +A (A) [Y/n/?] (NEW) + A0 (A0) [Y/n/?] (NEW) + A1_0 (A0_0) [N/y/?] (NEW) + A1 (A1) [Y/n/?] (NEW) + choice + > 1. A1_0 (A1_0) (NEW) + 2. A1_1 (A1_1) (NEW) + choice[1-2?]: +B (B) [N/y/?] (NEW) +C (C) [N/y/?] (NEW) diff --git a/xen/tools/kconfig/tests/choice/Kconfig b/xen/tools/kconfig/tests/choice/Kconfig new file mode 100644 index 000000000000..a412205b1b0c --- /dev/null +++ b/xen/tools/kconfig/tests/choice/Kconfig @@ -0,0 +1,56 @@ +# SPDX-License-Identifier: GPL-2.0 + +config MODULES + bool "Enable loadable module support" + option modules + default y + +choice + prompt "boolean choice" + default BOOL_CHOICE1 + +config BOOL_CHOICE0 + bool "choice 0" + +config BOOL_CHOICE1 + bool "choice 1" + +endchoice + +choice + prompt "optional boolean choice" + optional + default OPT_BOOL_CHOICE1 + +config OPT_BOOL_CHOICE0 + bool "choice 0" + +config OPT_BOOL_CHOICE1 + bool "choice 1" + +endchoice + +choice + prompt "tristate choice" + default TRI_CHOICE1 + +config TRI_CHOICE0 + tristate "choice 0" + +config TRI_CHOICE1 + tristate "choice 1" + +endchoice + +choice + prompt "optional tristate choice" + optional + default OPT_TRI_CHOICE1 + +config OPT_TRI_CHOICE0 + tristate "choice 0" + +config OPT_TRI_CHOICE1 + tristate "choice 1" + +endchoice diff --git a/xen/tools/kconfig/tests/choice/__init__.py b/xen/tools/kconfig/tests/choice/__init__.py new file mode 100644 index 000000000000..4318fce05912 --- /dev/null +++ b/xen/tools/kconfig/tests/choice/__init__.py @@ -0,0 +1,41 @@ +# SPDX-License-Identifier: GPL-2.0 +""" +Basic choice tests. + +The handling of 'choice' is a bit complicated part in Kconfig. + +The behavior of 'y' choice is intuitive. If choice values are tristate, +the choice can be 'm' where each value can be enabled independently. +Also, if a choice is marked as 'optional', the whole choice can be +invisible. +""" + + +def test_oldask0(conf): + assert conf.oldaskconfig() == 0 + assert conf.stdout_contains('oldask0_expected_stdout') + + +def test_oldask1(conf): + assert conf.oldaskconfig('oldask1_config') == 0 + assert conf.stdout_contains('oldask1_expected_stdout') + + +def test_allyes(conf): + assert conf.allyesconfig() == 0 + assert conf.config_contains('allyes_expected_config') + + +def test_allmod(conf): + assert conf.allmodconfig() == 0 + assert conf.config_contains('allmod_expected_config') + + +def test_allno(conf): + assert conf.allnoconfig() == 0 + assert conf.config_contains('allno_expected_config') + + +def test_alldef(conf): + assert conf.alldefconfig() == 0 + assert conf.config_contains('alldef_expected_config') diff --git a/xen/tools/kconfig/tests/choice/alldef_expected_config b/xen/tools/kconfig/tests/choice/alldef_expected_config new file mode 100644 index 000000000000..7a754bf4be94 --- /dev/null +++ b/xen/tools/kconfig/tests/choice/alldef_expected_config @@ -0,0 +1,5 @@ +CONFIG_MODULES=y +# CONFIG_BOOL_CHOICE0 is not set +CONFIG_BOOL_CHOICE1=y +# CONFIG_TRI_CHOICE0 is not set +# CONFIG_TRI_CHOICE1 is not set diff --git a/xen/tools/kconfig/tests/choice/allmod_expected_config b/xen/tools/kconfig/tests/choice/allmod_expected_config new file mode 100644 index 000000000000..f1f5dcdb7923 --- /dev/null +++ b/xen/tools/kconfig/tests/choice/allmod_expected_config @@ -0,0 +1,9 @@ +CONFIG_MODULES=y +# CONFIG_BOOL_CHOICE0 is not set +CONFIG_BOOL_CHOICE1=y +# CONFIG_OPT_BOOL_CHOICE0 is not set +CONFIG_OPT_BOOL_CHOICE1=y +CONFIG_TRI_CHOICE0=m +CONFIG_TRI_CHOICE1=m +CONFIG_OPT_TRI_CHOICE0=m +CONFIG_OPT_TRI_CHOICE1=m diff --git a/xen/tools/kconfig/tests/choice/allno_expected_config b/xen/tools/kconfig/tests/choice/allno_expected_config new file mode 100644 index 000000000000..b88ee7a43136 --- /dev/null +++ b/xen/tools/kconfig/tests/choice/allno_expected_config @@ -0,0 +1,5 @@ +# CONFIG_MODULES is not set +# CONFIG_BOOL_CHOICE0 is not set +CONFIG_BOOL_CHOICE1=y +# CONFIG_TRI_CHOICE0 is not set +CONFIG_TRI_CHOICE1=y diff --git a/xen/tools/kconfig/tests/choice/allyes_expected_config b/xen/tools/kconfig/tests/choice/allyes_expected_config new file mode 100644 index 000000000000..e5a062a1157c --- /dev/null +++ b/xen/tools/kconfig/tests/choice/allyes_expected_config @@ -0,0 +1,9 @@ +CONFIG_MODULES=y +# CONFIG_BOOL_CHOICE0 is not set +CONFIG_BOOL_CHOICE1=y +# CONFIG_OPT_BOOL_CHOICE0 is not set +CONFIG_OPT_BOOL_CHOICE1=y +# CONFIG_TRI_CHOICE0 is not set +CONFIG_TRI_CHOICE1=y +# CONFIG_OPT_TRI_CHOICE0 is not set +CONFIG_OPT_TRI_CHOICE1=y diff --git a/xen/tools/kconfig/tests/choice/oldask0_expected_stdout b/xen/tools/kconfig/tests/choice/oldask0_expected_stdout new file mode 100644 index 000000000000..b251bba9698b --- /dev/null +++ b/xen/tools/kconfig/tests/choice/oldask0_expected_stdout @@ -0,0 +1,10 @@ +Enable loadable module support (MODULES) [Y/n/?] (NEW) +boolean choice + 1. choice 0 (BOOL_CHOICE0) (NEW) +> 2. choice 1 (BOOL_CHOICE1) (NEW) +choice[1-2?]: +optional boolean choice [N/y/?] (NEW) +tristate choice [M/y/?] (NEW) + choice 0 (TRI_CHOICE0) [N/m/?] (NEW) + choice 1 (TRI_CHOICE1) [N/m/?] (NEW) +optional tristate choice [N/m/y/?] (NEW) diff --git a/xen/tools/kconfig/tests/choice/oldask1_config b/xen/tools/kconfig/tests/choice/oldask1_config new file mode 100644 index 000000000000..b67bfe3c641f --- /dev/null +++ b/xen/tools/kconfig/tests/choice/oldask1_config @@ -0,0 +1,2 @@ +# CONFIG_MODULES is not set +CONFIG_OPT_BOOL_CHOICE0=y diff --git a/xen/tools/kconfig/tests/choice/oldask1_expected_stdout b/xen/tools/kconfig/tests/choice/oldask1_expected_stdout new file mode 100644 index 000000000000..c2125e9bf96a --- /dev/null +++ b/xen/tools/kconfig/tests/choice/oldask1_expected_stdout @@ -0,0 +1,15 @@ +Enable loadable module support (MODULES) [N/y/?] +boolean choice + 1. choice 0 (BOOL_CHOICE0) (NEW) +> 2. choice 1 (BOOL_CHOICE1) (NEW) +choice[1-2?]: +optional boolean choice [Y/n/?] (NEW) +optional boolean choice +> 1. choice 0 (OPT_BOOL_CHOICE0) + 2. choice 1 (OPT_BOOL_CHOICE1) (NEW) +choice[1-2?]: +tristate choice + 1. choice 0 (TRI_CHOICE0) (NEW) +> 2. choice 1 (TRI_CHOICE1) (NEW) +choice[1-2?]: +optional tristate choice [N/y/?] diff --git a/xen/tools/kconfig/tests/choice_value_with_m_dep/Kconfig b/xen/tools/kconfig/tests/choice_value_with_m_dep/Kconfig new file mode 100644 index 000000000000..7106c26bb3a8 --- /dev/null +++ b/xen/tools/kconfig/tests/choice_value_with_m_dep/Kconfig @@ -0,0 +1,21 @@ +# SPDX-License-Identifier: GPL-2.0 + +config MODULES + def_bool y + option modules + +config DEP + tristate + default m + +choice + prompt "Tristate Choice" + +config CHOICE0 + tristate "Choice 0" + +config CHOICE1 + tristate "Choice 1" + depends on DEP + +endchoice diff --git a/xen/tools/kconfig/tests/choice_value_with_m_dep/__init__.py b/xen/tools/kconfig/tests/choice_value_with_m_dep/__init__.py new file mode 100644 index 000000000000..075b4e08696e --- /dev/null +++ b/xen/tools/kconfig/tests/choice_value_with_m_dep/__init__.py @@ -0,0 +1,16 @@ +# SPDX-License-Identifier: GPL-2.0 +""" +Hide tristate choice values with mod dependency in y choice. + +If tristate choice values depend on symbols set to 'm', they should be +hidden when the choice containing them is changed from 'm' to 'y' +(i.e. exclusive choice). + +Related Linux commit: fa64e5f6a35efd5e77d639125d973077ca506074 +""" + + +def test(conf): + assert conf.oldaskconfig('config', 'y') == 0 + assert conf.config_contains('expected_config') + assert conf.stdout_contains('expected_stdout') diff --git a/xen/tools/kconfig/tests/choice_value_with_m_dep/config b/xen/tools/kconfig/tests/choice_value_with_m_dep/config new file mode 100644 index 000000000000..3a126b7a2546 --- /dev/null +++ b/xen/tools/kconfig/tests/choice_value_with_m_dep/config @@ -0,0 +1,2 @@ +CONFIG_CHOICE0=m +CONFIG_CHOICE1=m diff --git a/xen/tools/kconfig/tests/choice_value_with_m_dep/expected_config b/xen/tools/kconfig/tests/choice_value_with_m_dep/expected_config new file mode 100644 index 000000000000..4d07b449540e --- /dev/null +++ b/xen/tools/kconfig/tests/choice_value_with_m_dep/expected_config @@ -0,0 +1,3 @@ +CONFIG_MODULES=y +CONFIG_DEP=m +CONFIG_CHOICE0=y diff --git a/xen/tools/kconfig/tests/choice_value_with_m_dep/expected_stdout b/xen/tools/kconfig/tests/choice_value_with_m_dep/expected_stdout new file mode 100644 index 000000000000..2b50ab65c86a --- /dev/null +++ b/xen/tools/kconfig/tests/choice_value_with_m_dep/expected_stdout @@ -0,0 +1,4 @@ +Tristate Choice [M/y/?] y +Tristate Choice +> 1. Choice 0 (CHOICE0) +choice[1]: 1 diff --git a/xen/tools/kconfig/tests/conftest.py b/xen/tools/kconfig/tests/conftest.py new file mode 100644 index 000000000000..0345ef6e3273 --- /dev/null +++ b/xen/tools/kconfig/tests/conftest.py @@ -0,0 +1,291 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Copyright (C) 2018 Masahiro Yamada +# + +""" +Kconfig unit testing framework. + +This provides fixture functions commonly used from test files. +""" + +import os +import pytest +import shutil +import subprocess +import tempfile + +CONF_PATH = os.path.abspath(os.path.join('scripts', 'kconfig', 'conf')) + + +class Conf: + """Kconfig runner and result checker. + + This class provides methods to run text-based interface of Kconfig + (scripts/kconfig/conf) and retrieve the resulted configuration, + stdout, and stderr. It also provides methods to compare those + results with expectations. + """ + + def __init__(self, request): + """Create a new Conf instance. + + request: object to introspect the requesting test module + """ + # the directory of the test being run + self._test_dir = os.path.dirname(str(request.fspath)) + + # runners + def _run_conf(self, mode, dot_config=None, out_file='.config', + interactive=False, in_keys=None, extra_env={}): + """Run text-based Kconfig executable and save the result. + + mode: input mode option (--oldaskconfig, --defconfig= etc.) + dot_config: .config file to use for configuration base + out_file: file name to contain the output config data + interactive: flag to specify the interactive mode + in_keys: key inputs for interactive modes + extra_env: additional environments + returncode: exit status of the Kconfig executable + """ + command = [CONF_PATH, mode, 'Kconfig'] + + # Override 'srctree' environment to make the test as the top directory + extra_env['srctree'] = self._test_dir + + # Run Kconfig in a temporary directory. + # This directory is automatically removed when done. + with tempfile.TemporaryDirectory() as temp_dir: + + # if .config is given, copy it to the working directory + if dot_config: + shutil.copyfile(os.path.join(self._test_dir, dot_config), + os.path.join(temp_dir, '.config')) + + ps = subprocess.Popen(command, + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + cwd=temp_dir, + env=dict(os.environ, **extra_env)) + + # If input key sequence is given, feed it to stdin. + if in_keys: + ps.stdin.write(in_keys.encode('utf-8')) + + while ps.poll() is None: + # For interactive modes such as oldaskconfig, oldconfig, + # send 'Enter' key until the program finishes. + if interactive: + ps.stdin.write(b'\n') + + self.retcode = ps.returncode + self.stdout = ps.stdout.read().decode() + self.stderr = ps.stderr.read().decode() + + # Retrieve the resulted config data only when .config is supposed + # to exist. If the command fails, the .config does not exist. + # 'listnewconfig' does not produce .config in the first place. + if self.retcode == 0 and out_file: + with open(os.path.join(temp_dir, out_file)) as f: + self.config = f.read() + else: + self.config = None + + # Logging: + # Pytest captures the following information by default. In failure + # of tests, the captured log will be displayed. This will be useful to + # figure out what has happened. + + print("[command]\n{}\n".format(' '.join(command))) + + print("[retcode]\n{}\n".format(self.retcode)) + + print("[stdout]") + print(self.stdout) + + print("[stderr]") + print(self.stderr) + + if self.config is not None: + print("[output for '{}']".format(out_file)) + print(self.config) + + return self.retcode + + def oldaskconfig(self, dot_config=None, in_keys=None): + """Run oldaskconfig. + + dot_config: .config file to use for configuration base (optional) + in_key: key inputs (optional) + returncode: exit status of the Kconfig executable + """ + return self._run_conf('--oldaskconfig', dot_config=dot_config, + interactive=True, in_keys=in_keys) + + def oldconfig(self, dot_config=None, in_keys=None): + """Run oldconfig. + + dot_config: .config file to use for configuration base (optional) + in_key: key inputs (optional) + returncode: exit status of the Kconfig executable + """ + return self._run_conf('--oldconfig', dot_config=dot_config, + interactive=True, in_keys=in_keys) + + def olddefconfig(self, dot_config=None): + """Run olddefconfig. + + dot_config: .config file to use for configuration base (optional) + returncode: exit status of the Kconfig executable + """ + return self._run_conf('--olddefconfig', dot_config=dot_config) + + def defconfig(self, defconfig): + """Run defconfig. + + defconfig: defconfig file for input + returncode: exit status of the Kconfig executable + """ + defconfig_path = os.path.join(self._test_dir, defconfig) + return self._run_conf('--defconfig={}'.format(defconfig_path)) + + def _allconfig(self, mode, all_config): + if all_config: + all_config_path = os.path.join(self._test_dir, all_config) + extra_env = {'KCONFIG_ALLCONFIG': all_config_path} + else: + extra_env = {} + + return self._run_conf('--{}config'.format(mode), extra_env=extra_env) + + def allyesconfig(self, all_config=None): + """Run allyesconfig. + + all_config: fragment config file for KCONFIG_ALLCONFIG (optional) + returncode: exit status of the Kconfig executable + """ + return self._allconfig('allyes', all_config) + + def allmodconfig(self, all_config=None): + """Run allmodconfig. + + all_config: fragment config file for KCONFIG_ALLCONFIG (optional) + returncode: exit status of the Kconfig executable + """ + return self._allconfig('allmod', all_config) + + def allnoconfig(self, all_config=None): + """Run allnoconfig. + + all_config: fragment config file for KCONFIG_ALLCONFIG (optional) + returncode: exit status of the Kconfig executable + """ + return self._allconfig('allno', all_config) + + def alldefconfig(self, all_config=None): + """Run alldefconfig. + + all_config: fragment config file for KCONFIG_ALLCONFIG (optional) + returncode: exit status of the Kconfig executable + """ + return self._allconfig('alldef', all_config) + + def randconfig(self, all_config=None): + """Run randconfig. + + all_config: fragment config file for KCONFIG_ALLCONFIG (optional) + returncode: exit status of the Kconfig executable + """ + return self._allconfig('rand', all_config) + + def savedefconfig(self, dot_config): + """Run savedefconfig. + + dot_config: .config file for input + returncode: exit status of the Kconfig executable + """ + return self._run_conf('--savedefconfig', out_file='defconfig') + + def listnewconfig(self, dot_config=None): + """Run listnewconfig. + + dot_config: .config file to use for configuration base (optional) + returncode: exit status of the Kconfig executable + """ + return self._run_conf('--listnewconfig', dot_config=dot_config, + out_file=None) + + # checkers + def _read_and_compare(self, compare, expected): + """Compare the result with expectation. + + compare: function to compare the result with expectation + expected: file that contains the expected data + """ + with open(os.path.join(self._test_dir, expected)) as f: + expected_data = f.read() + return compare(self, expected_data) + + def _contains(self, attr, expected): + return self._read_and_compare( + lambda s, e: getattr(s, attr).find(e) >= 0, + expected) + + def _matches(self, attr, expected): + return self._read_and_compare(lambda s, e: getattr(s, attr) == e, + expected) + + def config_contains(self, expected): + """Check if resulted configuration contains expected data. + + expected: file that contains the expected data + returncode: True if result contains the expected data, False otherwise + """ + return self._contains('config', expected) + + def config_matches(self, expected): + """Check if resulted configuration exactly matches expected data. + + expected: file that contains the expected data + returncode: True if result matches the expected data, False otherwise + """ + return self._matches('config', expected) + + def stdout_contains(self, expected): + """Check if resulted stdout contains expected data. + + expected: file that contains the expected data + returncode: True if result contains the expected data, False otherwise + """ + return self._contains('stdout', expected) + + def stdout_matches(self, expected): + """Check if resulted stdout exactly matches expected data. + + expected: file that contains the expected data + returncode: True if result matches the expected data, False otherwise + """ + return self._matches('stdout', expected) + + def stderr_contains(self, expected): + """Check if resulted stderr contains expected data. + + expected: file that contains the expected data + returncode: True if result contains the expected data, False otherwise + """ + return self._contains('stderr', expected) + + def stderr_matches(self, expected): + """Check if resulted stderr exactly matches expected data. + + expected: file that contains the expected data + returncode: True if result matches the expected data, False otherwise + """ + return self._matches('stderr', expected) + + +@pytest.fixture(scope="module") +def conf(request): + """Create a Conf instance and provide it to test functions.""" + return Conf(request) diff --git a/xen/tools/kconfig/tests/err_recursive_dep/Kconfig b/xen/tools/kconfig/tests/err_recursive_dep/Kconfig new file mode 100644 index 000000000000..ebdb3ffd8717 --- /dev/null +++ b/xen/tools/kconfig/tests/err_recursive_dep/Kconfig @@ -0,0 +1,63 @@ +# SPDX-License-Identifier: GPL-2.0 + +# depends on itself + +config A + bool "A" + depends on A + +# select itself + +config B + bool + select B + +# depends on each other + +config C1 + bool "C1" + depends on C2 + +config C2 + bool "C2" + depends on C1 + +# depends on and select + +config D1 + bool "D1" + depends on D2 + select D2 + +config D2 + bool + +# depends on and imply + +config E1 + bool "E1" + depends on E2 + imply E2 + +config E2 + bool "E2" + +# property + +config F1 + bool "F1" + default F2 + +config F2 + bool "F2" + depends on F1 + +# menu + +menu "menu depending on its content" + depends on G + +config G + bool "G" + +endmenu diff --git a/xen/tools/kconfig/tests/err_recursive_dep/__init__.py b/xen/tools/kconfig/tests/err_recursive_dep/__init__.py new file mode 100644 index 000000000000..5f3821b43ce6 --- /dev/null +++ b/xen/tools/kconfig/tests/err_recursive_dep/__init__.py @@ -0,0 +1,10 @@ +# SPDX-License-Identifier: GPL-2.0 +""" +Detect recursive dependency error. + +Recursive dependency should be treated as an error. +""" + +def test(conf): + assert conf.oldaskconfig() == 1 + assert conf.stderr_contains('expected_stderr') diff --git a/xen/tools/kconfig/tests/err_recursive_dep/expected_stderr b/xen/tools/kconfig/tests/err_recursive_dep/expected_stderr new file mode 100644 index 000000000000..c9f4abf9a791 --- /dev/null +++ b/xen/tools/kconfig/tests/err_recursive_dep/expected_stderr @@ -0,0 +1,38 @@ +Kconfig:11:error: recursive dependency detected! +Kconfig:11: symbol B is selected by B +For a resolution refer to Documentation/kbuild/kconfig-language.rst +subsection "Kconfig recursive dependency limitations" + +Kconfig:5:error: recursive dependency detected! +Kconfig:5: symbol A depends on A +For a resolution refer to Documentation/kbuild/kconfig-language.rst +subsection "Kconfig recursive dependency limitations" + +Kconfig:17:error: recursive dependency detected! +Kconfig:17: symbol C1 depends on C2 +Kconfig:21: symbol C2 depends on C1 +For a resolution refer to Documentation/kbuild/kconfig-language.rst +subsection "Kconfig recursive dependency limitations" + +Kconfig:32:error: recursive dependency detected! +Kconfig:32: symbol D2 is selected by D1 +Kconfig:27: symbol D1 depends on D2 +For a resolution refer to Documentation/kbuild/kconfig-language.rst +subsection "Kconfig recursive dependency limitations" + +Kconfig:37:error: recursive dependency detected! +Kconfig:37: symbol E1 depends on E2 +Kconfig:42: symbol E2 is implied by E1 +For a resolution refer to Documentation/kbuild/kconfig-language.rst +subsection "Kconfig recursive dependency limitations" + +Kconfig:60:error: recursive dependency detected! +Kconfig:60: symbol G depends on G +For a resolution refer to Documentation/kbuild/kconfig-language.rst +subsection "Kconfig recursive dependency limitations" + +Kconfig:51:error: recursive dependency detected! +Kconfig:51: symbol F2 depends on F1 +Kconfig:49: symbol F1 default value contains F2 +For a resolution refer to Documentation/kbuild/kconfig-language.rst +subsection "Kconfig recursive dependency limitations" diff --git a/xen/tools/kconfig/tests/err_recursive_inc/Kconfig b/xen/tools/kconfig/tests/err_recursive_inc/Kconfig new file mode 100644 index 000000000000..c6f4adec76d1 --- /dev/null +++ b/xen/tools/kconfig/tests/err_recursive_inc/Kconfig @@ -0,0 +1,2 @@ +# SPDX-License-Identifier: GPL-2.0-only +source "Kconfig.inc1" diff --git a/xen/tools/kconfig/tests/err_recursive_inc/Kconfig.inc1 b/xen/tools/kconfig/tests/err_recursive_inc/Kconfig.inc1 new file mode 100644 index 000000000000..01cbf0d69cce --- /dev/null +++ b/xen/tools/kconfig/tests/err_recursive_inc/Kconfig.inc1 @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0-only + + + +source "Kconfig.inc2" diff --git a/xen/tools/kconfig/tests/err_recursive_inc/Kconfig.inc2 b/xen/tools/kconfig/tests/err_recursive_inc/Kconfig.inc2 new file mode 100644 index 000000000000..82351075ab1b --- /dev/null +++ b/xen/tools/kconfig/tests/err_recursive_inc/Kconfig.inc2 @@ -0,0 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0-only + + +source "Kconfig.inc3" diff --git a/xen/tools/kconfig/tests/err_recursive_inc/Kconfig.inc3 b/xen/tools/kconfig/tests/err_recursive_inc/Kconfig.inc3 new file mode 100644 index 000000000000..c6f4adec76d1 --- /dev/null +++ b/xen/tools/kconfig/tests/err_recursive_inc/Kconfig.inc3 @@ -0,0 +1,2 @@ +# SPDX-License-Identifier: GPL-2.0-only +source "Kconfig.inc1" diff --git a/xen/tools/kconfig/tests/err_recursive_inc/__init__.py b/xen/tools/kconfig/tests/err_recursive_inc/__init__.py new file mode 100644 index 000000000000..27aa1895a0b2 --- /dev/null +++ b/xen/tools/kconfig/tests/err_recursive_inc/__init__.py @@ -0,0 +1,11 @@ +# SPDX-License-Identifier: GPL-2.0 +""" +Detect recursive inclusion error. + +If recursive inclusion is detected, it should fail with error messages. +""" + + +def test(conf): + assert conf.oldaskconfig() != 0 + assert conf.stderr_contains('expected_stderr') diff --git a/xen/tools/kconfig/tests/err_recursive_inc/expected_stderr b/xen/tools/kconfig/tests/err_recursive_inc/expected_stderr new file mode 100644 index 000000000000..b070a31fdfeb --- /dev/null +++ b/xen/tools/kconfig/tests/err_recursive_inc/expected_stderr @@ -0,0 +1,6 @@ +Recursive inclusion detected. +Inclusion path: + current file : Kconfig.inc1 + included from: Kconfig.inc3:2 + included from: Kconfig.inc2:4 + included from: Kconfig.inc1:5 diff --git a/xen/tools/kconfig/tests/inter_choice/Kconfig b/xen/tools/kconfig/tests/inter_choice/Kconfig new file mode 100644 index 000000000000..5698a4018dd0 --- /dev/null +++ b/xen/tools/kconfig/tests/inter_choice/Kconfig @@ -0,0 +1,25 @@ +# SPDX-License-Identifier: GPL-2.0 + +config MODULES + def_bool y + option modules + +choice + prompt "Choice" + +config CHOICE_VAL0 + tristate "Choice 0" + +config CHOIVE_VAL1 + tristate "Choice 1" + +endchoice + +choice + prompt "Another choice" + depends on CHOICE_VAL0 + +config DUMMY + bool "dummy" + +endchoice diff --git a/xen/tools/kconfig/tests/inter_choice/__init__.py b/xen/tools/kconfig/tests/inter_choice/__init__.py new file mode 100644 index 000000000000..ffea6b1148a6 --- /dev/null +++ b/xen/tools/kconfig/tests/inter_choice/__init__.py @@ -0,0 +1,15 @@ +# SPDX-License-Identifier: GPL-2.0 +""" +Do not affect user-assigned choice value by another choice. + +Handling of state flags for choices is complecated. In old days, +the defconfig result of a choice could be affected by another choice +if those choices interact by 'depends on', 'select', etc. + +Related Linux commit: fbe98bb9ed3dae23e320c6b113e35f129538d14a +""" + + +def test(conf): + assert conf.defconfig('defconfig') == 0 + assert conf.config_contains('expected_config') diff --git a/xen/tools/kconfig/tests/inter_choice/defconfig b/xen/tools/kconfig/tests/inter_choice/defconfig new file mode 100644 index 000000000000..162c4148e2a5 --- /dev/null +++ b/xen/tools/kconfig/tests/inter_choice/defconfig @@ -0,0 +1 @@ +CONFIG_CHOICE_VAL0=y diff --git a/xen/tools/kconfig/tests/inter_choice/expected_config b/xen/tools/kconfig/tests/inter_choice/expected_config new file mode 100644 index 000000000000..5dceefb054e3 --- /dev/null +++ b/xen/tools/kconfig/tests/inter_choice/expected_config @@ -0,0 +1,4 @@ +CONFIG_MODULES=y +CONFIG_CHOICE_VAL0=y +# CONFIG_CHOIVE_VAL1 is not set +CONFIG_DUMMY=y diff --git a/xen/tools/kconfig/tests/new_choice_with_dep/Kconfig b/xen/tools/kconfig/tests/new_choice_with_dep/Kconfig new file mode 100644 index 000000000000..127731c046b5 --- /dev/null +++ b/xen/tools/kconfig/tests/new_choice_with_dep/Kconfig @@ -0,0 +1,39 @@ +# SPDX-License-Identifier: GPL-2.0 + +config A + bool "A" + help + This is a new symbol. + +choice + prompt "Choice ?" + depends on A + help + "depends on A" has been newly added. + +config CHOICE_B + bool "Choice B" + +config CHOICE_C + bool "Choice C" + help + This is a new symbol, so should be asked. + +endchoice + +choice + prompt "Choice2 ?" + +config CHOICE_D + bool "Choice D" + +config CHOICE_E + bool "Choice E" + +config CHOICE_F + bool "Choice F" + depends on A + help + This is a new symbol, so should be asked. + +endchoice diff --git a/xen/tools/kconfig/tests/new_choice_with_dep/__init__.py b/xen/tools/kconfig/tests/new_choice_with_dep/__init__.py new file mode 100644 index 000000000000..fe9d322539c9 --- /dev/null +++ b/xen/tools/kconfig/tests/new_choice_with_dep/__init__.py @@ -0,0 +1,15 @@ +# SPDX-License-Identifier: GPL-2.0 +""" +Ask new choice values when they become visible. + +If new choice values are added with new dependency, and they become +visible during user configuration, oldconfig should recognize them +as (NEW), and ask the user for choice. + +Related Linux commit: 5d09598d488f081e3be23f885ed65cbbe2d073b5 +""" + + +def test(conf): + assert conf.oldconfig('config', 'y') == 0 + assert conf.stdout_contains('expected_stdout') diff --git a/xen/tools/kconfig/tests/new_choice_with_dep/config b/xen/tools/kconfig/tests/new_choice_with_dep/config new file mode 100644 index 000000000000..47ef95d567fd --- /dev/null +++ b/xen/tools/kconfig/tests/new_choice_with_dep/config @@ -0,0 +1,3 @@ +CONFIG_CHOICE_B=y +# CONFIG_CHOICE_D is not set +CONFIG_CHOICE_E=y diff --git a/xen/tools/kconfig/tests/new_choice_with_dep/expected_stdout b/xen/tools/kconfig/tests/new_choice_with_dep/expected_stdout new file mode 100644 index 000000000000..74dc0bcb22bc --- /dev/null +++ b/xen/tools/kconfig/tests/new_choice_with_dep/expected_stdout @@ -0,0 +1,10 @@ +A (A) [N/y/?] (NEW) y + Choice ? + > 1. Choice B (CHOICE_B) + 2. Choice C (CHOICE_C) (NEW) + choice[1-2?]: +Choice2 ? + 1. Choice D (CHOICE_D) +> 2. Choice E (CHOICE_E) + 3. Choice F (CHOICE_F) (NEW) +choice[1-3?]: diff --git a/xen/tools/kconfig/tests/no_write_if_dep_unmet/Kconfig b/xen/tools/kconfig/tests/no_write_if_dep_unmet/Kconfig new file mode 100644 index 000000000000..4767aab6d8e3 --- /dev/null +++ b/xen/tools/kconfig/tests/no_write_if_dep_unmet/Kconfig @@ -0,0 +1,16 @@ +# SPDX-License-Identifier: GPL-2.0 + +config A + bool "A" + +choice + prompt "Choice ?" + depends on A + +config CHOICE_B + bool "Choice B" + +config CHOICE_C + bool "Choice C" + +endchoice diff --git a/xen/tools/kconfig/tests/no_write_if_dep_unmet/__init__.py b/xen/tools/kconfig/tests/no_write_if_dep_unmet/__init__.py new file mode 100644 index 000000000000..ffd469d1f226 --- /dev/null +++ b/xen/tools/kconfig/tests/no_write_if_dep_unmet/__init__.py @@ -0,0 +1,20 @@ +# SPDX-License-Identifier: GPL-2.0 +""" +Do not write choice values to .config if the dependency is unmet. + +"# CONFIG_... is not set" should not be written into the .config file +for symbols with unmet dependency. + +This was not working correctly for choice values because choice needs +a bit different symbol computation. + +This checks that no unneeded "# COFIG_... is not set" is contained in +the .config file. + +Related Linux commit: cb67ab2cd2b8abd9650292c986c79901e3073a59 +""" + + +def test(conf): + assert conf.oldaskconfig('config', 'n') == 0 + assert conf.config_matches('expected_config') diff --git a/xen/tools/kconfig/tests/no_write_if_dep_unmet/config b/xen/tools/kconfig/tests/no_write_if_dep_unmet/config new file mode 100644 index 000000000000..abd280e2f616 --- /dev/null +++ b/xen/tools/kconfig/tests/no_write_if_dep_unmet/config @@ -0,0 +1 @@ +CONFIG_A=y diff --git a/xen/tools/kconfig/tests/no_write_if_dep_unmet/expected_config b/xen/tools/kconfig/tests/no_write_if_dep_unmet/expected_config new file mode 100644 index 000000000000..473228810c35 --- /dev/null +++ b/xen/tools/kconfig/tests/no_write_if_dep_unmet/expected_config @@ -0,0 +1,5 @@ +# +# Automatically generated file; DO NOT EDIT. +# Main menu +# +# CONFIG_A is not set diff --git a/xen/tools/kconfig/tests/preprocess/builtin_func/Kconfig b/xen/tools/kconfig/tests/preprocess/builtin_func/Kconfig new file mode 100644 index 000000000000..baa328827911 --- /dev/null +++ b/xen/tools/kconfig/tests/preprocess/builtin_func/Kconfig @@ -0,0 +1,27 @@ +# SPDX-License-Identifier: GPL-2.0 + +# 'info' prints the argument to stdout. +$(info,hello world 0) + +# 'warning-if', if the first argument is y, sends the second argument to stderr, +# and the message is prefixed with the current file name and line number. +$(warning-if,y,hello world 1) + +# 'error-if' is similar, but it terminates the parsing immediately. +# The following is just no-op since the first argument is not y. +$(error-if,n,this should not be printed) + +# Shorthand +warning = $(warning-if,y,$(1)) + +# 'shell' executes a command, and returns its stdout. +$(warning,$(shell,echo hello world 3)) + +# Every newline in the output is replaced with a space, +# but any trailing newlines are deleted. +$(warning,$(shell,printf 'hello\nworld\n\n4\n\n\n')) + +# 'filename' is expanded to the currently parsed file name, +# 'lineno' to the line number. +$(warning,filename=$(filename)) +$(warning,lineno=$(lineno)) diff --git a/xen/tools/kconfig/tests/preprocess/builtin_func/__init__.py b/xen/tools/kconfig/tests/preprocess/builtin_func/__init__.py new file mode 100644 index 000000000000..2e53ba08fca1 --- /dev/null +++ b/xen/tools/kconfig/tests/preprocess/builtin_func/__init__.py @@ -0,0 +1,9 @@ +# SPDX-License-Identifier: GPL-2.0 +""" +Built-in function tests. +""" + +def test(conf): + assert conf.oldaskconfig() == 0 + assert conf.stdout_contains('expected_stdout') + assert conf.stderr_matches('expected_stderr') diff --git a/xen/tools/kconfig/tests/preprocess/builtin_func/expected_stderr b/xen/tools/kconfig/tests/preprocess/builtin_func/expected_stderr new file mode 100644 index 000000000000..33ea9ca38400 --- /dev/null +++ b/xen/tools/kconfig/tests/preprocess/builtin_func/expected_stderr @@ -0,0 +1,5 @@ +Kconfig:8: hello world 1 +Kconfig:18: hello world 3 +Kconfig:22: hello world 4 +Kconfig:26: filename=Kconfig +Kconfig:27: lineno=27 diff --git a/xen/tools/kconfig/tests/preprocess/builtin_func/expected_stdout b/xen/tools/kconfig/tests/preprocess/builtin_func/expected_stdout new file mode 100644 index 000000000000..82de3a7e97de --- /dev/null +++ b/xen/tools/kconfig/tests/preprocess/builtin_func/expected_stdout @@ -0,0 +1 @@ +hello world 0 diff --git a/xen/tools/kconfig/tests/preprocess/circular_expansion/Kconfig b/xen/tools/kconfig/tests/preprocess/circular_expansion/Kconfig new file mode 100644 index 000000000000..6838997c23ba --- /dev/null +++ b/xen/tools/kconfig/tests/preprocess/circular_expansion/Kconfig @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0 + +X = $(Y) +Y = $(X) +$(info $(X)) diff --git a/xen/tools/kconfig/tests/preprocess/circular_expansion/__init__.py b/xen/tools/kconfig/tests/preprocess/circular_expansion/__init__.py new file mode 100644 index 000000000000..419bda3e075c --- /dev/null +++ b/xen/tools/kconfig/tests/preprocess/circular_expansion/__init__.py @@ -0,0 +1,11 @@ +# SPDX-License-Identifier: GPL-2.0 +""" +Detect circular variable expansion. + +If a recursively expanded variable references itself (eventually), +it should fail with an error message. +""" + +def test(conf): + assert conf.oldaskconfig() != 0 + assert conf.stderr_matches('expected_stderr') diff --git a/xen/tools/kconfig/tests/preprocess/circular_expansion/expected_stderr b/xen/tools/kconfig/tests/preprocess/circular_expansion/expected_stderr new file mode 100644 index 000000000000..cde68fa989d0 --- /dev/null +++ b/xen/tools/kconfig/tests/preprocess/circular_expansion/expected_stderr @@ -0,0 +1 @@ +Kconfig:5: Recursive variable 'X' references itself (eventually) diff --git a/xen/tools/kconfig/tests/preprocess/escape/Kconfig b/xen/tools/kconfig/tests/preprocess/escape/Kconfig new file mode 100644 index 000000000000..4e3f44445544 --- /dev/null +++ b/xen/tools/kconfig/tests/preprocess/escape/Kconfig @@ -0,0 +1,44 @@ +# SPDX-License-Identifier: GPL-2.0 + +# Shorthand +warning = $(warning-if,y,$(1)) + +# You can not pass commas directly to a function since they are treated as +# delimiters. You can use the following trick to do so. +comma := , +$(warning,hello$(comma) world) + +# Like Make, single quotes, double quotes, spaces are treated verbatim. +# The following prints the text as-is. +$(warning, ' " '" ' ''' "'") + +# Unlike Make, '$' has special meaning only when it is followed by '('. +# No need to escape '$' itself. +$(warning,$) +$(warning,$$) +$ := 1 +$(warning,$($)) + +# You need a trick to escape '$' followed by '(' +# The following should print "$(X)". It should not be expanded further. +dollar := $ +$(warning,$(dollar)(X)) + +# You need a trick to treat unbalanced parentheses. +# The following should print "(". +left_paren := ( +$(warning,$(left_paren)) + +# A simple expanded should not be expanded multiple times. +# The following should print "$(X)". It should not be expanded further. +Y := $(dollar)(X) +$(warning,$(Y)) + +# The following should print "$(X)" as well. +Y = $(dollar)(X) +$(warning,$(Y)) + +# The following should print "$(". +# It should not be emit "unterminated reference" error. +unterminated := $(dollar)( +$(warning,$(unterminated)) diff --git a/xen/tools/kconfig/tests/preprocess/escape/__init__.py b/xen/tools/kconfig/tests/preprocess/escape/__init__.py new file mode 100644 index 000000000000..7ee8e747f546 --- /dev/null +++ b/xen/tools/kconfig/tests/preprocess/escape/__init__.py @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: GPL-2.0 +""" +Escape sequence tests. +""" + +def test(conf): + assert conf.oldaskconfig() == 0 + assert conf.stderr_matches('expected_stderr') diff --git a/xen/tools/kconfig/tests/preprocess/escape/expected_stderr b/xen/tools/kconfig/tests/preprocess/escape/expected_stderr new file mode 100644 index 000000000000..1c00957ddaa9 --- /dev/null +++ b/xen/tools/kconfig/tests/preprocess/escape/expected_stderr @@ -0,0 +1,10 @@ +Kconfig:9: hello, world +Kconfig:13: ' " '" ' ''' "'" +Kconfig:17: $ +Kconfig:18: $$ +Kconfig:20: 1 +Kconfig:25: $(X) +Kconfig:30: ( +Kconfig:35: $(X) +Kconfig:39: $(X) +Kconfig:44: $( diff --git a/xen/tools/kconfig/tests/preprocess/variable/Kconfig b/xen/tools/kconfig/tests/preprocess/variable/Kconfig new file mode 100644 index 000000000000..9ce2f95cbd24 --- /dev/null +++ b/xen/tools/kconfig/tests/preprocess/variable/Kconfig @@ -0,0 +1,53 @@ +# SPDX-License-Identifier: GPL-2.0 + +# Shorthand +warning = $(warning-if,y,$(1)) + +# Simply expanded variable. +X := 1 +SIMPLE := $(X) +X := 2 +$(warning,SIMPLE = $(SIMPLE)) + +# Recursively expanded variable. +X := 1 +RECURSIVE = $(X) +X := 2 +$(warning,RECURSIVE = $(RECURSIVE)) + +# Append something to a simply expanded variable. +Y := 3 +SIMPLE += $(Y) +Y := 4 +$(warning,SIMPLE = $(SIMPLE)) + +# Append something to a recursively expanded variable. +Y := 3 +RECURSIVE += $(Y) +Y := 4 +$(warning,RECURSIVE = $(RECURSIVE)) + +# Use += operator to an undefined variable. +# This works as a recursively expanded variable. +Y := 3 +UNDEFINED_VARIABLE += $(Y) +Y := 4 +$(warning,UNDEFINED_VARIABLE = $(UNDEFINED_VARIABLE)) + +# You can use variable references for the lefthand side of assignment statement. +X := A +Y := B +$(X)$(Y) := 5 +$(warning,AB = $(AB)) + +# User-defined function. +greeting = $(1), my name is $(2). +$(warning,$(greeting,Hello,John)) + +# The number of arguments is not checked for user-defined functions. +# If some arguments are optional, it is useful to pass fewer parameters. +# $(2) will be blank in this case. +$(warning,$(greeting,Hello)) + +# Unreferenced parameters are just ignored. +$(warning,$(greeting,Hello,John,ignored,ignored)) diff --git a/xen/tools/kconfig/tests/preprocess/variable/__init__.py b/xen/tools/kconfig/tests/preprocess/variable/__init__.py new file mode 100644 index 000000000000..e88b1708d6d4 --- /dev/null +++ b/xen/tools/kconfig/tests/preprocess/variable/__init__.py @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: GPL-2.0 +""" +Variable and user-defined function tests. +""" + +def test(conf): + assert conf.oldaskconfig() == 0 + assert conf.stderr_matches('expected_stderr') diff --git a/xen/tools/kconfig/tests/preprocess/variable/expected_stderr b/xen/tools/kconfig/tests/preprocess/variable/expected_stderr new file mode 100644 index 000000000000..a4841c3fdff5 --- /dev/null +++ b/xen/tools/kconfig/tests/preprocess/variable/expected_stderr @@ -0,0 +1,9 @@ +Kconfig:10: SIMPLE = 1 +Kconfig:16: RECURSIVE = 2 +Kconfig:22: SIMPLE = 1 3 +Kconfig:28: RECURSIVE = 2 4 +Kconfig:35: UNDEFINED_VARIABLE = 4 +Kconfig:41: AB = 5 +Kconfig:45: Hello, my name is John. +Kconfig:50: Hello, my name is . +Kconfig:53: Hello, my name is John. diff --git a/xen/tools/kconfig/tests/pytest.ini b/xen/tools/kconfig/tests/pytest.ini new file mode 100644 index 000000000000..85d7ce8e448b --- /dev/null +++ b/xen/tools/kconfig/tests/pytest.ini @@ -0,0 +1,7 @@ +[pytest] +addopts = --verbose + +# Pytest requires that test files have unique names, because pytest imports +# them as top-level modules. It is silly to prefix or suffix a test file with +# the directory name that contains it. Use __init__.py for all test files. +python_files = __init__.py diff --git a/xen/tools/kconfig/tests/rand_nested_choice/Kconfig b/xen/tools/kconfig/tests/rand_nested_choice/Kconfig new file mode 100644 index 000000000000..8350de7f732b --- /dev/null +++ b/xen/tools/kconfig/tests/rand_nested_choice/Kconfig @@ -0,0 +1,35 @@ +# SPDX-License-Identifier: GPL-2.0 + +choice + prompt "choice" + +config A + bool "A" + +config B + bool "B" + +if B +choice + prompt "sub choice" + +config C + bool "C" + +config D + bool "D" + +if D +choice + prompt "subsub choice" + +config E + bool "E" + +endchoice +endif # D + +endchoice +endif # B + +endchoice diff --git a/xen/tools/kconfig/tests/rand_nested_choice/__init__.py b/xen/tools/kconfig/tests/rand_nested_choice/__init__.py new file mode 100644 index 000000000000..9e4b2db53581 --- /dev/null +++ b/xen/tools/kconfig/tests/rand_nested_choice/__init__.py @@ -0,0 +1,17 @@ +# SPDX-License-Identifier: GPL-2.0 +""" +Set random values recursively in nested choices. + +Kconfig can create a choice-in-choice structure by using 'if' statement. +randconfig should correctly set random choice values. + +Related Linux commit: 3b9a19e08960e5cdad5253998637653e592a3c29 +""" + + +def test(conf): + for i in range(20): + assert conf.randconfig() == 0 + assert (conf.config_contains('expected_stdout0') or + conf.config_contains('expected_stdout1') or + conf.config_contains('expected_stdout2')) diff --git a/xen/tools/kconfig/tests/rand_nested_choice/expected_stdout0 b/xen/tools/kconfig/tests/rand_nested_choice/expected_stdout0 new file mode 100644 index 000000000000..05450f3d4eb5 --- /dev/null +++ b/xen/tools/kconfig/tests/rand_nested_choice/expected_stdout0 @@ -0,0 +1,2 @@ +CONFIG_A=y +# CONFIG_B is not set diff --git a/xen/tools/kconfig/tests/rand_nested_choice/expected_stdout1 b/xen/tools/kconfig/tests/rand_nested_choice/expected_stdout1 new file mode 100644 index 000000000000..37ab29584157 --- /dev/null +++ b/xen/tools/kconfig/tests/rand_nested_choice/expected_stdout1 @@ -0,0 +1,4 @@ +# CONFIG_A is not set +CONFIG_B=y +CONFIG_C=y +# CONFIG_D is not set diff --git a/xen/tools/kconfig/tests/rand_nested_choice/expected_stdout2 b/xen/tools/kconfig/tests/rand_nested_choice/expected_stdout2 new file mode 100644 index 000000000000..849ff47e9848 --- /dev/null +++ b/xen/tools/kconfig/tests/rand_nested_choice/expected_stdout2 @@ -0,0 +1,5 @@ +# CONFIG_A is not set +CONFIG_B=y +# CONFIG_C is not set +CONFIG_D=y +CONFIG_E=y diff --git a/xen/tools/kconfig/util.c b/xen/tools/kconfig/util.c index 0e76042473cc..29585394df71 100644 --- a/xen/tools/kconfig/util.c +++ b/xen/tools/kconfig/util.c @@ -1,8 +1,7 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) 2002-2005 Roman Zippel * Copyright (C) 2002-2005 Sam Ravnborg - * - * Released under the terms of the GNU GPL v2.0. */ #include @@ -14,69 +13,21 @@ struct file *file_lookup(const char *name) { struct file *file; - const char *file_name = sym_expand_string_value(name); for (file = file_list; file; file = file->next) { if (!strcmp(name, file->name)) { - free((void *)file_name); return file; } } file = xmalloc(sizeof(*file)); memset(file, 0, sizeof(*file)); - file->name = file_name; + file->name = xstrdup(name); file->next = file_list; file_list = file; return file; } -/* write a dependency file as used by kbuild to track dependencies */ -int file_write_dep(const char *name) -{ - struct symbol *sym, *env_sym; - struct expr *e; - struct file *file; - FILE *out; - - if (!name) - name = ".kconfig.d"; - out = fopen("..config.tmp", "w"); - if (!out) - return 1; - fprintf(out, "deps_config := \\\n"); - for (file = file_list; file; file = file->next) { - if (file->next) - fprintf(out, "\t%s \\\n", file->name); - else - fprintf(out, "\t%s\n", file->name); - } - fprintf(out, "\n%s: \\\n" - "\t$(deps_config)\n\n", conf_get_autoconfig_name()); - - expr_list_for_each_sym(sym_env_list, e, sym) { - struct property *prop; - const char *value; - - prop = sym_get_env_prop(sym); - env_sym = prop_get_symbol(prop); - if (!env_sym) - continue; - value = getenv(env_sym->name); - if (!value) - value = ""; - fprintf(out, "ifneq \"$(%s)\" \"%s\"\n", env_sym->name, value); - fprintf(out, "%s: FORCE\n", conf_get_autoconfig_name()); - fprintf(out, "endif\n"); - } - - fprintf(out, "\n$(deps_config): ;\n"); - fclose(out); - rename("..config.tmp", name); - return 0; -} - - /* Allocate initial growable string */ struct gstr str_new(void) { @@ -104,7 +55,7 @@ void str_append(struct gstr *gs, const char *s) if (s) { l = strlen(gs->s) + strlen(s) + 1; if (l > gs->len) { - gs->s = realloc(gs->s, l); + gs->s = xrealloc(gs->s, l); gs->len = l; } strcat(gs->s, s); @@ -145,3 +96,34 @@ void *xcalloc(size_t nmemb, size_t size) fprintf(stderr, "Out of memory.\n"); exit(1); } + +void *xrealloc(void *p, size_t size) +{ + p = realloc(p, size); + if (p) + return p; + fprintf(stderr, "Out of memory.\n"); + exit(1); +} + +char *xstrdup(const char *s) +{ + char *p; + + p = strdup(s); + if (p) + return p; + fprintf(stderr, "Out of memory.\n"); + exit(1); +} + +char *xstrndup(const char *s, size_t n) +{ + char *p; + + p = strndup(s, n); + if (p) + return p; + fprintf(stderr, "Out of memory.\n"); + exit(1); +} diff --git a/xen/tools/kconfig/zconf.gperf b/xen/tools/kconfig/zconf.gperf deleted file mode 100644 index ac498f01b449..000000000000 --- a/xen/tools/kconfig/zconf.gperf +++ /dev/null @@ -1,49 +0,0 @@ -%language=ANSI-C -%define hash-function-name kconf_id_hash -%define lookup-function-name kconf_id_lookup -%define string-pool-name kconf_id_strings -%compare-strncmp -%enum -%pic -%struct-type - -struct kconf_id; - -static const struct kconf_id *kconf_id_lookup(register const char *str, register unsigned int len); - -%% -mainmenu, T_MAINMENU, TF_COMMAND -menu, T_MENU, TF_COMMAND -endmenu, T_ENDMENU, TF_COMMAND -source, T_SOURCE, TF_COMMAND -choice, T_CHOICE, TF_COMMAND -endchoice, T_ENDCHOICE, TF_COMMAND -comment, T_COMMENT, TF_COMMAND -config, T_CONFIG, TF_COMMAND -menuconfig, T_MENUCONFIG, TF_COMMAND -help, T_HELP, TF_COMMAND ----help---, T_HELP, TF_COMMAND -if, T_IF, TF_COMMAND|TF_PARAM -endif, T_ENDIF, TF_COMMAND -depends, T_DEPENDS, TF_COMMAND -optional, T_OPTIONAL, TF_COMMAND -default, T_DEFAULT, TF_COMMAND, S_UNKNOWN -prompt, T_PROMPT, TF_COMMAND -tristate, T_TYPE, TF_COMMAND, S_TRISTATE -def_tristate, T_DEFAULT, TF_COMMAND, S_TRISTATE -bool, T_TYPE, TF_COMMAND, S_BOOLEAN -boolean, T_TYPE, TF_COMMAND, S_BOOLEAN -def_bool, T_DEFAULT, TF_COMMAND, S_BOOLEAN -int, T_TYPE, TF_COMMAND, S_INT -hex, T_TYPE, TF_COMMAND, S_HEX -string, T_TYPE, TF_COMMAND, S_STRING -select, T_SELECT, TF_COMMAND -range, T_RANGE, TF_COMMAND -visible, T_VISIBLE, TF_COMMAND -option, T_OPTION, TF_COMMAND -on, T_ON, TF_PARAM -modules, T_OPT_MODULES, TF_OPTION -defconfig_list, T_OPT_DEFCONFIG_LIST,TF_OPTION -env, T_OPT_ENV, TF_OPTION -allnoconfig_y, T_OPT_ALLNOCONFIG_Y,TF_OPTION -%% diff --git a/xen/tools/kconfig/zconf.hash.c_shipped b/xen/tools/kconfig/zconf.hash.c_shipped deleted file mode 100644 index 360a62df2b5e..000000000000 --- a/xen/tools/kconfig/zconf.hash.c_shipped +++ /dev/null @@ -1,293 +0,0 @@ -/* ANSI-C code produced by gperf version 3.0.4 */ -/* Command-line: gperf -t --output-file scripts/kconfig/zconf.hash.c_shipped -a -C -E -g -k '1,3,$' -p -t scripts/kconfig/zconf.gperf */ - -#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \ - && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \ - && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \ - && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \ - && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \ - && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \ - && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \ - && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \ - && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \ - && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \ - && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \ - && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \ - && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \ - && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \ - && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \ - && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \ - && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \ - && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \ - && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \ - && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \ - && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \ - && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \ - && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126)) -/* The character set is not based on ISO-646. */ -#error "gperf generated tables don't work with this execution character set. Please report a bug to ." -#endif - -#line 10 "scripts/kconfig/zconf.gperf" -struct kconf_id; - -static const struct kconf_id *kconf_id_lookup(register const char *str, register unsigned int len); -/* maximum key range = 71, duplicates = 0 */ - -#ifdef __GNUC__ -__inline -#else -#ifdef __cplusplus -inline -#endif -#endif -static unsigned int -kconf_id_hash (register const char *str, register unsigned int len) -{ - static const unsigned char asso_values[] = - { - 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, - 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, - 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, - 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, - 73, 73, 73, 73, 73, 0, 73, 73, 73, 73, - 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, - 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, - 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, - 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, - 73, 73, 73, 73, 73, 73, 73, 5, 25, 25, - 0, 0, 0, 5, 0, 0, 73, 73, 5, 0, - 10, 5, 45, 73, 20, 20, 0, 15, 15, 73, - 20, 5, 73, 73, 73, 73, 73, 73, 73, 73, - 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, - 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, - 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, - 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, - 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, - 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, - 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, - 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, - 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, - 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, - 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, - 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, - 73, 73, 73, 73, 73, 73 - }; - register int hval = len; - - switch (hval) - { - default: - hval += asso_values[(unsigned char)str[2]]; - /*FALLTHROUGH*/ - case 2: - case 1: - hval += asso_values[(unsigned char)str[0]]; - break; - } - return hval + asso_values[(unsigned char)str[len - 1]]; -} - -struct kconf_id_strings_t - { - char kconf_id_strings_str2[sizeof("if")]; - char kconf_id_strings_str3[sizeof("int")]; - char kconf_id_strings_str5[sizeof("endif")]; - char kconf_id_strings_str7[sizeof("default")]; - char kconf_id_strings_str8[sizeof("tristate")]; - char kconf_id_strings_str9[sizeof("endchoice")]; - char kconf_id_strings_str10[sizeof("---help---")]; - char kconf_id_strings_str12[sizeof("def_tristate")]; - char kconf_id_strings_str13[sizeof("def_bool")]; - char kconf_id_strings_str14[sizeof("defconfig_list")]; - char kconf_id_strings_str17[sizeof("on")]; - char kconf_id_strings_str18[sizeof("optional")]; - char kconf_id_strings_str21[sizeof("option")]; - char kconf_id_strings_str22[sizeof("endmenu")]; - char kconf_id_strings_str23[sizeof("mainmenu")]; - char kconf_id_strings_str25[sizeof("menuconfig")]; - char kconf_id_strings_str27[sizeof("modules")]; - char kconf_id_strings_str28[sizeof("allnoconfig_y")]; - char kconf_id_strings_str29[sizeof("menu")]; - char kconf_id_strings_str31[sizeof("select")]; - char kconf_id_strings_str32[sizeof("comment")]; - char kconf_id_strings_str33[sizeof("env")]; - char kconf_id_strings_str35[sizeof("range")]; - char kconf_id_strings_str36[sizeof("choice")]; - char kconf_id_strings_str39[sizeof("bool")]; - char kconf_id_strings_str41[sizeof("source")]; - char kconf_id_strings_str42[sizeof("visible")]; - char kconf_id_strings_str43[sizeof("hex")]; - char kconf_id_strings_str46[sizeof("config")]; - char kconf_id_strings_str47[sizeof("boolean")]; - char kconf_id_strings_str51[sizeof("string")]; - char kconf_id_strings_str54[sizeof("help")]; - char kconf_id_strings_str56[sizeof("prompt")]; - char kconf_id_strings_str72[sizeof("depends")]; - }; -static const struct kconf_id_strings_t kconf_id_strings_contents = - { - "if", - "int", - "endif", - "default", - "tristate", - "endchoice", - "---help---", - "def_tristate", - "def_bool", - "defconfig_list", - "on", - "optional", - "option", - "endmenu", - "mainmenu", - "menuconfig", - "modules", - "allnoconfig_y", - "menu", - "select", - "comment", - "env", - "range", - "choice", - "bool", - "source", - "visible", - "hex", - "config", - "boolean", - "string", - "help", - "prompt", - "depends" - }; -#define kconf_id_strings ((const char *) &kconf_id_strings_contents) -#ifdef __GNUC__ -__inline -#if defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__ -__attribute__ ((__gnu_inline__)) -#endif -#endif -const struct kconf_id * -kconf_id_lookup (register const char *str, register unsigned int len) -{ - enum - { - TOTAL_KEYWORDS = 34, - MIN_WORD_LENGTH = 2, - MAX_WORD_LENGTH = 14, - MIN_HASH_VALUE = 2, - MAX_HASH_VALUE = 72 - }; - - static const struct kconf_id wordlist[] = - { - {-1}, {-1}, -#line 26 "scripts/kconfig/zconf.gperf" - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str2, T_IF, TF_COMMAND|TF_PARAM}, -#line 37 "scripts/kconfig/zconf.gperf" - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str3, T_TYPE, TF_COMMAND, S_INT}, - {-1}, -#line 27 "scripts/kconfig/zconf.gperf" - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str5, T_ENDIF, TF_COMMAND}, - {-1}, -#line 30 "scripts/kconfig/zconf.gperf" - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str7, T_DEFAULT, TF_COMMAND, S_UNKNOWN}, -#line 32 "scripts/kconfig/zconf.gperf" - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str8, T_TYPE, TF_COMMAND, S_TRISTATE}, -#line 20 "scripts/kconfig/zconf.gperf" - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str9, T_ENDCHOICE, TF_COMMAND}, -#line 25 "scripts/kconfig/zconf.gperf" - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str10, T_HELP, TF_COMMAND}, - {-1}, -#line 33 "scripts/kconfig/zconf.gperf" - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str12, T_DEFAULT, TF_COMMAND, S_TRISTATE}, -#line 36 "scripts/kconfig/zconf.gperf" - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str13, T_DEFAULT, TF_COMMAND, S_BOOLEAN}, -#line 46 "scripts/kconfig/zconf.gperf" - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str14, T_OPT_DEFCONFIG_LIST,TF_OPTION}, - {-1}, {-1}, -#line 44 "scripts/kconfig/zconf.gperf" - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str17, T_ON, TF_PARAM}, -#line 29 "scripts/kconfig/zconf.gperf" - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str18, T_OPTIONAL, TF_COMMAND}, - {-1}, {-1}, -#line 43 "scripts/kconfig/zconf.gperf" - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str21, T_OPTION, TF_COMMAND}, -#line 17 "scripts/kconfig/zconf.gperf" - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str22, T_ENDMENU, TF_COMMAND}, -#line 15 "scripts/kconfig/zconf.gperf" - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str23, T_MAINMENU, TF_COMMAND}, - {-1}, -#line 23 "scripts/kconfig/zconf.gperf" - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str25, T_MENUCONFIG, TF_COMMAND}, - {-1}, -#line 45 "scripts/kconfig/zconf.gperf" - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str27, T_OPT_MODULES, TF_OPTION}, -#line 48 "scripts/kconfig/zconf.gperf" - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str28, T_OPT_ALLNOCONFIG_Y,TF_OPTION}, -#line 16 "scripts/kconfig/zconf.gperf" - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str29, T_MENU, TF_COMMAND}, - {-1}, -#line 40 "scripts/kconfig/zconf.gperf" - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str31, T_SELECT, TF_COMMAND}, -#line 21 "scripts/kconfig/zconf.gperf" - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str32, T_COMMENT, TF_COMMAND}, -#line 47 "scripts/kconfig/zconf.gperf" - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str33, T_OPT_ENV, TF_OPTION}, - {-1}, -#line 41 "scripts/kconfig/zconf.gperf" - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str35, T_RANGE, TF_COMMAND}, -#line 19 "scripts/kconfig/zconf.gperf" - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str36, T_CHOICE, TF_COMMAND}, - {-1}, {-1}, -#line 34 "scripts/kconfig/zconf.gperf" - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str39, T_TYPE, TF_COMMAND, S_BOOLEAN}, - {-1}, -#line 18 "scripts/kconfig/zconf.gperf" - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str41, T_SOURCE, TF_COMMAND}, -#line 42 "scripts/kconfig/zconf.gperf" - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str42, T_VISIBLE, TF_COMMAND}, -#line 38 "scripts/kconfig/zconf.gperf" - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str43, T_TYPE, TF_COMMAND, S_HEX}, - {-1}, {-1}, -#line 22 "scripts/kconfig/zconf.gperf" - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str46, T_CONFIG, TF_COMMAND}, -#line 35 "scripts/kconfig/zconf.gperf" - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str47, T_TYPE, TF_COMMAND, S_BOOLEAN}, - {-1}, {-1}, {-1}, -#line 39 "scripts/kconfig/zconf.gperf" - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str51, T_TYPE, TF_COMMAND, S_STRING}, - {-1}, {-1}, -#line 24 "scripts/kconfig/zconf.gperf" - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str54, T_HELP, TF_COMMAND}, - {-1}, -#line 31 "scripts/kconfig/zconf.gperf" - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str56, T_PROMPT, TF_COMMAND}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, -#line 28 "scripts/kconfig/zconf.gperf" - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str72, T_DEPENDS, TF_COMMAND} - }; - - if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) - { - register int key = kconf_id_hash (str, len); - - if (key <= MAX_HASH_VALUE && key >= 0) - { - register int o = wordlist[key].name; - if (o >= 0) - { - register const char *s = o + kconf_id_strings; - - if (*str == *s && !strncmp (str + 1, s + 1, len - 1) && s[len] == '\0') - return &wordlist[key]; - } - } - } - return 0; -} -#line 49 "scripts/kconfig/zconf.gperf" - diff --git a/xen/tools/kconfig/zconf.l b/xen/tools/kconfig/zconf.l deleted file mode 100644 index c410d257da06..000000000000 --- a/xen/tools/kconfig/zconf.l +++ /dev/null @@ -1,374 +0,0 @@ -%option nostdinit noyywrap never-interactive full ecs -%option 8bit nodefault perf-report perf-report -%option noinput -%x COMMAND HELP STRING PARAM -%{ -/* - * Copyright (C) 2002 Roman Zippel - * Released under the terms of the GNU GPL v2.0. - */ - -#include -#include -#include -#include -#include - -#include "lkc.h" - -#define START_STRSIZE 16 - -static struct { - struct file *file; - int lineno; -} current_pos; - -static char *text; -static int text_size, text_asize; - -struct buffer { - struct buffer *parent; - YY_BUFFER_STATE state; -}; - -struct buffer *current_buf; - -static int last_ts, first_ts; - -static void zconf_endhelp(void); -static void zconf_endfile(void); - -static void new_string(void) -{ - text = xmalloc(START_STRSIZE); - text_asize = START_STRSIZE; - text_size = 0; - *text = 0; -} - -static void append_string(const char *str, int size) -{ - int new_size = text_size + size + 1; - if (new_size > text_asize) { - new_size += START_STRSIZE - 1; - new_size &= -START_STRSIZE; - text = realloc(text, new_size); - text_asize = new_size; - } - memcpy(text + text_size, str, size); - text_size += size; - text[text_size] = 0; -} - -static void alloc_string(const char *str, int size) -{ - text = xmalloc(size + 1); - memcpy(text, str, size); - text[size] = 0; -} - -static void warn_ignored_character(char chr) -{ - fprintf(stderr, - "%s:%d:warning: ignoring unsupported character '%c'\n", - zconf_curname(), zconf_lineno(), chr); -} -%} - -n [A-Za-z0-9_-] - -%% - int str = 0; - int ts, i; - -[ \t]*#.*\n | -[ \t]*\n { - current_file->lineno++; - return T_EOL; -} -[ \t]*#.* - - -[ \t]+ { - BEGIN(COMMAND); -} - -. { - unput(yytext[0]); - BEGIN(COMMAND); -} - - -{ - {n}+ { - const struct kconf_id *id = kconf_id_lookup(yytext, yyleng); - BEGIN(PARAM); - current_pos.file = current_file; - current_pos.lineno = current_file->lineno; - if (id && id->flags & TF_COMMAND) { - zconflval.id = id; - return id->token; - } - alloc_string(yytext, yyleng); - zconflval.string = text; - return T_WORD; - } - . warn_ignored_character(*yytext); - \n { - BEGIN(INITIAL); - current_file->lineno++; - return T_EOL; - } -} - -{ - "&&" return T_AND; - "||" return T_OR; - "(" return T_OPEN_PAREN; - ")" return T_CLOSE_PAREN; - "!" return T_NOT; - "=" return T_EQUAL; - "!=" return T_UNEQUAL; - "<=" return T_LESS_EQUAL; - ">=" return T_GREATER_EQUAL; - "<" return T_LESS; - ">" return T_GREATER; - \"|\' { - str = yytext[0]; - new_string(); - BEGIN(STRING); - } - \n BEGIN(INITIAL); current_file->lineno++; return T_EOL; - ({n}|[/.])+ { - const struct kconf_id *id = kconf_id_lookup(yytext, yyleng); - if (id && id->flags & TF_PARAM) { - zconflval.id = id; - return id->token; - } - alloc_string(yytext, yyleng); - zconflval.string = text; - return T_WORD; - } - #.* /* comment */ - \\\n current_file->lineno++; - [[:blank:]]+ - . warn_ignored_character(*yytext); - <> { - BEGIN(INITIAL); - } -} - -{ - [^'"\\\n]+/\n { - append_string(yytext, yyleng); - zconflval.string = text; - return T_WORD_QUOTE; - } - [^'"\\\n]+ { - append_string(yytext, yyleng); - } - \\.?/\n { - append_string(yytext + 1, yyleng - 1); - zconflval.string = text; - return T_WORD_QUOTE; - } - \\.? { - append_string(yytext + 1, yyleng - 1); - } - \'|\" { - if (str == yytext[0]) { - BEGIN(PARAM); - zconflval.string = text; - return T_WORD_QUOTE; - } else - append_string(yytext, 1); - } - \n { - printf("%s:%d:warning: multi-line strings not supported\n", zconf_curname(), zconf_lineno()); - current_file->lineno++; - BEGIN(INITIAL); - return T_EOL; - } - <> { - BEGIN(INITIAL); - } -} - -{ - [ \t]+ { - ts = 0; - for (i = 0; i < yyleng; i++) { - if (yytext[i] == '\t') - ts = (ts & ~7) + 8; - else - ts++; - } - last_ts = ts; - if (first_ts) { - if (ts < first_ts) { - zconf_endhelp(); - return T_HELPTEXT; - } - ts -= first_ts; - while (ts > 8) { - append_string(" ", 8); - ts -= 8; - } - append_string(" ", ts); - } - } - [ \t]*\n/[^ \t\n] { - current_file->lineno++; - zconf_endhelp(); - return T_HELPTEXT; - } - [ \t]*\n { - current_file->lineno++; - append_string("\n", 1); - } - [^ \t\n].* { - while (yyleng) { - if ((yytext[yyleng-1] != ' ') && (yytext[yyleng-1] != '\t')) - break; - yyleng--; - } - append_string(yytext, yyleng); - if (!first_ts) - first_ts = last_ts; - } - <> { - zconf_endhelp(); - return T_HELPTEXT; - } -} - -<> { - if (current_file) { - zconf_endfile(); - return T_EOL; - } - fclose(yyin); - yyterminate(); -} - -%% -void zconf_starthelp(void) -{ - new_string(); - last_ts = first_ts = 0; - BEGIN(HELP); -} - -static void zconf_endhelp(void) -{ - zconflval.string = text; - BEGIN(INITIAL); -} - - -/* - * Try to open specified file with following names: - * ./name - * $(srctree)/name - * The latter is used when srctree is separate from objtree - * when compiling the kernel. - * Return NULL if file is not found. - */ -FILE *zconf_fopen(const char *name) -{ - char *env, fullname[PATH_MAX+1]; - FILE *f; - - f = fopen(name, "r"); - if (!f && name != NULL && name[0] != '/') { - env = getenv(SRCTREE); - if (env) { - sprintf(fullname, "%s/%s", env, name); - f = fopen(fullname, "r"); - } - } - return f; -} - -void zconf_initscan(const char *name) -{ - yyin = zconf_fopen(name); - if (!yyin) { - printf("can't find file %s\n", name); - exit(1); - } - - current_buf = xmalloc(sizeof(*current_buf)); - memset(current_buf, 0, sizeof(*current_buf)); - - current_file = file_lookup(name); - current_file->lineno = 1; -} - -void zconf_nextfile(const char *name) -{ - struct file *iter; - struct file *file = file_lookup(name); - struct buffer *buf = xmalloc(sizeof(*buf)); - memset(buf, 0, sizeof(*buf)); - - current_buf->state = YY_CURRENT_BUFFER; - yyin = zconf_fopen(file->name); - if (!yyin) { - printf("%s:%d: can't open file \"%s\"\n", - zconf_curname(), zconf_lineno(), file->name); - exit(1); - } - yy_switch_to_buffer(yy_create_buffer(yyin, YY_BUF_SIZE)); - buf->parent = current_buf; - current_buf = buf; - - for (iter = current_file->parent; iter; iter = iter->parent ) { - if (!strcmp(current_file->name,iter->name) ) { - printf("%s:%d: recursive inclusion detected. " - "Inclusion path:\n current file : '%s'\n", - zconf_curname(), zconf_lineno(), - zconf_curname()); - iter = current_file->parent; - while (iter && \ - strcmp(iter->name,current_file->name)) { - printf(" included from: '%s:%d'\n", - iter->name, iter->lineno-1); - iter = iter->parent; - } - if (iter) - printf(" included from: '%s:%d'\n", - iter->name, iter->lineno+1); - exit(1); - } - } - file->lineno = 1; - file->parent = current_file; - current_file = file; -} - -static void zconf_endfile(void) -{ - struct buffer *parent; - - current_file = current_file->parent; - - parent = current_buf->parent; - if (parent) { - fclose(yyin); - yy_delete_buffer(YY_CURRENT_BUFFER); - yy_switch_to_buffer(parent->state); - } - free(current_buf); - current_buf = parent; -} - -int zconf_lineno(void) -{ - return current_pos.lineno; -} - -const char *zconf_curname(void) -{ - return current_pos.file ? current_pos.file->name : ""; -} diff --git a/xen/tools/kconfig/zconf.lex.c_shipped b/xen/tools/kconfig/zconf.lex.c_shipped deleted file mode 100644 index 37fdf6123505..000000000000 --- a/xen/tools/kconfig/zconf.lex.c_shipped +++ /dev/null @@ -1,2473 +0,0 @@ - -#line 3 "scripts/kconfig/zconf.lex.c_shipped" - -#define YY_INT_ALIGNED short int - -/* A lexical scanner generated by flex */ - -#define yy_create_buffer zconf_create_buffer -#define yy_delete_buffer zconf_delete_buffer -#define yy_flex_debug zconf_flex_debug -#define yy_init_buffer zconf_init_buffer -#define yy_flush_buffer zconf_flush_buffer -#define yy_load_buffer_state zconf_load_buffer_state -#define yy_switch_to_buffer zconf_switch_to_buffer -#define yyin zconfin -#define yyleng zconfleng -#define yylex zconflex -#define yylineno zconflineno -#define yyout zconfout -#define yyrestart zconfrestart -#define yytext zconftext -#define yywrap zconfwrap -#define yyalloc zconfalloc -#define yyrealloc zconfrealloc -#define yyfree zconffree - -#define FLEX_SCANNER -#define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 5 -#define YY_FLEX_SUBMINOR_VERSION 35 -#if YY_FLEX_SUBMINOR_VERSION > 0 -#define FLEX_BETA -#endif - -/* First, we deal with platform-specific or compiler-specific issues. */ - -/* begin standard C headers. */ -#include -#include -#include -#include - -/* end standard C headers. */ - -/* flex integer type definitions */ - -#ifndef FLEXINT_H -#define FLEXINT_H - -/* C99 systems have . Non-C99 systems may or may not. */ - -#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - -/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, - * if you want the limit (max/min) macros for int types. - */ -#ifndef __STDC_LIMIT_MACROS -#define __STDC_LIMIT_MACROS 1 -#endif - -#include -typedef int8_t flex_int8_t; -typedef uint8_t flex_uint8_t; -typedef int16_t flex_int16_t; -typedef uint16_t flex_uint16_t; -typedef int32_t flex_int32_t; -typedef uint32_t flex_uint32_t; -#else -typedef signed char flex_int8_t; -typedef short int flex_int16_t; -typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; -typedef unsigned short int flex_uint16_t; -typedef unsigned int flex_uint32_t; - -/* Limits of integral types. */ -#ifndef INT8_MIN -#define INT8_MIN (-128) -#endif -#ifndef INT16_MIN -#define INT16_MIN (-32767-1) -#endif -#ifndef INT32_MIN -#define INT32_MIN (-2147483647-1) -#endif -#ifndef INT8_MAX -#define INT8_MAX (127) -#endif -#ifndef INT16_MAX -#define INT16_MAX (32767) -#endif -#ifndef INT32_MAX -#define INT32_MAX (2147483647) -#endif -#ifndef UINT8_MAX -#define UINT8_MAX (255U) -#endif -#ifndef UINT16_MAX -#define UINT16_MAX (65535U) -#endif -#ifndef UINT32_MAX -#define UINT32_MAX (4294967295U) -#endif - -#endif /* ! C99 */ - -#endif /* ! FLEXINT_H */ - -#ifdef __cplusplus - -/* The "const" storage-class-modifier is valid. */ -#define YY_USE_CONST - -#else /* ! __cplusplus */ - -/* C99 requires __STDC__ to be defined as 1. */ -#if defined (__STDC__) - -#define YY_USE_CONST - -#endif /* defined (__STDC__) */ -#endif /* ! __cplusplus */ - -#ifdef YY_USE_CONST -#define yyconst const -#else -#define yyconst -#endif - -/* Returned upon end-of-file. */ -#define YY_NULL 0 - -/* Promotes a possibly negative, possibly signed char to an unsigned - * integer for use as an array index. If the signed char is negative, - * we want to instead treat it as an 8-bit unsigned char, hence the - * double cast. - */ -#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) - -/* Enter a start condition. This macro really ought to take a parameter, - * but we do it the disgusting crufty way forced on us by the ()-less - * definition of BEGIN. - */ -#define BEGIN (yy_start) = 1 + 2 * - -/* Translate the current start state into a value that can be later handed - * to BEGIN to return to the state. The YYSTATE alias is for lex - * compatibility. - */ -#define YY_START (((yy_start) - 1) / 2) -#define YYSTATE YY_START - -/* Action number for EOF rule of a given start state. */ -#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) - -/* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE zconfrestart(zconfin ) - -#define YY_END_OF_BUFFER_CHAR 0 - -/* Size of default input buffer. */ -#ifndef YY_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k. - * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. - * Ditto for the __ia64__ case accordingly. - */ -#define YY_BUF_SIZE 32768 -#else -#define YY_BUF_SIZE 16384 -#endif /* __ia64__ */ -#endif - -/* The state buf must be large enough to hold one state per character in the main buffer. - */ -#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) - -#ifndef YY_TYPEDEF_YY_BUFFER_STATE -#define YY_TYPEDEF_YY_BUFFER_STATE -typedef struct yy_buffer_state *YY_BUFFER_STATE; -#endif - -extern int zconfleng; - -extern FILE *zconfin, *zconfout; - -#define EOB_ACT_CONTINUE_SCAN 0 -#define EOB_ACT_END_OF_FILE 1 -#define EOB_ACT_LAST_MATCH 2 - - #define YY_LESS_LINENO(n) - -/* Return all but the first "n" matched characters back to the input stream. */ -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up zconftext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - *yy_cp = (yy_hold_char); \ - YY_RESTORE_YY_MORE_OFFSET \ - (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ - YY_DO_BEFORE_ACTION; /* set up zconftext again */ \ - } \ - while ( 0 ) - -#define unput(c) yyunput( c, (yytext_ptr) ) - -#ifndef YY_TYPEDEF_YY_SIZE_T -#define YY_TYPEDEF_YY_SIZE_T -typedef size_t yy_size_t; -#endif - -#ifndef YY_STRUCT_YY_BUFFER_STATE -#define YY_STRUCT_YY_BUFFER_STATE -struct yy_buffer_state - { - FILE *yy_input_file; - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - yy_size_t yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - int yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; - - int yy_bs_lineno; /**< The line count. */ - int yy_bs_column; /**< The column count. */ - - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; - - int yy_buffer_status; - -#define YY_BUFFER_NEW 0 -#define YY_BUFFER_NORMAL 1 - /* When an EOF's been seen but there's still some text to process - * then we mark the buffer as YY_EOF_PENDING, to indicate that we - * shouldn't try reading from the input source any more. We might - * still have a bunch of tokens to match, though, because of - * possible backing-up. - * - * When we actually see the EOF, we change the status to "new" - * (via zconfrestart()), so that the user can continue scanning by - * just pointing zconfin at a new input file. - */ -#define YY_BUFFER_EOF_PENDING 2 - - }; -#endif /* !YY_STRUCT_YY_BUFFER_STATE */ - -/* Stack of input buffers. */ -static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ -static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ -static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ - -/* We provide macros for accessing buffer states in case in the - * future we want to put the buffer states in a more general - * "scanner state". - * - * Returns the top of the stack, or NULL. - */ -#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ - ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ - : NULL) - -/* Same as previous macro, but useful when we know that the buffer stack is not - * NULL or when we need an lvalue. For internal use only. - */ -#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] - -/* yy_hold_char holds the character lost when zconftext is formed. */ -static char yy_hold_char; -static int yy_n_chars; /* number of characters read into yy_ch_buf */ -int zconfleng; - -/* Points to current character in buffer. */ -static char *yy_c_buf_p = (char *) 0; -static int yy_init = 0; /* whether we need to initialize */ -static int yy_start = 0; /* start state number */ - -/* Flag which is used to allow zconfwrap()'s to do buffer switches - * instead of setting up a fresh zconfin. A bit of a hack ... - */ -static int yy_did_buffer_switch_on_eof; - -void zconfrestart (FILE *input_file ); -void zconf_switch_to_buffer (YY_BUFFER_STATE new_buffer ); -YY_BUFFER_STATE zconf_create_buffer (FILE *file,int size ); -void zconf_delete_buffer (YY_BUFFER_STATE b ); -void zconf_flush_buffer (YY_BUFFER_STATE b ); -void zconfpush_buffer_state (YY_BUFFER_STATE new_buffer ); -void zconfpop_buffer_state (void ); - -static void zconfensure_buffer_stack (void ); -static void zconf_load_buffer_state (void ); -static void zconf_init_buffer (YY_BUFFER_STATE b,FILE *file ); - -#define YY_FLUSH_BUFFER zconf_flush_buffer(YY_CURRENT_BUFFER ) - -YY_BUFFER_STATE zconf_scan_buffer (char *base,yy_size_t size ); -YY_BUFFER_STATE zconf_scan_string (yyconst char *yy_str ); -YY_BUFFER_STATE zconf_scan_bytes (yyconst char *bytes,int len ); - -void *zconfalloc (yy_size_t ); -void *zconfrealloc (void *,yy_size_t ); -void zconffree (void * ); - -#define yy_new_buffer zconf_create_buffer - -#define yy_set_interactive(is_interactive) \ - { \ - if ( ! YY_CURRENT_BUFFER ){ \ - zconfensure_buffer_stack (); \ - YY_CURRENT_BUFFER_LVALUE = \ - zconf_create_buffer(zconfin,YY_BUF_SIZE ); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ - } - -#define yy_set_bol(at_bol) \ - { \ - if ( ! YY_CURRENT_BUFFER ){\ - zconfensure_buffer_stack (); \ - YY_CURRENT_BUFFER_LVALUE = \ - zconf_create_buffer(zconfin,YY_BUF_SIZE ); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ - } - -#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) - -/* Begin user sect3 */ - -#define zconfwrap(n) 1 -#define YY_SKIP_YYWRAP - -typedef unsigned char YY_CHAR; - -FILE *zconfin = (FILE *) 0, *zconfout = (FILE *) 0; - -typedef int yy_state_type; - -extern int zconflineno; - -int zconflineno = 1; - -extern char *zconftext; -#define yytext_ptr zconftext -static yyconst flex_int16_t yy_nxt[][18] = - { - { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0 - }, - - { - 11, 12, 13, 14, 12, 12, 15, 12, 12, 12, - 12, 12, 12, 12, 12, 12, 12, 12 - }, - - { - 11, 12, 13, 14, 12, 12, 15, 12, 12, 12, - 12, 12, 12, 12, 12, 12, 12, 12 - }, - - { - 11, 16, 16, 17, 16, 16, 16, 16, 16, 16, - 16, 18, 16, 16, 16, 16, 16, 16 - }, - - { - 11, 16, 16, 17, 16, 16, 16, 16, 16, 16, - 16, 18, 16, 16, 16, 16, 16, 16 - - }, - - { - 11, 19, 20, 21, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19 - }, - - { - 11, 19, 20, 21, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19 - }, - - { - 11, 22, 22, 23, 22, 24, 22, 22, 24, 22, - 22, 22, 22, 22, 22, 22, 25, 22 - }, - - { - 11, 22, 22, 23, 22, 24, 22, 22, 24, 22, - 22, 22, 22, 22, 22, 22, 25, 22 - }, - - { - 11, 26, 27, 28, 29, 30, 31, 32, 30, 33, - 34, 35, 35, 36, 37, 38, 39, 40 - - }, - - { - 11, 26, 27, 28, 29, 30, 31, 32, 30, 33, - 34, 35, 35, 36, 37, 38, 39, 40 - }, - - { - -11, -11, -11, -11, -11, -11, -11, -11, -11, -11, - -11, -11, -11, -11, -11, -11, -11, -11 - }, - - { - 11, -12, -12, -12, -12, -12, -12, -12, -12, -12, - -12, -12, -12, -12, -12, -12, -12, -12 - }, - - { - 11, -13, 41, 42, -13, -13, 43, -13, -13, -13, - -13, -13, -13, -13, -13, -13, -13, -13 - }, - - { - 11, -14, -14, -14, -14, -14, -14, -14, -14, -14, - -14, -14, -14, -14, -14, -14, -14, -14 - - }, - - { - 11, 44, 44, 45, 44, 44, 44, 44, 44, 44, - 44, 44, 44, 44, 44, 44, 44, 44 - }, - - { - 11, -16, -16, -16, -16, -16, -16, -16, -16, -16, - -16, -16, -16, -16, -16, -16, -16, -16 - }, - - { - 11, -17, -17, -17, -17, -17, -17, -17, -17, -17, - -17, -17, -17, -17, -17, -17, -17, -17 - }, - - { - 11, -18, -18, -18, -18, -18, -18, -18, -18, -18, - -18, 46, -18, -18, -18, -18, -18, -18 - }, - - { - 11, 47, 47, -19, 47, 47, 47, 47, 47, 47, - 47, 47, 47, 47, 47, 47, 47, 47 - - }, - - { - 11, -20, 48, 49, -20, -20, -20, -20, -20, -20, - -20, -20, -20, -20, -20, -20, -20, -20 - }, - - { - 11, 50, -21, -21, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50 - }, - - { - 11, 51, 51, 52, 51, -22, 51, 51, -22, 51, - 51, 51, 51, 51, 51, 51, -22, 51 - }, - - { - 11, -23, -23, -23, -23, -23, -23, -23, -23, -23, - -23, -23, -23, -23, -23, -23, -23, -23 - }, - - { - 11, -24, -24, -24, -24, -24, -24, -24, -24, -24, - -24, -24, -24, -24, -24, -24, -24, -24 - - }, - - { - 11, 53, 53, 54, 53, 53, 53, 53, 53, 53, - 53, 53, 53, 53, 53, 53, 53, 53 - }, - - { - 11, -26, -26, -26, -26, -26, -26, -26, -26, -26, - -26, -26, -26, -26, -26, -26, -26, -26 - }, - - { - 11, -27, 55, -27, -27, -27, -27, -27, -27, -27, - -27, -27, -27, -27, -27, -27, -27, -27 - }, - - { - 11, -28, -28, -28, -28, -28, -28, -28, -28, -28, - -28, -28, -28, -28, -28, -28, -28, -28 - }, - - { - 11, -29, -29, -29, -29, -29, -29, -29, -29, -29, - -29, -29, -29, -29, 56, -29, -29, -29 - - }, - - { - 11, -30, -30, -30, -30, -30, -30, -30, -30, -30, - -30, -30, -30, -30, -30, -30, -30, -30 - }, - - { - 11, 57, 57, -31, 57, 57, 57, 57, 57, 57, - 57, 57, 57, 57, 57, 57, 57, 57 - }, - - { - 11, -32, -32, -32, -32, -32, -32, 58, -32, -32, - -32, -32, -32, -32, -32, -32, -32, -32 - }, - - { - 11, -33, -33, -33, -33, -33, -33, -33, -33, -33, - -33, -33, -33, -33, -33, -33, -33, -33 - }, - - { - 11, -34, -34, -34, -34, -34, -34, -34, -34, -34, - -34, -34, -34, -34, -34, -34, -34, -34 - - }, - - { - 11, -35, -35, -35, -35, -35, -35, -35, -35, -35, - -35, 59, 59, -35, -35, -35, -35, -35 - }, - - { - 11, -36, -36, -36, -36, -36, -36, -36, -36, -36, - -36, -36, -36, -36, 60, -36, -36, -36 - }, - - { - 11, -37, -37, -37, -37, -37, -37, -37, -37, -37, - -37, -37, -37, -37, -37, -37, -37, -37 - }, - - { - 11, -38, -38, -38, -38, -38, -38, -38, -38, -38, - -38, -38, -38, -38, 61, -38, -38, -38 - }, - - { - 11, -39, -39, 62, -39, -39, -39, -39, -39, -39, - -39, -39, -39, -39, -39, -39, -39, -39 - - }, - - { - 11, -40, -40, -40, -40, -40, -40, -40, -40, -40, - -40, -40, -40, -40, -40, -40, -40, 63 - }, - - { - 11, -41, 41, 42, -41, -41, 43, -41, -41, -41, - -41, -41, -41, -41, -41, -41, -41, -41 - }, - - { - 11, -42, -42, -42, -42, -42, -42, -42, -42, -42, - -42, -42, -42, -42, -42, -42, -42, -42 - }, - - { - 11, 44, 44, 45, 44, 44, 44, 44, 44, 44, - 44, 44, 44, 44, 44, 44, 44, 44 - }, - - { - 11, 44, 44, 45, 44, 44, 44, 44, 44, 44, - 44, 44, 44, 44, 44, 44, 44, 44 - - }, - - { - 11, -45, -45, -45, -45, -45, -45, -45, -45, -45, - -45, -45, -45, -45, -45, -45, -45, -45 - }, - - { - 11, -46, -46, -46, -46, -46, -46, -46, -46, -46, - -46, 46, -46, -46, -46, -46, -46, -46 - }, - - { - 11, 47, 47, -47, 47, 47, 47, 47, 47, 47, - 47, 47, 47, 47, 47, 47, 47, 47 - }, - - { - 11, -48, 48, 49, -48, -48, -48, -48, -48, -48, - -48, -48, -48, -48, -48, -48, -48, -48 - }, - - { - 11, 50, -49, -49, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50 - - }, - - { - 11, -50, -50, -50, -50, -50, -50, -50, -50, -50, - -50, -50, -50, -50, -50, -50, -50, -50 - }, - - { - 11, 51, 51, 52, 51, -51, 51, 51, -51, 51, - 51, 51, 51, 51, 51, 51, -51, 51 - }, - - { - 11, -52, -52, -52, -52, -52, -52, -52, -52, -52, - -52, -52, -52, -52, -52, -52, -52, -52 - }, - - { - 11, -53, -53, 54, -53, -53, -53, -53, -53, -53, - -53, -53, -53, -53, -53, -53, -53, -53 - }, - - { - 11, -54, -54, -54, -54, -54, -54, -54, -54, -54, - -54, -54, -54, -54, -54, -54, -54, -54 - - }, - - { - 11, -55, 55, -55, -55, -55, -55, -55, -55, -55, - -55, -55, -55, -55, -55, -55, -55, -55 - }, - - { - 11, -56, -56, -56, -56, -56, -56, -56, -56, -56, - -56, -56, -56, -56, -56, -56, -56, -56 - }, - - { - 11, 57, 57, -57, 57, 57, 57, 57, 57, 57, - 57, 57, 57, 57, 57, 57, 57, 57 - }, - - { - 11, -58, -58, -58, -58, -58, -58, -58, -58, -58, - -58, -58, -58, -58, -58, -58, -58, -58 - }, - - { - 11, -59, -59, -59, -59, -59, -59, -59, -59, -59, - -59, 59, 59, -59, -59, -59, -59, -59 - - }, - - { - 11, -60, -60, -60, -60, -60, -60, -60, -60, -60, - -60, -60, -60, -60, -60, -60, -60, -60 - }, - - { - 11, -61, -61, -61, -61, -61, -61, -61, -61, -61, - -61, -61, -61, -61, -61, -61, -61, -61 - }, - - { - 11, -62, -62, -62, -62, -62, -62, -62, -62, -62, - -62, -62, -62, -62, -62, -62, -62, -62 - }, - - { - 11, -63, -63, -63, -63, -63, -63, -63, -63, -63, - -63, -63, -63, -63, -63, -63, -63, -63 - }, - - } ; - -static yy_state_type yy_get_previous_state (void ); -static yy_state_type yy_try_NUL_trans (yy_state_type current_state ); -static int yy_get_next_buffer (void ); -static void yy_fatal_error (yyconst char msg[] ); - -/* Done after the current pattern has been matched and before the - * corresponding action - sets up zconftext. - */ -#define YY_DO_BEFORE_ACTION \ - (yytext_ptr) = yy_bp; \ - zconfleng = (size_t) (yy_cp - yy_bp); \ - (yy_hold_char) = *yy_cp; \ - *yy_cp = '\0'; \ - (yy_c_buf_p) = yy_cp; - -#define YY_NUM_RULES 37 -#define YY_END_OF_BUFFER 38 -/* This struct is not used in this scanner, - but its presence is necessary. */ -struct yy_trans_info - { - flex_int32_t yy_verify; - flex_int32_t yy_nxt; - }; -static yyconst flex_int16_t yy_accept[64] = - { 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 38, 5, 4, 2, 3, 7, 8, 6, 36, 33, - 35, 28, 32, 31, 30, 26, 25, 21, 13, 20, - 23, 26, 11, 12, 22, 18, 14, 19, 26, 26, - 4, 2, 3, 3, 1, 6, 36, 33, 35, 34, - 28, 27, 30, 29, 25, 15, 23, 9, 22, 16, - 17, 24, 10 - } ; - -static yyconst flex_int32_t yy_ec[256] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 2, 4, 5, 6, 1, 1, 7, 8, 9, - 10, 1, 1, 1, 11, 12, 12, 11, 11, 11, - 11, 11, 11, 11, 11, 11, 11, 1, 1, 13, - 14, 15, 1, 1, 11, 11, 11, 11, 11, 11, - 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, - 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, - 1, 16, 1, 1, 11, 1, 11, 11, 11, 11, - - 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, - 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, - 11, 11, 1, 17, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1 - } ; - -extern int zconf_flex_debug; -int zconf_flex_debug = 0; - -/* The intent behind this definition is that it'll catch - * any uses of REJECT which flex missed. - */ -#define REJECT reject_used_but_not_detected -#define yymore() yymore_used_but_not_detected -#define YY_MORE_ADJ 0 -#define YY_RESTORE_YY_MORE_OFFSET -char *zconftext; -#define YY_NO_INPUT 1 - -/* - * Copyright (C) 2002 Roman Zippel - * Released under the terms of the GNU GPL v2.0. - */ - -#include -#include -#include -#include -#include - -#include "lkc.h" - -#define START_STRSIZE 16 - -static struct { - struct file *file; - int lineno; -} current_pos; - -static char *text; -static int text_size, text_asize; - -struct buffer { - struct buffer *parent; - YY_BUFFER_STATE state; -}; - -struct buffer *current_buf; - -static int last_ts, first_ts; - -static void zconf_endhelp(void); -static void zconf_endfile(void); - -static void new_string(void) -{ - text = xmalloc(START_STRSIZE); - text_asize = START_STRSIZE; - text_size = 0; - *text = 0; -} - -static void append_string(const char *str, int size) -{ - int new_size = text_size + size + 1; - if (new_size > text_asize) { - new_size += START_STRSIZE - 1; - new_size &= -START_STRSIZE; - text = realloc(text, new_size); - text_asize = new_size; - } - memcpy(text + text_size, str, size); - text_size += size; - text[text_size] = 0; -} - -static void alloc_string(const char *str, int size) -{ - text = xmalloc(size + 1); - memcpy(text, str, size); - text[size] = 0; -} - -static void warn_ignored_character(char chr) -{ - fprintf(stderr, - "%s:%d:warning: ignoring unsupported character '%c'\n", - zconf_curname(), zconf_lineno(), chr); -} - -#define INITIAL 0 -#define COMMAND 1 -#define HELP 2 -#define STRING 3 -#define PARAM 4 - -#ifndef YY_NO_UNISTD_H -/* Special case for "unistd.h", since it is non-ANSI. We include it way - * down here because we want the user's section 1 to have been scanned first. - * The user has a chance to override it with an option. - */ -#include -#endif - -#ifndef YY_EXTRA_TYPE -#define YY_EXTRA_TYPE void * -#endif - -static int yy_init_globals (void ); - -/* Accessor methods to globals. - These are made visible to non-reentrant scanners for convenience. */ - -int zconflex_destroy (void ); - -int zconfget_debug (void ); - -void zconfset_debug (int debug_flag ); - -YY_EXTRA_TYPE zconfget_extra (void ); - -void zconfset_extra (YY_EXTRA_TYPE user_defined ); - -FILE *zconfget_in (void ); - -void zconfset_in (FILE * in_str ); - -FILE *zconfget_out (void ); - -void zconfset_out (FILE * out_str ); - -int zconfget_leng (void ); - -char *zconfget_text (void ); - -int zconfget_lineno (void ); - -void zconfset_lineno (int line_number ); - -/* Macros after this point can all be overridden by user definitions in - * section 1. - */ - -#ifndef YY_SKIP_YYWRAP -#ifdef __cplusplus -extern "C" int zconfwrap (void ); -#else -extern int zconfwrap (void ); -#endif -#endif - - static void yyunput (int c,char *buf_ptr ); - -#ifndef yytext_ptr -static void yy_flex_strncpy (char *,yyconst char *,int ); -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * ); -#endif - -#ifndef YY_NO_INPUT - -#ifdef __cplusplus -static int yyinput (void ); -#else -static int input (void ); -#endif - -#endif - -/* Amount of stuff to slurp up with each read. */ -#ifndef YY_READ_BUF_SIZE -#ifdef __ia64__ -/* On IA-64, the buffer size is 16k, not 8k */ -#define YY_READ_BUF_SIZE 16384 -#else -#define YY_READ_BUF_SIZE 8192 -#endif /* __ia64__ */ -#endif - -/* Copy whatever the last rule matched to the standard output. */ -#ifndef ECHO -/* This used to be an fputs(), but since the string might contain NUL's, - * we now use fwrite(). - */ -#define ECHO do { if (fwrite( zconftext, zconfleng, 1, zconfout )) {} } while (0) -#endif - -/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, - * is returned in "result". - */ -#ifndef YY_INPUT -#define YY_INPUT(buf,result,max_size) \ - errno=0; \ - while ( (result = read( fileno(zconfin), (char *) buf, max_size )) < 0 ) \ - { \ - if( errno != EINTR) \ - { \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - break; \ - } \ - errno=0; \ - clearerr(zconfin); \ - }\ -\ - -#endif - -/* No semi-colon after return; correct usage is to write "yyterminate();" - - * we don't want an extra ';' after the "return" because that will cause - * some compilers to complain about unreachable statements. - */ -#ifndef yyterminate -#define yyterminate() return YY_NULL -#endif - -/* Number of entries by which start-condition stack grows. */ -#ifndef YY_START_STACK_INCR -#define YY_START_STACK_INCR 25 -#endif - -/* Report a fatal error. */ -#ifndef YY_FATAL_ERROR -#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) -#endif - -/* end tables serialization structures and prototypes */ - -/* Default declaration of generated scanner - a define so the user can - * easily add parameters. - */ -#ifndef YY_DECL -#define YY_DECL_IS_OURS 1 - -extern int zconflex (void); - -#define YY_DECL int zconflex (void) -#endif /* !YY_DECL */ - -/* Code executed at the beginning of each rule, after zconftext and zconfleng - * have been set up. - */ -#ifndef YY_USER_ACTION -#define YY_USER_ACTION -#endif - -/* Code executed at the end of each rule. */ -#ifndef YY_BREAK -#define YY_BREAK break; -#endif - -#define YY_RULE_SETUP \ - YY_USER_ACTION - -/** The main scanner function which does all the work. - */ -YY_DECL -{ - register yy_state_type yy_current_state; - register char *yy_cp, *yy_bp; - register int yy_act; - - int str = 0; - int ts, i; - - if ( !(yy_init) ) - { - (yy_init) = 1; - -#ifdef YY_USER_INIT - YY_USER_INIT; -#endif - - if ( ! (yy_start) ) - (yy_start) = 1; /* first start state */ - - if ( ! zconfin ) - zconfin = stdin; - - if ( ! zconfout ) - zconfout = stdout; - - if ( ! YY_CURRENT_BUFFER ) { - zconfensure_buffer_stack (); - YY_CURRENT_BUFFER_LVALUE = - zconf_create_buffer(zconfin,YY_BUF_SIZE ); - } - - zconf_load_buffer_state( ); - } - - while ( 1 ) /* loops until end-of-file is reached */ - { - yy_cp = (yy_c_buf_p); - - /* Support of zconftext. */ - *yy_cp = (yy_hold_char); - - /* yy_bp points to the position in yy_ch_buf of the start of - * the current run. - */ - yy_bp = yy_cp; - - yy_current_state = (yy_start); -yy_match: - while ( (yy_current_state = yy_nxt[yy_current_state][ yy_ec[YY_SC_TO_UI(*yy_cp)] ]) > 0 ) - ++yy_cp; - - yy_current_state = -yy_current_state; - -yy_find_action: - yy_act = yy_accept[yy_current_state]; - - YY_DO_BEFORE_ACTION; - -do_action: /* This label is used only to access EOF actions. */ - - switch ( yy_act ) - { /* beginning of action switch */ -case 1: -/* rule 1 can match eol */ -case 2: -/* rule 2 can match eol */ -YY_RULE_SETUP -{ - current_file->lineno++; - return T_EOL; -} - YY_BREAK -case 3: -YY_RULE_SETUP - - YY_BREAK -case 4: -YY_RULE_SETUP -{ - BEGIN(COMMAND); -} - YY_BREAK -case 5: -YY_RULE_SETUP -{ - unput(zconftext[0]); - BEGIN(COMMAND); -} - YY_BREAK - -case 6: -YY_RULE_SETUP -{ - const struct kconf_id *id = kconf_id_lookup(zconftext, zconfleng); - BEGIN(PARAM); - current_pos.file = current_file; - current_pos.lineno = current_file->lineno; - if (id && id->flags & TF_COMMAND) { - zconflval.id = id; - return id->token; - } - alloc_string(zconftext, zconfleng); - zconflval.string = text; - return T_WORD; - } - YY_BREAK -case 7: -YY_RULE_SETUP -warn_ignored_character(*zconftext); - YY_BREAK -case 8: -/* rule 8 can match eol */ -YY_RULE_SETUP -{ - BEGIN(INITIAL); - current_file->lineno++; - return T_EOL; - } - YY_BREAK - -case 9: -YY_RULE_SETUP -return T_AND; - YY_BREAK -case 10: -YY_RULE_SETUP -return T_OR; - YY_BREAK -case 11: -YY_RULE_SETUP -return T_OPEN_PAREN; - YY_BREAK -case 12: -YY_RULE_SETUP -return T_CLOSE_PAREN; - YY_BREAK -case 13: -YY_RULE_SETUP -return T_NOT; - YY_BREAK -case 14: -YY_RULE_SETUP -return T_EQUAL; - YY_BREAK -case 15: -YY_RULE_SETUP -return T_UNEQUAL; - YY_BREAK -case 16: -YY_RULE_SETUP -return T_LESS_EQUAL; - YY_BREAK -case 17: -YY_RULE_SETUP -return T_GREATER_EQUAL; - YY_BREAK -case 18: -YY_RULE_SETUP -return T_LESS; - YY_BREAK -case 19: -YY_RULE_SETUP -return T_GREATER; - YY_BREAK -case 20: -YY_RULE_SETUP -{ - str = zconftext[0]; - new_string(); - BEGIN(STRING); - } - YY_BREAK -case 21: -/* rule 21 can match eol */ -YY_RULE_SETUP -BEGIN(INITIAL); current_file->lineno++; return T_EOL; - YY_BREAK -case 22: -YY_RULE_SETUP -{ - const struct kconf_id *id = kconf_id_lookup(zconftext, zconfleng); - if (id && id->flags & TF_PARAM) { - zconflval.id = id; - return id->token; - } - alloc_string(zconftext, zconfleng); - zconflval.string = text; - return T_WORD; - } - YY_BREAK -case 23: -YY_RULE_SETUP -/* comment */ - YY_BREAK -case 24: -/* rule 24 can match eol */ -YY_RULE_SETUP -current_file->lineno++; - YY_BREAK -case 25: -YY_RULE_SETUP - - YY_BREAK -case 26: -YY_RULE_SETUP -warn_ignored_character(*zconftext); - YY_BREAK -case YY_STATE_EOF(PARAM): -{ - BEGIN(INITIAL); - } - YY_BREAK - -case 27: -/* rule 27 can match eol */ -*yy_cp = (yy_hold_char); /* undo effects of setting up zconftext */ -(yy_c_buf_p) = yy_cp -= 1; -YY_DO_BEFORE_ACTION; /* set up zconftext again */ -YY_RULE_SETUP -{ - append_string(zconftext, zconfleng); - zconflval.string = text; - return T_WORD_QUOTE; - } - YY_BREAK -case 28: -YY_RULE_SETUP -{ - append_string(zconftext, zconfleng); - } - YY_BREAK -case 29: -/* rule 29 can match eol */ -*yy_cp = (yy_hold_char); /* undo effects of setting up zconftext */ -(yy_c_buf_p) = yy_cp -= 1; -YY_DO_BEFORE_ACTION; /* set up zconftext again */ -YY_RULE_SETUP -{ - append_string(zconftext + 1, zconfleng - 1); - zconflval.string = text; - return T_WORD_QUOTE; - } - YY_BREAK -case 30: -YY_RULE_SETUP -{ - append_string(zconftext + 1, zconfleng - 1); - } - YY_BREAK -case 31: -YY_RULE_SETUP -{ - if (str == zconftext[0]) { - BEGIN(PARAM); - zconflval.string = text; - return T_WORD_QUOTE; - } else - append_string(zconftext, 1); - } - YY_BREAK -case 32: -/* rule 32 can match eol */ -YY_RULE_SETUP -{ - printf("%s:%d:warning: multi-line strings not supported\n", zconf_curname(), zconf_lineno()); - current_file->lineno++; - BEGIN(INITIAL); - return T_EOL; - } - YY_BREAK -case YY_STATE_EOF(STRING): -{ - BEGIN(INITIAL); - } - YY_BREAK - -case 33: -YY_RULE_SETUP -{ - ts = 0; - for (i = 0; i < zconfleng; i++) { - if (zconftext[i] == '\t') - ts = (ts & ~7) + 8; - else - ts++; - } - last_ts = ts; - if (first_ts) { - if (ts < first_ts) { - zconf_endhelp(); - return T_HELPTEXT; - } - ts -= first_ts; - while (ts > 8) { - append_string(" ", 8); - ts -= 8; - } - append_string(" ", ts); - } - } - YY_BREAK -case 34: -/* rule 34 can match eol */ -*yy_cp = (yy_hold_char); /* undo effects of setting up zconftext */ -(yy_c_buf_p) = yy_cp -= 1; -YY_DO_BEFORE_ACTION; /* set up zconftext again */ -YY_RULE_SETUP -{ - current_file->lineno++; - zconf_endhelp(); - return T_HELPTEXT; - } - YY_BREAK -case 35: -/* rule 35 can match eol */ -YY_RULE_SETUP -{ - current_file->lineno++; - append_string("\n", 1); - } - YY_BREAK -case 36: -YY_RULE_SETUP -{ - while (zconfleng) { - if ((zconftext[zconfleng-1] != ' ') && (zconftext[zconfleng-1] != '\t')) - break; - zconfleng--; - } - append_string(zconftext, zconfleng); - if (!first_ts) - first_ts = last_ts; - } - YY_BREAK -case YY_STATE_EOF(HELP): -{ - zconf_endhelp(); - return T_HELPTEXT; - } - YY_BREAK - -case YY_STATE_EOF(INITIAL): -case YY_STATE_EOF(COMMAND): -{ - if (current_file) { - zconf_endfile(); - return T_EOL; - } - fclose(zconfin); - yyterminate(); -} - YY_BREAK -case 37: -YY_RULE_SETUP -YY_FATAL_ERROR( "flex scanner jammed" ); - YY_BREAK - - case YY_END_OF_BUFFER: - { - /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; - - /* Undo the effects of YY_DO_BEFORE_ACTION. */ - *yy_cp = (yy_hold_char); - YY_RESTORE_YY_MORE_OFFSET - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) - { - /* We're scanning a new file or input source. It's - * possible that this happened because the user - * just pointed zconfin at a new source and called - * zconflex(). If so, then we have to assure - * consistency between YY_CURRENT_BUFFER and our - * globals. Here is the right place to do so, because - * this is the first action (other than possibly a - * back-up) that will match for the new input source. - */ - (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - YY_CURRENT_BUFFER_LVALUE->yy_input_file = zconfin; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; - } - - /* Note that here we test for yy_c_buf_p "<=" to the position - * of the first EOB in the buffer, since yy_c_buf_p will - * already have been incremented past the NUL character - * (since all states make transitions on EOB to the - * end-of-buffer state). Contrast this with the test - * in input(). - */ - if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) - { /* This was really a NUL. */ - yy_state_type yy_next_state; - - (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( ); - - /* Okay, we're now positioned to make the NUL - * transition. We couldn't have - * yy_get_previous_state() go ahead and do it - * for us because it doesn't know how to deal - * with the possibility of jamming (and we don't - * want to build jamming into it because then it - * will run more slowly). - */ - - yy_next_state = yy_try_NUL_trans( yy_current_state ); - - yy_bp = (yytext_ptr) + YY_MORE_ADJ; - - if ( yy_next_state ) - { - /* Consume the NUL. */ - yy_cp = ++(yy_c_buf_p); - yy_current_state = yy_next_state; - goto yy_match; - } - - else - { - yy_cp = (yy_c_buf_p); - goto yy_find_action; - } - } - - else switch ( yy_get_next_buffer( ) ) - { - case EOB_ACT_END_OF_FILE: - { - (yy_did_buffer_switch_on_eof) = 0; - - if ( zconfwrap( ) ) - { - /* Note: because we've taken care in - * yy_get_next_buffer() to have set up - * zconftext, we can now set up - * yy_c_buf_p so that if some total - * hoser (like flex itself) wants to - * call the scanner after we return the - * YY_NULL, it'll still work - another - * YY_NULL will get returned. - */ - (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; - - yy_act = YY_STATE_EOF(YY_START); - goto do_action; - } - - else - { - if ( ! (yy_did_buffer_switch_on_eof) ) - YY_NEW_FILE; - } - break; - } - - case EOB_ACT_CONTINUE_SCAN: - (yy_c_buf_p) = - (yytext_ptr) + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( ); - - yy_cp = (yy_c_buf_p); - yy_bp = (yytext_ptr) + YY_MORE_ADJ; - goto yy_match; - - case EOB_ACT_LAST_MATCH: - (yy_c_buf_p) = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; - - yy_current_state = yy_get_previous_state( ); - - yy_cp = (yy_c_buf_p); - yy_bp = (yytext_ptr) + YY_MORE_ADJ; - goto yy_find_action; - } - break; - } - - default: - YY_FATAL_ERROR( - "fatal flex scanner internal error--no action found" ); - } /* end of action switch */ - } /* end of scanning one token */ -} /* end of zconflex */ - -/* yy_get_next_buffer - try to read in a new buffer - * - * Returns a code representing an action: - * EOB_ACT_LAST_MATCH - - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position - * EOB_ACT_END_OF_FILE - end of file - */ -static int yy_get_next_buffer (void) -{ - register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; - register char *source = (yytext_ptr); - register int number_to_move, i; - int ret_val; - - if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) - YY_FATAL_ERROR( - "fatal flex scanner internal error--end of buffer missed" ); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) - { /* Don't try to fill the buffer, so this is an EOF. */ - if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) - { - /* We matched a single character, the EOB, so - * treat this as a final EOF. - */ - return EOB_ACT_END_OF_FILE; - } - - else - { - /* We matched some text prior to the EOB, first - * process it. - */ - return EOB_ACT_LAST_MATCH; - } - } - - /* Try to read more data. */ - - /* First move last chars to start of buffer. */ - number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; - - for ( i = 0; i < number_to_move; ++i ) - *(dest++) = *(source++); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) - /* don't do the read, it's not guaranteed to return an EOF, - * just force an EOF - */ - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; - - else - { - int num_to_read = - YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; - - while ( num_to_read <= 0 ) - { /* Not enough room in the buffer - grow it. */ - - /* just a shorter name for the current buffer */ - YY_BUFFER_STATE b = YY_CURRENT_BUFFER; - - int yy_c_buf_p_offset = - (int) ((yy_c_buf_p) - b->yy_ch_buf); - - if ( b->yy_is_our_buffer ) - { - int new_size = b->yy_buf_size * 2; - - if ( new_size <= 0 ) - b->yy_buf_size += b->yy_buf_size / 8; - else - b->yy_buf_size *= 2; - - b->yy_ch_buf = (char *) - /* Include room in for 2 EOB chars. */ - zconfrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); - } - else - /* Can't grow it, we don't own it. */ - b->yy_ch_buf = 0; - - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( - "fatal error - scanner input buffer overflow" ); - - (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; - - num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - - number_to_move - 1; - - } - - if ( num_to_read > YY_READ_BUF_SIZE ) - num_to_read = YY_READ_BUF_SIZE; - - /* Read in more data. */ - YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), - (yy_n_chars), (size_t) num_to_read ); - - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); - } - - if ( (yy_n_chars) == 0 ) - { - if ( number_to_move == YY_MORE_ADJ ) - { - ret_val = EOB_ACT_END_OF_FILE; - zconfrestart(zconfin ); - } - - else - { - ret_val = EOB_ACT_LAST_MATCH; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = - YY_BUFFER_EOF_PENDING; - } - } - - else - ret_val = EOB_ACT_CONTINUE_SCAN; - - if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { - /* Extend the array by 50%, plus the number we really need. */ - yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) zconfrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); - if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); - } - - (yy_n_chars) += number_to_move; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; - - (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; - - return ret_val; -} - -/* yy_get_previous_state - get the state just before the EOB char was reached */ - - static yy_state_type yy_get_previous_state (void) -{ - register yy_state_type yy_current_state; - register char *yy_cp; - - yy_current_state = (yy_start); - - for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) - { - yy_current_state = yy_nxt[yy_current_state][(*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1)]; - } - - return yy_current_state; -} - -/* yy_try_NUL_trans - try to make a transition on the NUL character - * - * synopsis - * next_state = yy_try_NUL_trans( current_state ); - */ - static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) -{ - register int yy_is_jam; - - yy_current_state = yy_nxt[yy_current_state][1]; - yy_is_jam = (yy_current_state <= 0); - - return yy_is_jam ? 0 : yy_current_state; -} - - static void yyunput (int c, register char * yy_bp ) -{ - register char *yy_cp; - - yy_cp = (yy_c_buf_p); - - /* undo effects of setting up zconftext */ - *yy_cp = (yy_hold_char); - - if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) - { /* need to shift things up to make room */ - /* +2 for EOB chars. */ - register int number_to_move = (yy_n_chars) + 2; - register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ - YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; - register char *source = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; - - while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) - *--dest = *--source; - - yy_cp += (int) (dest - source); - yy_bp += (int) (dest - source); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = - (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; - - if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) - YY_FATAL_ERROR( "flex scanner push-back overflow" ); - } - - *--yy_cp = (char) c; - - (yytext_ptr) = yy_bp; - (yy_hold_char) = *yy_cp; - (yy_c_buf_p) = yy_cp; -} - -#ifndef YY_NO_INPUT -#ifdef __cplusplus - static int yyinput (void) -#else - static int input (void) -#endif - -{ - int c; - - *(yy_c_buf_p) = (yy_hold_char); - - if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) - { - /* yy_c_buf_p now points to the character we want to return. - * If this occurs *before* the EOB characters, then it's a - * valid NUL; if not, then we've hit the end of the buffer. - */ - if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) - /* This was really a NUL. */ - *(yy_c_buf_p) = '\0'; - - else - { /* need more input */ - int offset = (yy_c_buf_p) - (yytext_ptr); - ++(yy_c_buf_p); - - switch ( yy_get_next_buffer( ) ) - { - case EOB_ACT_LAST_MATCH: - /* This happens because yy_g_n_b() - * sees that we've accumulated a - * token and flags that we need to - * try matching the token before - * proceeding. But for input(), - * there's no matching to consider. - * So convert the EOB_ACT_LAST_MATCH - * to EOB_ACT_END_OF_FILE. - */ - - /* Reset buffer status. */ - zconfrestart(zconfin ); - - /*FALLTHROUGH*/ - - case EOB_ACT_END_OF_FILE: - { - if ( zconfwrap( ) ) - return EOF; - - if ( ! (yy_did_buffer_switch_on_eof) ) - YY_NEW_FILE; -#ifdef __cplusplus - return yyinput(); -#else - return input(); -#endif - } - - case EOB_ACT_CONTINUE_SCAN: - (yy_c_buf_p) = (yytext_ptr) + offset; - break; - } - } - } - - c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ - *(yy_c_buf_p) = '\0'; /* preserve zconftext */ - (yy_hold_char) = *++(yy_c_buf_p); - - return c; -} -#endif /* ifndef YY_NO_INPUT */ - -/** Immediately switch to a different input stream. - * @param input_file A readable stream. - * - * @note This function does not reset the start condition to @c INITIAL . - */ - void zconfrestart (FILE * input_file ) -{ - - if ( ! YY_CURRENT_BUFFER ){ - zconfensure_buffer_stack (); - YY_CURRENT_BUFFER_LVALUE = - zconf_create_buffer(zconfin,YY_BUF_SIZE ); - } - - zconf_init_buffer(YY_CURRENT_BUFFER,input_file ); - zconf_load_buffer_state( ); -} - -/** Switch to a different input buffer. - * @param new_buffer The new input buffer. - * - */ - void zconf_switch_to_buffer (YY_BUFFER_STATE new_buffer ) -{ - - /* TODO. We should be able to replace this entire function body - * with - * zconfpop_buffer_state(); - * zconfpush_buffer_state(new_buffer); - */ - zconfensure_buffer_stack (); - if ( YY_CURRENT_BUFFER == new_buffer ) - return; - - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *(yy_c_buf_p) = (yy_hold_char); - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); - } - - YY_CURRENT_BUFFER_LVALUE = new_buffer; - zconf_load_buffer_state( ); - - /* We don't actually know whether we did this switch during - * EOF (zconfwrap()) processing, but the only time this flag - * is looked at is after zconfwrap() is called, so it's safe - * to go ahead and always set it. - */ - (yy_did_buffer_switch_on_eof) = 1; -} - -static void zconf_load_buffer_state (void) -{ - (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; - zconfin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; - (yy_hold_char) = *(yy_c_buf_p); -} - -/** Allocate and initialize an input buffer state. - * @param file A readable stream. - * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. - * - * @return the allocated buffer state. - */ - YY_BUFFER_STATE zconf_create_buffer (FILE * file, int size ) -{ - YY_BUFFER_STATE b; - - b = (YY_BUFFER_STATE) zconfalloc(sizeof( struct yy_buffer_state ) ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in zconf_create_buffer()" ); - - b->yy_buf_size = size; - - /* yy_ch_buf has to be 2 characters longer than the size given because - * we need to put in 2 end-of-buffer characters. - */ - b->yy_ch_buf = (char *) zconfalloc(b->yy_buf_size + 2 ); - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in zconf_create_buffer()" ); - - b->yy_is_our_buffer = 1; - - zconf_init_buffer(b,file ); - - return b; -} - -/** Destroy the buffer. - * @param b a buffer created with zconf_create_buffer() - * - */ - void zconf_delete_buffer (YY_BUFFER_STATE b ) -{ - - if ( ! b ) - return; - - if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ - YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; - - if ( b->yy_is_our_buffer ) - zconffree((void *) b->yy_ch_buf ); - - zconffree((void *) b ); -} - -/* Initializes or reinitializes a buffer. - * This function is sometimes called more than once on the same buffer, - * such as during a zconfrestart() or at EOF. - */ - static void zconf_init_buffer (YY_BUFFER_STATE b, FILE * file ) - -{ - int oerrno = errno; - - zconf_flush_buffer(b ); - - b->yy_input_file = file; - b->yy_fill_buffer = 1; - - /* If b is the current buffer, then zconf_init_buffer was _probably_ - * called from zconfrestart() or through yy_get_next_buffer. - * In that case, we don't want to reset the lineno or column. - */ - if (b != YY_CURRENT_BUFFER){ - b->yy_bs_lineno = 1; - b->yy_bs_column = 0; - } - - b->yy_is_interactive = 0; - - errno = oerrno; -} - -/** Discard all buffered characters. On the next scan, YY_INPUT will be called. - * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. - * - */ - void zconf_flush_buffer (YY_BUFFER_STATE b ) -{ - if ( ! b ) - return; - - b->yy_n_chars = 0; - - /* We always need two end-of-buffer characters. The first causes - * a transition to the end-of-buffer state. The second causes - * a jam in that state. - */ - b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; - b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; - - b->yy_buf_pos = &b->yy_ch_buf[0]; - - b->yy_at_bol = 1; - b->yy_buffer_status = YY_BUFFER_NEW; - - if ( b == YY_CURRENT_BUFFER ) - zconf_load_buffer_state( ); -} - -/** Pushes the new state onto the stack. The new state becomes - * the current state. This function will allocate the stack - * if necessary. - * @param new_buffer The new state. - * - */ -void zconfpush_buffer_state (YY_BUFFER_STATE new_buffer ) -{ - if (new_buffer == NULL) - return; - - zconfensure_buffer_stack(); - - /* This block is copied from zconf_switch_to_buffer. */ - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *(yy_c_buf_p) = (yy_hold_char); - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); - } - - /* Only push if top exists. Otherwise, replace top. */ - if (YY_CURRENT_BUFFER) - (yy_buffer_stack_top)++; - YY_CURRENT_BUFFER_LVALUE = new_buffer; - - /* copied from zconf_switch_to_buffer. */ - zconf_load_buffer_state( ); - (yy_did_buffer_switch_on_eof) = 1; -} - -/** Removes and deletes the top of the stack, if present. - * The next element becomes the new top. - * - */ -void zconfpop_buffer_state (void) -{ - if (!YY_CURRENT_BUFFER) - return; - - zconf_delete_buffer(YY_CURRENT_BUFFER ); - YY_CURRENT_BUFFER_LVALUE = NULL; - if ((yy_buffer_stack_top) > 0) - --(yy_buffer_stack_top); - - if (YY_CURRENT_BUFFER) { - zconf_load_buffer_state( ); - (yy_did_buffer_switch_on_eof) = 1; - } -} - -/* Allocates the stack if it does not exist. - * Guarantees space for at least one push. - */ -static void zconfensure_buffer_stack (void) -{ - int num_to_alloc; - - if (!(yy_buffer_stack)) { - - /* First allocation is just for 2 elements, since we don't know if this - * scanner will even need a stack. We use 2 instead of 1 to avoid an - * immediate realloc on the next call. - */ - num_to_alloc = 1; - (yy_buffer_stack) = (struct yy_buffer_state**)zconfalloc - (num_to_alloc * sizeof(struct yy_buffer_state*) - ); - if ( ! (yy_buffer_stack) ) - YY_FATAL_ERROR( "out of dynamic memory in zconfensure_buffer_stack()" ); - - memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - - (yy_buffer_stack_max) = num_to_alloc; - (yy_buffer_stack_top) = 0; - return; - } - - if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ - - /* Increase the buffer to prepare for a possible push. */ - int grow_size = 8 /* arbitrary grow size */; - - num_to_alloc = (yy_buffer_stack_max) + grow_size; - (yy_buffer_stack) = (struct yy_buffer_state**)zconfrealloc - ((yy_buffer_stack), - num_to_alloc * sizeof(struct yy_buffer_state*) - ); - if ( ! (yy_buffer_stack) ) - YY_FATAL_ERROR( "out of dynamic memory in zconfensure_buffer_stack()" ); - - /* zero only the new slots.*/ - memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); - (yy_buffer_stack_max) = num_to_alloc; - } -} - -/** Setup the input buffer state to scan directly from a user-specified character buffer. - * @param base the character buffer - * @param size the size in bytes of the character buffer - * - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE zconf_scan_buffer (char * base, yy_size_t size ) -{ - YY_BUFFER_STATE b; - - if ( size < 2 || - base[size-2] != YY_END_OF_BUFFER_CHAR || - base[size-1] != YY_END_OF_BUFFER_CHAR ) - /* They forgot to leave room for the EOB's. */ - return 0; - - b = (YY_BUFFER_STATE) zconfalloc(sizeof( struct yy_buffer_state ) ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in zconf_scan_buffer()" ); - - b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ - b->yy_buf_pos = b->yy_ch_buf = base; - b->yy_is_our_buffer = 0; - b->yy_input_file = 0; - b->yy_n_chars = b->yy_buf_size; - b->yy_is_interactive = 0; - b->yy_at_bol = 1; - b->yy_fill_buffer = 0; - b->yy_buffer_status = YY_BUFFER_NEW; - - zconf_switch_to_buffer(b ); - - return b; -} - -/** Setup the input buffer state to scan a string. The next call to zconflex() will - * scan from a @e copy of @a str. - * @param yystr a NUL-terminated string to scan - * - * @return the newly allocated buffer state object. - * @note If you want to scan bytes that may contain NUL values, then use - * zconf_scan_bytes() instead. - */ -YY_BUFFER_STATE zconf_scan_string (yyconst char * yystr ) -{ - - return zconf_scan_bytes(yystr,strlen(yystr) ); -} - -/** Setup the input buffer state to scan the given bytes. The next call to zconflex() will - * scan from a @e copy of @a bytes. - * @param yybytes the byte buffer to scan - * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. - * - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE zconf_scan_bytes (yyconst char * yybytes, int _yybytes_len ) -{ - YY_BUFFER_STATE b; - char *buf; - yy_size_t n; - int i; - - /* Get memory for full buffer, including space for trailing EOB's. */ - n = _yybytes_len + 2; - buf = (char *) zconfalloc(n ); - if ( ! buf ) - YY_FATAL_ERROR( "out of dynamic memory in zconf_scan_bytes()" ); - - for ( i = 0; i < _yybytes_len; ++i ) - buf[i] = yybytes[i]; - - buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; - - b = zconf_scan_buffer(buf,n ); - if ( ! b ) - YY_FATAL_ERROR( "bad buffer in zconf_scan_bytes()" ); - - /* It's okay to grow etc. this buffer, and we should throw it - * away when we're done. - */ - b->yy_is_our_buffer = 1; - - return b; -} - -#ifndef YY_EXIT_FAILURE -#define YY_EXIT_FAILURE 2 -#endif - -static void yy_fatal_error (yyconst char* msg ) -{ - (void) fprintf( stderr, "%s\n", msg ); - exit( YY_EXIT_FAILURE ); -} - -/* Redefine yyless() so it works in section 3 code. */ - -#undef yyless -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up zconftext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - zconftext[zconfleng] = (yy_hold_char); \ - (yy_c_buf_p) = zconftext + yyless_macro_arg; \ - (yy_hold_char) = *(yy_c_buf_p); \ - *(yy_c_buf_p) = '\0'; \ - zconfleng = yyless_macro_arg; \ - } \ - while ( 0 ) - -/* Accessor methods (get/set functions) to struct members. */ - -/** Get the current line number. - * - */ -int zconfget_lineno (void) -{ - - return zconflineno; -} - -/** Get the input stream. - * - */ -FILE *zconfget_in (void) -{ - return zconfin; -} - -/** Get the output stream. - * - */ -FILE *zconfget_out (void) -{ - return zconfout; -} - -/** Get the length of the current token. - * - */ -int zconfget_leng (void) -{ - return zconfleng; -} - -/** Get the current token. - * - */ - -char *zconfget_text (void) -{ - return zconftext; -} - -/** Set the current line number. - * @param line_number - * - */ -void zconfset_lineno (int line_number ) -{ - - zconflineno = line_number; -} - -/** Set the input stream. This does not discard the current - * input buffer. - * @param in_str A readable stream. - * - * @see zconf_switch_to_buffer - */ -void zconfset_in (FILE * in_str ) -{ - zconfin = in_str ; -} - -void zconfset_out (FILE * out_str ) -{ - zconfout = out_str ; -} - -int zconfget_debug (void) -{ - return zconf_flex_debug; -} - -void zconfset_debug (int bdebug ) -{ - zconf_flex_debug = bdebug ; -} - -static int yy_init_globals (void) -{ - /* Initialization is the same as for the non-reentrant scanner. - * This function is called from zconflex_destroy(), so don't allocate here. - */ - - (yy_buffer_stack) = 0; - (yy_buffer_stack_top) = 0; - (yy_buffer_stack_max) = 0; - (yy_c_buf_p) = (char *) 0; - (yy_init) = 0; - (yy_start) = 0; - -/* Defined in main.c */ -#ifdef YY_STDINIT - zconfin = stdin; - zconfout = stdout; -#else - zconfin = (FILE *) 0; - zconfout = (FILE *) 0; -#endif - - /* For future reference: Set errno on error, since we are called by - * zconflex_init() - */ - return 0; -} - -/* zconflex_destroy is for both reentrant and non-reentrant scanners. */ -int zconflex_destroy (void) -{ - - /* Pop the buffer stack, destroying each element. */ - while(YY_CURRENT_BUFFER){ - zconf_delete_buffer(YY_CURRENT_BUFFER ); - YY_CURRENT_BUFFER_LVALUE = NULL; - zconfpop_buffer_state(); - } - - /* Destroy the stack itself. */ - zconffree((yy_buffer_stack) ); - (yy_buffer_stack) = NULL; - - /* Reset the globals. This is important in a non-reentrant scanner so the next time - * zconflex() is called, initialization will occur. */ - yy_init_globals( ); - - return 0; -} - -/* - * Internal utility routines. - */ - -#ifndef yytext_ptr -static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) -{ - register int i; - for ( i = 0; i < n; ++i ) - s1[i] = s2[i]; -} -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * s ) -{ - register int n; - for ( n = 0; s[n]; ++n ) - ; - - return n; -} -#endif - -void *zconfalloc (yy_size_t size ) -{ - return (void *) malloc( size ); -} - -void *zconfrealloc (void * ptr, yy_size_t size ) -{ - /* The cast to (char *) in the following accommodates both - * implementations that use char* generic pointers, and those - * that use void* generic pointers. It works with the latter - * because both ANSI C and C++ allow castless assignment from - * any pointer type to void*, and deal with argument conversions - * as though doing an assignment. - */ - return (void *) realloc( (char *) ptr, size ); -} - -void zconffree (void * ptr ) -{ - free( (char *) ptr ); /* see zconfrealloc() for (char *) cast */ -} - -#define YYTABLES_NAME "yytables" - -void zconf_starthelp(void) -{ - new_string(); - last_ts = first_ts = 0; - BEGIN(HELP); -} - -static void zconf_endhelp(void) -{ - zconflval.string = text; - BEGIN(INITIAL); -} - -/* - * Try to open specified file with following names: - * ./name - * $(srctree)/name - * The latter is used when srctree is separate from objtree - * when compiling the kernel. - * Return NULL if file is not found. - */ -FILE *zconf_fopen(const char *name) -{ - char *env, fullname[PATH_MAX+1]; - FILE *f; - - f = fopen(name, "r"); - if (!f && name != NULL && name[0] != '/') { - env = getenv(SRCTREE); - if (env) { - sprintf(fullname, "%s/%s", env, name); - f = fopen(fullname, "r"); - } - } - return f; -} - -void zconf_initscan(const char *name) -{ - zconfin = zconf_fopen(name); - if (!zconfin) { - printf("can't find file %s\n", name); - exit(1); - } - - current_buf = xmalloc(sizeof(*current_buf)); - memset(current_buf, 0, sizeof(*current_buf)); - - current_file = file_lookup(name); - current_file->lineno = 1; -} - -void zconf_nextfile(const char *name) -{ - struct file *iter; - struct file *file = file_lookup(name); - struct buffer *buf = xmalloc(sizeof(*buf)); - memset(buf, 0, sizeof(*buf)); - - current_buf->state = YY_CURRENT_BUFFER; - zconfin = zconf_fopen(file->name); - if (!zconfin) { - printf("%s:%d: can't open file \"%s\"\n", - zconf_curname(), zconf_lineno(), file->name); - exit(1); - } - zconf_switch_to_buffer(zconf_create_buffer(zconfin,YY_BUF_SIZE)); - buf->parent = current_buf; - current_buf = buf; - - for (iter = current_file->parent; iter; iter = iter->parent ) { - if (!strcmp(current_file->name,iter->name) ) { - printf("%s:%d: recursive inclusion detected. " - "Inclusion path:\n current file : '%s'\n", - zconf_curname(), zconf_lineno(), - zconf_curname()); - iter = current_file->parent; - while (iter && \ - strcmp(iter->name,current_file->name)) { - printf(" included from: '%s:%d'\n", - iter->name, iter->lineno-1); - iter = iter->parent; - } - if (iter) - printf(" included from: '%s:%d'\n", - iter->name, iter->lineno+1); - exit(1); - } - } - file->lineno = 1; - file->parent = current_file; - current_file = file; -} - -static void zconf_endfile(void) -{ - struct buffer *parent; - - current_file = current_file->parent; - - parent = current_buf->parent; - if (parent) { - fclose(zconfin); - zconf_delete_buffer(YY_CURRENT_BUFFER); - zconf_switch_to_buffer(parent->state); - } - free(current_buf); - current_buf = parent; -} - -int zconf_lineno(void) -{ - return current_pos.lineno; -} - -const char *zconf_curname(void) -{ - return current_pos.file ? current_pos.file->name : ""; -} - diff --git a/xen/tools/kconfig/zconf.tab.c_shipped b/xen/tools/kconfig/zconf.tab.c_shipped deleted file mode 100644 index 0f1661d7b8d5..000000000000 --- a/xen/tools/kconfig/zconf.tab.c_shipped +++ /dev/null @@ -1,2580 +0,0 @@ -/* A Bison parser, made by GNU Bison 2.5.1. */ - -/* Bison implementation for Yacc-like parsers in C - - Copyright (C) 1984, 1989-1990, 2000-2012 Free Software Foundation, Inc. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -/* As a special exception, you may create a larger work that contains - part or all of the Bison parser skeleton and distribute that work - under terms of your choice, so long as that work isn't itself a - parser generator using the skeleton or a modified version thereof - as a parser skeleton. Alternatively, if you modify or redistribute - the parser skeleton itself, you may (at your option) remove this - special exception, which will cause the skeleton and the resulting - Bison output files to be licensed under the GNU General Public - License without this special exception. - - This special exception was added by the Free Software Foundation in - version 2.2 of Bison. */ - -/* C LALR(1) parser skeleton written by Richard Stallman, by - simplifying the original so-called "semantic" parser. */ - -/* All symbols defined below should begin with yy or YY, to avoid - infringing on user name space. This should be done even for local - variables, as they might otherwise be expanded by user macros. - There are some unavoidable exceptions within include files to - define necessary library symbols; they are noted "INFRINGES ON - USER NAME SPACE" below. */ - -/* Identify Bison output. */ -#define YYBISON 1 - -/* Bison version. */ -#define YYBISON_VERSION "2.5.1" - -/* Skeleton name. */ -#define YYSKELETON_NAME "yacc.c" - -/* Pure parsers. */ -#define YYPURE 0 - -/* Push parsers. */ -#define YYPUSH 0 - -/* Pull parsers. */ -#define YYPULL 1 - -/* Using locations. */ -#define YYLSP_NEEDED 0 - -/* Substitute the variable and function names. */ -#define yyparse zconfparse -#define yylex zconflex -#define yyerror zconferror -#define yylval zconflval -#define yychar zconfchar -#define yydebug zconfdebug -#define yynerrs zconfnerrs - - -/* Copy the first part of user declarations. */ - - -/* - * Copyright (C) 2002 Roman Zippel - * Released under the terms of the GNU GPL v2.0. - */ - -#include -#include -#include -#include -#include -#include - -#include "lkc.h" - -#define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt) - -#define PRINTD 0x0001 -#define DEBUG_PARSE 0x0002 - -int cdebug = PRINTD; - -extern int zconflex(void); -static void zconfprint(const char *err, ...); -static void zconf_error(const char *err, ...); -static void zconferror(const char *err); -static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtoken); - -struct symbol *symbol_hash[SYMBOL_HASHSIZE]; - -static struct menu *current_menu, *current_entry; - - - - -# ifndef YY_NULL -# if defined __cplusplus && 201103L <= __cplusplus -# define YY_NULL nullptr -# else -# define YY_NULL 0 -# endif -# endif - -/* Enabling traces. */ -#ifndef YYDEBUG -# define YYDEBUG 1 -#endif - -/* Enabling verbose error messages. */ -#ifdef YYERROR_VERBOSE -# undef YYERROR_VERBOSE -# define YYERROR_VERBOSE 1 -#else -# define YYERROR_VERBOSE 0 -#endif - -/* Enabling the token table. */ -#ifndef YYTOKEN_TABLE -# define YYTOKEN_TABLE 0 -#endif - - -/* Tokens. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - T_MAINMENU = 258, - T_MENU = 259, - T_ENDMENU = 260, - T_SOURCE = 261, - T_CHOICE = 262, - T_ENDCHOICE = 263, - T_COMMENT = 264, - T_CONFIG = 265, - T_MENUCONFIG = 266, - T_HELP = 267, - T_HELPTEXT = 268, - T_IF = 269, - T_ENDIF = 270, - T_DEPENDS = 271, - T_OPTIONAL = 272, - T_PROMPT = 273, - T_TYPE = 274, - T_DEFAULT = 275, - T_SELECT = 276, - T_RANGE = 277, - T_VISIBLE = 278, - T_OPTION = 279, - T_ON = 280, - T_WORD = 281, - T_WORD_QUOTE = 282, - T_UNEQUAL = 283, - T_LESS = 284, - T_LESS_EQUAL = 285, - T_GREATER = 286, - T_GREATER_EQUAL = 287, - T_CLOSE_PAREN = 288, - T_OPEN_PAREN = 289, - T_EOL = 290, - T_OR = 291, - T_AND = 292, - T_EQUAL = 293, - T_NOT = 294 - }; -#endif - - - -#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED -typedef union YYSTYPE -{ - - - char *string; - struct file *file; - struct symbol *symbol; - struct expr *expr; - struct menu *menu; - const struct kconf_id *id; - - - -} YYSTYPE; -# define YYSTYPE_IS_TRIVIAL 1 -# define yystype YYSTYPE /* obsolescent; will be withdrawn */ -# define YYSTYPE_IS_DECLARED 1 -#endif - - -/* Copy the second part of user declarations. */ - - -/* Include zconf.hash.c here so it can see the token constants. */ -#include "zconf.hash.c" - - - -#ifdef short -# undef short -#endif - -#ifdef YYTYPE_UINT8 -typedef YYTYPE_UINT8 yytype_uint8; -#else -typedef unsigned char yytype_uint8; -#endif - -#ifdef YYTYPE_INT8 -typedef YYTYPE_INT8 yytype_int8; -#elif (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -typedef signed char yytype_int8; -#else -typedef short int yytype_int8; -#endif - -#ifdef YYTYPE_UINT16 -typedef YYTYPE_UINT16 yytype_uint16; -#else -typedef unsigned short int yytype_uint16; -#endif - -#ifdef YYTYPE_INT16 -typedef YYTYPE_INT16 yytype_int16; -#else -typedef short int yytype_int16; -#endif - -#ifndef YYSIZE_T -# ifdef __SIZE_TYPE__ -# define YYSIZE_T __SIZE_TYPE__ -# elif defined size_t -# define YYSIZE_T size_t -# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -# include /* INFRINGES ON USER NAME SPACE */ -# define YYSIZE_T size_t -# else -# define YYSIZE_T unsigned int -# endif -#endif - -#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) - -#ifndef YY_ -# if defined YYENABLE_NLS && YYENABLE_NLS -# if ENABLE_NLS -# include /* INFRINGES ON USER NAME SPACE */ -# define YY_(msgid) dgettext ("bison-runtime", msgid) -# endif -# endif -# ifndef YY_ -# define YY_(msgid) msgid -# endif -#endif - -/* Suppress unused-variable warnings by "using" E. */ -#if ! defined lint || defined __GNUC__ -# define YYUSE(e) ((void) (e)) -#else -# define YYUSE(e) /* empty */ -#endif - -/* Identity function, used to suppress warnings about constant conditions. */ -#ifndef lint -# define YYID(n) (n) -#else -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static int -YYID (int yyi) -#else -static int -YYID (yyi) - int yyi; -#endif -{ - return yyi; -} -#endif - -#if ! defined yyoverflow || YYERROR_VERBOSE - -/* The parser invokes alloca or malloc; define the necessary symbols. */ - -# ifdef YYSTACK_USE_ALLOCA -# if YYSTACK_USE_ALLOCA -# ifdef __GNUC__ -# define YYSTACK_ALLOC __builtin_alloca -# elif defined __BUILTIN_VA_ARG_INCR -# include /* INFRINGES ON USER NAME SPACE */ -# elif defined _AIX -# define YYSTACK_ALLOC __alloca -# elif defined _MSC_VER -# include /* INFRINGES ON USER NAME SPACE */ -# define alloca _alloca -# else -# define YYSTACK_ALLOC alloca -# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -# include /* INFRINGES ON USER NAME SPACE */ - /* Use EXIT_SUCCESS as a witness for stdlib.h. */ -# ifndef EXIT_SUCCESS -# define EXIT_SUCCESS 0 -# endif -# endif -# endif -# endif -# endif - -# ifdef YYSTACK_ALLOC - /* Pacify GCC's `empty if-body' warning. */ -# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) -# ifndef YYSTACK_ALLOC_MAXIMUM - /* The OS might guarantee only one guard page at the bottom of the stack, - and a page size can be as small as 4096 bytes. So we cannot safely - invoke alloca (N) if N exceeds 4096. Use a slightly smaller number - to allow for a few compiler-allocated temporary stack slots. */ -# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ -# endif -# else -# define YYSTACK_ALLOC YYMALLOC -# define YYSTACK_FREE YYFREE -# ifndef YYSTACK_ALLOC_MAXIMUM -# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM -# endif -# if (defined __cplusplus && ! defined EXIT_SUCCESS \ - && ! ((defined YYMALLOC || defined malloc) \ - && (defined YYFREE || defined free))) -# include /* INFRINGES ON USER NAME SPACE */ -# ifndef EXIT_SUCCESS -# define EXIT_SUCCESS 0 -# endif -# endif -# ifndef YYMALLOC -# define YYMALLOC malloc -# if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ -# endif -# endif -# ifndef YYFREE -# define YYFREE free -# if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -void free (void *); /* INFRINGES ON USER NAME SPACE */ -# endif -# endif -# endif -#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ - - -#if (! defined yyoverflow \ - && (! defined __cplusplus \ - || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) - -/* A type that is properly aligned for any stack member. */ -union yyalloc -{ - yytype_int16 yyss_alloc; - YYSTYPE yyvs_alloc; -}; - -/* The size of the maximum gap between one aligned stack and the next. */ -# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) - -/* The size of an array large to enough to hold all stacks, each with - N elements. */ -# define YYSTACK_BYTES(N) \ - ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ - + YYSTACK_GAP_MAXIMUM) - -# define YYCOPY_NEEDED 1 - -/* Relocate STACK from its old location to the new one. The - local variables YYSIZE and YYSTACKSIZE give the old and new number of - elements in the stack, and YYPTR gives the new location of the - stack. Advance YYPTR to a properly aligned location for the next - stack. */ -# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ - do \ - { \ - YYSIZE_T yynewbytes; \ - YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ - Stack = &yyptr->Stack_alloc; \ - yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ - yyptr += yynewbytes / sizeof (*yyptr); \ - } \ - while (YYID (0)) - -#endif - -#if defined YYCOPY_NEEDED && YYCOPY_NEEDED -/* Copy COUNT objects from SRC to DST. The source and destination do - not overlap. */ -# ifndef YYCOPY -# if defined __GNUC__ && 1 < __GNUC__ -# define YYCOPY(Dst, Src, Count) \ - __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src))) -# else -# define YYCOPY(Dst, Src, Count) \ - do \ - { \ - YYSIZE_T yyi; \ - for (yyi = 0; yyi < (Count); yyi++) \ - (Dst)[yyi] = (Src)[yyi]; \ - } \ - while (YYID (0)) -# endif -# endif -#endif /* !YYCOPY_NEEDED */ - -/* YYFINAL -- State number of the termination state. */ -#define YYFINAL 11 -/* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 298 - -/* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 40 -/* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 50 -/* YYNRULES -- Number of rules. */ -#define YYNRULES 122 -/* YYNRULES -- Number of states. */ -#define YYNSTATES 199 - -/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ -#define YYUNDEFTOK 2 -#define YYMAXUTOK 294 - -#define YYTRANSLATE(YYX) \ - ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) - -/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ -static const yytype_uint8 yytranslate[] = -{ - 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, - 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, - 35, 36, 37, 38, 39 -}; - -#if YYDEBUG -/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in - YYRHS. */ -static const yytype_uint16 yyprhs[] = -{ - 0, 0, 3, 6, 8, 11, 13, 14, 17, 20, - 23, 26, 31, 36, 40, 42, 44, 46, 48, 50, - 52, 54, 56, 58, 60, 62, 64, 66, 68, 72, - 75, 79, 82, 86, 89, 90, 93, 96, 99, 102, - 105, 108, 112, 117, 122, 127, 133, 137, 138, 142, - 143, 146, 150, 153, 155, 159, 160, 163, 166, 169, - 172, 175, 180, 184, 187, 192, 193, 196, 200, 202, - 206, 207, 210, 213, 216, 220, 224, 228, 230, 234, - 235, 238, 241, 244, 248, 252, 255, 258, 261, 262, - 265, 268, 271, 276, 277, 280, 283, 286, 287, 290, - 292, 294, 297, 300, 303, 305, 308, 309, 312, 314, - 318, 322, 326, 330, 334, 338, 342, 345, 349, 353, - 355, 357, 358 -}; - -/* YYRHS -- A `-1'-separated list of the rules' RHS. */ -static const yytype_int8 yyrhs[] = -{ - 41, 0, -1, 85, 42, -1, 42, -1, 67, 43, - -1, 43, -1, -1, 43, 45, -1, 43, 59, -1, - 43, 71, -1, 43, 84, -1, 43, 26, 1, 35, - -1, 43, 44, 1, 35, -1, 43, 1, 35, -1, - 16, -1, 18, -1, 19, -1, 21, -1, 17, -1, - 22, -1, 20, -1, 23, -1, 35, -1, 65, -1, - 75, -1, 48, -1, 50, -1, 73, -1, 26, 1, - 35, -1, 1, 35, -1, 10, 26, 35, -1, 47, - 51, -1, 11, 26, 35, -1, 49, 51, -1, -1, - 51, 52, -1, 51, 53, -1, 51, 79, -1, 51, - 77, -1, 51, 46, -1, 51, 35, -1, 19, 82, - 35, -1, 18, 83, 86, 35, -1, 20, 87, 86, - 35, -1, 21, 26, 86, 35, -1, 22, 88, 88, - 86, 35, -1, 24, 54, 35, -1, -1, 54, 26, - 55, -1, -1, 38, 83, -1, 7, 89, 35, -1, - 56, 60, -1, 84, -1, 57, 62, 58, -1, -1, - 60, 61, -1, 60, 79, -1, 60, 77, -1, 60, - 35, -1, 60, 46, -1, 18, 83, 86, 35, -1, - 19, 82, 35, -1, 17, 35, -1, 20, 26, 86, - 35, -1, -1, 62, 45, -1, 14, 87, 85, -1, - 84, -1, 63, 66, 64, -1, -1, 66, 45, -1, - 66, 71, -1, 66, 59, -1, 3, 83, 85, -1, - 4, 83, 35, -1, 68, 80, 78, -1, 84, -1, - 69, 72, 70, -1, -1, 72, 45, -1, 72, 71, - -1, 72, 59, -1, 6, 83, 35, -1, 9, 83, - 35, -1, 74, 78, -1, 12, 35, -1, 76, 13, - -1, -1, 78, 79, -1, 78, 35, -1, 78, 46, - -1, 16, 25, 87, 35, -1, -1, 80, 81, -1, - 80, 35, -1, 23, 86, -1, -1, 83, 86, -1, - 26, -1, 27, -1, 5, 35, -1, 8, 35, -1, - 15, 35, -1, 35, -1, 85, 35, -1, -1, 14, - 87, -1, 88, -1, 88, 29, 88, -1, 88, 30, - 88, -1, 88, 31, 88, -1, 88, 32, 88, -1, - 88, 38, 88, -1, 88, 28, 88, -1, 34, 87, - 33, -1, 39, 87, -1, 87, 36, 87, -1, 87, - 37, 87, -1, 26, -1, 27, -1, -1, 26, -1 -}; - -/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ -static const yytype_uint16 yyrline[] = -{ - 0, 108, 108, 108, 110, 110, 112, 114, 115, 116, - 117, 118, 119, 123, 127, 127, 127, 127, 127, 127, - 127, 127, 131, 132, 133, 134, 135, 136, 140, 141, - 147, 155, 161, 169, 179, 181, 182, 183, 184, 185, - 186, 189, 197, 203, 213, 219, 225, 228, 230, 241, - 242, 247, 256, 261, 269, 272, 274, 275, 276, 277, - 278, 281, 287, 298, 304, 314, 316, 321, 329, 337, - 340, 342, 343, 344, 349, 356, 363, 368, 376, 379, - 381, 382, 383, 386, 394, 401, 408, 414, 421, 423, - 424, 425, 428, 436, 438, 439, 442, 449, 451, 456, - 457, 460, 461, 462, 466, 467, 470, 471, 474, 475, - 476, 477, 478, 479, 480, 481, 482, 483, 484, 487, - 488, 491, 492 -}; -#endif - -#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE -/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. - First, the terminals, then, starting at YYNTOKENS, nonterminals. */ -static const char *const yytname[] = -{ - "$end", "error", "$undefined", "T_MAINMENU", "T_MENU", "T_ENDMENU", - "T_SOURCE", "T_CHOICE", "T_ENDCHOICE", "T_COMMENT", "T_CONFIG", - "T_MENUCONFIG", "T_HELP", "T_HELPTEXT", "T_IF", "T_ENDIF", "T_DEPENDS", - "T_OPTIONAL", "T_PROMPT", "T_TYPE", "T_DEFAULT", "T_SELECT", "T_RANGE", - "T_VISIBLE", "T_OPTION", "T_ON", "T_WORD", "T_WORD_QUOTE", "T_UNEQUAL", - "T_LESS", "T_LESS_EQUAL", "T_GREATER", "T_GREATER_EQUAL", - "T_CLOSE_PAREN", "T_OPEN_PAREN", "T_EOL", "T_OR", "T_AND", "T_EQUAL", - "T_NOT", "$accept", "input", "start", "stmt_list", "option_name", - "common_stmt", "option_error", "config_entry_start", "config_stmt", - "menuconfig_entry_start", "menuconfig_stmt", "config_option_list", - "config_option", "symbol_option", "symbol_option_list", - "symbol_option_arg", "choice", "choice_entry", "choice_end", - "choice_stmt", "choice_option_list", "choice_option", "choice_block", - "if_entry", "if_end", "if_stmt", "if_block", "mainmenu_stmt", "menu", - "menu_entry", "menu_end", "menu_stmt", "menu_block", "source_stmt", - "comment", "comment_stmt", "help_start", "help", "depends_list", - "depends", "visibility_list", "visible", "prompt_stmt_opt", "prompt", - "end", "nl", "if_expr", "expr", "symbol", "word_opt", YY_NULL -}; -#endif - -# ifdef YYPRINT -/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to - token YYLEX-NUM. */ -static const yytype_uint16 yytoknum[] = -{ - 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, - 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, - 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, - 285, 286, 287, 288, 289, 290, 291, 292, 293, 294 -}; -# endif - -/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ -static const yytype_uint8 yyr1[] = -{ - 0, 40, 41, 41, 42, 42, 43, 43, 43, 43, - 43, 43, 43, 43, 44, 44, 44, 44, 44, 44, - 44, 44, 45, 45, 45, 45, 45, 45, 46, 46, - 47, 48, 49, 50, 51, 51, 51, 51, 51, 51, - 51, 52, 52, 52, 52, 52, 53, 54, 54, 55, - 55, 56, 57, 58, 59, 60, 60, 60, 60, 60, - 60, 61, 61, 61, 61, 62, 62, 63, 64, 65, - 66, 66, 66, 66, 67, 68, 69, 70, 71, 72, - 72, 72, 72, 73, 74, 75, 76, 77, 78, 78, - 78, 78, 79, 80, 80, 80, 81, 82, 82, 83, - 83, 84, 84, 84, 85, 85, 86, 86, 87, 87, - 87, 87, 87, 87, 87, 87, 87, 87, 87, 88, - 88, 89, 89 -}; - -/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ -static const yytype_uint8 yyr2[] = -{ - 0, 2, 2, 1, 2, 1, 0, 2, 2, 2, - 2, 4, 4, 3, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 3, 2, - 3, 2, 3, 2, 0, 2, 2, 2, 2, 2, - 2, 3, 4, 4, 4, 5, 3, 0, 3, 0, - 2, 3, 2, 1, 3, 0, 2, 2, 2, 2, - 2, 4, 3, 2, 4, 0, 2, 3, 1, 3, - 0, 2, 2, 2, 3, 3, 3, 1, 3, 0, - 2, 2, 2, 3, 3, 2, 2, 2, 0, 2, - 2, 2, 4, 0, 2, 2, 2, 0, 2, 1, - 1, 2, 2, 2, 1, 2, 0, 2, 1, 3, - 3, 3, 3, 3, 3, 3, 2, 3, 3, 1, - 1, 0, 1 -}; - -/* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM. - Performed when YYTABLE doesn't specify something else to do. Zero - means the default is an error. */ -static const yytype_uint8 yydefact[] = -{ - 6, 0, 104, 0, 3, 0, 6, 6, 99, 100, - 0, 1, 0, 0, 0, 0, 121, 0, 0, 0, - 0, 0, 0, 14, 18, 15, 16, 20, 17, 19, - 21, 0, 22, 0, 7, 34, 25, 34, 26, 55, - 65, 8, 70, 23, 93, 79, 9, 27, 88, 24, - 10, 0, 105, 2, 74, 13, 0, 101, 0, 122, - 0, 102, 0, 0, 0, 119, 120, 0, 0, 0, - 108, 103, 0, 0, 0, 0, 0, 0, 0, 88, - 0, 0, 75, 83, 51, 84, 30, 32, 0, 116, - 0, 0, 67, 0, 0, 0, 0, 0, 0, 11, - 12, 0, 0, 0, 0, 97, 0, 0, 0, 47, - 0, 40, 39, 35, 36, 0, 38, 37, 0, 0, - 97, 0, 59, 60, 56, 58, 57, 66, 54, 53, - 71, 73, 69, 72, 68, 106, 95, 0, 94, 80, - 82, 78, 81, 77, 90, 91, 89, 115, 117, 118, - 114, 109, 110, 111, 112, 113, 29, 86, 0, 106, - 0, 106, 106, 106, 0, 0, 0, 87, 63, 106, - 0, 106, 0, 96, 0, 0, 41, 98, 0, 0, - 106, 49, 46, 28, 0, 62, 0, 107, 92, 42, - 43, 44, 0, 0, 48, 61, 64, 45, 50 -}; - -/* YYDEFGOTO[NTERM-NUM]. */ -static const yytype_int16 yydefgoto[] = -{ - -1, 3, 4, 5, 33, 34, 112, 35, 36, 37, - 38, 74, 113, 114, 165, 194, 39, 40, 128, 41, - 76, 124, 77, 42, 132, 43, 78, 6, 44, 45, - 141, 46, 80, 47, 48, 49, 115, 116, 81, 117, - 79, 138, 160, 161, 50, 7, 173, 69, 70, 60 -}; - -/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing - STATE-NUM. */ -#define YYPACT_NINF -91 -static const yytype_int16 yypact[] = -{ - 19, 37, -91, 13, -91, 79, -91, 20, -91, -91, - -16, -91, 21, 37, 25, 37, 41, 36, 37, 78, - 83, 31, 56, -91, -91, -91, -91, -91, -91, -91, - -91, 116, -91, 127, -91, -91, -91, -91, -91, -91, - -91, -91, -91, -91, -91, -91, -91, -91, -91, -91, - -91, 147, -91, -91, 105, -91, 109, -91, 111, -91, - 114, -91, 136, 137, 142, -91, -91, 31, 31, 76, - 254, -91, 143, 146, 27, 115, 207, 258, 243, -14, - 243, 179, -91, -91, -91, -91, -91, -91, -7, -91, - 31, 31, 105, 51, 51, 51, 51, 51, 51, -91, - -91, 156, 168, 181, 37, 37, 31, 178, 51, -91, - 206, -91, -91, -91, -91, 196, -91, -91, 175, 37, - 37, 185, -91, -91, -91, -91, -91, -91, -91, -91, - -91, -91, -91, -91, -91, 214, -91, 230, -91, -91, - -91, -91, -91, -91, -91, -91, -91, -91, 183, -91, - -91, -91, -91, -91, -91, -91, -91, -91, 31, 214, - 194, 214, 45, 214, 51, 26, 195, -91, -91, 214, - 197, 214, 31, -91, 139, 208, -91, -91, 220, 224, - 214, 222, -91, -91, 226, -91, 227, 123, -91, -91, - -91, -91, 235, 37, -91, -91, -91, -91, -91 -}; - -/* YYPGOTO[NTERM-NUM]. */ -static const yytype_int16 yypgoto[] = -{ - -91, -91, 264, 268, -91, 30, -65, -91, -91, -91, - -91, 238, -91, -91, -91, -91, -91, -91, -91, -12, - -91, -91, -91, -91, -91, -91, -91, -91, -91, -91, - -91, -5, -91, -91, -91, -91, -91, 200, 209, -61, - -91, -91, 170, -1, 65, 0, 118, -66, -90, -91 -}; - -/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If - positive, shift that token. If negative, reduce the rule which - number is the opposite. If YYTABLE_NINF, syntax error. */ -#define YYTABLE_NINF -86 -static const yytype_int16 yytable[] = -{ - 10, 88, 89, 150, 151, 152, 153, 154, 155, 135, - 54, 123, 56, 11, 58, 126, 145, 62, 164, 2, - 146, 136, 1, 1, 148, 149, 147, -31, 101, 90, - 91, -31, -31, -31, -31, -31, -31, -31, -31, 102, - 162, -31, -31, 103, -31, 104, 105, 106, 107, 108, - -31, 109, 181, 110, 2, 52, 55, 65, 66, 172, - 57, 182, 111, 8, 9, 67, 131, 59, 140, 92, - 68, 61, 145, 133, 180, 142, 146, 65, 66, -5, - 12, 90, 91, 13, 14, 15, 16, 17, 18, 19, - 20, 71, 174, 21, 22, 23, 24, 25, 26, 27, - 28, 29, 30, 159, 63, 31, 187, 127, 130, 64, - 139, 2, 90, 91, 32, -33, 101, 72, 169, -33, - -33, -33, -33, -33, -33, -33, -33, 102, 73, -33, - -33, 103, -33, 104, 105, 106, 107, 108, -33, 109, - 52, 110, 129, 134, 82, 143, 83, -4, 12, 84, - 111, 13, 14, 15, 16, 17, 18, 19, 20, 90, - 91, 21, 22, 23, 24, 25, 26, 27, 28, 29, - 30, 85, 86, 31, 188, 90, 91, 87, 99, -85, - 101, 100, 32, -85, -85, -85, -85, -85, -85, -85, - -85, 156, 198, -85, -85, 103, -85, -85, -85, -85, - -85, -85, -85, 157, 163, 110, 158, 166, 101, 167, - 168, 171, -52, -52, 144, -52, -52, -52, -52, 102, - 91, -52, -52, 103, 118, 119, 120, 121, 172, 176, - 183, 101, 185, 110, -76, -76, -76, -76, -76, -76, - -76, -76, 122, 189, -76, -76, 103, 13, 14, 15, - 16, 17, 18, 19, 20, 190, 110, 21, 22, 191, - 193, 195, 196, 14, 15, 144, 17, 18, 19, 20, - 197, 53, 21, 22, 51, 75, 125, 175, 32, 177, - 178, 179, 93, 94, 95, 96, 97, 184, 137, 186, - 170, 0, 98, 32, 0, 0, 0, 0, 192 -}; - -#define yypact_value_is_default(yystate) \ - ((yystate) == (-91)) - -#define yytable_value_is_error(yytable_value) \ - YYID (0) - -static const yytype_int16 yycheck[] = -{ - 1, 67, 68, 93, 94, 95, 96, 97, 98, 23, - 10, 76, 13, 0, 15, 76, 81, 18, 108, 35, - 81, 35, 3, 3, 90, 91, 33, 0, 1, 36, - 37, 4, 5, 6, 7, 8, 9, 10, 11, 12, - 106, 14, 15, 16, 17, 18, 19, 20, 21, 22, - 23, 24, 26, 26, 35, 35, 35, 26, 27, 14, - 35, 35, 35, 26, 27, 34, 78, 26, 80, 69, - 39, 35, 137, 78, 164, 80, 137, 26, 27, 0, - 1, 36, 37, 4, 5, 6, 7, 8, 9, 10, - 11, 35, 158, 14, 15, 16, 17, 18, 19, 20, - 21, 22, 23, 104, 26, 26, 172, 77, 78, 26, - 80, 35, 36, 37, 35, 0, 1, 1, 119, 4, - 5, 6, 7, 8, 9, 10, 11, 12, 1, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 35, 26, 77, 78, 35, 80, 35, 0, 1, 35, - 35, 4, 5, 6, 7, 8, 9, 10, 11, 36, - 37, 14, 15, 16, 17, 18, 19, 20, 21, 22, - 23, 35, 35, 26, 35, 36, 37, 35, 35, 0, - 1, 35, 35, 4, 5, 6, 7, 8, 9, 10, - 11, 35, 193, 14, 15, 16, 17, 18, 19, 20, - 21, 22, 23, 35, 26, 26, 25, 1, 1, 13, - 35, 26, 5, 6, 35, 8, 9, 10, 11, 12, - 37, 14, 15, 16, 17, 18, 19, 20, 14, 35, - 35, 1, 35, 26, 4, 5, 6, 7, 8, 9, - 10, 11, 35, 35, 14, 15, 16, 4, 5, 6, - 7, 8, 9, 10, 11, 35, 26, 14, 15, 35, - 38, 35, 35, 5, 6, 35, 8, 9, 10, 11, - 35, 7, 14, 15, 6, 37, 76, 159, 35, 161, - 162, 163, 28, 29, 30, 31, 32, 169, 79, 171, - 120, -1, 38, 35, -1, -1, -1, -1, 180 -}; - -/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing - symbol of state STATE-NUM. */ -static const yytype_uint8 yystos[] = -{ - 0, 3, 35, 41, 42, 43, 67, 85, 26, 27, - 83, 0, 1, 4, 5, 6, 7, 8, 9, 10, - 11, 14, 15, 16, 17, 18, 19, 20, 21, 22, - 23, 26, 35, 44, 45, 47, 48, 49, 50, 56, - 57, 59, 63, 65, 68, 69, 71, 73, 74, 75, - 84, 43, 35, 42, 85, 35, 83, 35, 83, 26, - 89, 35, 83, 26, 26, 26, 27, 34, 39, 87, - 88, 35, 1, 1, 51, 51, 60, 62, 66, 80, - 72, 78, 35, 35, 35, 35, 35, 35, 87, 87, - 36, 37, 85, 28, 29, 30, 31, 32, 38, 35, - 35, 1, 12, 16, 18, 19, 20, 21, 22, 24, - 26, 35, 46, 52, 53, 76, 77, 79, 17, 18, - 19, 20, 35, 46, 61, 77, 79, 45, 58, 84, - 45, 59, 64, 71, 84, 23, 35, 78, 81, 45, - 59, 70, 71, 84, 35, 46, 79, 33, 87, 87, - 88, 88, 88, 88, 88, 88, 35, 35, 25, 83, - 82, 83, 87, 26, 88, 54, 1, 13, 35, 83, - 82, 26, 14, 86, 87, 86, 35, 86, 86, 86, - 88, 26, 35, 35, 86, 35, 86, 87, 35, 35, - 35, 35, 86, 38, 55, 35, 35, 35, 83 -}; - -#define yyerrok (yyerrstatus = 0) -#define yyclearin (yychar = YYEMPTY) -#define YYEMPTY (-2) -#define YYEOF 0 - -#define YYACCEPT goto yyacceptlab -#define YYABORT goto yyabortlab -#define YYERROR goto yyerrorlab - - -/* Like YYERROR except do call yyerror. This remains here temporarily - to ease the transition to the new meaning of YYERROR, for GCC. - Once GCC version 2 has supplanted version 1, this can go. However, - YYFAIL appears to be in use. Nevertheless, it is formally deprecated - in Bison 2.4.2's NEWS entry, where a plan to phase it out is - discussed. */ - -#define YYFAIL goto yyerrlab -#if defined YYFAIL - /* This is here to suppress warnings from the GCC cpp's - -Wunused-macros. Normally we don't worry about that warning, but - some users do, and we want to make it easy for users to remove - YYFAIL uses, which will produce warnings from Bison 2.5. */ -#endif - -#define YYRECOVERING() (!!yyerrstatus) - -#define YYBACKUP(Token, Value) \ -do \ - if (yychar == YYEMPTY) \ - { \ - yychar = (Token); \ - yylval = (Value); \ - YYPOPSTACK (yylen); \ - yystate = *yyssp; \ - goto yybackup; \ - } \ - else \ - { \ - yyerror (YY_("syntax error: cannot back up")); \ - YYERROR; \ - } \ -while (YYID (0)) - - -#define YYTERROR 1 -#define YYERRCODE 256 - - -/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. - If N is 0, then set CURRENT to the empty location which ends - the previous symbol: RHS[0] (always defined). */ - -#define YYRHSLOC(Rhs, K) ((Rhs)[K]) -#ifndef YYLLOC_DEFAULT -# define YYLLOC_DEFAULT(Current, Rhs, N) \ - do \ - if (YYID (N)) \ - { \ - (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ - (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ - (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ - (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ - } \ - else \ - { \ - (Current).first_line = (Current).last_line = \ - YYRHSLOC (Rhs, 0).last_line; \ - (Current).first_column = (Current).last_column = \ - YYRHSLOC (Rhs, 0).last_column; \ - } \ - while (YYID (0)) -#endif - - -/* This macro is provided for backward compatibility. */ - -#ifndef YY_LOCATION_PRINT -# define YY_LOCATION_PRINT(File, Loc) ((void) 0) -#endif - - -/* YYLEX -- calling `yylex' with the right arguments. */ - -#ifdef YYLEX_PARAM -# define YYLEX yylex (YYLEX_PARAM) -#else -# define YYLEX yylex () -#endif - -/* Enable debugging if requested. */ -#if YYDEBUG - -# ifndef YYFPRINTF -# include /* INFRINGES ON USER NAME SPACE */ -# define YYFPRINTF fprintf -# endif - -# define YYDPRINTF(Args) \ -do { \ - if (yydebug) \ - YYFPRINTF Args; \ -} while (YYID (0)) - -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ -do { \ - if (yydebug) \ - { \ - YYFPRINTF (stderr, "%s ", Title); \ - yy_symbol_print (stderr, \ - Type, Value); \ - YYFPRINTF (stderr, "\n"); \ - } \ -} while (YYID (0)) - - -/*--------------------------------. -| Print this symbol on YYOUTPUT. | -`--------------------------------*/ - -/*ARGSUSED*/ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static void -yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) -#else -static void -yy_symbol_value_print (yyoutput, yytype, yyvaluep) - FILE *yyoutput; - int yytype; - YYSTYPE const * const yyvaluep; -#endif -{ - FILE *yyo = yyoutput; - YYUSE (yyo); - if (!yyvaluep) - return; -# ifdef YYPRINT - if (yytype < YYNTOKENS) - YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); -# else - YYUSE (yyoutput); -# endif - switch (yytype) - { - default: - break; - } -} - - -/*--------------------------------. -| Print this symbol on YYOUTPUT. | -`--------------------------------*/ - -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static void -yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) -#else -static void -yy_symbol_print (yyoutput, yytype, yyvaluep) - FILE *yyoutput; - int yytype; - YYSTYPE const * const yyvaluep; -#endif -{ - if (yytype < YYNTOKENS) - YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); - else - YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); - - yy_symbol_value_print (yyoutput, yytype, yyvaluep); - YYFPRINTF (yyoutput, ")"); -} - -/*------------------------------------------------------------------. -| yy_stack_print -- Print the state stack from its BOTTOM up to its | -| TOP (included). | -`------------------------------------------------------------------*/ - -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static void -yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) -#else -static void -yy_stack_print (yybottom, yytop) - yytype_int16 *yybottom; - yytype_int16 *yytop; -#endif -{ - YYFPRINTF (stderr, "Stack now"); - for (; yybottom <= yytop; yybottom++) - { - int yybot = *yybottom; - YYFPRINTF (stderr, " %d", yybot); - } - YYFPRINTF (stderr, "\n"); -} - -# define YY_STACK_PRINT(Bottom, Top) \ -do { \ - if (yydebug) \ - yy_stack_print ((Bottom), (Top)); \ -} while (YYID (0)) - - -/*------------------------------------------------. -| Report that the YYRULE is going to be reduced. | -`------------------------------------------------*/ - -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static void -yy_reduce_print (YYSTYPE *yyvsp, int yyrule) -#else -static void -yy_reduce_print (yyvsp, yyrule) - YYSTYPE *yyvsp; - int yyrule; -#endif -{ - int yynrhs = yyr2[yyrule]; - int yyi; - unsigned long int yylno = yyrline[yyrule]; - YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", - yyrule - 1, yylno); - /* The symbols being reduced. */ - for (yyi = 0; yyi < yynrhs; yyi++) - { - YYFPRINTF (stderr, " $%d = ", yyi + 1); - yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], - &(yyvsp[(yyi + 1) - (yynrhs)]) - ); - YYFPRINTF (stderr, "\n"); - } -} - -# define YY_REDUCE_PRINT(Rule) \ -do { \ - if (yydebug) \ - yy_reduce_print (yyvsp, Rule); \ -} while (YYID (0)) - -/* Nonzero means print parse trace. It is left uninitialized so that - multiple parsers can coexist. */ -int yydebug; -#else /* !YYDEBUG */ -# define YYDPRINTF(Args) -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) -# define YY_STACK_PRINT(Bottom, Top) -# define YY_REDUCE_PRINT(Rule) -#endif /* !YYDEBUG */ - - -/* YYINITDEPTH -- initial size of the parser's stacks. */ -#ifndef YYINITDEPTH -# define YYINITDEPTH 200 -#endif - -/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only - if the built-in stack extension method is used). - - Do not make this value too large; the results are undefined if - YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) - evaluated with infinite-precision integer arithmetic. */ - -#ifndef YYMAXDEPTH -# define YYMAXDEPTH 10000 -#endif - - -#if YYERROR_VERBOSE - -# ifndef yystrlen -# if defined __GLIBC__ && defined _STRING_H -# define yystrlen strlen -# else -/* Return the length of YYSTR. */ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static YYSIZE_T -yystrlen (const char *yystr) -#else -static YYSIZE_T -yystrlen (yystr) - const char *yystr; -#endif -{ - YYSIZE_T yylen; - for (yylen = 0; yystr[yylen]; yylen++) - continue; - return yylen; -} -# endif -# endif - -# ifndef yystpcpy -# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE -# define yystpcpy stpcpy -# else -/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in - YYDEST. */ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static char * -yystpcpy (char *yydest, const char *yysrc) -#else -static char * -yystpcpy (yydest, yysrc) - char *yydest; - const char *yysrc; -#endif -{ - char *yyd = yydest; - const char *yys = yysrc; - - while ((*yyd++ = *yys++) != '\0') - continue; - - return yyd - 1; -} -# endif -# endif - -# ifndef yytnamerr -/* Copy to YYRES the contents of YYSTR after stripping away unnecessary - quotes and backslashes, so that it's suitable for yyerror. The - heuristic is that double-quoting is unnecessary unless the string - contains an apostrophe, a comma, or backslash (other than - backslash-backslash). YYSTR is taken from yytname. If YYRES is - null, do not copy; instead, return the length of what the result - would have been. */ -static YYSIZE_T -yytnamerr (char *yyres, const char *yystr) -{ - if (*yystr == '"') - { - YYSIZE_T yyn = 0; - char const *yyp = yystr; - - for (;;) - switch (*++yyp) - { - case '\'': - case ',': - goto do_not_strip_quotes; - - case '\\': - if (*++yyp != '\\') - goto do_not_strip_quotes; - /* Fall through. */ - default: - if (yyres) - yyres[yyn] = *yyp; - yyn++; - break; - - case '"': - if (yyres) - yyres[yyn] = '\0'; - return yyn; - } - do_not_strip_quotes: ; - } - - if (! yyres) - return yystrlen (yystr); - - return yystpcpy (yyres, yystr) - yyres; -} -# endif - -/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message - about the unexpected token YYTOKEN for the state stack whose top is - YYSSP. - - Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is - not large enough to hold the message. In that case, also set - *YYMSG_ALLOC to the required number of bytes. Return 2 if the - required number of bytes is too large to store. */ -static int -yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, - yytype_int16 *yyssp, int yytoken) -{ - YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]); - YYSIZE_T yysize = yysize0; - YYSIZE_T yysize1; - enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; - /* Internationalized format string. */ - const char *yyformat = YY_NULL; - /* Arguments of yyformat. */ - char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; - /* Number of reported tokens (one for the "unexpected", one per - "expected"). */ - int yycount = 0; - - /* There are many possibilities here to consider: - - Assume YYFAIL is not used. It's too flawed to consider. See - - for details. YYERROR is fine as it does not invoke this - function. - - If this state is a consistent state with a default action, then - the only way this function was invoked is if the default action - is an error action. In that case, don't check for expected - tokens because there are none. - - The only way there can be no lookahead present (in yychar) is if - this state is a consistent state with a default action. Thus, - detecting the absence of a lookahead is sufficient to determine - that there is no unexpected or expected token to report. In that - case, just report a simple "syntax error". - - Don't assume there isn't a lookahead just because this state is a - consistent state with a default action. There might have been a - previous inconsistent state, consistent state with a non-default - action, or user semantic action that manipulated yychar. - - Of course, the expected token list depends on states to have - correct lookahead information, and it depends on the parser not - to perform extra reductions after fetching a lookahead from the - scanner and before detecting a syntax error. Thus, state merging - (from LALR or IELR) and default reductions corrupt the expected - token list. However, the list is correct for canonical LR with - one exception: it will still contain any token that will not be - accepted due to an error action in a later state. - */ - if (yytoken != YYEMPTY) - { - int yyn = yypact[*yyssp]; - yyarg[yycount++] = yytname[yytoken]; - if (!yypact_value_is_default (yyn)) - { - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. In other words, skip the first -YYN actions for - this state because they are default actions. */ - int yyxbegin = yyn < 0 ? -yyn : 0; - /* Stay within bounds of both yycheck and yytname. */ - int yychecklim = YYLAST - yyn + 1; - int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; - int yyx; - - for (yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR - && !yytable_value_is_error (yytable[yyx + yyn])) - { - if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) - { - yycount = 1; - yysize = yysize0; - break; - } - yyarg[yycount++] = yytname[yyx]; - yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]); - if (! (yysize <= yysize1 - && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) - return 2; - yysize = yysize1; - } - } - } - - switch (yycount) - { -# define YYCASE_(N, S) \ - case N: \ - yyformat = S; \ - break - YYCASE_(0, YY_("syntax error")); - YYCASE_(1, YY_("syntax error, unexpected %s")); - YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); - YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); - YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); - YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); -# undef YYCASE_ - } - - yysize1 = yysize + yystrlen (yyformat); - if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) - return 2; - yysize = yysize1; - - if (*yymsg_alloc < yysize) - { - *yymsg_alloc = 2 * yysize; - if (! (yysize <= *yymsg_alloc - && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) - *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM; - return 1; - } - - /* Avoid sprintf, as that infringes on the user's name space. - Don't have undefined behavior even if the translation - produced a string with the wrong number of "%s"s. */ - { - char *yyp = *yymsg; - int yyi = 0; - while ((*yyp = *yyformat) != '\0') - if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) - { - yyp += yytnamerr (yyp, yyarg[yyi++]); - yyformat += 2; - } - else - { - yyp++; - yyformat++; - } - } - return 0; -} -#endif /* YYERROR_VERBOSE */ - -/*-----------------------------------------------. -| Release the memory associated to this symbol. | -`-----------------------------------------------*/ - -/*ARGSUSED*/ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static void -yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) -#else -static void -yydestruct (yymsg, yytype, yyvaluep) - const char *yymsg; - int yytype; - YYSTYPE *yyvaluep; -#endif -{ - YYUSE (yyvaluep); - - if (!yymsg) - yymsg = "Deleting"; - YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); - - switch (yytype) - { - case 57: /* "choice_entry" */ - - { - fprintf(stderr, "%s:%d: missing end statement for this entry\n", - (yyvaluep->menu)->file->name, (yyvaluep->menu)->lineno); - if (current_menu == (yyvaluep->menu)) - menu_end_menu(); -}; - - break; - case 63: /* "if_entry" */ - - { - fprintf(stderr, "%s:%d: missing end statement for this entry\n", - (yyvaluep->menu)->file->name, (yyvaluep->menu)->lineno); - if (current_menu == (yyvaluep->menu)) - menu_end_menu(); -}; - - break; - case 69: /* "menu_entry" */ - - { - fprintf(stderr, "%s:%d: missing end statement for this entry\n", - (yyvaluep->menu)->file->name, (yyvaluep->menu)->lineno); - if (current_menu == (yyvaluep->menu)) - menu_end_menu(); -}; - - break; - - default: - break; - } -} - - -/* Prevent warnings from -Wmissing-prototypes. */ -#ifdef YYPARSE_PARAM -#if defined __STDC__ || defined __cplusplus -int yyparse (void *YYPARSE_PARAM); -#else -int yyparse (); -#endif -#else /* ! YYPARSE_PARAM */ -#if defined __STDC__ || defined __cplusplus -int yyparse (void); -#else -int yyparse (); -#endif -#endif /* ! YYPARSE_PARAM */ - - -/* The lookahead symbol. */ -int yychar; - -/* The semantic value of the lookahead symbol. */ -YYSTYPE yylval; - -/* Number of syntax errors so far. */ -int yynerrs; - - -/*----------. -| yyparse. | -`----------*/ - -#ifdef YYPARSE_PARAM -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -int -yyparse (void *YYPARSE_PARAM) -#else -int -yyparse (YYPARSE_PARAM) - void *YYPARSE_PARAM; -#endif -#else /* ! YYPARSE_PARAM */ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -int -yyparse (void) -#else -int -yyparse () - -#endif -#endif -{ - int yystate; - /* Number of tokens to shift before error messages enabled. */ - int yyerrstatus; - - /* The stacks and their tools: - `yyss': related to states. - `yyvs': related to semantic values. - - Refer to the stacks through separate pointers, to allow yyoverflow - to reallocate them elsewhere. */ - - /* The state stack. */ - yytype_int16 yyssa[YYINITDEPTH]; - yytype_int16 *yyss; - yytype_int16 *yyssp; - - /* The semantic value stack. */ - YYSTYPE yyvsa[YYINITDEPTH]; - YYSTYPE *yyvs; - YYSTYPE *yyvsp; - - YYSIZE_T yystacksize; - - int yyn; - int yyresult; - /* Lookahead token as an internal (translated) token number. */ - int yytoken; - /* The variables used to return semantic value and location from the - action routines. */ - YYSTYPE yyval; - -#if YYERROR_VERBOSE - /* Buffer for error messages, and its allocated size. */ - char yymsgbuf[128]; - char *yymsg = yymsgbuf; - YYSIZE_T yymsg_alloc = sizeof yymsgbuf; -#endif - -#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) - - /* The number of symbols on the RHS of the reduced rule. - Keep to zero when no symbol should be popped. */ - int yylen = 0; - - yytoken = 0; - yyss = yyssa; - yyvs = yyvsa; - yystacksize = YYINITDEPTH; - - YYDPRINTF ((stderr, "Starting parse\n")); - - yystate = 0; - yyerrstatus = 0; - yynerrs = 0; - yychar = YYEMPTY; /* Cause a token to be read. */ - - /* Initialize stack pointers. - Waste one element of value and location stack - so that they stay on the same level as the state stack. - The wasted elements are never initialized. */ - yyssp = yyss; - yyvsp = yyvs; - - goto yysetstate; - -/*------------------------------------------------------------. -| yynewstate -- Push a new state, which is found in yystate. | -`------------------------------------------------------------*/ - yynewstate: - /* In all cases, when you get here, the value and location stacks - have just been pushed. So pushing a state here evens the stacks. */ - yyssp++; - - yysetstate: - *yyssp = yystate; - - if (yyss + yystacksize - 1 <= yyssp) - { - /* Get the current used size of the three stacks, in elements. */ - YYSIZE_T yysize = yyssp - yyss + 1; - -#ifdef yyoverflow - { - /* Give user a chance to reallocate the stack. Use copies of - these so that the &'s don't force the real ones into - memory. */ - YYSTYPE *yyvs1 = yyvs; - yytype_int16 *yyss1 = yyss; - - /* Each stack pointer address is followed by the size of the - data in use in that stack, in bytes. This used to be a - conditional around just the two extra args, but that might - be undefined if yyoverflow is a macro. */ - yyoverflow (YY_("memory exhausted"), - &yyss1, yysize * sizeof (*yyssp), - &yyvs1, yysize * sizeof (*yyvsp), - &yystacksize); - - yyss = yyss1; - yyvs = yyvs1; - } -#else /* no yyoverflow */ -# ifndef YYSTACK_RELOCATE - goto yyexhaustedlab; -# else - /* Extend the stack our own way. */ - if (YYMAXDEPTH <= yystacksize) - goto yyexhaustedlab; - yystacksize *= 2; - if (YYMAXDEPTH < yystacksize) - yystacksize = YYMAXDEPTH; - - { - yytype_int16 *yyss1 = yyss; - union yyalloc *yyptr = - (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); - if (! yyptr) - goto yyexhaustedlab; - YYSTACK_RELOCATE (yyss_alloc, yyss); - YYSTACK_RELOCATE (yyvs_alloc, yyvs); -# undef YYSTACK_RELOCATE - if (yyss1 != yyssa) - YYSTACK_FREE (yyss1); - } -# endif -#endif /* no yyoverflow */ - - yyssp = yyss + yysize - 1; - yyvsp = yyvs + yysize - 1; - - YYDPRINTF ((stderr, "Stack size increased to %lu\n", - (unsigned long int) yystacksize)); - - if (yyss + yystacksize - 1 <= yyssp) - YYABORT; - } - - YYDPRINTF ((stderr, "Entering state %d\n", yystate)); - - if (yystate == YYFINAL) - YYACCEPT; - - goto yybackup; - -/*-----------. -| yybackup. | -`-----------*/ -yybackup: - - /* Do appropriate processing given the current state. Read a - lookahead token if we need one and don't already have one. */ - - /* First try to decide what to do without reference to lookahead token. */ - yyn = yypact[yystate]; - if (yypact_value_is_default (yyn)) - goto yydefault; - - /* Not known => get a lookahead token if don't already have one. */ - - /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ - if (yychar == YYEMPTY) - { - YYDPRINTF ((stderr, "Reading a token: ")); - yychar = YYLEX; - } - - if (yychar <= YYEOF) - { - yychar = yytoken = YYEOF; - YYDPRINTF ((stderr, "Now at end of input.\n")); - } - else - { - yytoken = YYTRANSLATE (yychar); - YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); - } - - /* If the proper action on seeing token YYTOKEN is to reduce or to - detect an error, take that action. */ - yyn += yytoken; - if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) - goto yydefault; - yyn = yytable[yyn]; - if (yyn <= 0) - { - if (yytable_value_is_error (yyn)) - goto yyerrlab; - yyn = -yyn; - goto yyreduce; - } - - /* Count tokens shifted since error; after three, turn off error - status. */ - if (yyerrstatus) - yyerrstatus--; - - /* Shift the lookahead token. */ - YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); - - /* Discard the shifted token. */ - yychar = YYEMPTY; - - yystate = yyn; - *++yyvsp = yylval; - - goto yynewstate; - - -/*-----------------------------------------------------------. -| yydefault -- do the default action for the current state. | -`-----------------------------------------------------------*/ -yydefault: - yyn = yydefact[yystate]; - if (yyn == 0) - goto yyerrlab; - goto yyreduce; - - -/*-----------------------------. -| yyreduce -- Do a reduction. | -`-----------------------------*/ -yyreduce: - /* yyn is the number of a rule to reduce with. */ - yylen = yyr2[yyn]; - - /* If YYLEN is nonzero, implement the default value of the action: - `$$ = $1'. - - Otherwise, the following line sets YYVAL to garbage. - This behavior is undocumented and Bison - users should not rely upon it. Assigning to YYVAL - unconditionally makes the parser a bit smaller, and it avoids a - GCC warning that YYVAL may be used uninitialized. */ - yyval = yyvsp[1-yylen]; - - - YY_REDUCE_PRINT (yyn); - switch (yyn) - { - case 10: - - { zconf_error("unexpected end statement"); } - break; - - case 11: - - { zconf_error("unknown statement \"%s\"", (yyvsp[(2) - (4)].string)); } - break; - - case 12: - - { - zconf_error("unexpected option \"%s\"", kconf_id_strings + (yyvsp[(2) - (4)].id)->name); -} - break; - - case 13: - - { zconf_error("invalid statement"); } - break; - - case 28: - - { zconf_error("unknown option \"%s\"", (yyvsp[(1) - (3)].string)); } - break; - - case 29: - - { zconf_error("invalid option"); } - break; - - case 30: - - { - struct symbol *sym = sym_lookup((yyvsp[(2) - (3)].string), 0); - sym->flags |= SYMBOL_OPTIONAL; - menu_add_entry(sym); - printd(DEBUG_PARSE, "%s:%d:config %s\n", zconf_curname(), zconf_lineno(), (yyvsp[(2) - (3)].string)); -} - break; - - case 31: - - { - menu_end_entry(); - printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno()); -} - break; - - case 32: - - { - struct symbol *sym = sym_lookup((yyvsp[(2) - (3)].string), 0); - sym->flags |= SYMBOL_OPTIONAL; - menu_add_entry(sym); - printd(DEBUG_PARSE, "%s:%d:menuconfig %s\n", zconf_curname(), zconf_lineno(), (yyvsp[(2) - (3)].string)); -} - break; - - case 33: - - { - if (current_entry->prompt) - current_entry->prompt->type = P_MENU; - else - zconfprint("warning: menuconfig statement without prompt"); - menu_end_entry(); - printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno()); -} - break; - - case 41: - - { - menu_set_type((yyvsp[(1) - (3)].id)->stype); - printd(DEBUG_PARSE, "%s:%d:type(%u)\n", - zconf_curname(), zconf_lineno(), - (yyvsp[(1) - (3)].id)->stype); -} - break; - - case 42: - - { - menu_add_prompt(P_PROMPT, (yyvsp[(2) - (4)].string), (yyvsp[(3) - (4)].expr)); - printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno()); -} - break; - - case 43: - - { - menu_add_expr(P_DEFAULT, (yyvsp[(2) - (4)].expr), (yyvsp[(3) - (4)].expr)); - if ((yyvsp[(1) - (4)].id)->stype != S_UNKNOWN) - menu_set_type((yyvsp[(1) - (4)].id)->stype); - printd(DEBUG_PARSE, "%s:%d:default(%u)\n", - zconf_curname(), zconf_lineno(), - (yyvsp[(1) - (4)].id)->stype); -} - break; - - case 44: - - { - menu_add_symbol(P_SELECT, sym_lookup((yyvsp[(2) - (4)].string), 0), (yyvsp[(3) - (4)].expr)); - printd(DEBUG_PARSE, "%s:%d:select\n", zconf_curname(), zconf_lineno()); -} - break; - - case 45: - - { - menu_add_expr(P_RANGE, expr_alloc_comp(E_RANGE,(yyvsp[(2) - (5)].symbol), (yyvsp[(3) - (5)].symbol)), (yyvsp[(4) - (5)].expr)); - printd(DEBUG_PARSE, "%s:%d:range\n", zconf_curname(), zconf_lineno()); -} - break; - - case 48: - - { - const struct kconf_id *id = kconf_id_lookup((yyvsp[(2) - (3)].string), strlen((yyvsp[(2) - (3)].string))); - if (id && id->flags & TF_OPTION) - menu_add_option(id->token, (yyvsp[(3) - (3)].string)); - else - zconfprint("warning: ignoring unknown option %s", (yyvsp[(2) - (3)].string)); - free((yyvsp[(2) - (3)].string)); -} - break; - - case 49: - - { (yyval.string) = NULL; } - break; - - case 50: - - { (yyval.string) = (yyvsp[(2) - (2)].string); } - break; - - case 51: - - { - struct symbol *sym = sym_lookup((yyvsp[(2) - (3)].string), SYMBOL_CHOICE); - sym->flags |= SYMBOL_AUTO; - menu_add_entry(sym); - menu_add_expr(P_CHOICE, NULL, NULL); - printd(DEBUG_PARSE, "%s:%d:choice\n", zconf_curname(), zconf_lineno()); -} - break; - - case 52: - - { - (yyval.menu) = menu_add_menu(); -} - break; - - case 53: - - { - if (zconf_endtoken((yyvsp[(1) - (1)].id), T_CHOICE, T_ENDCHOICE)) { - menu_end_menu(); - printd(DEBUG_PARSE, "%s:%d:endchoice\n", zconf_curname(), zconf_lineno()); - } -} - break; - - case 61: - - { - menu_add_prompt(P_PROMPT, (yyvsp[(2) - (4)].string), (yyvsp[(3) - (4)].expr)); - printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno()); -} - break; - - case 62: - - { - if ((yyvsp[(1) - (3)].id)->stype == S_BOOLEAN || (yyvsp[(1) - (3)].id)->stype == S_TRISTATE) { - menu_set_type((yyvsp[(1) - (3)].id)->stype); - printd(DEBUG_PARSE, "%s:%d:type(%u)\n", - zconf_curname(), zconf_lineno(), - (yyvsp[(1) - (3)].id)->stype); - } else - YYERROR; -} - break; - - case 63: - - { - current_entry->sym->flags |= SYMBOL_OPTIONAL; - printd(DEBUG_PARSE, "%s:%d:optional\n", zconf_curname(), zconf_lineno()); -} - break; - - case 64: - - { - if ((yyvsp[(1) - (4)].id)->stype == S_UNKNOWN) { - menu_add_symbol(P_DEFAULT, sym_lookup((yyvsp[(2) - (4)].string), 0), (yyvsp[(3) - (4)].expr)); - printd(DEBUG_PARSE, "%s:%d:default\n", - zconf_curname(), zconf_lineno()); - } else - YYERROR; -} - break; - - case 67: - - { - printd(DEBUG_PARSE, "%s:%d:if\n", zconf_curname(), zconf_lineno()); - menu_add_entry(NULL); - menu_add_dep((yyvsp[(2) - (3)].expr)); - (yyval.menu) = menu_add_menu(); -} - break; - - case 68: - - { - if (zconf_endtoken((yyvsp[(1) - (1)].id), T_IF, T_ENDIF)) { - menu_end_menu(); - printd(DEBUG_PARSE, "%s:%d:endif\n", zconf_curname(), zconf_lineno()); - } -} - break; - - case 74: - - { - menu_add_prompt(P_MENU, (yyvsp[(2) - (3)].string), NULL); -} - break; - - case 75: - - { - menu_add_entry(NULL); - menu_add_prompt(P_MENU, (yyvsp[(2) - (3)].string), NULL); - printd(DEBUG_PARSE, "%s:%d:menu\n", zconf_curname(), zconf_lineno()); -} - break; - - case 76: - - { - (yyval.menu) = menu_add_menu(); -} - break; - - case 77: - - { - if (zconf_endtoken((yyvsp[(1) - (1)].id), T_MENU, T_ENDMENU)) { - menu_end_menu(); - printd(DEBUG_PARSE, "%s:%d:endmenu\n", zconf_curname(), zconf_lineno()); - } -} - break; - - case 83: - - { - printd(DEBUG_PARSE, "%s:%d:source %s\n", zconf_curname(), zconf_lineno(), (yyvsp[(2) - (3)].string)); - zconf_nextfile((yyvsp[(2) - (3)].string)); -} - break; - - case 84: - - { - menu_add_entry(NULL); - menu_add_prompt(P_COMMENT, (yyvsp[(2) - (3)].string), NULL); - printd(DEBUG_PARSE, "%s:%d:comment\n", zconf_curname(), zconf_lineno()); -} - break; - - case 85: - - { - menu_end_entry(); -} - break; - - case 86: - - { - printd(DEBUG_PARSE, "%s:%d:help\n", zconf_curname(), zconf_lineno()); - zconf_starthelp(); -} - break; - - case 87: - - { - current_entry->help = (yyvsp[(2) - (2)].string); -} - break; - - case 92: - - { - menu_add_dep((yyvsp[(3) - (4)].expr)); - printd(DEBUG_PARSE, "%s:%d:depends on\n", zconf_curname(), zconf_lineno()); -} - break; - - case 96: - - { - menu_add_visibility((yyvsp[(2) - (2)].expr)); -} - break; - - case 98: - - { - menu_add_prompt(P_PROMPT, (yyvsp[(1) - (2)].string), (yyvsp[(2) - (2)].expr)); -} - break; - - case 101: - - { (yyval.id) = (yyvsp[(1) - (2)].id); } - break; - - case 102: - - { (yyval.id) = (yyvsp[(1) - (2)].id); } - break; - - case 103: - - { (yyval.id) = (yyvsp[(1) - (2)].id); } - break; - - case 106: - - { (yyval.expr) = NULL; } - break; - - case 107: - - { (yyval.expr) = (yyvsp[(2) - (2)].expr); } - break; - - case 108: - - { (yyval.expr) = expr_alloc_symbol((yyvsp[(1) - (1)].symbol)); } - break; - - case 109: - - { (yyval.expr) = expr_alloc_comp(E_LTH, (yyvsp[(1) - (3)].symbol), (yyvsp[(3) - (3)].symbol)); } - break; - - case 110: - - { (yyval.expr) = expr_alloc_comp(E_LEQ, (yyvsp[(1) - (3)].symbol), (yyvsp[(3) - (3)].symbol)); } - break; - - case 111: - - { (yyval.expr) = expr_alloc_comp(E_GTH, (yyvsp[(1) - (3)].symbol), (yyvsp[(3) - (3)].symbol)); } - break; - - case 112: - - { (yyval.expr) = expr_alloc_comp(E_GEQ, (yyvsp[(1) - (3)].symbol), (yyvsp[(3) - (3)].symbol)); } - break; - - case 113: - - { (yyval.expr) = expr_alloc_comp(E_EQUAL, (yyvsp[(1) - (3)].symbol), (yyvsp[(3) - (3)].symbol)); } - break; - - case 114: - - { (yyval.expr) = expr_alloc_comp(E_UNEQUAL, (yyvsp[(1) - (3)].symbol), (yyvsp[(3) - (3)].symbol)); } - break; - - case 115: - - { (yyval.expr) = (yyvsp[(2) - (3)].expr); } - break; - - case 116: - - { (yyval.expr) = expr_alloc_one(E_NOT, (yyvsp[(2) - (2)].expr)); } - break; - - case 117: - - { (yyval.expr) = expr_alloc_two(E_OR, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); } - break; - - case 118: - - { (yyval.expr) = expr_alloc_two(E_AND, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); } - break; - - case 119: - - { (yyval.symbol) = sym_lookup((yyvsp[(1) - (1)].string), 0); free((yyvsp[(1) - (1)].string)); } - break; - - case 120: - - { (yyval.symbol) = sym_lookup((yyvsp[(1) - (1)].string), SYMBOL_CONST); free((yyvsp[(1) - (1)].string)); } - break; - - case 121: - - { (yyval.string) = NULL; } - break; - - - - default: break; - } - /* User semantic actions sometimes alter yychar, and that requires - that yytoken be updated with the new translation. We take the - approach of translating immediately before every use of yytoken. - One alternative is translating here after every semantic action, - but that translation would be missed if the semantic action invokes - YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or - if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an - incorrect destructor might then be invoked immediately. In the - case of YYERROR or YYBACKUP, subsequent parser actions might lead - to an incorrect destructor call or verbose syntax error message - before the lookahead is translated. */ - YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); - - YYPOPSTACK (yylen); - yylen = 0; - YY_STACK_PRINT (yyss, yyssp); - - *++yyvsp = yyval; - - /* Now `shift' the result of the reduction. Determine what state - that goes to, based on the state we popped back to and the rule - number reduced by. */ - - yyn = yyr1[yyn]; - - yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; - if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) - yystate = yytable[yystate]; - else - yystate = yydefgoto[yyn - YYNTOKENS]; - - goto yynewstate; - - -/*------------------------------------. -| yyerrlab -- here on detecting error | -`------------------------------------*/ -yyerrlab: - /* Make sure we have latest lookahead translation. See comments at - user semantic actions for why this is necessary. */ - yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar); - - /* If not already recovering from an error, report this error. */ - if (!yyerrstatus) - { - ++yynerrs; -#if ! YYERROR_VERBOSE - yyerror (YY_("syntax error")); -#else -# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ - yyssp, yytoken) - { - char const *yymsgp = YY_("syntax error"); - int yysyntax_error_status; - yysyntax_error_status = YYSYNTAX_ERROR; - if (yysyntax_error_status == 0) - yymsgp = yymsg; - else if (yysyntax_error_status == 1) - { - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); - yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); - if (!yymsg) - { - yymsg = yymsgbuf; - yymsg_alloc = sizeof yymsgbuf; - yysyntax_error_status = 2; - } - else - { - yysyntax_error_status = YYSYNTAX_ERROR; - yymsgp = yymsg; - } - } - yyerror (yymsgp); - if (yysyntax_error_status == 2) - goto yyexhaustedlab; - } -# undef YYSYNTAX_ERROR -#endif - } - - - - if (yyerrstatus == 3) - { - /* If just tried and failed to reuse lookahead token after an - error, discard it. */ - - if (yychar <= YYEOF) - { - /* Return failure if at end of input. */ - if (yychar == YYEOF) - YYABORT; - } - else - { - yydestruct ("Error: discarding", - yytoken, &yylval); - yychar = YYEMPTY; - } - } - - /* Else will try to reuse lookahead token after shifting the error - token. */ - goto yyerrlab1; - - -/*---------------------------------------------------. -| yyerrorlab -- error raised explicitly by YYERROR. | -`---------------------------------------------------*/ -yyerrorlab: - - /* Pacify compilers like GCC when the user code never invokes - YYERROR and the label yyerrorlab therefore never appears in user - code. */ - if (/*CONSTCOND*/ 0) - goto yyerrorlab; - - /* Do not reclaim the symbols of the rule which action triggered - this YYERROR. */ - YYPOPSTACK (yylen); - yylen = 0; - YY_STACK_PRINT (yyss, yyssp); - yystate = *yyssp; - goto yyerrlab1; - - -/*-------------------------------------------------------------. -| yyerrlab1 -- common code for both syntax error and YYERROR. | -`-------------------------------------------------------------*/ -yyerrlab1: - yyerrstatus = 3; /* Each real token shifted decrements this. */ - - for (;;) - { - yyn = yypact[yystate]; - if (!yypact_value_is_default (yyn)) - { - yyn += YYTERROR; - if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) - { - yyn = yytable[yyn]; - if (0 < yyn) - break; - } - } - - /* Pop the current state because it cannot handle the error token. */ - if (yyssp == yyss) - YYABORT; - - - yydestruct ("Error: popping", - yystos[yystate], yyvsp); - YYPOPSTACK (1); - yystate = *yyssp; - YY_STACK_PRINT (yyss, yyssp); - } - - *++yyvsp = yylval; - - - /* Shift the error token. */ - YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); - - yystate = yyn; - goto yynewstate; - - -/*-------------------------------------. -| yyacceptlab -- YYACCEPT comes here. | -`-------------------------------------*/ -yyacceptlab: - yyresult = 0; - goto yyreturn; - -/*-----------------------------------. -| yyabortlab -- YYABORT comes here. | -`-----------------------------------*/ -yyabortlab: - yyresult = 1; - goto yyreturn; - -#if !defined yyoverflow || YYERROR_VERBOSE -/*-------------------------------------------------. -| yyexhaustedlab -- memory exhaustion comes here. | -`-------------------------------------------------*/ -yyexhaustedlab: - yyerror (YY_("memory exhausted")); - yyresult = 2; - /* Fall through. */ -#endif - -yyreturn: - if (yychar != YYEMPTY) - { - /* Make sure we have latest lookahead translation. See comments at - user semantic actions for why this is necessary. */ - yytoken = YYTRANSLATE (yychar); - yydestruct ("Cleanup: discarding lookahead", - yytoken, &yylval); - } - /* Do not reclaim the symbols of the rule which action triggered - this YYABORT or YYACCEPT. */ - YYPOPSTACK (yylen); - YY_STACK_PRINT (yyss, yyssp); - while (yyssp != yyss) - { - yydestruct ("Cleanup: popping", - yystos[*yyssp], yyvsp); - YYPOPSTACK (1); - } -#ifndef yyoverflow - if (yyss != yyssa) - YYSTACK_FREE (yyss); -#endif -#if YYERROR_VERBOSE - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); -#endif - /* Make sure YYID is used. */ - return YYID (yyresult); -} - - - - - -void conf_parse(const char *name) -{ - struct symbol *sym; - int i; - - zconf_initscan(name); - - sym_init(); - _menu_init(); - rootmenu.prompt = menu_add_prompt(P_MENU, "Linux Kernel Configuration", NULL); - - if (getenv("ZCONF_DEBUG")) - zconfdebug = 1; - zconfparse(); - if (zconfnerrs) - exit(1); - if (!modules_sym) - modules_sym = sym_find( "n" ); - - rootmenu.prompt->text = rootmenu.prompt->text; - rootmenu.prompt->text = sym_expand_string_value(rootmenu.prompt->text); - - menu_finalize(&rootmenu); - for_all_symbols(i, sym) { - if (sym_check_deps(sym)) - zconfnerrs++; - } - if (zconfnerrs) - exit(1); - sym_set_change_count(1); -} - -static const char *zconf_tokenname(int token) -{ - switch (token) { - case T_MENU: return "menu"; - case T_ENDMENU: return "endmenu"; - case T_CHOICE: return "choice"; - case T_ENDCHOICE: return "endchoice"; - case T_IF: return "if"; - case T_ENDIF: return "endif"; - case T_DEPENDS: return "depends"; - case T_VISIBLE: return "visible"; - } - return ""; -} - -static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtoken) -{ - if (id->token != endtoken) { - zconf_error("unexpected '%s' within %s block", - kconf_id_strings + id->name, zconf_tokenname(starttoken)); - zconfnerrs++; - return false; - } - if (current_menu->file != current_file) { - zconf_error("'%s' in different file than '%s'", - kconf_id_strings + id->name, zconf_tokenname(starttoken)); - fprintf(stderr, "%s:%d: location of the '%s'\n", - current_menu->file->name, current_menu->lineno, - zconf_tokenname(starttoken)); - zconfnerrs++; - return false; - } - return true; -} - -static void zconfprint(const char *err, ...) -{ - va_list ap; - - fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno()); - va_start(ap, err); - vfprintf(stderr, err, ap); - va_end(ap); - fprintf(stderr, "\n"); -} - -static void zconf_error(const char *err, ...) -{ - va_list ap; - - zconfnerrs++; - fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno()); - va_start(ap, err); - vfprintf(stderr, err, ap); - va_end(ap); - fprintf(stderr, "\n"); -} - -static void zconferror(const char *err) -{ - fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno() + 1, err); -} - -static void print_quoted_string(FILE *out, const char *str) -{ - const char *p; - int len; - - putc('"', out); - while ((p = strchr(str, '"'))) { - len = p - str; - if (len) - fprintf(out, "%.*s", len, str); - fputs("\\\"", out); - str = p + 1; - } - fputs(str, out); - putc('"', out); -} - -static void print_symbol(FILE *out, struct menu *menu) -{ - struct symbol *sym = menu->sym; - struct property *prop; - - if (sym_is_choice(sym)) - fprintf(out, "\nchoice\n"); - else - fprintf(out, "\nconfig %s\n", sym->name); - switch (sym->type) { - case S_BOOLEAN: - fputs(" boolean\n", out); - break; - case S_TRISTATE: - fputs(" tristate\n", out); - break; - case S_STRING: - fputs(" string\n", out); - break; - case S_INT: - fputs(" integer\n", out); - break; - case S_HEX: - fputs(" hex\n", out); - break; - default: - fputs(" ???\n", out); - break; - } - for (prop = sym->prop; prop; prop = prop->next) { - if (prop->menu != menu) - continue; - switch (prop->type) { - case P_PROMPT: - fputs(" prompt ", out); - print_quoted_string(out, prop->text); - if (!expr_is_yes(prop->visible.expr)) { - fputs(" if ", out); - expr_fprint(prop->visible.expr, out); - } - fputc('\n', out); - break; - case P_DEFAULT: - fputs( " default ", out); - expr_fprint(prop->expr, out); - if (!expr_is_yes(prop->visible.expr)) { - fputs(" if ", out); - expr_fprint(prop->visible.expr, out); - } - fputc('\n', out); - break; - case P_CHOICE: - fputs(" #choice value\n", out); - break; - case P_SELECT: - fputs( " select ", out); - expr_fprint(prop->expr, out); - fputc('\n', out); - break; - case P_RANGE: - fputs( " range ", out); - expr_fprint(prop->expr, out); - fputc('\n', out); - break; - case P_MENU: - fputs( " menu ", out); - print_quoted_string(out, prop->text); - fputc('\n', out); - break; - default: - fprintf(out, " unknown prop %d!\n", prop->type); - break; - } - } - if (menu->help) { - int len = strlen(menu->help); - while (menu->help[--len] == '\n') - menu->help[len] = 0; - fprintf(out, " help\n%s\n", menu->help); - } -} - -void zconfdump(FILE *out) -{ - struct property *prop; - struct symbol *sym; - struct menu *menu; - - menu = rootmenu.list; - while (menu) { - if ((sym = menu->sym)) - print_symbol(out, menu); - else if ((prop = menu->prompt)) { - switch (prop->type) { - case P_COMMENT: - fputs("\ncomment ", out); - print_quoted_string(out, prop->text); - fputs("\n", out); - break; - case P_MENU: - fputs("\nmenu ", out); - print_quoted_string(out, prop->text); - fputs("\n", out); - break; - default: - ; - } - if (!expr_is_yes(prop->visible.expr)) { - fputs(" depends ", out); - expr_fprint(prop->visible.expr, out); - fputc('\n', out); - } - } - - if (menu->list) - menu = menu->list; - else if (menu->next) - menu = menu->next; - else while ((menu = menu->parent)) { - if (menu->prompt && menu->prompt->type == P_MENU) - fputs("\nendmenu\n", out); - if (menu->next) { - menu = menu->next; - break; - } - } - } -} - -#include "zconf.lex.c" -#include "util.c" -#include "confdata.c" -#include "expr.c" -#include "symbol.c" -#include "menu.c" - From patchwork Wed Oct 23 16:48:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 11207231 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EFB87112B for ; Wed, 23 Oct 2019 16:50:50 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9C2D921906 for ; Wed, 23 Oct 2019 16:50:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="UVGp+izZ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9C2D921906 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNJoq-0007c0-CE; Wed, 23 Oct 2019 16:49:08 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNJop-0007bN-F8 for xen-devel@lists.xenproject.org; Wed, 23 Oct 2019 16:49:07 +0000 X-Inumbo-ID: f90ae36e-f5b4-11e9-beca-bc764e2007e4 Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id f90ae36e-f5b4-11e9-beca-bc764e2007e4; Wed, 23 Oct 2019 16:48:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1571849323; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=uURSjeXsAm7GqDZ5RKilUL6S2+jUyWd8LpuXoGXkveY=; b=UVGp+izZPlEkb/4jqzNLiAbyCKfcDaomPN+lI7LgYgeixC2XsfKs7RRM os0DpiJDS25Dhp8NTsyFQ/f8Vlp0AHeHuN/t0IM1T2sMl/IDleRQZLOhC pGh2q42dk4TCPB5ZKxEPTx5GqqyMZbZxcK1nsMnTYNOGiH7vFvduqg1FA g=; Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=anthony.perard@citrix.com; spf=Pass smtp.mailfrom=anthony.perard@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa4.hc3370-68.iphmx.com: no sender authenticity information available from domain of anthony.perard@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa4.hc3370-68.iphmx.com: domain of anthony.perard@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa4.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: K4p6Nebna2gbimho1Jhmy4lRmUpR7GI5DVpsR+rkjwqoNsDFZwOJn0FuShC8yLy46DSS7m9IGM VCNGMSbyXnVTj+vzFFK+xrW526nCqwKl1qLKah2e4Dm1GaP7VDwuzzLHK8YMSz6Xr+wjVFDDQq kSkiwr5qFMALHFGhXmdGqVBUr+2I9fOfIzSMmZMjo/Q/hqzu0HXazWokqxAhHZwo4n5ArAiNvt zQqFBPSBfBy/IId306rYcXYD1JVZg/sjiKRWqs6GfjhmX0jAfch/ij5AS71sAHrA+Qk7vXUQ5D tKQ= X-SBRS: 2.7 X-MesageID: 7778034 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.68,221,1569297600"; d="scan'208";a="7778034" From: Anthony PERARD To: Date: Wed, 23 Oct 2019 17:48:18 +0100 Message-ID: <20191023164837.2700240-5-anthony.perard@citrix.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191023164837.2700240-1-anthony.perard@citrix.com> References: <20191023164837.2700240-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [RFC XEN PATCH 04/23] build: Import Kbuild from Linux v5.3 X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Anthony PERARD Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" This patch import part of Kbuild, the build system from Linux v5.3, 4d856f72c10ecb060868ed10ff1b1453943fc6c8. File imported: scripts/{Makefile.*,Kbuild.include} -> xen/scripts/ scripts/basic -> xen/scripts/basic scripts/mkmakefile -> xen/scripts/Makefile but without: - Extra warning (ccflags) Makefile.extrawarn - Support to build modules Makefile.modbuiltin Makefile.modinst Makefile.modpost Makefile.modsign - Support to install dtb files Makefile.dtbinst `scripts/basic' is for fixdep, a helper to fix dependencies generated by gcc, and add Kbuild generated dependencies. `scripts/mkmakefile' is used for out-of-tree builds. Also update xen/.gitignore to exclude files generated by Kbuild. Signed-off-by: Anthony PERARD --- xen/.gitignore | 4 + xen/scripts/Kbuild.include | 333 +++++++++++++++++++ xen/scripts/Makefile.asm-generic | 58 ++++ xen/scripts/Makefile.build | 528 +++++++++++++++++++++++++++++++ xen/scripts/Makefile.clean | 90 ++++++ xen/scripts/Makefile.gcc-plugins | 59 ++++ xen/scripts/Makefile.headersinst | 102 ++++++ xen/scripts/Makefile.host | 164 ++++++++++ xen/scripts/Makefile.kasan | 51 +++ xen/scripts/Makefile.kcov | 10 + xen/scripts/Makefile.lib | 435 +++++++++++++++++++++++++ xen/scripts/Makefile.ubsan | 19 ++ xen/scripts/basic/.gitignore | 1 + xen/scripts/basic/Makefile | 16 + xen/scripts/basic/fixdep.c | 410 ++++++++++++++++++++++++ xen/scripts/mkmakefile | 17 + 16 files changed, 2297 insertions(+) create mode 100644 xen/scripts/Kbuild.include create mode 100644 xen/scripts/Makefile.asm-generic create mode 100644 xen/scripts/Makefile.build create mode 100644 xen/scripts/Makefile.clean create mode 100644 xen/scripts/Makefile.gcc-plugins create mode 100644 xen/scripts/Makefile.headersinst create mode 100644 xen/scripts/Makefile.host create mode 100644 xen/scripts/Makefile.kasan create mode 100644 xen/scripts/Makefile.kcov create mode 100644 xen/scripts/Makefile.lib create mode 100644 xen/scripts/Makefile.ubsan create mode 100644 xen/scripts/basic/.gitignore create mode 100644 xen/scripts/basic/Makefile create mode 100644 xen/scripts/basic/fixdep.c create mode 100755 xen/scripts/mkmakefile diff --git a/xen/.gitignore b/xen/.gitignore index 9fef41a09b47..516bbd459342 100644 --- a/xen/.gitignore +++ b/xen/.gitignore @@ -1,2 +1,6 @@ +.* *.lex.c *.tab.[ch] + +# We don't want to ignore the following even if they are dot-files +!.gitignore diff --git a/xen/scripts/Kbuild.include b/xen/scripts/Kbuild.include new file mode 100644 index 000000000000..4b0432e095ae --- /dev/null +++ b/xen/scripts/Kbuild.include @@ -0,0 +1,333 @@ +# SPDX-License-Identifier: GPL-2.0 +#### +# kbuild: Generic definitions + +# Convenient variables +comma := , +quote := " +squote := ' +empty := +space := $(empty) $(empty) +space_escape := _-_SPACE_-_ +pound := \# + +### +# Name of target with a '.' as filename prefix. foo/bar.o => foo/.bar.o +dot-target = $(dir $@).$(notdir $@) + +### +# The temporary file to save gcc -MD generated dependencies must not +# contain a comma +depfile = $(subst $(comma),_,$(dot-target).d) + +### +# filename of target with directory and extension stripped +basetarget = $(basename $(notdir $@)) + +### +# real prerequisites without phony targets +real-prereqs = $(filter-out $(PHONY), $^) + +### +# Escape single quote for use in echo statements +escsq = $(subst $(squote),'\$(squote)',$1) + +### +# Easy method for doing a status message + kecho := : + quiet_kecho := echo +silent_kecho := : +kecho := $($(quiet)kecho) + +### +# filechk is used to check if the content of a generated file is updated. +# Sample usage: +# +# filechk_sample = echo $(KERNELRELEASE) +# version.h: FORCE +# $(call filechk,sample) +# +# The rule defined shall write to stdout the content of the new file. +# The existing file will be compared with the new one. +# - If no file exist it is created +# - If the content differ the new file is used +# - If they are equal no change, and no timestamp update +# - stdin is piped in from the first prerequisite ($<) so one has +# to specify a valid file as first prerequisite (often the kbuild file) +define filechk + $(Q)set -e; \ + mkdir -p $(dir $@); \ + { $(filechk_$(1)); } > $@.tmp; \ + if [ -r $@ ] && cmp -s $@ $@.tmp; then \ + rm -f $@.tmp; \ + else \ + $(kecho) ' UPD $@'; \ + mv -f $@.tmp $@; \ + fi +endef + +###### +# gcc support functions +# See documentation in Documentation/kbuild/makefiles.rst + +# cc-cross-prefix +# Usage: CROSS_COMPILE := $(call cc-cross-prefix, m68k-linux-gnu- m68k-linux-) +# Return first where a gcc is found in PATH. +# If no gcc found in PATH with listed prefixes return nothing +# +# Note: '2>/dev/null' is here to force Make to invoke a shell. Otherwise, it +# would try to directly execute the shell builtin 'command'. This workaround +# should be kept for a long time since this issue was fixed only after the +# GNU Make 4.2.1 release. +cc-cross-prefix = $(firstword $(foreach c, $(1), \ + $(if $(shell command -v -- $(c)gcc 2>/dev/null), $(c)))) + +# output directory for tests below +TMPOUT := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/) + +# try-run +# Usage: option = $(call try-run, $(CC)...-o "$$TMP",option-ok,otherwise) +# Exit code chooses option. "$$TMP" serves as a temporary file and is +# automatically cleaned up. +try-run = $(shell set -e; \ + TMP="$(TMPOUT).$$$$.tmp"; \ + TMPO="$(TMPOUT).$$$$.o"; \ + if ($(1)) >/dev/null 2>&1; \ + then echo "$(2)"; \ + else echo "$(3)"; \ + fi; \ + rm -f "$$TMP" "$$TMPO") + +# as-option +# Usage: cflags-y += $(call as-option,-Wa$(comma)-isa=foo,) + +as-option = $(call try-run,\ + $(CC) $(KBUILD_CFLAGS) $(1) -c -x assembler /dev/null -o "$$TMP",$(1),$(2)) + +# as-instr +# Usage: cflags-y += $(call as-instr,instr,option1,option2) + +as-instr = $(call try-run,\ + printf "%b\n" "$(1)" | $(CC) $(KBUILD_AFLAGS) -c -x assembler -o "$$TMP" -,$(2),$(3)) + +# __cc-option +# Usage: MY_CFLAGS += $(call __cc-option,$(CC),$(MY_CFLAGS),-march=winchip-c6,-march=i586) +__cc-option = $(call try-run,\ + $(1) -Werror $(2) $(3) -c -x c /dev/null -o "$$TMP",$(3),$(4)) + +# Do not attempt to build with gcc plugins during cc-option tests. +# (And this uses delayed resolution so the flags will be up to date.) +CC_OPTION_CFLAGS = $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS)) + +# cc-option +# Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586) + +cc-option = $(call __cc-option, $(CC),\ + $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS),$(1),$(2)) + +# cc-option-yn +# Usage: flag := $(call cc-option-yn,-march=winchip-c6) +cc-option-yn = $(call try-run,\ + $(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) $(1) -c -x c /dev/null -o "$$TMP",y,n) + +# cc-disable-warning +# Usage: cflags-y += $(call cc-disable-warning,unused-but-set-variable) +cc-disable-warning = $(call try-run,\ + $(CC) -Werror $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1))) + +# cc-ifversion +# Usage: EXTRA_CFLAGS += $(call cc-ifversion, -lt, 0402, -O1) +cc-ifversion = $(shell [ $(CONFIG_GCC_VERSION)0 $(1) $(2)000 ] && echo $(3) || echo $(4)) + +# ld-option +# Usage: KBUILD_LDFLAGS += $(call ld-option, -X, -Y) +ld-option = $(call try-run, $(LD) $(KBUILD_LDFLAGS) $(1) -v,$(1),$(2),$(3)) + +# ar-option +# Usage: KBUILD_ARFLAGS := $(call ar-option,D) +# Important: no spaces around options +ar-option = $(call try-run, $(AR) rc$(1) "$$TMP",$(1),$(2)) + +# ld-version +# Note this is mainly for HJ Lu's 3 number binutil versions +ld-version = $(shell $(LD) --version | $(srctree)/scripts/ld-version.sh) + +# ld-ifversion +# Usage: $(call ld-ifversion, -ge, 22252, y) +ld-ifversion = $(shell [ $(ld-version) $(1) $(2) ] && echo $(3) || echo $(4)) + +###### + +### +# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.build obj= +# Usage: +# $(Q)$(MAKE) $(build)=dir +build := -f $(srctree)/scripts/Makefile.build obj + +### +# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.modbuiltin obj= +# Usage: +# $(Q)$(MAKE) $(modbuiltin)=dir +modbuiltin := -f $(srctree)/scripts/Makefile.modbuiltin obj + +### +# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.dtbinst obj= +# Usage: +# $(Q)$(MAKE) $(dtbinst)=dir +dtbinst := -f $(srctree)/scripts/Makefile.dtbinst obj + +### +# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.clean obj= +# Usage: +# $(Q)$(MAKE) $(clean)=dir +clean := -f $(srctree)/scripts/Makefile.clean obj + +# echo command. +# Short version is used, if $(quiet) equals `quiet_', otherwise full one. +echo-cmd = $(if $($(quiet)cmd_$(1)),\ + echo ' $(call escsq,$($(quiet)cmd_$(1)))$(echo-why)';) + +# printing commands +cmd = @set -e; $(echo-cmd) $(cmd_$(1)) + +### +# if_changed - execute command if any prerequisite is newer than +# target, or command line has changed +# if_changed_dep - as if_changed, but uses fixdep to reveal dependencies +# including used config symbols +# if_changed_rule - as if_changed but execute rule instead +# See Documentation/kbuild/makefiles.rst for more info + +ifneq ($(KBUILD_NOCMDDEP),1) +# Check if both commands are the same including their order. Result is empty +# string if equal. User may override this check using make KBUILD_NOCMDDEP=1 +cmd-check = $(filter-out $(subst $(space),$(space_escape),$(strip $(cmd_$@))), \ + $(subst $(space),$(space_escape),$(strip $(cmd_$1)))) +else +cmd-check = $(if $(strip $(cmd_$@)),,1) +endif + +# Replace >$< with >$$< to preserve $ when reloading the .cmd file +# (needed for make) +# Replace >#< with >$(pound)< to avoid starting a comment in the .cmd file +# (needed for make) +# Replace >'< with >'\''< to be able to enclose the whole string in '...' +# (needed for the shell) +make-cmd = $(call escsq,$(subst $(pound),$$(pound),$(subst $$,$$$$,$(cmd_$(1))))) + +# Find any prerequisites that is newer than target or that does not exist. +# PHONY targets skipped in both cases. +any-prereq = $(filter-out $(PHONY),$?)$(filter-out $(PHONY) $(wildcard $^),$^) + +# Execute command if command has changed or prerequisite(s) are updated. +if_changed = $(if $(any-prereq)$(cmd-check), \ + $(cmd); \ + printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd, @:) + +# Execute the command and also postprocess generated .d dependencies file. +if_changed_dep = $(if $(any-prereq)$(cmd-check),$(cmd_and_fixdep),@:) + +cmd_and_fixdep = \ + $(cmd); \ + scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(dot-target).cmd;\ + rm -f $(depfile) + +# Usage: $(call if_changed_rule,foo) +# Will check if $(cmd_foo) or any of the prerequisites changed, +# and if so will execute $(rule_foo). +if_changed_rule = $(if $(any-prereq)$(cmd-check),$(rule_$(1)),@:) + +### +# why - tell why a target got built +# enabled by make V=2 +# Output (listed in the order they are checked): +# (1) - due to target is PHONY +# (2) - due to target missing +# (3) - due to: file1.h file2.h +# (4) - due to command line change +# (5) - due to missing .cmd file +# (6) - due to target not in $(targets) +# (1) PHONY targets are always build +# (2) No target, so we better build it +# (3) Prerequisite is newer than target +# (4) The command line stored in the file named dir/.target.cmd +# differed from actual command line. This happens when compiler +# options changes +# (5) No dir/.target.cmd file (used to store command line) +# (6) No dir/.target.cmd file and target not listed in $(targets) +# This is a good hint that there is a bug in the kbuild file +ifeq ($(KBUILD_VERBOSE),2) +why = \ + $(if $(filter $@, $(PHONY)),- due to target is PHONY, \ + $(if $(wildcard $@), \ + $(if $(any-prereq),- due to: $(any-prereq), \ + $(if $(cmd-check), \ + $(if $(cmd_$@),- due to command line change, \ + $(if $(filter $@, $(targets)), \ + - due to missing .cmd file, \ + - due to $(notdir $@) not in $$(targets) \ + ) \ + ) \ + ) \ + ), \ + - due to target missing \ + ) \ + ) + +echo-why = $(call escsq, $(strip $(why))) +endif + +############################################################################### +# +# When a Kconfig string contains a filename, it is suitable for +# passing to shell commands. It is surrounded by double-quotes, and +# any double-quotes or backslashes within it are escaped by +# backslashes. +# +# This is no use for dependencies or $(wildcard). We need to strip the +# surrounding quotes and the escaping from quotes and backslashes, and +# we *do* need to escape any spaces in the string. So, for example: +# +# Usage: $(eval $(call config_filename,FOO)) +# +# Defines FOO_FILENAME based on the contents of the CONFIG_FOO option, +# transformed as described above to be suitable for use within the +# makefile. +# +# Also, if the filename is a relative filename and exists in the source +# tree but not the build tree, define FOO_SRCPREFIX as $(srctree)/ to +# be prefixed to *both* command invocation and dependencies. +# +# Note: We also print the filenames in the quiet_cmd_foo text, and +# perhaps ought to have a version specially escaped for that purpose. +# But it's only cosmetic, and $(patsubst "%",%,$(CONFIG_FOO)) is good +# enough. It'll strip the quotes in the common case where there's no +# space and it's a simple filename, and it'll retain the quotes when +# there's a space. There are some esoteric cases in which it'll print +# the wrong thing, but we don't really care. The actual dependencies +# and commands *do* get it right, with various combinations of single +# and double quotes, backslashes and spaces in the filenames. +# +############################################################################### +# +define config_filename +ifneq ($$(CONFIG_$(1)),"") +$(1)_FILENAME := $$(subst \\,\,$$(subst \$$(quote),$$(quote),$$(subst $$(space_escape),\$$(space),$$(patsubst "%",%,$$(subst $$(space),$$(space_escape),$$(CONFIG_$(1))))))) +ifneq ($$(patsubst /%,%,$$(firstword $$($(1)_FILENAME))),$$(firstword $$($(1)_FILENAME))) +else +ifeq ($$(wildcard $$($(1)_FILENAME)),) +ifneq ($$(wildcard $$(srctree)/$$($(1)_FILENAME)),) +$(1)_SRCPREFIX := $(srctree)/ +endif +endif +endif +endif +endef +# +############################################################################### + +# delete partially updated (i.e. corrupted) files on error +.DELETE_ON_ERROR: + +# do not delete intermediate files automatically +.SECONDARY: diff --git a/xen/scripts/Makefile.asm-generic b/xen/scripts/Makefile.asm-generic new file mode 100644 index 000000000000..82ad63dcd62b --- /dev/null +++ b/xen/scripts/Makefile.asm-generic @@ -0,0 +1,58 @@ +# SPDX-License-Identifier: GPL-2.0 +# include/asm-generic contains a lot of files that are used +# verbatim by several architectures. +# +# This Makefile reads the file arch/$(SRCARCH)/include/(uapi/)/asm/Kbuild +# and for each file listed in this file with generic-y creates +# a small wrapper file in arch/$(SRCARCH)/include/generated/(uapi/)/asm. + +PHONY := all +all: + +src := $(subst /generated,,$(obj)) +-include $(src)/Kbuild + +# $(generic)/Kbuild lists mandatory-y. Exclude um since it is a special case. +ifneq ($(SRCARCH),um) +include $(generic)/Kbuild +endif + +include scripts/Kbuild.include + +redundant := $(filter $(mandatory-y) $(generated-y), $(generic-y)) +redundant += $(foreach f, $(generic-y), $(if $(wildcard $(srctree)/$(src)/$(f)),$(f))) +redundant := $(sort $(redundant)) +$(if $(redundant),\ + $(warning redundant generic-y found in $(src)/Kbuild: $(redundant))) + +# If arch does not implement mandatory headers, fallback to asm-generic ones. +mandatory-y := $(filter-out $(generated-y), $(mandatory-y)) +generic-y += $(foreach f, $(mandatory-y), $(if $(wildcard $(srctree)/$(src)/$(f)),,$(f))) + +generic-y := $(addprefix $(obj)/, $(generic-y)) +generated-y := $(addprefix $(obj)/, $(generated-y)) + +# Remove stale wrappers when the corresponding files are removed from generic-y +old-headers := $(wildcard $(obj)/*.h) +unwanted := $(filter-out $(generic-y) $(generated-y),$(old-headers)) + +quiet_cmd_wrap = WRAP $@ + cmd_wrap = echo "\#include " > $@ + +quiet_cmd_remove = REMOVE $(unwanted) + cmd_remove = rm -f $(unwanted) + +all: $(generic-y) + $(if $(unwanted),$(call cmd,remove)) + @: + +$(obj)/%.h: + $(call cmd,wrap) + +# Create output directory. Skip it if at least one old header exists +# since we know the output directory already exists. +ifeq ($(old-headers),) +$(shell mkdir -p $(obj)) +endif + +.PHONY: $(PHONY) diff --git a/xen/scripts/Makefile.build b/xen/scripts/Makefile.build new file mode 100644 index 000000000000..2f66ed388d1c --- /dev/null +++ b/xen/scripts/Makefile.build @@ -0,0 +1,528 @@ +# SPDX-License-Identifier: GPL-2.0 +# ========================================================================== +# Building +# ========================================================================== + +src := $(obj) + +PHONY := __build +__build: + +# Init all relevant variables used in kbuild files so +# 1) they have correct type +# 2) they do not inherit any value from the environment +obj-y := +obj-m := +lib-y := +lib-m := +always := +targets := +subdir-y := +subdir-m := +EXTRA_AFLAGS := +EXTRA_CFLAGS := +EXTRA_CPPFLAGS := +EXTRA_LDFLAGS := +asflags-y := +ccflags-y := +cppflags-y := +ldflags-y := + +subdir-asflags-y := +subdir-ccflags-y := + +# Read auto.conf if it exists, otherwise ignore +-include include/config/auto.conf + +include scripts/Kbuild.include + +# The filename Kbuild has precedence over Makefile +kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src)) +kbuild-file := $(if $(wildcard $(kbuild-dir)/Kbuild),$(kbuild-dir)/Kbuild,$(kbuild-dir)/Makefile) +include $(kbuild-file) + +include scripts/Makefile.lib + +# Do not include host rules unless needed +ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m)$(hostcxxlibs-y)$(hostcxxlibs-m),) +include scripts/Makefile.host +endif + +ifndef obj +$(warning kbuild: Makefile.build is included improperly) +endif + +ifeq ($(MAKECMDGOALS)$(need-modorder),) +ifneq ($(obj-m),) +$(warning $(patsubst %.o,'%.ko',$(obj-m)) will not be built even though obj-m is specified.) +$(warning You cannot use subdir-y/m to visit a module Makefile. Use obj-y/m instead.) +endif +endif + +# =========================================================================== + +ifneq ($(strip $(lib-y) $(lib-m) $(lib-)),) +lib-target := $(obj)/lib.a +real-obj-y += $(obj)/lib-ksyms.o +endif + +ifneq ($(strip $(real-obj-y) $(need-builtin)),) +builtin-target := $(obj)/built-in.a +endif + +ifeq ($(CONFIG_MODULES)$(need-modorder),y1) +modorder-target := $(obj)/modules.order +endif + +mod-targets := $(patsubst %.o, %.mod, $(obj-m)) + +__build: $(if $(KBUILD_BUILTIN),$(builtin-target) $(lib-target) $(extra-y)) \ + $(if $(KBUILD_MODULES),$(obj-m) $(mod-targets) $(modorder-target)) \ + $(subdir-ym) $(always) + @: + +# Linus' kernel sanity checking tool +ifeq ($(KBUILD_CHECKSRC),1) + quiet_cmd_checksrc = CHECK $< + cmd_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $< +else ifeq ($(KBUILD_CHECKSRC),2) + quiet_cmd_force_checksrc = CHECK $< + cmd_force_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $< +endif + +ifneq ($(KBUILD_ENABLE_EXTRA_GCC_CHECKS),) + cmd_checkdoc = $(srctree)/scripts/kernel-doc -none $< +endif + +# Compile C sources (.c) +# --------------------------------------------------------------------------- + +# Default is built-in, unless we know otherwise +$(foreach x, i ll lst o s symtypes, $(patsubst %.o,%.$(x),$(real-obj-m))): \ + part-of-module := y + +modkern_cflags = \ + $(if $(part-of-module), \ + $(KBUILD_CFLAGS_MODULE) $(CFLAGS_MODULE), \ + $(KBUILD_CFLAGS_KERNEL) $(CFLAGS_KERNEL)) +quiet_modtag = $(if $(part-of-module),[M], ) + +quiet_cmd_cc_s_c = CC $(quiet_modtag) $@ + cmd_cc_s_c = $(CC) $(filter-out $(DEBUG_CFLAGS), $(c_flags)) $(DISABLE_LTO) -fverbose-asm -S -o $@ $< + +$(obj)/%.s: $(src)/%.c FORCE + $(call if_changed_dep,cc_s_c) + +quiet_cmd_cpp_i_c = CPP $(quiet_modtag) $@ +cmd_cpp_i_c = $(CPP) $(c_flags) -o $@ $< + +$(obj)/%.i: $(src)/%.c FORCE + $(call if_changed_dep,cpp_i_c) + +# These mirror gensymtypes_S and co below, keep them in synch. +cmd_gensymtypes_c = \ + $(CPP) -D__GENKSYMS__ $(c_flags) $< | \ + scripts/genksyms/genksyms $(if $(1), -T $(2)) \ + $(patsubst y,-R,$(CONFIG_MODULE_REL_CRCS)) \ + $(if $(KBUILD_PRESERVE),-p) \ + -r $(firstword $(wildcard $(2:.symtypes=.symref) /dev/null)) + +quiet_cmd_cc_symtypes_c = SYM $(quiet_modtag) $@ +cmd_cc_symtypes_c = \ + $(call cmd_gensymtypes_c,true,$@) >/dev/null; \ + test -s $@ || rm -f $@ + +$(obj)/%.symtypes : $(src)/%.c FORCE + $(call cmd,cc_symtypes_c) + +# LLVM assembly +# Generate .ll files from .c +quiet_cmd_cc_ll_c = CC $(quiet_modtag) $@ + cmd_cc_ll_c = $(CC) $(c_flags) -emit-llvm -S -o $@ $< + +$(obj)/%.ll: $(src)/%.c FORCE + $(call if_changed_dep,cc_ll_c) + +# C (.c) files +# The C file is compiled and updated dependency information is generated. +# (See cmd_cc_o_c + relevant part of rule_cc_o_c) + +quiet_cmd_cc_o_c = CC $(quiet_modtag) $@ + cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< + +ifdef CONFIG_MODVERSIONS +# When module versioning is enabled the following steps are executed: +# o compile a .o from .c +# o if .o doesn't contain a __ksymtab version, i.e. does +# not export symbols, it's done. +# o otherwise, we calculate symbol versions using the good old +# genksyms on the preprocessed source and postprocess them in a way +# that they are usable as a linker script +# o generate .tmp_.o from .o using the linker to +# replace the unresolved symbols __crc_exported_symbol with +# the actual value of the checksum generated by genksyms +# o remove .tmp_.o to .o + +cmd_modversions_c = \ + if $(OBJDUMP) -h $@ | grep -q __ksymtab; then \ + $(call cmd_gensymtypes_c,$(KBUILD_SYMTYPES),$(@:.o=.symtypes)) \ + > $(@D)/.tmp_$(@F:.o=.ver); \ + \ + $(LD) $(KBUILD_LDFLAGS) -r -o $(@D)/.tmp_$(@F) $@ \ + -T $(@D)/.tmp_$(@F:.o=.ver); \ + mv -f $(@D)/.tmp_$(@F) $@; \ + rm -f $(@D)/.tmp_$(@F:.o=.ver); \ + fi +endif + +ifdef CONFIG_FTRACE_MCOUNT_RECORD +ifndef CC_USING_RECORD_MCOUNT +# compiler will not generate __mcount_loc use recordmcount or recordmcount.pl +ifdef BUILD_C_RECORDMCOUNT +ifeq ("$(origin RECORDMCOUNT_WARN)", "command line") + RECORDMCOUNT_FLAGS = -w +endif +# Due to recursion, we must skip empty.o. +# The empty.o file is created in the make process in order to determine +# the target endianness and word size. It is made before all other C +# files, including recordmcount. +sub_cmd_record_mcount = \ + if [ $(@) != "scripts/mod/empty.o" ]; then \ + $(objtree)/scripts/recordmcount $(RECORDMCOUNT_FLAGS) "$(@)"; \ + fi; +recordmcount_source := $(srctree)/scripts/recordmcount.c \ + $(srctree)/scripts/recordmcount.h +else +sub_cmd_record_mcount = perl $(srctree)/scripts/recordmcount.pl "$(ARCH)" \ + "$(if $(CONFIG_CPU_BIG_ENDIAN),big,little)" \ + "$(if $(CONFIG_64BIT),64,32)" \ + "$(OBJDUMP)" "$(OBJCOPY)" "$(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS)" \ + "$(LD) $(KBUILD_LDFLAGS)" "$(NM)" "$(RM)" "$(MV)" \ + "$(if $(part-of-module),1,0)" "$(@)"; +recordmcount_source := $(srctree)/scripts/recordmcount.pl +endif # BUILD_C_RECORDMCOUNT +cmd_record_mcount = $(if $(findstring $(strip $(CC_FLAGS_FTRACE)),$(_c_flags)), \ + $(sub_cmd_record_mcount)) +endif # CC_USING_RECORD_MCOUNT +endif # CONFIG_FTRACE_MCOUNT_RECORD + +ifdef CONFIG_STACK_VALIDATION +ifneq ($(SKIP_STACK_VALIDATION),1) + +__objtool_obj := $(objtree)/tools/objtool/objtool + +objtool_args = $(if $(CONFIG_UNWINDER_ORC),orc generate,check) + +objtool_args += $(if $(part-of-module), --module,) + +ifndef CONFIG_FRAME_POINTER +objtool_args += --no-fp +endif +ifdef CONFIG_GCOV_KERNEL +objtool_args += --no-unreachable +endif +ifdef CONFIG_RETPOLINE + objtool_args += --retpoline +endif +ifdef CONFIG_X86_SMAP + objtool_args += --uaccess +endif + +# 'OBJECT_FILES_NON_STANDARD := y': skip objtool checking for a directory +# 'OBJECT_FILES_NON_STANDARD_foo.o := 'y': skip objtool checking for a file +# 'OBJECT_FILES_NON_STANDARD_foo.o := 'n': override directory skip for a file +cmd_objtool = $(if $(patsubst y%,, \ + $(OBJECT_FILES_NON_STANDARD_$(basetarget).o)$(OBJECT_FILES_NON_STANDARD)n), \ + $(__objtool_obj) $(objtool_args) $@) +objtool_obj = $(if $(patsubst y%,, \ + $(OBJECT_FILES_NON_STANDARD_$(basetarget).o)$(OBJECT_FILES_NON_STANDARD)n), \ + $(__objtool_obj)) + +endif # SKIP_STACK_VALIDATION +endif # CONFIG_STACK_VALIDATION + +# Rebuild all objects when objtool changes, or is enabled/disabled. +objtool_dep = $(objtool_obj) \ + $(wildcard include/config/orc/unwinder.h \ + include/config/stack/validation.h) + +ifdef CONFIG_TRIM_UNUSED_KSYMS +cmd_gen_ksymdeps = \ + $(CONFIG_SHELL) $(srctree)/scripts/gen_ksymdeps.sh $@ >> $(dot-target).cmd +endif + +define rule_cc_o_c + $(call cmd,checksrc) + $(call cmd_and_fixdep,cc_o_c) + $(call cmd,gen_ksymdeps) + $(call cmd,checkdoc) + $(call cmd,objtool) + $(call cmd,modversions_c) + $(call cmd,record_mcount) +endef + +define rule_as_o_S + $(call cmd_and_fixdep,as_o_S) + $(call cmd,gen_ksymdeps) + $(call cmd,objtool) + $(call cmd,modversions_S) +endef + +# List module undefined symbols (or empty line if not enabled) +ifdef CONFIG_TRIM_UNUSED_KSYMS +cmd_undef_syms = $(NM) $< | sed -n 's/^ *U //p' | xargs echo +else +cmd_undef_syms = echo +endif + +# Built-in and composite module parts +$(obj)/%.o: $(src)/%.c $(recordmcount_source) $(objtool_dep) FORCE + $(call cmd,force_checksrc) + $(call if_changed_rule,cc_o_c) + +cmd_mod = { \ + echo $(if $($*-objs)$($*-y)$($*-m), $(addprefix $(obj)/, $($*-objs) $($*-y) $($*-m)), $(@:.mod=.o)); \ + $(cmd_undef_syms); \ + } > $@ + +$(obj)/%.mod: $(obj)/%.o FORCE + $(call if_changed,mod) + +targets += $(mod-targets) + +quiet_cmd_cc_lst_c = MKLST $@ + cmd_cc_lst_c = $(CC) $(c_flags) -g -c -o $*.o $< && \ + $(CONFIG_SHELL) $(srctree)/scripts/makelst $*.o \ + System.map $(OBJDUMP) > $@ + +$(obj)/%.lst: $(src)/%.c FORCE + $(call if_changed_dep,cc_lst_c) + +# header test (header-test-y, header-test-m target) +# --------------------------------------------------------------------------- + +quiet_cmd_cc_s_h = CC $@ + cmd_cc_s_h = $(CC) $(c_flags) -S -o $@ -x c /dev/null -include $< + +$(obj)/%.h.s: $(src)/%.h FORCE + $(call if_changed_dep,cc_s_h) + +# Compile assembler sources (.S) +# --------------------------------------------------------------------------- + +modkern_aflags := $(KBUILD_AFLAGS_KERNEL) $(AFLAGS_KERNEL) + +$(real-obj-m) : modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE) +$(real-obj-m:.o=.s): modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE) + +# .S file exports must have their C prototypes defined in asm/asm-prototypes.h +# or a file that it includes, in order to get versioned symbols. We build a +# dummy C file that includes asm-prototypes and the EXPORT_SYMBOL lines from +# the .S file (with trailing ';'), and run genksyms on that, to extract vers. +# +# This is convoluted. The .S file must first be preprocessed to run guards and +# expand names, then the resulting exports must be constructed into plain +# EXPORT_SYMBOL(symbol); to build our dummy C file, and that gets preprocessed +# to make the genksyms input. +# +# These mirror gensymtypes_c and co above, keep them in synch. +cmd_gensymtypes_S = \ + { echo "\#include " ; \ + echo "\#include " ; \ + $(CPP) $(a_flags) $< | \ + grep "\<___EXPORT_SYMBOL\>" | \ + sed 's/.*___EXPORT_SYMBOL[[:space:]]*\([a-zA-Z0-9_]*\)[[:space:]]*,.*/EXPORT_SYMBOL(\1);/' ; } | \ + $(CPP) -D__GENKSYMS__ $(c_flags) -xc - | \ + scripts/genksyms/genksyms $(if $(1), -T $(2)) \ + $(patsubst y,-R,$(CONFIG_MODULE_REL_CRCS)) \ + $(if $(KBUILD_PRESERVE),-p) \ + -r $(firstword $(wildcard $(2:.symtypes=.symref) /dev/null)) + +quiet_cmd_cc_symtypes_S = SYM $(quiet_modtag) $@ +cmd_cc_symtypes_S = \ + $(call cmd_gensymtypes_S,true,$@) >/dev/null; \ + test -s $@ || rm -f $@ + +$(obj)/%.symtypes : $(src)/%.S FORCE + $(call cmd,cc_symtypes_S) + + +quiet_cmd_cpp_s_S = CPP $(quiet_modtag) $@ +cmd_cpp_s_S = $(CPP) $(a_flags) -o $@ $< + +$(obj)/%.s: $(src)/%.S FORCE + $(call if_changed_dep,cpp_s_S) + +quiet_cmd_as_o_S = AS $(quiet_modtag) $@ + cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $< + +ifdef CONFIG_MODVERSIONS + +ASM_PROTOTYPES := $(wildcard $(srctree)/arch/$(SRCARCH)/include/asm/asm-prototypes.h) + +ifneq ($(ASM_PROTOTYPES),) + +# versioning matches the C process described above, with difference that +# we parse asm-prototypes.h C header to get function definitions. + +cmd_modversions_S = \ + if $(OBJDUMP) -h $@ | grep -q __ksymtab; then \ + $(call cmd_gensymtypes_S,$(KBUILD_SYMTYPES),$(@:.o=.symtypes)) \ + > $(@D)/.tmp_$(@F:.o=.ver); \ + \ + $(LD) $(KBUILD_LDFLAGS) -r -o $(@D)/.tmp_$(@F) $@ \ + -T $(@D)/.tmp_$(@F:.o=.ver); \ + mv -f $(@D)/.tmp_$(@F) $@; \ + rm -f $(@D)/.tmp_$(@F:.o=.ver); \ + fi +endif +endif + +$(obj)/%.o: $(src)/%.S $(objtool_dep) FORCE + $(call if_changed_rule,as_o_S) + +targets += $(filter-out $(subdir-obj-y), $(real-obj-y)) $(real-obj-m) $(lib-y) +targets += $(extra-y) $(MAKECMDGOALS) $(always) + +# Linker scripts preprocessor (.lds.S -> .lds) +# --------------------------------------------------------------------------- +quiet_cmd_cpp_lds_S = LDS $@ + cmd_cpp_lds_S = $(CPP) $(cpp_flags) -P -U$(ARCH) \ + -D__ASSEMBLY__ -DLINKER_SCRIPT -o $@ $< + +$(obj)/%.lds: $(src)/%.lds.S FORCE + $(call if_changed_dep,cpp_lds_S) + +# ASN.1 grammar +# --------------------------------------------------------------------------- +quiet_cmd_asn1_compiler = ASN.1 $@ + cmd_asn1_compiler = $(objtree)/scripts/asn1_compiler $< \ + $(subst .h,.c,$@) $(subst .c,.h,$@) + +$(obj)/%.asn1.c $(obj)/%.asn1.h: $(src)/%.asn1 $(objtree)/scripts/asn1_compiler + $(call cmd,asn1_compiler) + +# Build the compiled-in targets +# --------------------------------------------------------------------------- + +# To build objects in subdirs, we need to descend into the directories +$(sort $(subdir-obj-y)): $(subdir-ym) ; + +# +# Rule to compile a set of .o files into one .a file (without symbol table) +# +ifdef builtin-target + +quiet_cmd_ar_builtin = AR $@ + cmd_ar_builtin = rm -f $@; $(AR) rcSTP$(KBUILD_ARFLAGS) $@ $(real-prereqs) + +$(builtin-target): $(real-obj-y) FORCE + $(call if_changed,ar_builtin) + +targets += $(builtin-target) +endif # builtin-target + +# +# Rule to create modules.order file +# +# Create commands to either record .ko file or cat modules.order from +# a subdirectory +$(modorder-target): $(subdir-ym) FORCE + $(Q){ $(foreach m, $(modorder), \ + $(if $(filter %/modules.order, $m), cat $m, echo $m);) :; } \ + | $(AWK) '!x[$$0]++' - > $@ + +# +# Rule to compile a set of .o files into one .a file (with symbol table) +# +ifdef lib-target + +$(lib-target): $(lib-y) FORCE + $(call if_changed,ar) + +targets += $(lib-target) + +dummy-object = $(obj)/.lib_exports.o +ksyms-lds = $(dot-target).lds + +quiet_cmd_export_list = EXPORTS $@ +cmd_export_list = $(OBJDUMP) -h $< | \ + sed -ne '/___ksymtab/s/.*+\([^ ]*\).*/EXTERN(\1)/p' >$(ksyms-lds);\ + rm -f $(dummy-object);\ + echo | $(CC) $(a_flags) -c -o $(dummy-object) -x assembler -;\ + $(LD) $(ld_flags) -r -o $@ -T $(ksyms-lds) $(dummy-object);\ + rm $(dummy-object) $(ksyms-lds) + +$(obj)/lib-ksyms.o: $(lib-target) FORCE + $(call if_changed,export_list) + +targets += $(obj)/lib-ksyms.o + +endif + +# NOTE: +# Do not replace $(filter %.o,^) with $(real-prereqs). When a single object +# module is turned into a multi object module, $^ will contain header file +# dependencies recorded in the .*.cmd file. +quiet_cmd_link_multi-m = LD [M] $@ + cmd_link_multi-m = $(LD) $(ld_flags) -r -o $@ $(filter %.o,$^) + +$(multi-used-m): FORCE + $(call if_changed,link_multi-m) +$(call multi_depend, $(multi-used-m), .o, -objs -y -m) + +targets += $(multi-used-m) +targets := $(filter-out $(PHONY), $(targets)) + +# Add intermediate targets: +# When building objects with specific suffix patterns, add intermediate +# targets that the final targets are derived from. +intermediate_targets = $(foreach sfx, $(2), \ + $(patsubst %$(strip $(1)),%$(sfx), \ + $(filter %$(strip $(1)), $(targets)))) +# %.asn1.o <- %.asn1.[ch] <- %.asn1 +# %.dtb.o <- %.dtb.S <- %.dtb <- %.dts +# %.lex.o <- %.lex.c <- %.l +# %.tab.o <- %.tab.[ch] <- %.y +targets += $(call intermediate_targets, .asn1.o, .asn1.c .asn1.h) \ + $(call intermediate_targets, .dtb.o, .dtb.S .dtb) \ + $(call intermediate_targets, .lex.o, .lex.c) \ + $(call intermediate_targets, .tab.o, .tab.c .tab.h) + +# Descending +# --------------------------------------------------------------------------- + +PHONY += $(subdir-ym) +$(subdir-ym): + $(Q)$(MAKE) $(build)=$@ \ + need-builtin=$(if $(filter $@/built-in.a, $(subdir-obj-y)),1) \ + need-modorder=$(if $(need-modorder),$(if $(filter $@/modules.order, $(modorder)),1)) + +# Add FORCE to the prequisites of a target to force it to be always rebuilt. +# --------------------------------------------------------------------------- + +PHONY += FORCE + +FORCE: + +# Read all saved command lines and dependencies for the $(targets) we +# may be building above, using $(if_changed{,_dep}). As an +# optimization, we don't need to read them if the target does not +# exist, we will rebuild anyway in that case. + +existing-targets := $(wildcard $(sort $(targets))) + +-include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd) + +ifdef building_out_of_srctree +# Create directories for object files if they do not exist +obj-dirs := $(sort $(obj) $(patsubst %/,%, $(dir $(targets)))) +# If targets exist, their directories apparently exist. Skip mkdir. +existing-dirs := $(sort $(patsubst %/,%, $(dir $(existing-targets)))) +obj-dirs := $(strip $(filter-out $(existing-dirs), $(obj-dirs))) +ifneq ($(obj-dirs),) +$(shell mkdir -p $(obj-dirs)) +endif +endif + +.PHONY: $(PHONY) diff --git a/xen/scripts/Makefile.clean b/xen/scripts/Makefile.clean new file mode 100644 index 000000000000..0b80e3207b20 --- /dev/null +++ b/xen/scripts/Makefile.clean @@ -0,0 +1,90 @@ +# SPDX-License-Identifier: GPL-2.0 +# ========================================================================== +# Cleaning up +# ========================================================================== + +src := $(obj) + +PHONY := __clean +__clean: + +include scripts/Kbuild.include + +# The filename Kbuild has precedence over Makefile +kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src)) +include $(if $(wildcard $(kbuild-dir)/Kbuild), $(kbuild-dir)/Kbuild, $(kbuild-dir)/Makefile) + +# Figure out what we need to build from the various variables +# ========================================================================== + +__subdir-y := $(patsubst %/,%,$(filter %/, $(obj-y))) +subdir-y += $(__subdir-y) +__subdir-m := $(patsubst %/,%,$(filter %/, $(obj-m))) +subdir-m += $(__subdir-m) +__subdir- := $(patsubst %/,%,$(filter %/, $(obj-))) +subdir- += $(__subdir-) + +# Subdirectories we need to descend into + +subdir-ym := $(sort $(subdir-y) $(subdir-m)) +subdir-ymn := $(sort $(subdir-ym) $(subdir-)) + +# Add subdir path + +subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn)) + +# build a list of files to remove, usually relative to the current +# directory + +__clean-files := $(extra-y) $(extra-m) $(extra-) \ + $(always) $(targets) $(clean-files) \ + $(hostprogs-y) $(hostprogs-m) $(hostprogs-) \ + $(hostlibs-y) $(hostlibs-m) $(hostlibs-) \ + $(hostcxxlibs-y) $(hostcxxlibs-m) + +__clean-files := $(filter-out $(no-clean-files), $(__clean-files)) + +# clean-files is given relative to the current directory, unless it +# starts with $(objtree)/ (which means "./", so do not add "./" unless +# you want to delete a file from the toplevel object directory). + +__clean-files := $(wildcard \ + $(addprefix $(obj)/, $(filter-out $(objtree)/%, $(__clean-files))) \ + $(filter $(objtree)/%, $(__clean-files))) + +# same as clean-files + +__clean-dirs := $(wildcard \ + $(addprefix $(obj)/, $(filter-out $(objtree)/%, $(clean-dirs))) \ + $(filter $(objtree)/%, $(clean-dirs))) + +# ========================================================================== + +quiet_cmd_clean = CLEAN $(obj) + cmd_clean = rm -f $(__clean-files) +quiet_cmd_cleandir = CLEAN $(__clean-dirs) + cmd_cleandir = rm -rf $(__clean-dirs) + + +__clean: $(subdir-ymn) +ifneq ($(strip $(__clean-files)),) + +$(call cmd,clean) +endif +ifneq ($(strip $(__clean-dirs)),) + +$(call cmd,cleandir) +endif + @: + + +# =========================================================================== +# Generic stuff +# =========================================================================== + +# Descending +# --------------------------------------------------------------------------- + +PHONY += $(subdir-ymn) +$(subdir-ymn): + $(Q)$(MAKE) $(clean)=$@ + +.PHONY: $(PHONY) diff --git a/xen/scripts/Makefile.gcc-plugins b/xen/scripts/Makefile.gcc-plugins new file mode 100644 index 000000000000..5f7df50cfe7a --- /dev/null +++ b/xen/scripts/Makefile.gcc-plugins @@ -0,0 +1,59 @@ +# SPDX-License-Identifier: GPL-2.0 + +gcc-plugin-$(CONFIG_GCC_PLUGIN_CYC_COMPLEXITY) += cyc_complexity_plugin.so + +gcc-plugin-$(CONFIG_GCC_PLUGIN_LATENT_ENTROPY) += latent_entropy_plugin.so +gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_LATENT_ENTROPY) \ + += -DLATENT_ENTROPY_PLUGIN +ifdef CONFIG_GCC_PLUGIN_LATENT_ENTROPY + DISABLE_LATENT_ENTROPY_PLUGIN += -fplugin-arg-latent_entropy_plugin-disable +endif +export DISABLE_LATENT_ENTROPY_PLUGIN + +gcc-plugin-$(CONFIG_GCC_PLUGIN_SANCOV) += sancov_plugin.so + +gcc-plugin-$(CONFIG_GCC_PLUGIN_STRUCTLEAK) += structleak_plugin.so +gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK_VERBOSE) \ + += -fplugin-arg-structleak_plugin-verbose +gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF) \ + += -fplugin-arg-structleak_plugin-byref +gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL) \ + += -fplugin-arg-structleak_plugin-byref-all +gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK) \ + += -DSTRUCTLEAK_PLUGIN + +gcc-plugin-$(CONFIG_GCC_PLUGIN_RANDSTRUCT) += randomize_layout_plugin.so +gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_RANDSTRUCT) \ + += -DRANDSTRUCT_PLUGIN +gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_RANDSTRUCT_PERFORMANCE) \ + += -fplugin-arg-randomize_layout_plugin-performance-mode + +gcc-plugin-$(CONFIG_GCC_PLUGIN_STACKLEAK) += stackleak_plugin.so +gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STACKLEAK) \ + += -DSTACKLEAK_PLUGIN +gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STACKLEAK) \ + += -fplugin-arg-stackleak_plugin-track-min-size=$(CONFIG_STACKLEAK_TRACK_MIN_SIZE) +ifdef CONFIG_GCC_PLUGIN_STACKLEAK + DISABLE_STACKLEAK_PLUGIN += -fplugin-arg-stackleak_plugin-disable +endif +export DISABLE_STACKLEAK_PLUGIN + +gcc-plugin-$(CONFIG_GCC_PLUGIN_ARM_SSP_PER_TASK) += arm_ssp_per_task_plugin.so +ifdef CONFIG_GCC_PLUGIN_ARM_SSP_PER_TASK + DISABLE_ARM_SSP_PER_TASK_PLUGIN += -fplugin-arg-arm_ssp_per_task_plugin-disable +endif +export DISABLE_ARM_SSP_PER_TASK_PLUGIN + +# All the plugin CFLAGS are collected here in case a build target needs to +# filter them out of the KBUILD_CFLAGS. +GCC_PLUGINS_CFLAGS := $(strip $(addprefix -fplugin=$(objtree)/scripts/gcc-plugins/, $(gcc-plugin-y)) $(gcc-plugin-cflags-y)) +# The sancov_plugin.so is included via CFLAGS_KCOV, so it is removed here. +GCC_PLUGINS_CFLAGS := $(filter-out %/sancov_plugin.so, $(GCC_PLUGINS_CFLAGS)) +export GCC_PLUGINS_CFLAGS + +# Add the flags to the build! +KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS) + +# All enabled GCC plugins are collected here for building below. +GCC_PLUGIN := $(gcc-plugin-y) +export GCC_PLUGIN diff --git a/xen/scripts/Makefile.headersinst b/xen/scripts/Makefile.headersinst new file mode 100644 index 000000000000..1b405a7ed14f --- /dev/null +++ b/xen/scripts/Makefile.headersinst @@ -0,0 +1,102 @@ +# SPDX-License-Identifier: GPL-2.0 +# ========================================================================== +# Installing headers +# +# All headers under include/uapi, include/generated/uapi, +# arch//include/uapi and arch//include/generated/uapi are +# exported. +# They are preprocessed to remove __KERNEL__ section of the file. +# +# ========================================================================== + +PHONY := __headers +__headers: + +include scripts/Kbuild.include + +src := $(srctree)/$(obj) +gen := $(objtree)/$(subst include/,include/generated/,$(obj)) +dst := usr/include + +-include $(src)/Kbuild + +# $(filter %/, ...) is a workaround for GNU Make <= 4.2.1, where +# $(wildcard $(src)/*/) contains not only directories but also regular files. +src-subdirs := $(patsubst $(src)/%/,%,$(filter %/, $(wildcard $(src)/*/))) +gen-subdirs := $(patsubst $(gen)/%/,%,$(filter %/, $(wildcard $(gen)/*/))) +all-subdirs := $(sort $(src-subdirs) $(gen-subdirs)) + +src-headers := $(if $(src-subdirs), $(shell cd $(src) && find $(src-subdirs) -name '*.h')) +src-headers := $(filter-out $(no-export-headers), $(src-headers)) +gen-headers := $(if $(gen-subdirs), $(shell cd $(gen) && find $(gen-subdirs) -name '*.h')) +gen-headers := $(filter-out $(no-export-headers), $(gen-headers)) + +# If the same header is exported from source and generated directories, +# the former takes precedence, but this should be warned. +duplicated := $(filter $(gen-headers), $(src-headers)) +$(if $(duplicated), $(warning duplicated header export: $(duplicated))) + +gen-headers := $(filter-out $(duplicated), $(gen-headers)) + +# Add dst path prefix +all-subdirs := $(addprefix $(dst)/, $(all-subdirs)) +src-headers := $(addprefix $(dst)/, $(src-headers)) +gen-headers := $(addprefix $(dst)/, $(gen-headers)) +all-headers := $(src-headers) $(gen-headers) + +# Work out what needs to be removed +old-subdirs := $(wildcard $(all-subdirs)) +old-headers := $(if $(old-subdirs),$(shell find $(old-subdirs) -name '*.h')) +unwanted := $(filter-out $(all-headers), $(old-headers)) + +# Create directories +existing-dirs := $(sort $(dir $(old-headers))) +wanted-dirs := $(sort $(dir $(all-headers))) +new-dirs := $(filter-out $(existing-dirs), $(wanted-dirs)) +$(if $(new-dirs), $(shell mkdir -p $(new-dirs))) + +# Rules + +ifndef HDRCHECK + +quiet_cmd_install = HDRINST $@ + cmd_install = $(CONFIG_SHELL) $(srctree)/scripts/headers_install.sh $< $@ + +$(src-headers): $(dst)/%.h: $(src)/%.h $(srctree)/scripts/headers_install.sh FORCE + $(call if_changed,install) + +$(gen-headers): $(dst)/%.h: $(gen)/%.h $(srctree)/scripts/headers_install.sh FORCE + $(call if_changed,install) + +quiet_cmd_remove = REMOVE $(unwanted) + cmd_remove = rm -f $(unwanted) + +__headers: $(all-headers) +ifneq ($(unwanted),) + $(call cmd,remove) +endif + @: + +existing-headers := $(filter $(old-headers), $(all-headers)) + +-include $(foreach f,$(existing-headers),$(dir $(f)).$(notdir $(f)).cmd) + +else + +quiet_cmd_check = HDRCHK $< + cmd_check = $(PERL) $(srctree)/scripts/headers_check.pl $(dst) $(SRCARCH) $<; touch $@ + +check-files := $(addsuffix .chk, $(all-headers)) + +$(check-files): $(dst)/%.chk : $(dst)/% $(srctree)/scripts/headers_check.pl + $(call cmd,check) + +__headers: $(check-files) + @: + +endif + +PHONY += FORCE +FORCE: + +.PHONY: $(PHONY) diff --git a/xen/scripts/Makefile.host b/xen/scripts/Makefile.host new file mode 100644 index 000000000000..2208ebbd8c4c --- /dev/null +++ b/xen/scripts/Makefile.host @@ -0,0 +1,164 @@ +# SPDX-License-Identifier: GPL-2.0 +# ========================================================================== +# Building binaries on the host system +# Binaries are used during the compilation of the kernel, for example +# to preprocess a data file. +# +# Both C and C++ are supported, but preferred language is C for such utilities. +# +# Sample syntax (see Documentation/kbuild/makefiles.rst for reference) +# hostprogs-y := bin2hex +# Will compile bin2hex.c and create an executable named bin2hex +# +# hostprogs-y := lxdialog +# lxdialog-objs := checklist.o lxdialog.o +# Will compile lxdialog.c and checklist.c, and then link the executable +# lxdialog, based on checklist.o and lxdialog.o +# +# hostprogs-y := qconf +# qconf-cxxobjs := qconf.o +# qconf-objs := menu.o +# Will compile qconf as a C++ program, and menu as a C program. +# They are linked as C++ code to the executable qconf + +__hostprogs := $(sort $(hostprogs-y) $(hostprogs-m)) +host-cshlib := $(sort $(hostlibs-y) $(hostlibs-m)) +host-cxxshlib := $(sort $(hostcxxlibs-y) $(hostcxxlibs-m)) + +# C code +# Executables compiled from a single .c file +host-csingle := $(foreach m,$(__hostprogs), \ + $(if $($(m)-objs)$($(m)-cxxobjs),,$(m))) + +# C executables linked based on several .o files +host-cmulti := $(foreach m,$(__hostprogs),\ + $(if $($(m)-cxxobjs),,$(if $($(m)-objs),$(m)))) + +# Object (.o) files compiled from .c files +host-cobjs := $(sort $(foreach m,$(__hostprogs),$($(m)-objs))) + +# C++ code +# C++ executables compiled from at least one .cc file +# and zero or more .c files +host-cxxmulti := $(foreach m,$(__hostprogs),$(if $($(m)-cxxobjs),$(m))) + +# C++ Object (.o) files compiled from .cc files +host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs))) + +# Object (.o) files used by the shared libaries +host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs)))) +host-cxxshobjs := $(sort $(foreach m,$(host-cxxshlib),$($(m:.so=-objs)))) + +host-csingle := $(addprefix $(obj)/,$(host-csingle)) +host-cmulti := $(addprefix $(obj)/,$(host-cmulti)) +host-cobjs := $(addprefix $(obj)/,$(host-cobjs)) +host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti)) +host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs)) +host-cshlib := $(addprefix $(obj)/,$(host-cshlib)) +host-cxxshlib := $(addprefix $(obj)/,$(host-cxxshlib)) +host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs)) +host-cxxshobjs := $(addprefix $(obj)/,$(host-cxxshobjs)) + +##### +# Handle options to gcc. Support building with separate output directory + +_hostc_flags = $(KBUILD_HOSTCFLAGS) $(HOST_EXTRACFLAGS) \ + $(HOSTCFLAGS_$(basetarget).o) +_hostcxx_flags = $(KBUILD_HOSTCXXFLAGS) $(HOST_EXTRACXXFLAGS) \ + $(HOSTCXXFLAGS_$(basetarget).o) + +# $(objtree)/$(obj) for including generated headers from checkin source files +ifeq ($(KBUILD_EXTMOD),) +ifdef building_out_of_srctree +_hostc_flags += -I $(objtree)/$(obj) +_hostcxx_flags += -I $(objtree)/$(obj) +endif +endif + +hostc_flags = -Wp,-MD,$(depfile) $(_hostc_flags) +hostcxx_flags = -Wp,-MD,$(depfile) $(_hostcxx_flags) + +##### +# Compile programs on the host + +# Create executable from a single .c file +# host-csingle -> Executable +quiet_cmd_host-csingle = HOSTCC $@ + cmd_host-csingle = $(HOSTCC) $(hostc_flags) $(KBUILD_HOSTLDFLAGS) -o $@ $< \ + $(KBUILD_HOSTLDLIBS) $(HOSTLDLIBS_$(@F)) +$(host-csingle): $(obj)/%: $(src)/%.c FORCE + $(call if_changed_dep,host-csingle) + +# Link an executable based on list of .o files, all plain c +# host-cmulti -> executable +quiet_cmd_host-cmulti = HOSTLD $@ + cmd_host-cmulti = $(HOSTCC) $(KBUILD_HOSTLDFLAGS) -o $@ \ + $(addprefix $(obj)/,$($(@F)-objs)) \ + $(KBUILD_HOSTLDLIBS) $(HOSTLDLIBS_$(@F)) +$(host-cmulti): FORCE + $(call if_changed,host-cmulti) +$(call multi_depend, $(host-cmulti), , -objs) + +# Create .o file from a single .c file +# host-cobjs -> .o +quiet_cmd_host-cobjs = HOSTCC $@ + cmd_host-cobjs = $(HOSTCC) $(hostc_flags) -c -o $@ $< +$(host-cobjs): $(obj)/%.o: $(src)/%.c FORCE + $(call if_changed_dep,host-cobjs) + +# Link an executable based on list of .o files, a mixture of .c and .cc +# host-cxxmulti -> executable +quiet_cmd_host-cxxmulti = HOSTLD $@ + cmd_host-cxxmulti = $(HOSTCXX) $(KBUILD_HOSTLDFLAGS) -o $@ \ + $(foreach o,objs cxxobjs,\ + $(addprefix $(obj)/,$($(@F)-$(o)))) \ + $(KBUILD_HOSTLDLIBS) $(HOSTLDLIBS_$(@F)) +$(host-cxxmulti): FORCE + $(call if_changed,host-cxxmulti) +$(call multi_depend, $(host-cxxmulti), , -objs -cxxobjs) + +# Create .o file from a single .cc (C++) file +quiet_cmd_host-cxxobjs = HOSTCXX $@ + cmd_host-cxxobjs = $(HOSTCXX) $(hostcxx_flags) -c -o $@ $< +$(host-cxxobjs): $(obj)/%.o: $(src)/%.cc FORCE + $(call if_changed_dep,host-cxxobjs) + +# Compile .c file, create position independent .o file +# host-cshobjs -> .o +quiet_cmd_host-cshobjs = HOSTCC -fPIC $@ + cmd_host-cshobjs = $(HOSTCC) $(hostc_flags) -fPIC -c -o $@ $< +$(host-cshobjs): $(obj)/%.o: $(src)/%.c FORCE + $(call if_changed_dep,host-cshobjs) + +# Compile .c file, create position independent .o file +# Note that plugin capable gcc versions can be either C or C++ based +# therefore plugin source files have to be compilable in both C and C++ mode. +# This is why a C++ compiler is invoked on a .c file. +# host-cxxshobjs -> .o +quiet_cmd_host-cxxshobjs = HOSTCXX -fPIC $@ + cmd_host-cxxshobjs = $(HOSTCXX) $(hostcxx_flags) -fPIC -c -o $@ $< +$(host-cxxshobjs): $(obj)/%.o: $(src)/%.c FORCE + $(call if_changed_dep,host-cxxshobjs) + +# Link a shared library, based on position independent .o files +# *.o -> .so shared library (host-cshlib) +quiet_cmd_host-cshlib = HOSTLLD -shared $@ + cmd_host-cshlib = $(HOSTCC) $(KBUILD_HOSTLDFLAGS) -shared -o $@ \ + $(addprefix $(obj)/,$($(@F:.so=-objs))) \ + $(KBUILD_HOSTLDLIBS) $(HOSTLDLIBS_$(@F)) +$(host-cshlib): FORCE + $(call if_changed,host-cshlib) +$(call multi_depend, $(host-cshlib), .so, -objs) + +# Link a shared library, based on position independent .o files +# *.o -> .so shared library (host-cxxshlib) +quiet_cmd_host-cxxshlib = HOSTLLD -shared $@ + cmd_host-cxxshlib = $(HOSTCXX) $(KBUILD_HOSTLDFLAGS) -shared -o $@ \ + $(addprefix $(obj)/,$($(@F:.so=-objs))) \ + $(KBUILD_HOSTLDLIBS) $(HOSTLDLIBS_$(@F)) +$(host-cxxshlib): FORCE + $(call if_changed,host-cxxshlib) +$(call multi_depend, $(host-cxxshlib), .so, -objs) + +targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\ + $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs) $(host-cxxshlib) $(host-cxxshobjs) diff --git a/xen/scripts/Makefile.kasan b/xen/scripts/Makefile.kasan new file mode 100644 index 000000000000..6410bd22fe38 --- /dev/null +++ b/xen/scripts/Makefile.kasan @@ -0,0 +1,51 @@ +# SPDX-License-Identifier: GPL-2.0 +ifdef CONFIG_KASAN_GENERIC + +ifdef CONFIG_KASAN_INLINE + call_threshold := 10000 +else + call_threshold := 0 +endif + +KASAN_SHADOW_OFFSET ?= $(CONFIG_KASAN_SHADOW_OFFSET) + +CFLAGS_KASAN_MINIMAL := -fsanitize=kernel-address + +cc-param = $(call cc-option, -mllvm -$(1), $(call cc-option, --param $(1))) + +# -fasan-shadow-offset fails without -fsanitize +CFLAGS_KASAN_SHADOW := $(call cc-option, -fsanitize=kernel-address \ + -fasan-shadow-offset=$(KASAN_SHADOW_OFFSET), \ + $(call cc-option, -fsanitize=kernel-address \ + -mllvm -asan-mapping-offset=$(KASAN_SHADOW_OFFSET))) + +ifeq ($(strip $(CFLAGS_KASAN_SHADOW)),) + CFLAGS_KASAN := $(CFLAGS_KASAN_MINIMAL) +else + # Now add all the compiler specific options that are valid standalone + CFLAGS_KASAN := $(CFLAGS_KASAN_SHADOW) \ + $(call cc-param,asan-globals=1) \ + $(call cc-param,asan-instrumentation-with-call-threshold=$(call_threshold)) \ + $(call cc-param,asan-stack=$(CONFIG_KASAN_STACK)) \ + $(call cc-param,asan-instrument-allocas=1) +endif + +endif # CONFIG_KASAN_GENERIC + +ifdef CONFIG_KASAN_SW_TAGS + +ifdef CONFIG_KASAN_INLINE + instrumentation_flags := -mllvm -hwasan-mapping-offset=$(KASAN_SHADOW_OFFSET) +else + instrumentation_flags := -mllvm -hwasan-instrument-with-calls=1 +endif + +CFLAGS_KASAN := -fsanitize=kernel-hwaddress \ + -mllvm -hwasan-instrument-stack=0 \ + $(instrumentation_flags) + +endif # CONFIG_KASAN_SW_TAGS + +ifdef CONFIG_KASAN +CFLAGS_KASAN_NOSANITIZE := -fno-builtin +endif diff --git a/xen/scripts/Makefile.kcov b/xen/scripts/Makefile.kcov new file mode 100644 index 000000000000..52b113302443 --- /dev/null +++ b/xen/scripts/Makefile.kcov @@ -0,0 +1,10 @@ +# SPDX-License-Identifier: GPL-2.0-only +ifdef CONFIG_KCOV + +kcov-flags-$(CONFIG_CC_HAS_SANCOV_TRACE_PC) += -fsanitize-coverage=trace-pc +kcov-flags-$(CONFIG_KCOV_ENABLE_COMPARISONS) += -fsanitize-coverage=trace-cmp +kcov-flags-$(CONFIG_GCC_PLUGIN_SANCOV) += -fplugin=$(objtree)/scripts/gcc-plugins/sancov_plugin.so + +export CFLAGS_KCOV := $(kcov-flags-y) + +endif diff --git a/xen/scripts/Makefile.lib b/xen/scripts/Makefile.lib new file mode 100644 index 000000000000..41c50f9461e5 --- /dev/null +++ b/xen/scripts/Makefile.lib @@ -0,0 +1,435 @@ +# SPDX-License-Identifier: GPL-2.0 +# Backward compatibility +asflags-y += $(EXTRA_AFLAGS) +ccflags-y += $(EXTRA_CFLAGS) +cppflags-y += $(EXTRA_CPPFLAGS) +ldflags-y += $(EXTRA_LDFLAGS) + +# flags that take effect in current and sub directories +KBUILD_AFLAGS += $(subdir-asflags-y) +KBUILD_CFLAGS += $(subdir-ccflags-y) + +# Figure out what we need to build from the various variables +# =========================================================================== + +# When an object is listed to be built compiled-in and modular, +# only build the compiled-in version +obj-m := $(filter-out $(obj-y),$(obj-m)) + +# Libraries are always collected in one lib file. +# Filter out objects already built-in +lib-y := $(filter-out $(obj-y), $(sort $(lib-y) $(lib-m))) + +# Determine modorder. +# Unfortunately, we don't have information about ordering between -y +# and -m subdirs. Just put -y's first. +modorder := $(patsubst %/,%/modules.order, $(filter %/, $(obj-y)) $(obj-m:.o=.ko)) + +# Handle objects in subdirs +# --------------------------------------------------------------------------- +# o if we encounter foo/ in $(obj-y), replace it by foo/built-in.a +# and add the directory to the list of dirs to descend into: $(subdir-y) +# o if we encounter foo/ in $(obj-m), remove it from $(obj-m) +# and add the directory to the list of dirs to descend into: $(subdir-m) +__subdir-y := $(patsubst %/,%,$(filter %/, $(obj-y))) +subdir-y += $(__subdir-y) +__subdir-m := $(patsubst %/,%,$(filter %/, $(obj-m))) +subdir-m += $(__subdir-m) +obj-y := $(patsubst %/, %/built-in.a, $(obj-y)) +obj-m := $(filter-out %/, $(obj-m)) + +# Subdirectories we need to descend into +subdir-ym := $(sort $(subdir-y) $(subdir-m)) + +# if $(foo-objs), $(foo-y), or $(foo-m) exists, foo.o is a composite object +multi-used-y := $(sort $(foreach m,$(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))), $(m)))) +multi-used-m := $(sort $(foreach m,$(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m))), $(m)))) +multi-used := $(multi-used-y) $(multi-used-m) + +# $(subdir-obj-y) is the list of objects in $(obj-y) which uses dir/ to +# tell kbuild to descend +subdir-obj-y := $(filter %/built-in.a, $(obj-y)) + +# Replace multi-part objects by their individual parts, +# including built-in.a from subdirectories +real-obj-y := $(foreach m, $(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m))) +real-obj-m := $(foreach m, $(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m))),$($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m)),$(m))) + +# DTB +# If CONFIG_OF_ALL_DTBS is enabled, all DT blobs are built +extra-y += $(dtb-y) +extra-$(CONFIG_OF_ALL_DTBS) += $(dtb-) + +ifneq ($(CHECK_DTBS),) +extra-y += $(patsubst %.dtb,%.dt.yaml, $(dtb-y)) +extra-$(CONFIG_OF_ALL_DTBS) += $(patsubst %.dtb,%.dt.yaml, $(dtb-)) +endif + +# Test self-contained headers + +# Wildcard searches in $(srctree)/$(src)/, but not in $(objtree)/$(obj)/. +# Stale generated headers are often left over, so pattern matching should +# be avoided. Please notice $(srctree)/$(src)/ and $(objtree)/$(obj) point +# to the same location for in-tree building. So, header-test-pattern-y should +# be used with care. +header-test-y += $(filter-out $(header-test-), \ + $(patsubst $(srctree)/$(src)/%, %, \ + $(wildcard $(addprefix $(srctree)/$(src)/, \ + $(header-test-pattern-y))))) + +extra-$(CONFIG_HEADER_TEST) += $(addsuffix .s, $(header-test-y) $(header-test-m)) + +# Add subdir path + +extra-y := $(addprefix $(obj)/,$(extra-y)) +always := $(addprefix $(obj)/,$(always)) +targets := $(addprefix $(obj)/,$(targets)) +modorder := $(addprefix $(obj)/,$(modorder)) +obj-m := $(addprefix $(obj)/,$(obj-m)) +lib-y := $(addprefix $(obj)/,$(lib-y)) +subdir-obj-y := $(addprefix $(obj)/,$(subdir-obj-y)) +real-obj-y := $(addprefix $(obj)/,$(real-obj-y)) +real-obj-m := $(addprefix $(obj)/,$(real-obj-m)) +multi-used-m := $(addprefix $(obj)/,$(multi-used-m)) +subdir-ym := $(addprefix $(obj)/,$(subdir-ym)) + +# Finds the multi-part object the current object will be linked into. +# If the object belongs to two or more multi-part objects, all of them are +# concatenated with a colon separator. +modname-multi = $(subst $(space),:,$(sort $(foreach m,$(multi-used),\ + $(if $(filter $*.o, $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m))),$(m:.o=))))) + +modname = $(if $(modname-multi),$(modname-multi),$(basetarget)) + +# These flags are needed for modversions and compiling, so we define them here +# $(modname_flags) defines KBUILD_MODNAME as the name of the module it will +# end up in (or would, if it gets compiled in) +name-fix = $(squote)$(quote)$(subst $(comma),_,$(subst -,_,$1))$(quote)$(squote) +basename_flags = -DKBUILD_BASENAME=$(call name-fix,$(basetarget)) +modname_flags = -DKBUILD_MODNAME=$(call name-fix,$(modname)) + +orig_c_flags = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) \ + $(ccflags-y) $(CFLAGS_$(basetarget).o) +_c_flags = $(filter-out $(CFLAGS_REMOVE_$(basetarget).o), $(orig_c_flags)) +orig_a_flags = $(KBUILD_CPPFLAGS) $(KBUILD_AFLAGS) \ + $(asflags-y) $(AFLAGS_$(basetarget).o) +_a_flags = $(filter-out $(AFLAGS_REMOVE_$(basetarget).o), $(orig_a_flags)) +_cpp_flags = $(KBUILD_CPPFLAGS) $(cppflags-y) $(CPPFLAGS_$(@F)) + +# +# Enable gcov profiling flags for a file, directory or for all files depending +# on variables GCOV_PROFILE_obj.o, GCOV_PROFILE and CONFIG_GCOV_PROFILE_ALL +# (in this order) +# +ifeq ($(CONFIG_GCOV_KERNEL),y) +_c_flags += $(if $(patsubst n%,, \ + $(GCOV_PROFILE_$(basetarget).o)$(GCOV_PROFILE)$(CONFIG_GCOV_PROFILE_ALL)), \ + $(CFLAGS_GCOV)) +endif + +# +# Enable address sanitizer flags for kernel except some files or directories +# we don't want to check (depends on variables KASAN_SANITIZE_obj.o, KASAN_SANITIZE) +# +ifeq ($(CONFIG_KASAN),y) +_c_flags += $(if $(patsubst n%,, \ + $(KASAN_SANITIZE_$(basetarget).o)$(KASAN_SANITIZE)y), \ + $(CFLAGS_KASAN), $(CFLAGS_KASAN_NOSANITIZE)) +endif + +ifeq ($(CONFIG_UBSAN),y) +_c_flags += $(if $(patsubst n%,, \ + $(UBSAN_SANITIZE_$(basetarget).o)$(UBSAN_SANITIZE)$(CONFIG_UBSAN_SANITIZE_ALL)), \ + $(CFLAGS_UBSAN)) +endif + +ifeq ($(CONFIG_KCOV),y) +_c_flags += $(if $(patsubst n%,, \ + $(KCOV_INSTRUMENT_$(basetarget).o)$(KCOV_INSTRUMENT)$(CONFIG_KCOV_INSTRUMENT_ALL)), \ + $(CFLAGS_KCOV)) +endif + +# $(srctree)/$(src) for including checkin headers from generated source files +# $(objtree)/$(obj) for including generated headers from checkin source files +ifeq ($(KBUILD_EXTMOD),) +ifdef building_out_of_srctree +_c_flags += -I $(srctree)/$(src) -I $(objtree)/$(obj) +_a_flags += -I $(srctree)/$(src) -I $(objtree)/$(obj) +_cpp_flags += -I $(srctree)/$(src) -I $(objtree)/$(obj) +endif +endif + +c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ + -include $(srctree)/include/linux/compiler_types.h \ + $(_c_flags) $(modkern_cflags) \ + $(basename_flags) $(modname_flags) + +a_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ + $(_a_flags) $(modkern_aflags) + +cpp_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ + $(_cpp_flags) + +ld_flags = $(KBUILD_LDFLAGS) $(ldflags-y) $(LDFLAGS_$(@F)) + +DTC_INCLUDE := $(srctree)/scripts/dtc/include-prefixes + +dtc_cpp_flags = -Wp,-MD,$(depfile).pre.tmp -nostdinc \ + $(addprefix -I,$(DTC_INCLUDE)) \ + -undef -D__DTS__ + +# Useful for describing the dependency of composite objects +# Usage: +# $(call multi_depend, multi_used_targets, suffix_to_remove, suffix_to_add) +define multi_depend +$(foreach m, $(notdir $1), \ + $(eval $(obj)/$m: \ + $(addprefix $(obj)/, $(foreach s, $3, $($(m:%$(strip $2)=%$(s))))))) +endef + +# LEX +# --------------------------------------------------------------------------- +quiet_cmd_flex = LEX $@ + cmd_flex = $(LEX) -o$@ -L $< + +$(obj)/%.lex.c: $(src)/%.l FORCE + $(call if_changed,flex) + +# YACC +# --------------------------------------------------------------------------- +quiet_cmd_bison = YACC $@ + cmd_bison = $(YACC) -o$@ -t -l $< + +$(obj)/%.tab.c: $(src)/%.y FORCE + $(call if_changed,bison) + +quiet_cmd_bison_h = YACC $@ + cmd_bison_h = $(YACC) -o/dev/null --defines=$@ -t -l $< + +$(obj)/%.tab.h: $(src)/%.y FORCE + $(call if_changed,bison_h) + +# Shipped files +# =========================================================================== + +quiet_cmd_shipped = SHIPPED $@ +cmd_shipped = cat $< > $@ + +$(obj)/%: $(src)/%_shipped + $(call cmd,shipped) + +# Commands useful for building a boot image +# =========================================================================== +# +# Use as following: +# +# target: source(s) FORCE +# $(if_changed,ld/objcopy/gzip) +# +# and add target to extra-y so that we know we have to +# read in the saved command line + +# Linking +# --------------------------------------------------------------------------- + +quiet_cmd_ld = LD $@ + cmd_ld = $(LD) $(ld_flags) $(real-prereqs) -o $@ + +# Archive +# --------------------------------------------------------------------------- + +quiet_cmd_ar = AR $@ + cmd_ar = rm -f $@; $(AR) rcsTP$(KBUILD_ARFLAGS) $@ $(real-prereqs) + +# Objcopy +# --------------------------------------------------------------------------- + +quiet_cmd_objcopy = OBJCOPY $@ +cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@ + +# Gzip +# --------------------------------------------------------------------------- + +quiet_cmd_gzip = GZIP $@ + cmd_gzip = cat $(real-prereqs) | gzip -n -f -9 > $@ + +# DTC +# --------------------------------------------------------------------------- +DTC ?= $(objtree)/scripts/dtc/dtc + +# Disable noisy checks by default +ifeq ($(findstring 1,$(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),) +DTC_FLAGS += -Wno-unit_address_vs_reg \ + -Wno-unit_address_format \ + -Wno-avoid_unnecessary_addr_size \ + -Wno-alias_paths \ + -Wno-graph_child_address \ + -Wno-simple_bus_reg \ + -Wno-unique_unit_address \ + -Wno-pci_device_reg +endif + +ifneq ($(findstring 2,$(KBUILD_ENABLE_EXTRA_GCC_CHECKS)),) +DTC_FLAGS += -Wnode_name_chars_strict \ + -Wproperty_name_chars_strict +endif + +DTC_FLAGS += $(DTC_FLAGS_$(basetarget)) + +# Generate an assembly file to wrap the output of the device tree compiler +quiet_cmd_dt_S_dtb= DTB $@ +cmd_dt_S_dtb= \ +{ \ + echo '\#include '; \ + echo '.section .dtb.init.rodata,"a"'; \ + echo '.balign STRUCT_ALIGNMENT'; \ + echo '.global __dtb_$(subst -,_,$(*F))_begin'; \ + echo '__dtb_$(subst -,_,$(*F))_begin:'; \ + echo '.incbin "$<" '; \ + echo '__dtb_$(subst -,_,$(*F))_end:'; \ + echo '.global __dtb_$(subst -,_,$(*F))_end'; \ + echo '.balign STRUCT_ALIGNMENT'; \ +} > $@ + +$(obj)/%.dtb.S: $(obj)/%.dtb FORCE + $(call if_changed,dt_S_dtb) + +quiet_cmd_dtc = DTC $@ +cmd_dtc = mkdir -p $(dir ${dtc-tmp}) ; \ + $(HOSTCC) -E $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \ + $(DTC) -O $(2) -o $@ -b 0 \ + $(addprefix -i,$(dir $<) $(DTC_INCLUDE)) $(DTC_FLAGS) \ + -d $(depfile).dtc.tmp $(dtc-tmp) ; \ + cat $(depfile).pre.tmp $(depfile).dtc.tmp > $(depfile) + +$(obj)/%.dtb: $(src)/%.dts $(DTC) FORCE + $(call if_changed_dep,dtc,dtb) + +DT_CHECKER ?= dt-validate +DT_BINDING_DIR := Documentation/devicetree/bindings +DT_TMP_SCHEMA := $(objtree)/$(DT_BINDING_DIR)/processed-schema.yaml + +quiet_cmd_dtb_check = CHECK $@ + cmd_dtb_check = $(DT_CHECKER) -u $(srctree)/$(DT_BINDING_DIR) -p $(DT_TMP_SCHEMA) $@ ; + +define rule_dtc_dt_yaml + $(call cmd_and_fixdep,dtc,yaml) + $(call cmd,dtb_check) +endef + +$(obj)/%.dt.yaml: $(src)/%.dts $(DTC) $(DT_TMP_SCHEMA) FORCE + $(call if_changed_rule,dtc_dt_yaml) + +dtc-tmp = $(subst $(comma),_,$(dot-target).dts.tmp) + +# Bzip2 +# --------------------------------------------------------------------------- + +# Bzip2 and LZMA do not include size in file... so we have to fake that; +# append the size as a 32-bit littleendian number as gzip does. +size_append = printf $(shell \ +dec_size=0; \ +for F in $(real-prereqs); do \ + fsize=$$($(CONFIG_SHELL) $(srctree)/scripts/file-size.sh $$F); \ + dec_size=$$(expr $$dec_size + $$fsize); \ +done; \ +printf "%08x\n" $$dec_size | \ + sed 's/\(..\)/\1 /g' | { \ + read ch0 ch1 ch2 ch3; \ + for ch in $$ch3 $$ch2 $$ch1 $$ch0; do \ + printf '%s%03o' '\\' $$((0x$$ch)); \ + done; \ + } \ +) + +quiet_cmd_bzip2 = BZIP2 $@ + cmd_bzip2 = { cat $(real-prereqs) | bzip2 -9; $(size_append); } > $@ + +# Lzma +# --------------------------------------------------------------------------- + +quiet_cmd_lzma = LZMA $@ + cmd_lzma = { cat $(real-prereqs) | lzma -9; $(size_append); } > $@ + +quiet_cmd_lzo = LZO $@ + cmd_lzo = { cat $(real-prereqs) | lzop -9; $(size_append); } > $@ + +quiet_cmd_lz4 = LZ4 $@ + cmd_lz4 = { cat $(real-prereqs) | lz4c -l -c1 stdin stdout; \ + $(size_append); } > $@ + +# U-Boot mkimage +# --------------------------------------------------------------------------- + +MKIMAGE := $(srctree)/scripts/mkuboot.sh + +# SRCARCH just happens to match slightly more than ARCH (on sparc), so reduces +# the number of overrides in arch makefiles +UIMAGE_ARCH ?= $(SRCARCH) +UIMAGE_COMPRESSION ?= $(if $(2),$(2),none) +UIMAGE_OPTS-y ?= +UIMAGE_TYPE ?= kernel +UIMAGE_LOADADDR ?= arch_must_set_this +UIMAGE_ENTRYADDR ?= $(UIMAGE_LOADADDR) +UIMAGE_NAME ?= 'Linux-$(KERNELRELEASE)' + +quiet_cmd_uimage = UIMAGE $@ + cmd_uimage = $(CONFIG_SHELL) $(MKIMAGE) -A $(UIMAGE_ARCH) -O linux \ + -C $(UIMAGE_COMPRESSION) $(UIMAGE_OPTS-y) \ + -T $(UIMAGE_TYPE) \ + -a $(UIMAGE_LOADADDR) -e $(UIMAGE_ENTRYADDR) \ + -n $(UIMAGE_NAME) -d $< $@ + +# XZ +# --------------------------------------------------------------------------- +# Use xzkern to compress the kernel image and xzmisc to compress other things. +# +# xzkern uses a big LZMA2 dictionary since it doesn't increase memory usage +# of the kernel decompressor. A BCJ filter is used if it is available for +# the target architecture. xzkern also appends uncompressed size of the data +# using size_append. The .xz format has the size information available at +# the end of the file too, but it's in more complex format and it's good to +# avoid changing the part of the boot code that reads the uncompressed size. +# Note that the bytes added by size_append will make the xz tool think that +# the file is corrupt. This is expected. +# +# xzmisc doesn't use size_append, so it can be used to create normal .xz +# files. xzmisc uses smaller LZMA2 dictionary than xzkern, because a very +# big dictionary would increase the memory usage too much in the multi-call +# decompression mode. A BCJ filter isn't used either. +quiet_cmd_xzkern = XZKERN $@ + cmd_xzkern = { cat $(real-prereqs) | sh $(srctree)/scripts/xz_wrap.sh; \ + $(size_append); } > $@ + +quiet_cmd_xzmisc = XZMISC $@ + cmd_xzmisc = cat $(real-prereqs) | xz --check=crc32 --lzma2=dict=1MiB > $@ + +# ASM offsets +# --------------------------------------------------------------------------- + +# Default sed regexp - multiline due to syntax constraints +# +# Use [:space:] because LLVM's integrated assembler inserts around +# the .ascii directive whereas GCC keeps the as-is. +define sed-offsets + 's:^[[:space:]]*\.ascii[[:space:]]*"\(.*\)".*:\1:; \ + /^->/{s:->#\(.*\):/* \1 */:; \ + s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \ + s:->::; p;}' +endef + +# Use filechk to avoid rebuilds when a header changes, but the resulting file +# does not +define filechk_offsets + echo "#ifndef $2"; \ + echo "#define $2"; \ + echo "/*"; \ + echo " * DO NOT MODIFY."; \ + echo " *"; \ + echo " * This file was generated by Kbuild"; \ + echo " */"; \ + echo ""; \ + sed -ne $(sed-offsets) < $<; \ + echo ""; \ + echo "#endif" +endef diff --git a/xen/scripts/Makefile.ubsan b/xen/scripts/Makefile.ubsan new file mode 100644 index 000000000000..019771b845c5 --- /dev/null +++ b/xen/scripts/Makefile.ubsan @@ -0,0 +1,19 @@ +# SPDX-License-Identifier: GPL-2.0 +ifdef CONFIG_UBSAN + CFLAGS_UBSAN += $(call cc-option, -fsanitize=shift) + CFLAGS_UBSAN += $(call cc-option, -fsanitize=integer-divide-by-zero) + CFLAGS_UBSAN += $(call cc-option, -fsanitize=unreachable) + CFLAGS_UBSAN += $(call cc-option, -fsanitize=signed-integer-overflow) + CFLAGS_UBSAN += $(call cc-option, -fsanitize=bounds) + CFLAGS_UBSAN += $(call cc-option, -fsanitize=object-size) + CFLAGS_UBSAN += $(call cc-option, -fsanitize=bool) + CFLAGS_UBSAN += $(call cc-option, -fsanitize=enum) + +ifdef CONFIG_UBSAN_ALIGNMENT + CFLAGS_UBSAN += $(call cc-option, -fsanitize=alignment) +endif + + # -fsanitize=* options makes GCC less smart than usual and + # increase number of 'maybe-uninitialized false-positives + CFLAGS_UBSAN += $(call cc-option, -Wno-maybe-uninitialized) +endif diff --git a/xen/scripts/basic/.gitignore b/xen/scripts/basic/.gitignore new file mode 100644 index 000000000000..a776371a3502 --- /dev/null +++ b/xen/scripts/basic/.gitignore @@ -0,0 +1 @@ +fixdep diff --git a/xen/scripts/basic/Makefile b/xen/scripts/basic/Makefile new file mode 100644 index 000000000000..548aeb592806 --- /dev/null +++ b/xen/scripts/basic/Makefile @@ -0,0 +1,16 @@ +# SPDX-License-Identifier: GPL-2.0-only +### +# This Makefile lists the most basic programs used during the build process. +# The programs listed herein are what are needed to do the basic stuff, +# such as fix file dependencies. +# This initial step is needed to avoid files to be recompiled +# when kernel configuration changes (which is what happens when +# .config is included by main Makefile. +# --------------------------------------------------------------------------- +# fixdep: Used to generate dependency information during build process + +hostprogs-y := fixdep +always := $(hostprogs-y) + +# fixdep is needed to compile other host programs +$(addprefix $(obj)/,$(filter-out fixdep,$(always))): $(obj)/fixdep diff --git a/xen/scripts/basic/fixdep.c b/xen/scripts/basic/fixdep.c new file mode 100644 index 000000000000..9ba47b0a47b9 --- /dev/null +++ b/xen/scripts/basic/fixdep.c @@ -0,0 +1,410 @@ +/* + * "Optimize" a list of dependencies as spit out by gcc -MD + * for the kernel build + * =========================================================================== + * + * Author Kai Germaschewski + * Copyright 2002 by Kai Germaschewski + * + * This software may be used and distributed according to the terms + * of the GNU General Public License, incorporated herein by reference. + * + * + * Introduction: + * + * gcc produces a very nice and correct list of dependencies which + * tells make when to remake a file. + * + * To use this list as-is however has the drawback that virtually + * every file in the kernel includes autoconf.h. + * + * If the user re-runs make *config, autoconf.h will be + * regenerated. make notices that and will rebuild every file which + * includes autoconf.h, i.e. basically all files. This is extremely + * annoying if the user just changed CONFIG_HIS_DRIVER from n to m. + * + * So we play the same trick that "mkdep" played before. We replace + * the dependency on autoconf.h by a dependency on every config + * option which is mentioned in any of the listed prerequisites. + * + * kconfig populates a tree in include/config/ with an empty file + * for each config symbol and when the configuration is updated + * the files representing changed config options are touched + * which then let make pick up the changes and the files that use + * the config symbols are rebuilt. + * + * So if the user changes his CONFIG_HIS_DRIVER option, only the objects + * which depend on "include/config/his/driver.h" will be rebuilt, + * so most likely only his driver ;-) + * + * The idea above dates, by the way, back to Michael E Chastain, AFAIK. + * + * So to get dependencies right, there are two issues: + * o if any of the files the compiler read changed, we need to rebuild + * o if the command line given to the compile the file changed, we + * better rebuild as well. + * + * The former is handled by using the -MD output, the later by saving + * the command line used to compile the old object and comparing it + * to the one we would now use. + * + * Again, also this idea is pretty old and has been discussed on + * kbuild-devel a long time ago. I don't have a sensibly working + * internet connection right now, so I rather don't mention names + * without double checking. + * + * This code here has been based partially based on mkdep.c, which + * says the following about its history: + * + * Copyright abandoned, Michael Chastain, . + * This is a C version of syncdep.pl by Werner Almesberger. + * + * + * It is invoked as + * + * fixdep + * + * and will read the dependency file + * + * The transformed dependency snipped is written to stdout. + * + * It first generates a line + * + * cmd_ = + * + * and then basically copies the ..d file to stdout, in the + * process filtering out the dependency on autoconf.h and adding + * dependencies on include/config/my/option.h for every + * CONFIG_MY_OPTION encountered in any of the prerequisites. + * + * It will also filter out all the dependencies on *.ver. We need + * to make sure that the generated version checksum are globally up + * to date before even starting the recursive build, so it's too late + * at this point anyway. + * + * We don't even try to really parse the header files, but + * merely grep, i.e. if CONFIG_FOO is mentioned in a comment, it will + * be picked up as well. It's not a problem with respect to + * correctness, since that can only give too many dependencies, thus + * we cannot miss a rebuild. Since people tend to not mention totally + * unrelated CONFIG_ options all over the place, it's not an + * efficiency problem either. + * + * (Note: it'd be easy to port over the complete mkdep state machine, + * but I don't think the added complexity is worth it) + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static void usage(void) +{ + fprintf(stderr, "Usage: fixdep \n"); + exit(1); +} + +/* + * In the intended usage of this program, the stdout is redirected to .*.cmd + * files. The return value of printf() and putchar() must be checked to catch + * any error, e.g. "No space left on device". + */ +static void xprintf(const char *format, ...) +{ + va_list ap; + int ret; + + va_start(ap, format); + ret = vprintf(format, ap); + if (ret < 0) { + perror("fixdep"); + exit(1); + } + va_end(ap); +} + +static void xputchar(int c) +{ + int ret; + + ret = putchar(c); + if (ret == EOF) { + perror("fixdep"); + exit(1); + } +} + +/* + * Print out a dependency path from a symbol name + */ +static void print_dep(const char *m, int slen, const char *dir) +{ + int c, prev_c = '/', i; + + xprintf(" $(wildcard %s/", dir); + for (i = 0; i < slen; i++) { + c = m[i]; + if (c == '_') + c = '/'; + else + c = tolower(c); + if (c != '/' || prev_c != '/') + xputchar(c); + prev_c = c; + } + xprintf(".h) \\\n"); +} + +struct item { + struct item *next; + unsigned int len; + unsigned int hash; + char name[0]; +}; + +#define HASHSZ 256 +static struct item *hashtab[HASHSZ]; + +static unsigned int strhash(const char *str, unsigned int sz) +{ + /* fnv32 hash */ + unsigned int i, hash = 2166136261U; + + for (i = 0; i < sz; i++) + hash = (hash ^ str[i]) * 0x01000193; + return hash; +} + +/* + * Lookup a value in the configuration string. + */ +static int is_defined_config(const char *name, int len, unsigned int hash) +{ + struct item *aux; + + for (aux = hashtab[hash % HASHSZ]; aux; aux = aux->next) { + if (aux->hash == hash && aux->len == len && + memcmp(aux->name, name, len) == 0) + return 1; + } + return 0; +} + +/* + * Add a new value to the configuration string. + */ +static void define_config(const char *name, int len, unsigned int hash) +{ + struct item *aux = malloc(sizeof(*aux) + len); + + if (!aux) { + perror("fixdep:malloc"); + exit(1); + } + memcpy(aux->name, name, len); + aux->len = len; + aux->hash = hash; + aux->next = hashtab[hash % HASHSZ]; + hashtab[hash % HASHSZ] = aux; +} + +/* + * Record the use of a CONFIG_* word. + */ +static void use_config(const char *m, int slen) +{ + unsigned int hash = strhash(m, slen); + + if (is_defined_config(m, slen, hash)) + return; + + define_config(m, slen, hash); + print_dep(m, slen, "include/config"); +} + +/* test if s ends in sub */ +static int str_ends_with(const char *s, int slen, const char *sub) +{ + int sublen = strlen(sub); + + if (sublen > slen) + return 0; + + return !memcmp(s + slen - sublen, sub, sublen); +} + +static void parse_config_file(const char *p) +{ + const char *q, *r; + const char *start = p; + + while ((p = strstr(p, "CONFIG_"))) { + if (p > start && (isalnum(p[-1]) || p[-1] == '_')) { + p += 7; + continue; + } + p += 7; + q = p; + while (*q && (isalnum(*q) || *q == '_')) + q++; + if (str_ends_with(p, q - p, "_MODULE")) + r = q - 7; + else + r = q; + if (r > p) + use_config(p, r - p); + p = q; + } +} + +static void *read_file(const char *filename) +{ + struct stat st; + int fd; + char *buf; + + fd = open(filename, O_RDONLY); + if (fd < 0) { + fprintf(stderr, "fixdep: error opening file: "); + perror(filename); + exit(2); + } + if (fstat(fd, &st) < 0) { + fprintf(stderr, "fixdep: error fstat'ing file: "); + perror(filename); + exit(2); + } + buf = malloc(st.st_size + 1); + if (!buf) { + perror("fixdep: malloc"); + exit(2); + } + if (read(fd, buf, st.st_size) != st.st_size) { + perror("fixdep: read"); + exit(2); + } + buf[st.st_size] = '\0'; + close(fd); + + return buf; +} + +/* Ignore certain dependencies */ +static int is_ignored_file(const char *s, int len) +{ + return str_ends_with(s, len, "include/generated/autoconf.h") || + str_ends_with(s, len, "include/generated/autoksyms.h") || + str_ends_with(s, len, ".ver"); +} + +/* + * Important: The below generated source_foo.o and deps_foo.o variable + * assignments are parsed not only by make, but also by the rather simple + * parser in scripts/mod/sumversion.c. + */ +static void parse_dep_file(char *m, const char *target) +{ + char *p; + int is_last, is_target; + int saw_any_target = 0; + int is_first_dep = 0; + void *buf; + + while (1) { + /* Skip any "white space" */ + while (*m == ' ' || *m == '\\' || *m == '\n') + m++; + + if (!*m) + break; + + /* Find next "white space" */ + p = m; + while (*p && *p != ' ' && *p != '\\' && *p != '\n') + p++; + is_last = (*p == '\0'); + /* Is the token we found a target name? */ + is_target = (*(p-1) == ':'); + /* Don't write any target names into the dependency file */ + if (is_target) { + /* The /next/ file is the first dependency */ + is_first_dep = 1; + } else if (!is_ignored_file(m, p - m)) { + *p = '\0'; + + /* + * Do not list the source file as dependency, so that + * kbuild is not confused if a .c file is rewritten + * into .S or vice versa. Storing it in source_* is + * needed for modpost to compute srcversions. + */ + if (is_first_dep) { + /* + * If processing the concatenation of multiple + * dependency files, only process the first + * target name, which will be the original + * source name, and ignore any other target + * names, which will be intermediate temporary + * files. + */ + if (!saw_any_target) { + saw_any_target = 1; + xprintf("source_%s := %s\n\n", + target, m); + xprintf("deps_%s := \\\n", target); + } + is_first_dep = 0; + } else { + xprintf(" %s \\\n", m); + } + + buf = read_file(m); + parse_config_file(buf); + free(buf); + } + + if (is_last) + break; + + /* + * Start searching for next token immediately after the first + * "whitespace" character that follows this token. + */ + m = p + 1; + } + + if (!saw_any_target) { + fprintf(stderr, "fixdep: parse error; no targets found\n"); + exit(1); + } + + xprintf("\n%s: $(deps_%s)\n\n", target, target); + xprintf("$(deps_%s):\n", target); +} + +int main(int argc, char *argv[]) +{ + const char *depfile, *target, *cmdline; + void *buf; + + if (argc != 4) + usage(); + + depfile = argv[1]; + target = argv[2]; + cmdline = argv[3]; + + xprintf("cmd_%s := %s\n\n", target, cmdline); + + buf = read_file(depfile); + parse_dep_file(buf, target); + free(buf); + + return 0; +} diff --git a/xen/scripts/mkmakefile b/xen/scripts/mkmakefile new file mode 100755 index 000000000000..4d0faebb1719 --- /dev/null +++ b/xen/scripts/mkmakefile @@ -0,0 +1,17 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# Generates a small Makefile used in the root of the output +# directory, to allow make to be started from there. +# The Makefile also allow for more convinient build of external modules + +# Usage +# $1 - Kernel src directory + +if [ "${quiet}" != "silent_" ]; then + echo " GEN Makefile" +fi + +cat << EOF > Makefile +# Automatically generated by $(realpath $0): don't edit +include $(realpath $1/Makefile) +EOF From patchwork Wed Oct 23 16:48:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 11207219 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6B85F112B for ; Wed, 23 Oct 2019 16:50:07 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 470EB21906 for ; Wed, 23 Oct 2019 16:50:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="bWxSLQX2" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 470EB21906 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNJoR-0007O1-Ff; Wed, 23 Oct 2019 16:48:43 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNJoQ-0007Ns-Fb for xen-devel@lists.xenproject.org; Wed, 23 Oct 2019 16:48:42 +0000 X-Inumbo-ID: f7956bee-f5b4-11e9-8aca-bc764e2007e4 Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id f7956bee-f5b4-11e9-8aca-bc764e2007e4; Wed, 23 Oct 2019 16:48:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1571849321; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZYTzn5O48B3iY841/piidmycHXTvRCe/DVdR+RGMjkE=; b=bWxSLQX2fN3VfkT3sgEo2jlv7x9mVEd9UweBk6jgalV5v8ZH5jwbT7d6 co62wvNZfQ8xLQXE46vKqpLDl9TLDIiXYMd/fHXG0713cXd8pblFc+AUL wQKwyPcxjePc5A/llJGJhiZvueeXDGRPXcTU6c8GORl2oq2sJjhWIij9h 4=; Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=anthony.perard@citrix.com; spf=Pass smtp.mailfrom=anthony.perard@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa4.hc3370-68.iphmx.com: no sender authenticity information available from domain of anthony.perard@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa4.hc3370-68.iphmx.com: domain of anthony.perard@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa4.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: qWiFIBRKQejgETHiIT0InDgQpjmBdkj0g+LtLnd29Xy0zXsA6tHybVS+Mj2FHSwhljh0kUd94k uBd9ocrhYdZX/Up+PLtMLbvB2VNBwLeIuGIZkjlqYkTLXj1ATDRH8MBkglUESDKzzJGAA9JAfn 9atfD1T6G4Hyb/BWdAJqfHKBup4fhy2gAMHw+8bvFHGtW3gsOxcuVkGdO/ambaJyj6UfS3aoZi 1XSxYjGSrN25RYjTQLG44yDWJx1ASS2Jiqz8PURyk3mwPsDKBlbGIBORZ4Mavm53upny04vGjN Za4= X-SBRS: 2.7 X-MesageID: 7778029 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.68,221,1569297600"; d="scan'208";a="7778029" From: Anthony PERARD To: Date: Wed, 23 Oct 2019 17:48:19 +0100 Message-ID: <20191023164837.2700240-6-anthony.perard@citrix.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191023164837.2700240-1-anthony.perard@citrix.com> References: <20191023164837.2700240-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [RFC XEN PATCH 05/23] xen: Kbuild: Remove extra -include from C flags X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Anthony PERARD Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Kbuild includes linux/compiler_types.h into the CFLAGS list, but Xen don't need that. Signed-off-by: Anthony PERARD --- xen/scripts/Makefile.lib | 1 - 1 file changed, 1 deletion(-) diff --git a/xen/scripts/Makefile.lib b/xen/scripts/Makefile.lib index 41c50f9461e5..b746199b7f6b 100644 --- a/xen/scripts/Makefile.lib +++ b/xen/scripts/Makefile.lib @@ -160,7 +160,6 @@ endif endif c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ - -include $(srctree)/include/linux/compiler_types.h \ $(_c_flags) $(modkern_cflags) \ $(basename_flags) $(modname_flags) From patchwork Wed Oct 23 16:48:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 11207225 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 69EB81515 for ; Wed, 23 Oct 2019 16:50:08 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 464A821925 for ; Wed, 23 Oct 2019 16:50:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="YyG5d4TN" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 464A821925 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNJoW-0007OL-OH; Wed, 23 Oct 2019 16:48:48 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNJoV-0007OC-FL for xen-devel@lists.xenproject.org; Wed, 23 Oct 2019 16:48:47 +0000 X-Inumbo-ID: f8262972-f5b4-11e9-beca-bc764e2007e4 Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id f8262972-f5b4-11e9-beca-bc764e2007e4; Wed, 23 Oct 2019 16:48:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1571849322; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jtXtAC2JzvQtQkNrbbAgn69NPPK0O23isaUX6kj9pmI=; b=YyG5d4TNYa4+Je+y0C4rXa3jnPciYchj6lsv4Q5FIa/scSiGI1gH/7Ft mw/3xH68scCfzUYD9Iw9wh9MfyEN22jwtIxG8jKBprfTcGXmPQ4ql7eLG BjhcZyeQ3zDhGFTCnmOYQwyXuAGhBLMirDVLLzZyNtSQ99EwZkGLIuZjV Y=; Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=anthony.perard@citrix.com; spf=Pass smtp.mailfrom=anthony.perard@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa4.hc3370-68.iphmx.com: no sender authenticity information available from domain of anthony.perard@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa4.hc3370-68.iphmx.com: domain of anthony.perard@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa4.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: uhgN+IsIj0DNv9WjgAIvyenoYBmeQvn47XmMSMt+GTovarMynXO+Z+BHE/uJEPxnJYQwxEbP8s 3H7Lw04HuuR+Z/e+5c4Gg0Y7HVMu0CTRFwQAs8cKXK1lsV04pgruul0kRnghMbxypFfosl1Ecr +V+rQhTYQNlDc6TA6uyMwghuQ1dxUJbIwiMqHeT38RebWHQGE1BQ56Gh5tdY5p5MRyiRksoFtQ +iq1ezNnnCC5oyJXJgmJqg5O+M1cAJKXsfAcyGjW5wQ54pmhVZuMQGBjSuT+y2CD/hMsNSze4l ymA= X-SBRS: 2.7 X-MesageID: 7778030 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.68,221,1569297600"; d="scan'208";a="7778030" From: Anthony PERARD To: Date: Wed, 23 Oct 2019 17:48:20 +0100 Message-ID: <20191023164837.2700240-7-anthony.perard@citrix.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191023164837.2700240-1-anthony.perard@citrix.com> References: <20191023164837.2700240-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [RFC XEN PATCH 06/23] xen, Kbuild: filter-out -Wa, % from CFLAGS for %.i:%.c rules X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Anthony PERARD Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" As it is done currently in Rules.mk. Signed-off-by: Anthony PERARD --- xen/scripts/Makefile.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/scripts/Makefile.build b/xen/scripts/Makefile.build index 2f66ed388d1c..dd972d5b5edb 100644 --- a/xen/scripts/Makefile.build +++ b/xen/scripts/Makefile.build @@ -114,7 +114,7 @@ $(obj)/%.s: $(src)/%.c FORCE $(call if_changed_dep,cc_s_c) quiet_cmd_cpp_i_c = CPP $(quiet_modtag) $@ -cmd_cpp_i_c = $(CPP) $(c_flags) -o $@ $< +cmd_cpp_i_c = $(CPP) $(filter-out -Wa$(comma)%,$(c_flags)) -o $@ $< $(obj)/%.i: $(src)/%.c FORCE $(call if_changed_dep,cpp_i_c) From patchwork Wed Oct 23 16:48:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 11207221 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7A5221515 for ; Wed, 23 Oct 2019 16:50:07 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5679C21925 for ; Wed, 23 Oct 2019 16:50:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="bhPRlh2N" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5679C21925 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNJob-0007Ps-AA; Wed, 23 Oct 2019 16:48:53 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNJoa-0007PX-EJ for xen-devel@lists.xenproject.org; Wed, 23 Oct 2019 16:48:52 +0000 X-Inumbo-ID: f87304b8-f5b4-11e9-8aca-bc764e2007e4 Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id f87304b8-f5b4-11e9-8aca-bc764e2007e4; Wed, 23 Oct 2019 16:48:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1571849322; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Y0FIGjiDgCfrCtvVDl/alvj9oiarFxRbWo4lLPMs7go=; b=bhPRlh2NIp7GKhDiRSaNdkBVMbo0W6/f4kXvue5VUTrIjbKxX3zMeYIM H6v2j/Lr5jV12wUUjU+1bx8jEyGJ9nJljXfL4DVBn/CCVt1cxmVMzB7Cg hdZe804AWcJ6o8WJ8reKDPYcEsthVTxSYfI17lPR56oz8cV1MP2/FCsrd c=; Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=anthony.perard@citrix.com; spf=Pass smtp.mailfrom=anthony.perard@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa4.hc3370-68.iphmx.com: no sender authenticity information available from domain of anthony.perard@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa4.hc3370-68.iphmx.com: domain of anthony.perard@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa4.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: yKiBPdXyuu/vc7oB8ss7mW29PQ7Ayo/226IZUNZjpy1IlrGh/hamTc4s2R+AsgYH2alAn9c+CP FAIUt5QsmIIoAuETD8fG//zlq1oX9ots8e9VLlajhwr+cGaK3GnU1+eyOTKw1ad86nMdlIbfLE 9dKmSkkvSyP2zK8hu0/OboBSaDO7RPx7Ghqf1sWawfd96v+NkYGB73+rLfHCSNMUKcLBXAEsVX UdxxcoIcWwp3TgsXTYGmHYVhDcvTmSSV6ZuIKtzy5mdfnDKl26vqWqGc3AbnOFsmqG6wiZeptF rxo= X-SBRS: 2.7 X-MesageID: 7778031 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.68,221,1569297600"; d="scan'208";a="7778031" From: Anthony PERARD To: Date: Wed, 23 Oct 2019 17:48:21 +0100 Message-ID: <20191023164837.2700240-8-anthony.perard@citrix.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191023164837.2700240-1-anthony.perard@citrix.com> References: <20191023164837.2700240-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [RFC XEN PATCH 07/23] xen, Kbuild: Handle obj-bin-y and %.init.o objects X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Anthony PERARD Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" SPECIAL_DATA_SECTIONS is put in Kbuild.include so it can be use in kbuild makefiles. Signed-off-by: Anthony PERARD --- xen/scripts/Kbuild.include | 10 ++++++++++ xen/scripts/Makefile.build | 24 ++++++++++++++++++++++++ xen/scripts/Makefile.lib | 7 +++++++ 3 files changed, 41 insertions(+) diff --git a/xen/scripts/Kbuild.include b/xen/scripts/Kbuild.include index 4b0432e095ae..6f95a2519f3c 100644 --- a/xen/scripts/Kbuild.include +++ b/xen/scripts/Kbuild.include @@ -326,6 +326,16 @@ endef # ############################################################################### +# For building %.init.o files, can be used in kbuild makefiles +SPECIAL_DATA_SECTIONS := rodata $(foreach a,1 2 4 8 16, \ + $(foreach w,1 2 4, \ + rodata.str$(w).$(a)) \ + rodata.cst$(a)) \ + $(foreach r,rel rel.ro,data.$(r).local) + +############################################################################### + + # delete partially updated (i.e. corrupted) files on error .DELETE_ON_ERROR: diff --git a/xen/scripts/Makefile.build b/xen/scripts/Makefile.build index dd972d5b5edb..68b504c9bdc5 100644 --- a/xen/scripts/Makefile.build +++ b/xen/scripts/Makefile.build @@ -384,6 +384,30 @@ $(obj)/%.o: $(src)/%.S $(objtool_dep) FORCE targets += $(filter-out $(subdir-obj-y), $(real-obj-y)) $(real-obj-m) $(lib-y) targets += $(extra-y) $(MAKECMDGOALS) $(always) +# %.init.o objects +# ---------------- + +quiet_cmd_obj_init_o = INIT_OBJ $@ +define cmd_obj_init_o + set -e; \ + $(OBJDUMP) -h $< | sed -n '/[0-9]/{s,00*,0,g;p;}' | while read idx name sz rest; do \ + case "$$name" in \ + .*.local) ;; \ + .text|.text.*|.data|.data.*|.bss) \ + test $$sz != 0 || continue; \ + echo "Error: size of $<:$$name is 0x$$sz" >&2; \ + exit $$(expr $$idx + 1);; \ + esac; \ + done; \ + $(OBJCOPY) $(foreach s,$(SPECIAL_DATA_SECTIONS),--rename-section .$(s)=.init.$(s)) $< $@ +endef + +$(obj)/%.init.o: $(obj)/%.o FORCE + $(call if_changed,obj_init_o) + +# Add intermediates files into tagets +targets += $(patsubst %.init.o,%.o,$(filter %.init.o,$(targets))) + # Linker scripts preprocessor (.lds.S -> .lds) # --------------------------------------------------------------------------- quiet_cmd_cpp_lds_S = LDS $@ diff --git a/xen/scripts/Makefile.lib b/xen/scripts/Makefile.lib index b746199b7f6b..e022f053494e 100644 --- a/xen/scripts/Makefile.lib +++ b/xen/scripts/Makefile.lib @@ -16,6 +16,10 @@ KBUILD_CFLAGS += $(subdir-ccflags-y) # only build the compiled-in version obj-m := $(filter-out $(obj-y),$(obj-m)) +# For a non-LTO build, bundle obj-bin targets in with the normal objs. +obj-y += $(obj-bin-y) +obj-bin-y := + # Libraries are always collected in one lib file. # Filter out objects already built-in lib-y := $(filter-out $(obj-y), $(sort $(lib-y) $(lib-m))) @@ -108,6 +112,9 @@ name-fix = $(squote)$(quote)$(subst $(comma),_,$(subst -,_,$1))$(quote)$(squote) basename_flags = -DKBUILD_BASENAME=$(call name-fix,$(basetarget)) modname_flags = -DKBUILD_MODNAME=$(call name-fix,$(modname)) +# See comment about INIT_SECTIONS_ONLY in include/xen/compiler.h +$(filter %.init.o,$(real-obj-y) $(extra-y)): ccflags-y += -DINIT_SECTIONS_ONLY + orig_c_flags = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) \ $(ccflags-y) $(CFLAGS_$(basetarget).o) _c_flags = $(filter-out $(CFLAGS_REMOVE_$(basetarget).o), $(orig_c_flags)) From patchwork Wed Oct 23 16:48:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 11207223 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 55BA3112B for ; Wed, 23 Oct 2019 16:50:08 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 319D721906 for ; Wed, 23 Oct 2019 16:50:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="YL8OmkPC" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 319D721906 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNJog-0007Sv-4w; Wed, 23 Oct 2019 16:48:58 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNJof-0007SV-Er for xen-devel@lists.xenproject.org; Wed, 23 Oct 2019 16:48:57 +0000 X-Inumbo-ID: f8ad77c4-f5b4-11e9-beca-bc764e2007e4 Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id f8ad77c4-f5b4-11e9-beca-bc764e2007e4; Wed, 23 Oct 2019 16:48:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1571849322; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4hXr9w3jPULxpMPUxVm6mEQo/0Q3sw5db8ib06NgEAk=; b=YL8OmkPC3m7K2kymxmFfF09Gkngj5nRQ/tpW7cCRYutAjCL25zfq9c5n P2iGx6O3MULMC88VcivP00WCcUq1G5TGOuIASFo+a3ZM7JNMASThIsCTE ahevphjYwxlz39VNTbOGOP/pV7ug1FcsAjybhyX4Wkg88FmALirNTjS+w U=; Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=anthony.perard@citrix.com; spf=Pass smtp.mailfrom=anthony.perard@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa4.hc3370-68.iphmx.com: no sender authenticity information available from domain of anthony.perard@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa4.hc3370-68.iphmx.com: domain of anthony.perard@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa4.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: D4hiskaVKU5bP9gLi3odpCa4mRDJUQhKZcyQbOMmbbFW5gSm++iSLlQ+YrZ9OHZ/nNl3GkO/W1 25o2GVX7q+KVd8K4v23rW8OFdkRa559kDyIje4nIgRp0LlB4EztiXRfR2RPFS6J8KNVDYONr4a SO5wHKHkf+4itmWEZMz8JLlpEyOeudIhQEfEMEleKWiR4zUViRJ6MbdOcds7zdJ/HxpPWp7jLB 5TVmvPPG7iZaylRPvi3LlOjbJZR6Kz4cnj7z21njn8Za2f5sbAwJQTUbS/hQsJEMkF6N7Pd+dS ck4= X-SBRS: 2.7 X-MesageID: 7778032 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.68,221,1569297600"; d="scan'208";a="7778032" From: Anthony PERARD To: Date: Wed, 23 Oct 2019 17:48:22 +0100 Message-ID: <20191023164837.2700240-9-anthony.perard@citrix.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191023164837.2700240-1-anthony.perard@citrix.com> References: <20191023164837.2700240-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [RFC XEN PATCH 08/23] xen, Kbuild: Change filechk_offsets X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Anthony PERARD Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" This functions will be use later to generate asm-offsets.h. Signed-off-by: Anthony PERARD --- xen/scripts/Makefile.lib | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/xen/scripts/Makefile.lib b/xen/scripts/Makefile.lib index e022f053494e..19641e836dc3 100644 --- a/xen/scripts/Makefile.lib +++ b/xen/scripts/Makefile.lib @@ -413,29 +413,26 @@ quiet_cmd_xzmisc = XZMISC $@ # ASM offsets # --------------------------------------------------------------------------- -# Default sed regexp - multiline due to syntax constraints +# Default sed regexp # -# Use [:space:] because LLVM's integrated assembler inserts around -# the .ascii directive whereas GCC keeps the as-is. define sed-offsets - 's:^[[:space:]]*\.ascii[[:space:]]*"\(.*\)".*:\1:; \ - /^->/{s:->#\(.*\):/* \1 */:; \ - s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \ - s:->::; p;}' + '/^[^#].*==>/{s:.*==>(.*)<==.*:\1:; s: [\$$#]: :; p;}' endef # Use filechk to avoid rebuilds when a header changes, but the resulting file # does not define filechk_offsets - echo "#ifndef $2"; \ - echo "#define $2"; \ echo "/*"; \ echo " * DO NOT MODIFY."; \ echo " *"; \ - echo " * This file was generated by Kbuild"; \ + echo " * This file was auto-generated from $<"; \ + echo " *"; \ echo " */"; \ echo ""; \ - sed -ne $(sed-offsets) < $<; \ + echo "#ifndef $2"; \ + echo "#define $2"; \ + echo ""; \ + sed -rne $(sed-offsets) < $<; \ echo ""; \ echo "#endif" endef From patchwork Wed Oct 23 16:48:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 11207227 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8AFF7139A for ; Wed, 23 Oct 2019 16:50:22 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 66A3B21906 for ; Wed, 23 Oct 2019 16:50:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="MIc8l1CK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 66A3B21906 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNJom-0007Yp-0S; Wed, 23 Oct 2019 16:49:04 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNJok-0007Xe-Fu for xen-devel@lists.xenproject.org; Wed, 23 Oct 2019 16:49:02 +0000 X-Inumbo-ID: f8e41540-f5b4-11e9-8aca-bc764e2007e4 Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id f8e41540-f5b4-11e9-8aca-bc764e2007e4; Wed, 23 Oct 2019 16:48:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1571849322; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=GbCEadOnlibfgnGlreYrGVowE/llHZXoqLw3/6FnuoI=; b=MIc8l1CKHe6HzX+ujHFtyM4SABbVPye7rbFO4XGV+ErAdhOruAKP7EQB EhZ6FzKRYxNYNczZVvfRsozGavyz790VnA2wJY4PznKJ4yxmRgQynXuky vQm1FZ6/+ScnKOY8Iu0+J1A3GBnKEDPHj9+SiKQJ0ym1cDAv9kwMLNmXH 8=; Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=anthony.perard@citrix.com; spf=Pass smtp.mailfrom=anthony.perard@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa4.hc3370-68.iphmx.com: no sender authenticity information available from domain of anthony.perard@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa4.hc3370-68.iphmx.com: domain of anthony.perard@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa4.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: Rw/3vui0w59tSTtdvEJx/Ji/nV5bBmAp9rh7dOjJ98W5AxS1XZJ4VbYAd2TijFOHaJVJR15b0p kfMJT0u3ln8ewny8Lt7kW9ibhNdXTjinxvL6A7ZzIqWQXNhejhJPmlDT9x6k9HEo0EHfo8nO4O 48hBiaqVzmw35I3YrF17MLjgCO0Sq9ueBzllOQwLp+9YJRGO2wjLokTG++jDrAqlmqV6T55J1F Fzu/Rn1LXcDaMXOGpc4dpvGIZhrDApkNKQVlUfv2ovHYJxXGCuZB2A+ZlpPOyV+T+1iRfwAFej 4DQ= X-SBRS: 2.7 X-MesageID: 7778033 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.68,221,1569297600"; d="scan'208";a="7778033" From: Anthony PERARD To: Date: Wed, 23 Oct 2019 17:48:23 +0100 Message-ID: <20191023164837.2700240-10-anthony.perard@citrix.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191023164837.2700240-1-anthony.perard@citrix.com> References: <20191023164837.2700240-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [RFC XEN PATCH 09/23] xen, Kbuild: Filter-out -Wa, in %.s:%.c rules X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Anthony PERARD Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" As it is done in the same rule in Rules.mk. Signed-off-by: Anthony PERARD --- xen/scripts/Makefile.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/scripts/Makefile.build b/xen/scripts/Makefile.build index 68b504c9bdc5..c8ef52220a61 100644 --- a/xen/scripts/Makefile.build +++ b/xen/scripts/Makefile.build @@ -108,7 +108,7 @@ modkern_cflags = \ quiet_modtag = $(if $(part-of-module),[M], ) quiet_cmd_cc_s_c = CC $(quiet_modtag) $@ - cmd_cc_s_c = $(CC) $(filter-out $(DEBUG_CFLAGS), $(c_flags)) $(DISABLE_LTO) -fverbose-asm -S -o $@ $< + cmd_cc_s_c = $(CC) $(filter-out $(DEBUG_CFLAGS) -Wa$(comma)%, $(c_flags)) $(DISABLE_LTO) -fverbose-asm -S -o $@ $< $(obj)/%.s: $(src)/%.c FORCE $(call if_changed_dep,cc_s_c) From patchwork Wed Oct 23 16:48:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 11207259 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9D3FB13BD for ; Wed, 23 Oct 2019 17:11:55 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 77E8B20640 for ; Wed, 23 Oct 2019 17:11:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="K0WGfLix" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 77E8B20640 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNK9i-0002ap-MG; Wed, 23 Oct 2019 17:10:42 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNK9h-0002a9-Iu for xen-devel@lists.xenproject.org; Wed, 23 Oct 2019 17:10:41 +0000 X-Inumbo-ID: 07c7680c-f5b8-11e9-bbab-bc764e2007e4 Received: from esa5.hc3370-68.iphmx.com (unknown [216.71.155.168]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 07c7680c-f5b8-11e9-bbab-bc764e2007e4; Wed, 23 Oct 2019 17:10:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1571850636; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6DwBOQrMxNt1og8JUZZST8JkQc0dcoT2LOmCvNitEp4=; b=K0WGfLixgZuT1F3o9HX1ka+Bpr3CSELY5nSsAztobYZdM0Ace2Rnff7q ud8A45SvgHJyKO68Kw6uW9oInLKUCrbFhziGze/9iZIxP1ALARPtx1LMr 3Bi3zIQxBKU3jmGXeWXrKLr9pqnGCnXlTqIrjxZ5Tl7oIOFKqN0gAcTjE Q=; Authentication-Results: esa5.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=anthony.perard@citrix.com; spf=Pass smtp.mailfrom=anthony.perard@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa5.hc3370-68.iphmx.com: no sender authenticity information available from domain of anthony.perard@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa5.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa5.hc3370-68.iphmx.com: domain of anthony.perard@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa5.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa5.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa5.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: aDN0t4NhP09v2ZMQ/H814fpWXsziTIH+Ixh4gEfvb9RGEDfbpUo7rrVU3w+i2GCbUoCm4xpnwJ jJWjfhy38+KER2xVIrUNBJVRNzT0xqTWZV372cLQwY/9ZpKW/ZDWxz+fOtrtF2VD5MrbUsuPJK 63gOIBSseGQYRriOUeIv0P2tFg2SsxSf2RKn/iYJ2wDfKil7XWP5i/wTTm579PSh5v/cAFnAv7 RjFl5SRRQ9QvqlO093OqCZXyq/pUSSrRdXYKzGqGh10KqHS5UaqHesucQjb6n/Mp7h9CGNbMwi KQE= X-SBRS: 2.7 X-MesageID: 7642018 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.68,221,1569297600"; d="scan'208";a="7642018" From: Anthony PERARD To: Date: Wed, 23 Oct 2019 17:48:24 +0100 Message-ID: <20191023164837.2700240-11-anthony.perard@citrix.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191023164837.2700240-1-anthony.perard@citrix.com> References: <20191023164837.2700240-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [RFC XEN PATCH 10/23] xen,Kbuild: Handle __OBJECT_*__ X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Anthony PERARD Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Define __OBJECT_FILE__ and __OBJECT_LABEL__ as it is done in arch/x86/Rules.mk. Those defines would also be created when doing an ARM build, when Kbuild will be used to build xen. Signed-off-by: Anthony PERARD --- xen/scripts/Makefile.lib | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/xen/scripts/Makefile.lib b/xen/scripts/Makefile.lib index 19641e836dc3..7ba3cf034c98 100644 --- a/xen/scripts/Makefile.lib +++ b/xen/scripts/Makefile.lib @@ -97,20 +97,12 @@ real-obj-m := $(addprefix $(obj)/,$(real-obj-m)) multi-used-m := $(addprefix $(obj)/,$(multi-used-m)) subdir-ym := $(addprefix $(obj)/,$(subdir-ym)) -# Finds the multi-part object the current object will be linked into. -# If the object belongs to two or more multi-part objects, all of them are -# concatenated with a colon separator. -modname-multi = $(subst $(space),:,$(sort $(foreach m,$(multi-used),\ - $(if $(filter $*.o, $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m))),$(m:.o=))))) - -modname = $(if $(modname-multi),$(modname-multi),$(basetarget)) - -# These flags are needed for modversions and compiling, so we define them here -# $(modname_flags) defines KBUILD_MODNAME as the name of the module it will -# end up in (or would, if it gets compiled in) -name-fix = $(squote)$(quote)$(subst $(comma),_,$(subst -,_,$1))$(quote)$(squote) -basename_flags = -DKBUILD_BASENAME=$(call name-fix,$(basetarget)) -modname_flags = -DKBUILD_MODNAME=$(call name-fix,$(modname)) +object_file_flags = '-D__OBJECT_FILE__="$(subst $(obj)/,,$@)"' +ifeq ($(findstring -DHAVE_AS_QUOTED_SYM,$(KBUILD_CFLAGS)),) +object_file_flags += '-D__OBJECT_LABEL__=$(subst /,$$,$(subst -,_,$(@)))' +else +object_file_flags += '-D__OBJECT_LABEL__=$(subst -,_,$(@))' +endif # See comment about INIT_SECTIONS_ONLY in include/xen/compiler.h $(filter %.init.o,$(real-obj-y) $(extra-y)): ccflags-y += -DINIT_SECTIONS_ONLY @@ -168,13 +160,13 @@ endif c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ $(_c_flags) $(modkern_cflags) \ - $(basename_flags) $(modname_flags) + $(object_file_flags) a_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ - $(_a_flags) $(modkern_aflags) + $(object_file_flags) $(_a_flags) cpp_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ - $(_cpp_flags) + $(object_file_flags) $(_cpp_flags) ld_flags = $(KBUILD_LDFLAGS) $(ldflags-y) $(LDFLAGS_$(@F)) From patchwork Wed Oct 23 16:48:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 11207277 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2A5F9112C for ; Wed, 23 Oct 2019 17:12:27 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EEEFA2086D for ; Wed, 23 Oct 2019 17:12:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="fu8cfUKN" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EEEFA2086D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNKAD-00030X-6D; Wed, 23 Oct 2019 17:11:13 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNKAB-0002zM-KI for xen-devel@lists.xenproject.org; Wed, 23 Oct 2019 17:11:11 +0000 X-Inumbo-ID: 18993b60-f5b8-11e9-bbab-bc764e2007e4 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 18993b60-f5b8-11e9-bbab-bc764e2007e4; Wed, 23 Oct 2019 17:11:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1571850666; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4H2b7k5wmb+lFuniuqv3msRKI8CBEGAGNAtixDHFl7A=; b=fu8cfUKNJG4kLU9v0FdgVlIgdO6F4oq78Qd47MU/JJd3vjg2oSb60Eqm QhkvGZ/lMf8eZgHQbf7cZfjWBrZyiB2w5FCM6876B+qdPFPeMBGCoV2WA hI5bVtNUc1PGYU5yn5SLv2XA250zkoiAqM+V6xKzTVqPTMDF2X87JE6Ck E=; Authentication-Results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=anthony.perard@citrix.com; spf=Pass smtp.mailfrom=anthony.perard@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa1.hc3370-68.iphmx.com: no sender authenticity information available from domain of anthony.perard@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa1.hc3370-68.iphmx.com: domain of anthony.perard@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa1.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: 1AYaBcrvx93FbRej3cEJ+12E9KAwnQ0gF+FJ2qUCkZL3ArSltnfbsAfU3IN4aPzlKRq424toCF Cnn9+EoOXaLC2+cmM9TEGkF/usR4CreeIlFuWoEH8cirIgvOoIUONYxtJDlwvGpsfP7cOgzStK btISv+TnjmJmasdazZNlnIaAbn1VTj9v7cZnuDFPTkbnxBu5coBvZjawZ7vtbRUx/gVsBqpWfu n2UnsoNHUgYOP5bu0adNREfPfqbEmRUfrpEG9tWEGAlxiavJeqQx7KdYaV57eDCIrJaM4TaFUQ njQ= X-SBRS: 2.7 X-MesageID: 7429249 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.68,221,1569297600"; d="scan'208";a="7429249" From: Anthony PERARD To: Date: Wed, 23 Oct 2019 17:48:25 +0100 Message-ID: <20191023164837.2700240-12-anthony.perard@citrix.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191023164837.2700240-1-anthony.perard@citrix.com> References: <20191023164837.2700240-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [RFC XEN PATCH 11/23] First conversion to kbuild makefiles X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Anthony PERARD Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Kbuild uses obj-y=subdir/ instead of subdir-y=subdir Adding CFLAGS in a specific subdirectory is done via ccflags-y instead of CFLAGS. Done with sed: sed -i -r 's#^subdir-(.*)#obj-\1/#; s#^CFLAGS #ccflags-y #' **/*/Makefile --- xen/arch/arm/Makefile | 14 +++++++------- xen/arch/arm/arm32/Makefile | 2 +- xen/arch/arm/arm64/Makefile | 2 +- xen/arch/arm/efi/Makefile | 2 +- xen/arch/x86/Makefile | 18 +++++++++--------- xen/arch/x86/acpi/Makefile | 2 +- xen/arch/x86/cpu/Makefile | 4 ++-- xen/arch/x86/efi/Makefile | 2 +- xen/arch/x86/hvm/Makefile | 6 +++--- xen/arch/x86/mm/Makefile | 4 ++-- xen/arch/x86/x86_64/Makefile | 2 +- xen/common/Makefile | 8 ++++---- xen/common/libelf/Makefile | 2 +- xen/common/libfdt/Makefile | 2 +- xen/drivers/Makefile | 14 +++++++------- xen/drivers/acpi/Makefile | 6 +++--- xen/drivers/passthrough/Makefile | 8 ++++---- xen/drivers/passthrough/vtd/Makefile | 2 +- xen/lib/Makefile | 2 +- xen/xsm/Makefile | 2 +- xen/xsm/flask/Makefile | 4 ++-- xen/xsm/flask/ss/Makefile | 2 +- 22 files changed, 55 insertions(+), 55 deletions(-) diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile index 70f532e42a06..1044c2298a05 100644 --- a/xen/arch/arm/Makefile +++ b/xen/arch/arm/Makefile @@ -1,11 +1,11 @@ -subdir-$(CONFIG_ARM_32) += arm32 -subdir-$(CONFIG_ARM_64) += arm64 -subdir-$(CONFIG_ARM_64) += efi -subdir-$(CONFIG_ACPI) += acpi +obj-$(CONFIG_ARM_32) += arm32/ +obj-$(CONFIG_ARM_64) += arm64/ +obj-$(CONFIG_ARM_64) += efi/ +obj-$(CONFIG_ACPI) += acpi/ ifneq ($(CONFIG_NO_PLAT),y) -subdir-y += platforms +obj-y += platforms/ endif -subdir-$(CONFIG_TEE) += tee +obj-$(CONFIG_TEE) += tee/ obj-$(CONFIG_HAS_ALTERNATIVE) += alternative.o obj-y += bootfdt.init.o @@ -48,7 +48,7 @@ obj-y += sysctl.o obj-y += time.o obj-y += traps.o obj-y += vcpreg.o -subdir-$(CONFIG_NEW_VGIC) += vgic +obj-$(CONFIG_NEW_VGIC) += vgic/ ifneq ($(CONFIG_NEW_VGIC),y) obj-y += gic-vgic.o obj-y += vgic.o diff --git a/xen/arch/arm/arm32/Makefile b/xen/arch/arm/arm32/Makefile index 0ac254f34714..539bbef298a7 100644 --- a/xen/arch/arm/arm32/Makefile +++ b/xen/arch/arm/arm32/Makefile @@ -1,4 +1,4 @@ -subdir-y += lib +obj-y += lib/ obj-$(EARLY_PRINTK) += debug.o obj-y += domctl.o diff --git a/xen/arch/arm/arm64/Makefile b/xen/arch/arm/arm64/Makefile index c4f3a28a0d0b..db8565b71a33 100644 --- a/xen/arch/arm/arm64/Makefile +++ b/xen/arch/arm/arm64/Makefile @@ -1,4 +1,4 @@ -subdir-y += lib +obj-y += lib/ obj-y += cache.o obj-$(CONFIG_HARDEN_BRANCH_PREDICTOR) += bpi.o diff --git a/xen/arch/arm/efi/Makefile b/xen/arch/arm/efi/Makefile index d34c9168914a..e4aaba3e074b 100644 --- a/xen/arch/arm/efi/Makefile +++ b/xen/arch/arm/efi/Makefile @@ -1,4 +1,4 @@ -CFLAGS += -fshort-wchar +ccflags-y += -fshort-wchar obj-y += boot.init.o runtime.o obj-$(CONFIG_ACPI) += efi-dom0.init.o diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile index af6c83dfbae6..864a0669bc9f 100644 --- a/xen/arch/x86/Makefile +++ b/xen/arch/x86/Makefile @@ -1,12 +1,12 @@ -subdir-y += acpi -subdir-y += cpu -subdir-y += genapic -subdir-$(CONFIG_XEN_GUEST) += guest -subdir-$(CONFIG_HVM) += hvm -subdir-y += mm -subdir-$(CONFIG_XENOPROF) += oprofile -subdir-$(CONFIG_PV) += pv -subdir-y += x86_64 +obj-y += acpi/ +obj-y += cpu/ +obj-y += genapic/ +obj-$(CONFIG_XEN_GUEST) += guest/ +obj-$(CONFIG_HVM) += hvm/ +obj-y += mm/ +obj-$(CONFIG_XENOPROF) += oprofile/ +obj-$(CONFIG_PV) += pv/ +obj-y += x86_64/ alternative-y := alternative.init.o alternative-$(CONFIG_LIVEPATCH) := diff --git a/xen/arch/x86/acpi/Makefile b/xen/arch/x86/acpi/Makefile index 27b4aa30b0ca..1b9e62571301 100644 --- a/xen/arch/x86/acpi/Makefile +++ b/xen/arch/x86/acpi/Makefile @@ -1,4 +1,4 @@ -subdir-y += cpufreq +obj-y += cpufreq/ obj-y += lib.o power.o suspend.o cpu_idle.o cpuidle_menu.o obj-bin-y += boot.init.o wakeup_prot.o diff --git a/xen/arch/x86/cpu/Makefile b/xen/arch/x86/cpu/Makefile index 466acc8b10e5..de983006a1b1 100644 --- a/xen/arch/x86/cpu/Makefile +++ b/xen/arch/x86/cpu/Makefile @@ -1,5 +1,5 @@ -subdir-y += mcheck -subdir-y += mtrr +obj-y += mcheck/ +obj-y += mtrr/ obj-y += amd.o obj-y += centaur.o diff --git a/xen/arch/x86/efi/Makefile b/xen/arch/x86/efi/Makefile index 4bc0a196e9ca..2cbb3de3a8ab 100644 --- a/xen/arch/x86/efi/Makefile +++ b/xen/arch/x86/efi/Makefile @@ -1,4 +1,4 @@ -CFLAGS += -fshort-wchar +ccflags-y += -fshort-wchar %.o: %.ihex $(OBJCOPY) -I ihex -O binary $< $@ diff --git a/xen/arch/x86/hvm/Makefile b/xen/arch/x86/hvm/Makefile index 43e5f3a21f8b..346419154460 100644 --- a/xen/arch/x86/hvm/Makefile +++ b/xen/arch/x86/hvm/Makefile @@ -1,6 +1,6 @@ -subdir-y += svm -subdir-y += vmx -subdir-y += viridian +obj-y += svm/ +obj-y += vmx/ +obj-y += viridian/ obj-y += asid.o obj-y += dm.o diff --git a/xen/arch/x86/mm/Makefile b/xen/arch/x86/mm/Makefile index 5010a29d6cb0..d87dc0aa6eeb 100644 --- a/xen/arch/x86/mm/Makefile +++ b/xen/arch/x86/mm/Makefile @@ -1,5 +1,5 @@ -subdir-y += shadow -subdir-$(CONFIG_HVM) += hap +obj-y += shadow/ +obj-$(CONFIG_HVM) += hap/ obj-$(CONFIG_HVM) += altp2m.o obj-$(CONFIG_HVM) += guest_walk_2.o guest_walk_3.o guest_walk_4.o diff --git a/xen/arch/x86/x86_64/Makefile b/xen/arch/x86/x86_64/Makefile index 4bfa1480eb7e..2bb1eb0a8131 100644 --- a/xen/arch/x86/x86_64/Makefile +++ b/xen/arch/x86/x86_64/Makefile @@ -1,4 +1,4 @@ -subdir-$(CONFIG_PV) += compat +obj-$(CONFIG_PV) += compat/ obj-bin-y += entry.o obj-y += traps.o diff --git a/xen/common/Makefile b/xen/common/Makefile index 62b34e69e95c..d4db0a6d466a 100644 --- a/xen/common/Makefile +++ b/xen/common/Makefile @@ -73,8 +73,8 @@ obj-$(CONFIG_COMPAT) += $(addprefix compat/,domain.o kernel.o memory.o multicall extra-y := symbols-dummy.o -subdir-$(CONFIG_COVERAGE) += coverage -subdir-$(CONFIG_UBSAN) += ubsan +obj-$(CONFIG_COVERAGE) += coverage/ +obj-$(CONFIG_UBSAN) += ubsan/ -subdir-$(CONFIG_NEEDS_LIBELF) += libelf -subdir-$(CONFIG_HAS_DEVICE_TREE) += libfdt +obj-$(CONFIG_NEEDS_LIBELF) += libelf/ +obj-$(CONFIG_HAS_DEVICE_TREE) += libfdt/ diff --git a/xen/common/libelf/Makefile b/xen/common/libelf/Makefile index 3d9e38f27e65..9a433f01fbd4 100644 --- a/xen/common/libelf/Makefile +++ b/xen/common/libelf/Makefile @@ -3,7 +3,7 @@ nocov-y += libelf.o SECTIONS := text data $(SPECIAL_DATA_SECTIONS) -CFLAGS += -Wno-pointer-sign +ccflags-y += -Wno-pointer-sign libelf.o: libelf-temp.o Makefile $(OBJCOPY) $(foreach s,$(SECTIONS),--rename-section .$(s)=.init.$(s)) $< $@ diff --git a/xen/common/libfdt/Makefile b/xen/common/libfdt/Makefile index c075bbf5462a..9ea5c696d52a 100644 --- a/xen/common/libfdt/Makefile +++ b/xen/common/libfdt/Makefile @@ -5,7 +5,7 @@ SECTIONS := text data $(SPECIAL_DATA_SECTIONS) obj-y += libfdt.o nocov-y += libfdt.o -CFLAGS += -I$(BASEDIR)/include/xen/libfdt/ +ccflags-y += -I$(BASEDIR)/include/xen/libfdt/ libfdt.o: libfdt-temp.o Makefile $(OBJCOPY) $(foreach s,$(SECTIONS),--rename-section .$(s)=.init.$(s)) $< $@ diff --git a/xen/drivers/Makefile b/xen/drivers/Makefile index 30bab3cfdb36..2a1ae8ad130a 100644 --- a/xen/drivers/Makefile +++ b/xen/drivers/Makefile @@ -1,7 +1,7 @@ -subdir-y += char -subdir-$(CONFIG_HAS_CPUFREQ) += cpufreq -subdir-$(CONFIG_HAS_PCI) += pci -subdir-$(CONFIG_HAS_VPCI) += vpci -subdir-$(CONFIG_HAS_PASSTHROUGH) += passthrough -subdir-$(CONFIG_ACPI) += acpi -subdir-$(CONFIG_VIDEO) += video +obj-y += char/ +obj-$(CONFIG_HAS_CPUFREQ) += cpufreq/ +obj-$(CONFIG_HAS_PCI) += pci/ +obj-$(CONFIG_HAS_VPCI) += vpci/ +obj-$(CONFIG_HAS_PASSTHROUGH) += passthrough/ +obj-$(CONFIG_ACPI) += acpi/ +obj-$(CONFIG_VIDEO) += video/ diff --git a/xen/drivers/acpi/Makefile b/xen/drivers/acpi/Makefile index 444b11d5839d..4f8e97228ee2 100644 --- a/xen/drivers/acpi/Makefile +++ b/xen/drivers/acpi/Makefile @@ -1,6 +1,6 @@ -subdir-y += tables -subdir-y += utilities -subdir-$(CONFIG_X86) += apei +obj-y += tables/ +obj-y += utilities/ +obj-$(CONFIG_X86) += apei/ obj-bin-y += tables.init.o obj-$(CONFIG_NUMA) += numa.o diff --git a/xen/drivers/passthrough/Makefile b/xen/drivers/passthrough/Makefile index d50ab188c83c..e973e16c7484 100644 --- a/xen/drivers/passthrough/Makefile +++ b/xen/drivers/passthrough/Makefile @@ -1,7 +1,7 @@ -subdir-$(CONFIG_X86) += vtd -subdir-$(CONFIG_X86) += amd -subdir-$(CONFIG_X86) += x86 -subdir-$(CONFIG_ARM) += arm +obj-$(CONFIG_X86) += vtd/ +obj-$(CONFIG_X86) += amd/ +obj-$(CONFIG_X86) += x86/ +obj-$(CONFIG_ARM) += arm/ obj-y += iommu.o obj-$(CONFIG_HAS_PCI) += pci.o diff --git a/xen/drivers/passthrough/vtd/Makefile b/xen/drivers/passthrough/vtd/Makefile index f302653858a0..fde7555fac07 100644 --- a/xen/drivers/passthrough/vtd/Makefile +++ b/xen/drivers/passthrough/vtd/Makefile @@ -1,4 +1,4 @@ -subdir-$(CONFIG_X86) += x86 +obj-$(CONFIG_X86) += x86/ obj-y += iommu.o obj-y += dmar.o diff --git a/xen/lib/Makefile b/xen/lib/Makefile index dcdb75931378..7019ca00e8fd 100644 --- a/xen/lib/Makefile +++ b/xen/lib/Makefile @@ -1 +1 @@ -subdir-$(CONFIG_X86) += x86 +obj-$(CONFIG_X86) += x86/ diff --git a/xen/xsm/Makefile b/xen/xsm/Makefile index e4d581e065f8..cf0a728f1c96 100644 --- a/xen/xsm/Makefile +++ b/xen/xsm/Makefile @@ -3,4 +3,4 @@ obj-$(CONFIG_XSM) += xsm_policy.o obj-$(CONFIG_XSM) += dummy.o obj-$(CONFIG_XSM_SILO) += silo.o -subdir-$(CONFIG_XSM_FLASK) += flask +obj-$(CONFIG_XSM_FLASK) += flask/ diff --git a/xen/xsm/flask/Makefile b/xen/xsm/flask/Makefile index f5ffab12268c..b1fd96a6ccec 100644 --- a/xen/xsm/flask/Makefile +++ b/xen/xsm/flask/Makefile @@ -2,9 +2,9 @@ obj-y += avc.o obj-y += hooks.o obj-y += flask_op.o -subdir-y += ss +obj-y += ss/ -CFLAGS += -I./include +ccflags-y += -I./include AWK = awk diff --git a/xen/xsm/flask/ss/Makefile b/xen/xsm/flask/ss/Makefile index 046ce8f53326..30f910a9c9c1 100644 --- a/xen/xsm/flask/ss/Makefile +++ b/xen/xsm/flask/ss/Makefile @@ -8,4 +8,4 @@ obj-y += services.o obj-y += conditional.o obj-y += mls.o -CFLAGS += -I../include +ccflags-y += -I../include From patchwork Wed Oct 23 16:48:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 11207263 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8C2BD112C for ; Wed, 23 Oct 2019 17:12:00 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 677B120640 for ; Wed, 23 Oct 2019 17:12:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="O1sYz/uz" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 677B120640 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNK9s-0002iy-VP; Wed, 23 Oct 2019 17:10:52 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNK9r-0002hy-In for xen-devel@lists.xenproject.org; Wed, 23 Oct 2019 17:10:51 +0000 X-Inumbo-ID: 0a0723dc-f5b8-11e9-beca-bc764e2007e4 Received: from esa6.hc3370-68.iphmx.com (unknown [216.71.155.175]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 0a0723dc-f5b8-11e9-beca-bc764e2007e4; Wed, 23 Oct 2019 17:10:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1571850640; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=YbA9SI4dXaBhkfGcxHlkutqpTm/GLo57nNWGOBv7ixE=; b=O1sYz/uz9u0cRepLg++FbFXDC/d24B/rJDBkx1o6e43ROlII1kjoTcZB 5AeUM4HvZ2JHwjkRwHPXDcIQODfimc30enM/z/GLMY8j2gwhdH/2vGdGW YK3dOSWOfwYi85AIZPTX3GUteP7vHO6SMJ3TRaAp2E14IrjY1xya95F6u o=; Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=anthony.perard@citrix.com; spf=Pass smtp.mailfrom=anthony.perard@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa6.hc3370-68.iphmx.com: no sender authenticity information available from domain of anthony.perard@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa6.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa6.hc3370-68.iphmx.com: domain of anthony.perard@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa6.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa6.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa6.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: +vtZqGqoUm+raEUwmCYorwR5lLkJvtnxHL6GOlH02ToyVPuhlp6CN/rMtAxm3EQq/Oh+dxF0Kg GlULQncaiYML4ewBQPHhFmw8vsrbrSSzXV8ZVbJm1hBWbnZvDaMdHULQBv24F63GjPl5sZM7qS 5ZxtrtueXqH188ECo187yBJTqLsIrXYijcPicDz94AeUecTNmZ1XE0PppE0TJIwHPEqV3fXzSq hRwyenidytqVGa72OZRnY/CQpHA9HQyQB6CgKhxUbj2aSsjXs5SEk4gNhxgbtusp8+HWAgFYvP mx0= X-SBRS: 2.7 X-MesageID: 7683600 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.68,221,1569297600"; d="scan'208";a="7683600" From: Anthony PERARD To: Date: Wed, 23 Oct 2019 17:48:26 +0100 Message-ID: <20191023164837.2700240-13-anthony.perard@citrix.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191023164837.2700240-1-anthony.perard@citrix.com> References: <20191023164837.2700240-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [RFC XEN PATCH 12/23] Build guest_walk* in arch/x86/mm X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Anthony PERARD Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Rewrite the rules to build the different level of guest page walk so the work and use Kbuild functions. Signed-off-by: Anthony PERARD --- xen/arch/x86/mm/Makefile | 14 +++++++------- xen/arch/x86/mm/hap/Makefile | 14 +++++++------- xen/arch/x86/mm/shadow/Makefile | 14 +++++++------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/xen/arch/x86/mm/Makefile b/xen/arch/x86/mm/Makefile index d87dc0aa6eeb..9c6d14c2fabb 100644 --- a/xen/arch/x86/mm/Makefile +++ b/xen/arch/x86/mm/Makefile @@ -11,11 +11,11 @@ obj-y += p2m.o p2m-pt.o obj-$(CONFIG_HVM) += p2m-ept.o p2m-pod.o obj-y += paging.o -guest_walk_%.o: guest_walk.c Makefile - $(CC) $(CFLAGS) -DGUEST_PAGING_LEVELS=$* -c $< -o $@ +$(foreach sfx,o i s,$(obj)/guest_walk_%.$(sfx)): ccflags-y = -DGUEST_PAGING_LEVELS=$* -guest_walk_%.i: guest_walk.c Makefile - $(CPP) $(filter-out -Wa$(comma)%,$(CFLAGS)) -DGUEST_PAGING_LEVELS=$* -c $< -o $@ - -guest_walk_%.s: guest_walk.c Makefile - $(CC) $(filter-out -Wa$(comma)%,$(CFLAGS)) -DGUEST_PAGING_LEVELS=$* -S $< -o $@ +$(obj)/guest_walk_%.o: $(src)/guest_walk.c FORCE + $(call if_changed_dep,cc_o_c) +$(obj)/guest_walk_%.i: $(src)/guest_walk.c FORCE + $(call if_changed_dep,cpp_i_c) +$(obj)/guest_walk_%.s: $(src)/guest_walk.c FORCE + $(call if_changed_dep,cc_s_c) diff --git a/xen/arch/x86/mm/hap/Makefile b/xen/arch/x86/mm/hap/Makefile index b14a9aff93d2..a0da2bfe77e6 100644 --- a/xen/arch/x86/mm/hap/Makefile +++ b/xen/arch/x86/mm/hap/Makefile @@ -5,11 +5,11 @@ obj-y += guest_walk_4level.o obj-y += nested_hap.o obj-y += nested_ept.o -guest_walk_%level.o: guest_walk.c Makefile - $(CC) $(CFLAGS) -DGUEST_PAGING_LEVELS=$* -c $< -o $@ +$(foreach sfx,o i s,$(obj)/guest_walk_%level.$(sfx)): ccflags-y = -DGUEST_PAGING_LEVELS=$* -guest_walk_%level.i: guest_walk.c Makefile - $(CPP) $(filter-out -Wa$(comma)%,$(CFLAGS)) -DGUEST_PAGING_LEVELS=$* -c $< -o $@ - -guest_walk_%level.s: guest_walk.c Makefile - $(CC) $(filter-out -Wa$(comma)%,$(CFLAGS)) -DGUEST_PAGING_LEVELS=$* -S $< -o $@ +$(obj)/guest_walk_%level.o: $(src)/guest_walk.c FORCE + $(call if_changed_dep,cc_o_c) +$(obj)/guest_walk_%level.i: $(src)/guest_walk.c FORCE + $(call if_changed_dep,cpp_i_c) +$(obj)/guest_walk_%level.s: $(src)/guest_walk.c FORCE + $(call if_changed_dep,cc_s_c) diff --git a/xen/arch/x86/mm/shadow/Makefile b/xen/arch/x86/mm/shadow/Makefile index ff03a9937f9b..8c264fab7fda 100644 --- a/xen/arch/x86/mm/shadow/Makefile +++ b/xen/arch/x86/mm/shadow/Makefile @@ -6,11 +6,11 @@ else obj-y += none.o endif -guest_%.o: multi.c Makefile - $(CC) $(CFLAGS) -DGUEST_PAGING_LEVELS=$* -c $< -o $@ +$(foreach sfx,o i s,$(obj)/guest_%.$(sfx)): ccflags-y = -DGUEST_PAGING_LEVELS=$* -guest_%.i: multi.c Makefile - $(CPP) $(filter-out -Wa$(comma)%,$(CFLAGS)) -DGUEST_PAGING_LEVELS=$* -c $< -o $@ - -guest_%.s: multi.c Makefile - $(CC) $(filter-out -Wa$(comma)%,$(CFLAGS)) -DGUEST_PAGING_LEVELS=$* -S $< -o $@ +$(obj)/guest_%.o: $(src)/multi.c FORCE + $(call if_changed_dep,cc_o_c) +$(obj)/guest_%.i: $(src)/multi.c FORCE + $(call if_changed_dep,cpp_i_c) +$(obj)/guest_%.s: $(src)/multi.c FORCE + $(call if_changed_dep,cc_s_c) From patchwork Wed Oct 23 16:48:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 11207255 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 39845112C for ; Wed, 23 Oct 2019 17:11:47 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1573A2086D for ; Wed, 23 Oct 2019 17:11:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="XLR/ulK7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1573A2086D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNK9c-0002Xs-FS; Wed, 23 Oct 2019 17:10:36 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNK9b-0002Xn-LS for xen-devel@lists.xenproject.org; Wed, 23 Oct 2019 17:10:35 +0000 X-Inumbo-ID: 067caf3f-f5b8-11e9-9488-12813bfff9fa Received: from esa3.hc3370-68.iphmx.com (unknown [216.71.145.155]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 067caf3f-f5b8-11e9-9488-12813bfff9fa; Wed, 23 Oct 2019 17:10:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1571850635; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=aY7iD/LqfH2ZB4ECeLUSyagCqlADJ5VK5pbp31qzZ84=; b=XLR/ulK72HhJoY4LXS/Nml3bYuFqQhFXKVa3mROmbpGBkQKmo7gLbPVp Er+jJb0EPS1/n6fkw/fraOAY048u53+cvL1lwE1pLqVoBGYOowpKVOYqC +aWMhRtxoq7YBfKVx/TDf3G2hgTViqFYHMF9D6ZxfcCE/QGPUu7u3iht6 w=; Authentication-Results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=anthony.perard@citrix.com; spf=Pass smtp.mailfrom=anthony.perard@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa3.hc3370-68.iphmx.com: no sender authenticity information available from domain of anthony.perard@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa3.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa3.hc3370-68.iphmx.com: domain of anthony.perard@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa3.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa3.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa3.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: GLFrNqBW108BBvu4r1iGnJRky+GBLZZfFMfeX0mI8i22tin7b/QhBPpoIj/13S5EvivOFkfdxJ bGtPSVBNJDcFh2dG0VzzTltwUSI1tQKKl5WC+9viXN0FtFDpuZ+wWcRUxCHVCMr1nWsNJg9R0O u0WhDSfo04FEdN9VZBrRvyhbIXPP0HtT23DixVo3B9612F1BMheWLH0Z4zFUoScB8ttpLo4Ogn V5vIkJWYHgt2RDXBj9toneBLOlDMTnWoaRmSMyVF5qtzSgsHGPbBuBgJadt9ppDoB/8B/cWQuT rr0= X-SBRS: 2.7 X-MesageID: 7333651 X-Ironport-Server: esa3.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.68,221,1569297600"; d="scan'208";a="7333651" From: Anthony PERARD To: Date: Wed, 23 Oct 2019 17:48:27 +0100 Message-ID: <20191023164837.2700240-14-anthony.perard@citrix.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191023164837.2700240-1-anthony.perard@citrix.com> References: <20191023164837.2700240-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [RFC XEN PATCH 13/23] convert common/libelf/Makefile to kbuild makefile X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Anthony PERARD Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Use existing command line of objcopy and ld instead of writing new one and simply edit the flags. `targets' is to let know kbuild that other files beside the one declared in obj-bin-y will be built. Signed-off-by: Anthony PERARD --- xen/common/libelf/Makefile | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/xen/common/libelf/Makefile b/xen/common/libelf/Makefile index 9a433f01fbd4..2be9ea82b241 100644 --- a/xen/common/libelf/Makefile +++ b/xen/common/libelf/Makefile @@ -4,9 +4,14 @@ nocov-y += libelf.o SECTIONS := text data $(SPECIAL_DATA_SECTIONS) ccflags-y += -Wno-pointer-sign +ldflags-y += -r +OBJCOPYFLAGS += $(foreach s,$(SECTIONS),--rename-section .$(s)=.init.$(s)) -libelf.o: libelf-temp.o Makefile - $(OBJCOPY) $(foreach s,$(SECTIONS),--rename-section .$(s)=.init.$(s)) $< $@ +libelf-temp-objs := libelf-tools.o libelf-loader.o libelf-dominfo.o #libelf-relocate.o +targets += $(libelf-temp-objs) libelf-temp.o -libelf-temp.o: libelf-tools.o libelf-loader.o libelf-dominfo.o #libelf-relocate.o - $(LD) $(LDFLAGS) -r -o $@ $^ +$(obj)/libelf.o: $(obj)/libelf-temp.o FORCE + $(call if_changed,objcopy) + +$(obj)/libelf-temp.o: $(addprefix $(obj)/,$(libelf-temp-objs)) FORCE + $(call if_changed,ld) From patchwork Wed Oct 23 16:48:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 11207261 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A02F21747 for ; Wed, 23 Oct 2019 17:11:55 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 79A1121925 for ; Wed, 23 Oct 2019 17:11:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="eNerlisI" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 79A1121925 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNK9n-0002ep-LL; Wed, 23 Oct 2019 17:10:47 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNK9m-0002dv-Iz for xen-devel@lists.xenproject.org; Wed, 23 Oct 2019 17:10:46 +0000 X-Inumbo-ID: 0940da92-f5b8-11e9-beca-bc764e2007e4 Received: from esa5.hc3370-68.iphmx.com (unknown [216.71.155.168]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 0940da92-f5b8-11e9-beca-bc764e2007e4; Wed, 23 Oct 2019 17:10:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1571850639; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=fSwD/FC99n3T96nVJdnlbsnR9cdA3q+GxDc4nqoWIYY=; b=eNerlisI0iOTbh4Bv+lqgtUQCEQJnZofwYgOxYQ9Z+vGY2s3erxd71eU oEqO14P551r73JAlubRufUY6yLqxBTIAzlganpvLDNgS4jMNMWOZiFnC7 6dC8GTGrpo/aeWT/gXVmh1PEN5HFyX1yJUPsdAQu5JZ0RyBJRXKL3kP5q 8=; Authentication-Results: esa5.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=anthony.perard@citrix.com; spf=Pass smtp.mailfrom=anthony.perard@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa5.hc3370-68.iphmx.com: no sender authenticity information available from domain of anthony.perard@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa5.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa5.hc3370-68.iphmx.com: domain of anthony.perard@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa5.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa5.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa5.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: vYPmbaGETsa2/vNDU6CMB7KIkioEIKqz7CvhUlnsU8NCakD2pTUFQAv3BEwOO+0IGTPKFHjRiT IfdK3+htnDHndDt4zSINwEJSgkYgPuUx4aBUcFYVYPZQS3xFO17WOuOf/PJyVnY467kdZirp5z /B3teKp7Uy4/N8eZwPcKIvfdZ+CplGJvtFDB3SOfFNvqmfZa5lq9Rz75/D7bvYNl8x5ht5BS/l nzrZPDyb7CQA1TRntSE15YsFOy5qttN3m4n0nrHHeym1B9dHhUevmHzEdwo5FeH4hxFgrEh9Y8 A7g= X-SBRS: 2.7 X-MesageID: 7642020 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.68,221,1569297600"; d="scan'208";a="7642020" From: Anthony PERARD To: Date: Wed, 23 Oct 2019 17:48:28 +0100 Message-ID: <20191023164837.2700240-15-anthony.perard@citrix.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191023164837.2700240-1-anthony.perard@citrix.com> References: <20191023164837.2700240-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [RFC XEN PATCH 14/23] convert common/libfdt to kbuild makefile X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Anthony PERARD Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" UNTESTED --- xen/common/libfdt/Makefile | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/xen/common/libfdt/Makefile b/xen/common/libfdt/Makefile index 9ea5c696d52a..a233d82b15ee 100644 --- a/xen/common/libfdt/Makefile +++ b/xen/common/libfdt/Makefile @@ -1,14 +1,16 @@ -include Makefile.libfdt +include $(srctree)/$(src)/Makefile.libfdt SECTIONS := text data $(SPECIAL_DATA_SECTIONS) obj-y += libfdt.o nocov-y += libfdt.o -ccflags-y += -I$(BASEDIR)/include/xen/libfdt/ +ccflags-y += -I$(srctree)/include/xen/libfdt/ +ldflags-y += -r +OBJCOPYFLAGS += $(foreach s,$(SECTIONS),--rename-section .$(s)=.init.$(s)) -libfdt.o: libfdt-temp.o Makefile - $(OBJCOPY) $(foreach s,$(SECTIONS),--rename-section .$(s)=.init.$(s)) $< $@ +$(obj)/libfdt.o: $(obj)/libfdt-temp.o FORCE + $(call if_changed,objcopy) -libfdt-temp.o: $(LIBFDT_OBJS) - $(LD) $(LDFLAGS) -r -o $@ $^ +$(obj)/libfdt-temp.o: $(addprefix $(obj)/,$(LIBFDT_OBJS)) FORCE + $(call if_changed,ld) From patchwork Wed Oct 23 16:48:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 11207271 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9168F112C for ; Wed, 23 Oct 2019 17:12:14 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6A96421925 for ; Wed, 23 Oct 2019 17:12:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="hEFVo3N+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6A96421925 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNKA3-0002sc-90; Wed, 23 Oct 2019 17:11:03 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNKA1-0002rM-JC for xen-devel@lists.xenproject.org; Wed, 23 Oct 2019 17:11:01 +0000 X-Inumbo-ID: 0b553800-f5b8-11e9-8aca-bc764e2007e4 Received: from esa3.hc3370-68.iphmx.com (unknown [216.71.145.155]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 0b553800-f5b8-11e9-8aca-bc764e2007e4; Wed, 23 Oct 2019 17:10:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1571850643; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OFqLPj2kV8PSftL12ZLJDfyzqvavohsPHr58Q3YuqZo=; b=hEFVo3N+PcBN/6ULP2YU/aZLNyJ6pVmr0iF3EVLYYMEcJwGt51Z1Rnz2 q4VzxFDTg+8kg2JzssxTG10fg/9udiai/DWnw4vaWBfPKWv/HUsgG8kJR cFYjIzsEOmIoE1Yi6DmTq01+2LxSuWO/nDMSch1OZEyJ655hhxDfPTnfN 0=; Authentication-Results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=anthony.perard@citrix.com; spf=Pass smtp.mailfrom=anthony.perard@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa3.hc3370-68.iphmx.com: no sender authenticity information available from domain of anthony.perard@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa3.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa3.hc3370-68.iphmx.com: domain of anthony.perard@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa3.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa3.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa3.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: j/XAibLl1a0JSzKn3KCY9isVkb208tdI0hB2UnSR0rzIm1irz71LSU2uuLLpxoIuJAYYFEy/fE 3EAUooH9Mh1JIy/eb16AZ4BUq+o7ePX8YF62rCDTiXyLJWfHEfFyaiQcJpvg1Fuk/kOBpU1eb6 +lmAQj+FY0J/1YB2lN5r98Aa6EEpLm2JCexQJ2foGbWsSodAFJUztlytqS3MODcNnHVRt8mLA5 jrS91TJlSQXIMNC/U/LFgoHwIAXrJaeAmWx7B677loNo5c0592UIrfeEUyN+NLEbPpwGISKn0u B7Q= X-SBRS: 2.7 X-MesageID: 7333657 X-Ironport-Server: esa3.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.68,221,1569297600"; d="scan'208";a="7333657" From: Anthony PERARD To: Date: Wed, 23 Oct 2019 17:48:29 +0100 Message-ID: <20191023164837.2700240-16-anthony.perard@citrix.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191023164837.2700240-1-anthony.perard@citrix.com> References: <20191023164837.2700240-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [RFC XEN PATCH 15/23] convert tools/Makefile to kbuild X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Anthony PERARD Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" --- xen/tools/Makefile | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/xen/tools/Makefile b/xen/tools/Makefile index e940939d61f4..b43f62592019 100644 --- a/xen/tools/Makefile +++ b/xen/tools/Makefile @@ -1,13 +1,2 @@ - -include $(XEN_ROOT)/Config.mk - -.PHONY: default -default: - $(MAKE) symbols - -.PHONY: clean -clean: - rm -f *.o symbols - -symbols: symbols.c - $(HOSTCC) $(HOSTCFLAGS) -o $@ $< +hostprogs-y += symbols +always += $(hostprogs-y) From patchwork Wed Oct 23 16:48:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 11207281 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A8BB3112C for ; Wed, 23 Oct 2019 17:12:41 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 795C52086D for ; Wed, 23 Oct 2019 17:12:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="TPtYBnKR" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 795C52086D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNKAM-00038r-RG; Wed, 23 Oct 2019 17:11:22 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNKAL-00037p-Ki for xen-devel@lists.xenproject.org; Wed, 23 Oct 2019 17:11:21 +0000 X-Inumbo-ID: 1bb60d82-f5b8-11e9-bbab-bc764e2007e4 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 1bb60d82-f5b8-11e9-bbab-bc764e2007e4; Wed, 23 Oct 2019 17:11:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1571850670; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Uaesok/CDrpWx/oY/5QEU2IwqrcXqWtMiGZQgQQmCsg=; b=TPtYBnKR1ggd0iN9pII4zxxFCdfZpmPnLt8Dw2bfCFUYhRDVzdwNajr2 5Yw1kioUrOC7P9BNnPoIhzFxB7kYVTccbcVGyvkijihctfPwChHWLZzCq ORFpzwSMcC2dbw9RJCpedNs3NoF9jliGU9yvVTGzb2ldz1UWJFvWtUsTU I=; Authentication-Results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=anthony.perard@citrix.com; spf=Pass smtp.mailfrom=anthony.perard@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa1.hc3370-68.iphmx.com: no sender authenticity information available from domain of anthony.perard@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa1.hc3370-68.iphmx.com: domain of anthony.perard@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa1.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: bSlCuKR6Oo22JpCosZyf+HLIWVwfw9lzJKzCLscmzma6JfjrObCdHnrt6bwa52/6BsJcy5AWZ7 RQqX4l4K1Ww43USdhcddGHHexNC0XVzI1hvixpKeBiwn2gOEHz6Hv+BSMr6BzQlj4JH9WQAt4W JDgzhjZNHcioWP4QqJGTQgFc6Vg/oT8NxI22fdojYEfq6Xl7A5unlW9j+b1tWcGUxzNipXL4Q6 esYAno3/e/7X+3PpwpM02FTud+qWS5sWWhQgB0N5zbzOPvvdZDHHtNzaaORBZVn8RfYOZMB2yN e4w= X-SBRS: 2.7 X-MesageID: 7429247 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.68,221,1569297600"; d="scan'208";a="7429247" From: Anthony PERARD To: Date: Wed, 23 Oct 2019 17:48:30 +0100 Message-ID: <20191023164837.2700240-17-anthony.perard@citrix.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191023164837.2700240-1-anthony.perard@citrix.com> References: <20191023164837.2700240-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [RFC XEN PATCH 16/23] convert include/Makefile to Kbuild X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Anthony PERARD Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" --- xen/include/Makefile | 125 ++++++++++++++++++++++++++++--------------- 1 file changed, 82 insertions(+), 43 deletions(-) diff --git a/xen/include/Makefile b/xen/include/Makefile index c3e0283d347f..56eb9b7f4540 100644 --- a/xen/include/Makefile +++ b/xen/include/Makefile @@ -1,5 +1,3 @@ -include $(XEN_ROOT)/Config.mk - ifneq ($(CONFIG_COMPAT),) compat-arch-$(CONFIG_X86) := x86_32 @@ -46,67 +44,96 @@ endif endif -public-$(CONFIG_X86) := $(wildcard public/arch-x86/*.h public/arch-x86/*/*.h) -public-$(CONFIG_ARM) := $(wildcard public/arch-arm/*.h public/arch-arm/*/*.h) +public-$(CONFIG_X86) := $(wildcard $(srctree)/$(src)/public/arch-x86/*.h $(srctree)/$(src)/public/arch-x86/*/*.h) +public-$(CONFIG_ARM) := $(wildcard $(srctree)/$(src)/public/arch-arm/*.h $(srctree)/$(src)/public/arch-arm/*/*.h) + +all: $(addprefix $(obj)/,$(headers-y)) -.PHONY: all -all: $(headers-y) +$(obj)/compat/%.h: $(obj)/compat/%.i $(srctree)/tools/compat-build-header.py FORCE + $(call if_changed,compat_header) -compat/%.h: compat/%.i Makefile $(BASEDIR)/tools/compat-build-header.py - set -e; id=_$$(echo $@ | tr '[:lower:]-/.' '[:upper:]___'); \ +quiet_cmd_compat_header = COMPAT-H $@ +define cmd_compat_header + set -e; id=_$$(echo $(patsubst $(obj)/%,%,$(@)) | tr '[:lower:]-/.' '[:upper:]___'); \ echo "#ifndef $$id" >$@.new; \ echo "#define $$id" >>$@.new; \ echo "#include " >>$@.new; \ - $(if $(filter-out compat/arch-%.h,$@),echo "#include <$(patsubst compat/%,public/%,$@)>" >>$@.new;) \ + $(if $(filter-out $(obj)/compat/arch-%.h,$@),echo "#include <$(patsubst $(obj)/compat/%,public/%,$@)>" >>$@.new;) \ $(if $(prefix-y),echo "$(prefix-y)" >>$@.new;) \ grep -v '^# [0-9]' $< | \ - $(PYTHON) $(BASEDIR)/tools/compat-build-header.py | uniq >>$@.new; \ + (cd $(srctree)/$(src); $(PYTHON) $(abs_srctree)/tools/compat-build-header.py) | uniq >>$@.new; \ $(if $(suffix-y),echo "$(suffix-y)" >>$@.new;) \ - echo "#endif /* $$id */" >>$@.new + echo "#endif /* $$id */" >>$@.new; \ mv -f $@.new $@ +endef + +$(obj)/compat/%.i: $(obj)/compat/%.c FORCE + $(call if_changed,compat_i_c) + +quiet_cmd_compat_i_c = CPP $@ + cmd_compat_i_c = $(CPP) $(filter-out -Wa$(comma)% -include %/include/xen/config.h,$(KBUILD_CFLAGS)) $(cppflags-y) -o $@ $< -compat/%.i: compat/%.c Makefile - $(CPP) $(filter-out -Wa$(comma)% -M% %.d -include %/include/xen/config.h,$(CFLAGS)) $(cppflags-y) -o $@ $< +$(obj)/compat/%.c: $(src)/public/%.h $(src)/xlat.lst $(srctree)/tools/compat-build-source.py FORCE + $(call if_changed,compat_source) -compat/%.c: public/%.h xlat.lst Makefile $(BASEDIR)/tools/compat-build-source.py - mkdir -p $(@D) +quiet_cmd_compat_source = COMPAT-C $@ +define cmd_compat_source + set -e; \ + mkdir -p $(@D); \ grep -v 'DEFINE_XEN_GUEST_HANDLE(long)' $< | \ - $(PYTHON) $(BASEDIR)/tools/compat-build-source.py >$@.new + (cd $(srctree)/$(src); $(PYTHON) $(abs_srctree)/tools/compat-build-source.py) >$@.new; \ mv -f $@.new $@ +endef -compat/.xlat/%.h: compat/%.h compat/.xlat/%.lst $(BASEDIR)/tools/get-fields.sh Makefile - export PYTHON=$(PYTHON); \ +$(obj)/compat/.xlat/%.h: $(obj)/compat/%.h $(obj)/compat/.xlat/%.lst $(srctree)/tools/get-fields.sh FORCE + $(call if_changed,sub_xlat_h) + +quiet_cmd_sub_xlat_h = SUBXLAT $@ +define cmd_sub_xlat_h + set -e; \ while read what name; do \ - $(SHELL) $(BASEDIR)/tools/get-fields.sh "$$what" compat_$$name $< || exit $$?; \ - done <$(patsubst compat/%,compat/.xlat/%,$(basename $<)).lst >$@.new + $(SHELL) $(srctree)/tools/get-fields.sh "$$what" compat_$$name $< || exit $$?; \ + done <$(patsubst $(obj)/compat/%,$(obj)/compat/.xlat/%,$(basename $<)).lst >$@.new; \ mv -f $@.new $@ +endef + +$(obj)/compat/.xlat/%.lst: $(src)/xlat.lst $(src)/Makefile + $(call filechk,xlat_lst) -.PRECIOUS: compat/.xlat/%.lst -compat/.xlat/%.lst: xlat.lst Makefile - mkdir -p $(@D) - grep -v '^[[:blank:]]*#' $< | sed -ne 's,@arch@,$(compat-arch-y),g' -re 's,[[:blank:]]+$*\.h[[:blank:]]*$$,,p' >$@.new - $(call move-if-changed,$@.new,$@) +define filechk_xlat_lst + grep -v '^[[:blank:]]*#' $< | sed -ne 's,@arch@,$(compat-arch-y),g' -re 's,[[:blank:]]+$*\.h[[:blank:]]*$$,,p' +endef -xlat-y := $(shell sed -ne 's,@arch@,$(compat-arch-y),g' -re 's,^[?!][[:blank:]]+[^[:blank:]]+[[:blank:]]+,,p' xlat.lst | uniq) +xlat-y := $(shell sed -ne 's,@arch@,$(compat-arch-y),g' -re 's,^[?!][[:blank:]]+[^[:blank:]]+[[:blank:]]+,,p' $(srctree)/$(src)/xlat.lst | uniq) xlat-y := $(filter $(patsubst compat/%,%,$(headers-y)),$(xlat-y)) -compat/xlat.h: $(addprefix compat/.xlat/,$(xlat-y)) Makefile - cat $(filter %.h,$^) >$@.new +$(obj)/compat/xlat.h: $(addprefix $(obj)/compat/.xlat/,$(xlat-y)) + $(call if_changed,xlat_h) + +quiet_cmd_xlat_h = UPD $@ +define cmd_xlat_h + set -e; \ + cat $(filter %.h,$^) >$@.new; \ mv -f $@.new $@ +endef ifeq ($(XEN_TARGET_ARCH),$(XEN_COMPILE_ARCH)) -all: headers.chk headers99.chk headers++.chk +all: $(obj)/headers.chk $(obj)/headers99.chk $(obj)/headers++.chk -PUBLIC_HEADERS := $(filter-out public/arch-% public/dom0_ops.h, $(wildcard public/*.h public/*/*.h) $(public-y)) +PUBLIC_HEADERS := $(filter-out $(srctree)/$(src)/public/arch-% $(srctree)/$(src)/public/dom0_ops.h, $(wildcard $(srctree)/$(src)/public/*.h $(srctree)/$(src)/public/*/*.h) $(public-y)) -PUBLIC_C99_HEADERS := public/io/9pfs.h public/io/pvcalls.h -PUBLIC_ANSI_HEADERS := $(filter-out public/%ctl.h public/xsm/% public/%hvm/save.h $(PUBLIC_C99_HEADERS), $(PUBLIC_HEADERS)) +PUBLIC_C99_HEADERS := $(srctree)/$(src)/public/io/9pfs.h $(srctree)/$(src)/public/io/pvcalls.h +PUBLIC_ANSI_HEADERS := $(filter-out $(srctree)/$(src)/public/%ctl.h $(srctree)/$(src)/public/xsm/% $(srctree)/$(src)/public/%hvm/save.h $(PUBLIC_C99_HEADERS), $(PUBLIC_HEADERS)) -public/io/9pfs.h-prereq := string -public/io/pvcalls.h-prereq := string +# XXX for in tree build +$(src)/public/io/9pfs.h-prereq := string +$(src)/public/io/pvcalls.h-prereq := string +# XXX for out of tree build +$(srctree)/$(src)/public/io/9pfs.h-prereq := string +$(srctree)/$(src)/public/io/pvcalls.h-prereq := string -headers.chk: $(PUBLIC_ANSI_HEADERS) Makefile +$(obj)/headers.chk: $(PUBLIC_ANSI_HEADERS) $(src)/Makefile for i in $(filter %.h,$^); do \ $(CC) -x c -ansi -Wall -Werror -include stdint.h \ -S -o /dev/null $$i || exit 1; \ @@ -114,7 +141,7 @@ headers.chk: $(PUBLIC_ANSI_HEADERS) Makefile done >$@.new mv $@.new $@ -headers99.chk: $(PUBLIC_C99_HEADERS) Makefile +$(obj)/headers99.chk: $(PUBLIC_C99_HEADERS) $(src)/Makefile rm -f $@.new $(foreach i, $(filter %.h,$^), \ echo "#include "\"$(i)\" \ @@ -124,7 +151,7 @@ headers99.chk: $(PUBLIC_C99_HEADERS) Makefile || exit $$?; echo $(i) >> $@.new;) mv $@.new $@ -headers++.chk: $(PUBLIC_HEADERS) Makefile +$(obj)/headers++.chk: $(PUBLIC_HEADERS) $(src)/Makefile rm -f $@.new if ! $(CXX) -v >/dev/null 2>&1; then \ touch $@.new; \ @@ -133,21 +160,33 @@ headers++.chk: $(PUBLIC_HEADERS) Makefile $(foreach i, $(filter %.h,$^), \ echo "#include "\"$(i)\" \ | $(CXX) -x c++ -std=gnu++98 -Wall -Werror -D__XEN_TOOLS__ \ - -include stdint.h -include public/xen.h \ + -include stdint.h -include $(srctree)/$(src)/public/xen.h \ $(foreach j, $($(i)-prereq), -include c$(j)) -S -o /dev/null - \ || exit $$?; echo $(i) >> $@.new;) mv $@.new $@ endif -ifeq ($(XEN_TARGET_ARCH),x86_64) +ifeq ($(ARCH),x86_64) .PHONY: lib-x86-all lib-x86-all: - $(MAKE) -C xen/lib/x86 all + $(Q)$(MAKE) XEN_ROOT=$(abs_srctree)/.. -C $(srctree)/$(src)/xen/lib/x86 all all: lib-x86-all endif -clean:: - rm -rf compat config generated headers*.chk - rm -f $(BASEDIR)/include/xen/lib/x86/cpuid-autogen.h +# Update targets to help Kbuild finding which dependency file to load. +targets += $(headers-y) +# Adding intermediate targets +targets += $(foreach h, $(headers-y), \ + $(h:.h=.i) $(h:.h=.c)) +# Adding intermediate targets of xlat.h +targets += $(addprefix compat/.xlat/,$(xlat-y)) + +clean-dirs += compat config generated +clean-files += headers*.chk +clean-files += xen/lib/x86/cpuid-autogen.h + +PHONY += all +all: + @: From patchwork Wed Oct 23 16:48:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 11207269 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8E84613BD for ; Wed, 23 Oct 2019 17:12:14 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6A1E32086D for ; Wed, 23 Oct 2019 17:12:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="cFzZXXy7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6A1E32086D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNK9x-0002oU-UM; Wed, 23 Oct 2019 17:10:57 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNK9w-0002nO-Iz for xen-devel@lists.xenproject.org; Wed, 23 Oct 2019 17:10:56 +0000 X-Inumbo-ID: 0aa14930-f5b8-11e9-beca-bc764e2007e4 Received: from esa6.hc3370-68.iphmx.com (unknown [216.71.155.175]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 0aa14930-f5b8-11e9-beca-bc764e2007e4; Wed, 23 Oct 2019 17:10:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1571850641; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wnCv9ZGrrESUtmv06BSWa5amQpOi4qJIM6JevnOyWqE=; b=cFzZXXy7cP5J5glC1csqbI2X/MT63vRbubRqNBJ+fpKwJHUN7SiTN0eX PRjwhbNf+7WKj53crl3kLe4icnH+Bd2JtBBoMePin1oT9Pb1pGkwpNBTu NFl6ajv+VxIigYhKn/UtGNKmX9Lr1AZ4u+aN1rPuuCgg6wMbDcRNJiNS5 A=; Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=anthony.perard@citrix.com; spf=Pass smtp.mailfrom=anthony.perard@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa6.hc3370-68.iphmx.com: no sender authenticity information available from domain of anthony.perard@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa6.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa6.hc3370-68.iphmx.com: domain of anthony.perard@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa6.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa6.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa6.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: NUHm0shS0X5MEjsNC/5JnyrZJ6VBgdPZgh92ZH1Qp7112qH07SrB3vC5Q/5yE8E6tNsGv1E2J7 PHhZiJ7v85czJPI+6YSZxao3+gR/TaA4+J1zvy2syqzxgS8M021QedTNPdGgbtWzuikbzz0l2O ntlVpUbhXmcBX8vmmjA7Lz3ltugOg3YCc3ZbwmcFb7yb63RYgDIfzT+6jonVJZcfFYw62htjip iIygpdWOKPZy2uf8PEY4d2D6gz6Beo/LgcDpz8B7sAM4KZZIkGt/mHSaWYiWvutwthJb9yHVNm eW8= X-SBRS: 2.7 X-MesageID: 7683603 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.68,221,1569297600"; d="scan'208";a="7683603" From: Anthony PERARD To: Date: Wed, 23 Oct 2019 17:48:31 +0100 Message-ID: <20191023164837.2700240-18-anthony.perard@citrix.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191023164837.2700240-1-anthony.perard@citrix.com> References: <20191023164837.2700240-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [RFC XEN PATCH 17/23] convert arch/x86/boot/Makefile to kbuild X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Anthony PERARD Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Sources of *FLAGS for 32bit build: - Config.mk - config/x86_32.mk - deleted build32.mk --- xen/arch/x86/boot/Makefile | 72 +++++++++++++++++++++++++++++------- xen/arch/x86/boot/build32.mk | 40 -------------------- 2 files changed, 58 insertions(+), 54 deletions(-) delete mode 100644 xen/arch/x86/boot/build32.mk diff --git a/xen/arch/x86/boot/Makefile b/xen/arch/x86/boot/Makefile index 9b31bfcbfb8a..fe6344aa0022 100644 --- a/xen/arch/x86/boot/Makefile +++ b/xen/arch/x86/boot/Makefile @@ -1,20 +1,64 @@ -obj-bin-y += head.o +# Add -Iinclude so cc-option calls can work properly. (The current CFLAGS want +# to include a header which includes ) +KBUILD_CFLAGS += $(LINUXINCLUDE) +# Prepare CFLAGS to have 32bit build for the deps of head.S +CFLAGS_S_c := -m32 -march=i686 +CFLAGS_S_c += -fno-strict-aliasing -std=gnu99 -Wall -Wstrict-prototypes +CFLAGS_S_c += $(call cc-option,-Wdeclaration-after-statement) +CFLAGS_S_c += $(call cc-disable-warning,unused-but-set-variable) +CFLAGS_S_c += $(call cc-disable-warning,unused-local-typedefs) -DEFS_H_DEPS = defs.h $(BASEDIR)/include/xen/stdbool.h +EMBEDDED_EXTRA_CFLAGS := -nopie -fno-stack-protector -fno-stack-protector-all +EMBEDDED_EXTRA_CFLAGS += -fno-exceptions +CFLAGS_S_c += $(foreach o,$(EMBEDDED_EXTRA_CFLAGS),$(call cc-option,$(o))) +CFLAGS_S_c += -Werror -fno-asynchronous-unwind-tables -fno-builtin -g0 -msoft-float +CFLAGS_S_c := $(filter-out -flto,$(CFLAGS_S_c)) +CFLAGS_S_c += -fpic +LDFLAGS_emulation_OpenBSD := _obsd +LDFLAGS_emulation_FreeBSD := _fbsd +LDFLAGS_S_c := -melf_i386$(LDFLAGS_emulation_$(XEN_OS)) -N -T $(srctree)/$(src)/build32.lds -CMDLINE_DEPS = $(DEFS_H_DEPS) video.h +head-deps := cmdline.S reloc.S +targets += $(foreach o,$(head-deps), \ + $(foreach sfx,o lnk bin S, \ + $(patsubst %.S,%.$(sfx),$(o)))) -RELOC_DEPS = $(DEFS_H_DEPS) \ - $(BASEDIR)/include/generated/autoconf.h \ - $(BASEDIR)/include/xen/kconfig.h \ - $(BASEDIR)/include/xen/multiboot.h \ - $(BASEDIR)/include/xen/multiboot2.h \ - $(BASEDIR)/include/public/arch-x86/hvm/start_info.h +$(addprefix $(obj)/,$(head-deps:.S=.o)): KBUILD_CFLAGS := $(CFLAGS_S_c) +$(addprefix $(obj)/,$(head-deps:.S=.lnk)): KBUILD_LDFLAGS := $(LDFLAGS_S_c) -head.o: cmdline.S reloc.S +$(obj)/head.o: $(addprefix $(obj)/,$(head-deps)) +obj-y := head.o -cmdline.S: cmdline.c $(CMDLINE_DEPS) - $(MAKE) -f build32.mk $@ CMDLINE_DEPS="$(CMDLINE_DEPS)" +# NB. awk invocation is a portable alternative to 'head -n -1' +quiet_cmd_sed_S_bin = UPD $@ +define cmd_sed_S_bin + (od -v -t x $< | tr -s ' ' | awk 'NR > 1 {print s} {s=$$0}' | \ + sed 's/ /,0x/g' | sed 's/,0x$$//' | sed 's/^[0-9]*,/ .long /') >$@ +endef +$(addprefix $(obj)/,cmdline.S reloc.S): $(obj)/%.S: $(obj)/%.bin FORCE + $(call if_changed,sed_S_bin) -reloc.S: reloc.c $(RELOC_DEPS) - $(MAKE) -f build32.mk $@ RELOC_DEPS="$(RELOC_DEPS)" +# Drop .got.plt during conversion to plain binary format. +# Please check build32.lds for more details. +quiet_cmd_check_obj_got_plt = CHECK $@ +define cmd_check_obj_got_plt + set -e; \ + $(OBJDUMP) -h $< | sed -n '/[0-9]/{s,00*,0,g;p;}' | \ + while read idx name sz rest; do \ + case "$$name" in \ + .got.plt) \ + test $$sz != 0c || continue; \ + echo "Error: non-empty $$name: 0x$$sz" >&2; \ + exit $$(expr $$idx + 1);; \ + esac; \ + done +endef +quiet_cmd_check_obj_drop_got_plt = OBJCOPY $@ +cmd_check_obj_drop_got_plt = $(cmd_check_obj_got_plt); $(cmd_objcopy) + +OBJCOPYFLAGS := -O binary -R .got.plt +$(obj)/%.bin: $(obj)/%.lnk FORCE + $(call if_changed,check_obj_drop_got_plt) + +$(obj)/%.lnk: $(obj)/%.o FORCE + $(call if_changed,ld) diff --git a/xen/arch/x86/boot/build32.mk b/xen/arch/x86/boot/build32.mk deleted file mode 100644 index 48c7407c002f..000000000000 --- a/xen/arch/x86/boot/build32.mk +++ /dev/null @@ -1,40 +0,0 @@ -override XEN_TARGET_ARCH=x86_32 -CFLAGS = -include $(XEN_ROOT)/Config.mk - -$(call cc-options-add,CFLAGS,CC,$(EMBEDDED_EXTRA_CFLAGS)) - -CFLAGS += -Werror -fno-asynchronous-unwind-tables -fno-builtin -g0 -msoft-float -CFLAGS += -I$(XEN_ROOT)/xen/include -CFLAGS := $(filter-out -flto,$(CFLAGS)) - -# NB. awk invocation is a portable alternative to 'head -n -1' -%.S: %.bin - (od -v -t x $< | tr -s ' ' | awk 'NR > 1 {print s} {s=$$0}' | \ - sed 's/ /,0x/g' | sed 's/,0x$$//' | sed 's/^[0-9]*,/ .long /') >$@ - -# Drop .got.plt during conversion to plain binary format. -# Please check build32.lds for more details. -%.bin: %.lnk - $(OBJDUMP) -h $< | sed -n '/[0-9]/{s,00*,0,g;p;}' | \ - while read idx name sz rest; do \ - case "$$name" in \ - .got.plt) \ - test $$sz != 0c || continue; \ - echo "Error: non-empty $$name: 0x$$sz" >&2; \ - exit $$(expr $$idx + 1);; \ - esac; \ - done - $(OBJCOPY) -O binary -R .got.plt $< $@ - -%.lnk: %.o - $(LD) $(LDFLAGS_DIRECT) -N -T build32.lds -o $@ $< - -%.o: %.c - $(CC) $(CFLAGS) -c -fpic $< -o $@ - -cmdline.o: cmdline.c $(CMDLINE_DEPS) - -reloc.o: reloc.c $(RELOC_DEPS) - -.PRECIOUS: %.bin %.lnk From patchwork Wed Oct 23 16:48:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 11207273 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6324A13BD for ; Wed, 23 Oct 2019 17:12:23 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 339BC2086D for ; Wed, 23 Oct 2019 17:12:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="Ywf7F5cY" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 339BC2086D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNKA8-0002wM-Ka; Wed, 23 Oct 2019 17:11:08 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNKA6-0002v8-JS for xen-devel@lists.xenproject.org; Wed, 23 Oct 2019 17:11:06 +0000 X-Inumbo-ID: 0eca61ea-f5b8-11e9-8aca-bc764e2007e4 Received: from esa3.hc3370-68.iphmx.com (unknown [216.71.145.155]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 0eca61ea-f5b8-11e9-8aca-bc764e2007e4; Wed, 23 Oct 2019 17:10:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1571850648; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=VkPNM8eB2g+blwW/+f1fejfXCBhRbUl28kmW/LxAdfE=; b=Ywf7F5cYRHtQjhIO6/Lp6xH9lD9GNqBnR7HU1pA9y3j4Nc098dB3cQmL p3uUEN64n8JRXLWf9a6dpA+bIsikTtVtE8fHqGODBLAHecW51ZArfiYhH 1d4NQmZImzjhsxXH1WUxws8HycH0X0jFZW9GT6Awbz8Fgq7dP6iE4ZLcR w=; Authentication-Results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=anthony.perard@citrix.com; spf=Pass smtp.mailfrom=anthony.perard@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa3.hc3370-68.iphmx.com: no sender authenticity information available from domain of anthony.perard@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa3.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa3.hc3370-68.iphmx.com: domain of anthony.perard@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa3.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa3.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa3.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: 1aBr0Qdml6ZkS4aycuz1jMffgTxDzce3NNWTlRumzIOQTEygMlN6WaEG7Ztd4vhH5U18cegnSE MHqgmNLZNaUqs7SLgUp+Y8YQHCPHSaUjxchZSBHqjIHLQpHc2SuNRajOW1ajIJ2zw8fyN94Q9F /aUZ3sX+RT9L6rcJJtT1FvsD4x8WssRZG2QuTb5DYXD1eLXN41qD7I5bTUWC9cqaH9B3tFLn5/ S2aF4ATnjmwIVujVaIkdVQQhQCS+HMlBIEcjY3z347ab4y2BSQ5Yw6ZmWjMLFm+f8cGvXEeHUg Hlk= X-SBRS: 2.7 X-MesageID: 7333662 X-Ironport-Server: esa3.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.68,221,1569297600"; d="scan'208";a="7333662" From: Anthony PERARD To: Date: Wed, 23 Oct 2019 17:48:32 +0100 Message-ID: <20191023164837.2700240-19-anthony.perard@citrix.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191023164837.2700240-1-anthony.perard@citrix.com> References: <20191023164837.2700240-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [RFC XEN PATCH 18/23] arch/x86: Start moving build targets out of Makefile into Kbuild. X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Anthony PERARD Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" arch/*/Makefile will be included by the root makefile, its job will mosty be to generate the *FLAGS for this arch. arch/*/Kbuild will be used by recursive make, to build *.o and others. --- xen/arch/x86/Kbuild | 153 ++++++++++++++++++++++++++++++++++++++++++ xen/arch/x86/Makefile | 148 ---------------------------------------- 2 files changed, 153 insertions(+), 148 deletions(-) create mode 100644 xen/arch/x86/Kbuild diff --git a/xen/arch/x86/Kbuild b/xen/arch/x86/Kbuild new file mode 100644 index 000000000000..5cad96bed111 --- /dev/null +++ b/xen/arch/x86/Kbuild @@ -0,0 +1,153 @@ +obj-y += acpi/ +obj-y += cpu/ +obj-y += genapic/ +obj-$(CONFIG_XEN_GUEST) += guest/ +obj-$(CONFIG_HVM) += hvm/ +obj-y += mm/ +obj-$(CONFIG_XENOPROF) += oprofile/ +obj-$(CONFIG_PV) += pv/ +obj-y += x86_64/ + +alternative-y := alternative.init.o +alternative-$(CONFIG_LIVEPATCH) := +obj-bin-y += $(alternative-y) +obj-y += apic.o +obj-y += bitops.o +obj-bin-y += bzimage.init.o +obj-bin-y += clear_page.o +obj-bin-y += copy_page.o +obj-y += cpuid.o +obj-$(CONFIG_PV) += compat.o x86_64/compat.o +obj-$(CONFIG_KEXEC) += crash.o +obj-y += debug.o +obj-y += delay.o +obj-y += desc.o +obj-bin-y += dmi_scan.init.o +obj-y += domctl.o +obj-y += domain.o +obj-bin-y += dom0_build.init.o +obj-y += domain_page.o +obj-y += e820.o +obj-y += emul-i8254.o +obj-y += extable.o +obj-y += flushtlb.o +obj-$(CONFIG_CRASH_DEBUG) += gdbstub.o +obj-y += hypercall.o +obj-y += i387.o +obj-y += i8259.o +obj-y += io_apic.o +obj-$(CONFIG_LIVEPATCH) += alternative.o livepatch.o +obj-y += msi.o +obj-y += msr.o +obj-$(CONFIG_INDIRECT_THUNK) += indirect-thunk.o +obj-y += ioport_emulate.o +obj-y += irq.o +obj-$(CONFIG_KEXEC) += machine_kexec.o +obj-y += microcode_amd.o +obj-y += microcode_intel.o +obj-y += microcode.o +obj-y += mm.o x86_64/mm.o +obj-$(CONFIG_HVM) += monitor.o +obj-y += mpparse.o +obj-y += nmi.o +obj-y += numa.o +obj-y += pci.o +obj-y += percpu.o +obj-y += physdev.o x86_64/physdev.o +obj-y += platform_hypercall.o x86_64/platform_hypercall.o +obj-y += psr.o +obj-y += setup.o +obj-y += shutdown.o +obj-y += smp.o +obj-y += smpboot.o +obj-y += spec_ctrl.o +obj-y += srat.o +obj-y += string.o +obj-y += sysctl.o +obj-y += time.o +obj-y += trace.o +obj-y += traps.o +obj-y += usercopy.o +obj-y += x86_emulate.o +obj-$(CONFIG_TBOOT) += tboot.o +obj-y += hpet.o +obj-y += vm_event.o +obj-y += xstate.o + +extra-y += xen.lds efi.lds + +hostprogs-y += boot/mkelf32 + +ifneq ($(build_id_linker),) +notes_phdrs = --notes +else +ifeq ($(CONFIG_PVH_GUEST),y) +notes_phdrs = --notes +endif +endif + +ifdef CONFIG_LIVEPATCH +all_symbols = --all-symbols +ifdef CONFIG_FAST_SYMBOL_LOOKUP +all_symbols = --all-symbols --sort-by-name +endif +else +all_symbols = +endif + +syms-warn-dup-y := --warn-dup +syms-warn-dup-$(CONFIG_SUPPRESS_DUPLICATE_SYMBOL_WARNINGS) := + +$(TARGET): TMP = $(@D)/.$(@F).elf32 +$(TARGET): $(TARGET)-syms $(efi-y) $(obj)/boot/mkelf32 + $(obj)/boot/mkelf32 $(notes_phdrs) $(TARGET)-syms $(TMP) $(XEN_IMG_OFFSET) \ + `$(NM) $(TARGET)-syms | sed -ne 's/^\([^ ]*\) . __2M_rwdata_end$$/0x\1/p'` + od -t x4 -N 8192 $(TMP) | grep 1badb002 > /dev/null || \ + { echo "No Multiboot1 header found" >&2; false; } + od -t x4 -N 32768 $(TMP) | grep e85250d6 > /dev/null || \ + { echo "No Multiboot2 header found" >&2; false; } + mv $(TMP) $(TARGET) + +targets += prelink.o +LDFLAGS_prelink.o := -r --whole-archive +$(obj)/prelink.o: $(ALL_OBJS) FORCE + $(call if_changed,ld) + +LDFLAGS_$(TARGET)-syms += -T $(obj)/xen.lds -N +$(TARGET)-syms: $(obj)/prelink.o $(obj)/xen.lds + $(LD) $(ld_flags) $< $(build_id_linker) \ + $(objtree)/common/symbols-dummy.o -o $(@D)/.$(@F).0 + $(NM) -pa --format=sysv $(@D)/.$(@F).0 \ + | $(objtree)/tools/symbols $(all_symbols) --sysv --sort \ + >$(@D)/.$(@F).0.S + $(MAKE) $(build)=$(@D) $(@D)/.$(@F).0.o + $(LD) $(ld_flags) $< $(build_id_linker) \ + $(@D)/.$(@F).0.o -o $(@D)/.$(@F).1 + $(NM) -pa --format=sysv $(@D)/.$(@F).1 \ + | $(objtree)/tools/symbols $(all_symbols) --sysv --sort $(syms-warn-dup-y) \ + >$(@D)/.$(@F).1.S + $(MAKE) $(build)=$(@D) $(@D)/.$(@F).1.o + $(LD) $(ld_flags) $< $(build_id_linker) \ + $(@D)/.$(@F).1.o -o $@ + $(NM) -pa --format=sysv $(@D)/$(@F) \ + | $(objtree)/tools/symbols --xensyms --sysv --sort \ + >$(@D)/$(@F).map + rm -f $(@D)/.$(@F).[0-9]* $(@D)/..$(@F).[0-9]* + +targets += asm-offsets.s +CFLAGS_REMOVE_asm-offsets.o := -flto +$(obj)/asm-offsets.s: $(src)/$(ARCH)/asm-offsets.c $(objtree)/include/asm-x86/asm-macros.h FORCE + $(call if_changed_dep,cc_s_c) + +# FLAGS for asm-macros.i +CFLAGS_asm-macros.o := -D__ASSEMBLY__ -P + +# Extra aflags for efi.lds +AFLAGS_efi.o := -DEFI + +quiet_cmd_xen_cpp_lds_S = LDS $@ + cmd_xen_cpp_lds_S = $(CPP) $(filter-out -Wa$(comma)%,$(a_flags)) -P -Ui386 \ + -o $@ $< + +$(obj)/%.lds: $(src)/xen.lds.S FORCE + $(call if_changed_dep,xen_cpp_lds_S) diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile index 864a0669bc9f..49b7eb9fd116 100644 --- a/xen/arch/x86/Makefile +++ b/xen/arch/x86/Makefile @@ -1,115 +1,8 @@ -obj-y += acpi/ -obj-y += cpu/ -obj-y += genapic/ -obj-$(CONFIG_XEN_GUEST) += guest/ -obj-$(CONFIG_HVM) += hvm/ -obj-y += mm/ -obj-$(CONFIG_XENOPROF) += oprofile/ -obj-$(CONFIG_PV) += pv/ -obj-y += x86_64/ - -alternative-y := alternative.init.o -alternative-$(CONFIG_LIVEPATCH) := -obj-bin-y += $(alternative-y) -obj-y += apic.o -obj-y += bitops.o -obj-bin-y += bzimage.init.o -obj-bin-y += clear_page.o -obj-bin-y += copy_page.o -obj-y += cpuid.o -obj-$(CONFIG_PV) += compat.o x86_64/compat.o -obj-$(CONFIG_KEXEC) += crash.o -obj-y += debug.o -obj-y += delay.o -obj-y += desc.o -obj-bin-y += dmi_scan.init.o -obj-y += domctl.o -obj-y += domain.o -obj-bin-y += dom0_build.init.o -obj-y += domain_page.o -obj-y += e820.o -obj-y += emul-i8254.o -obj-y += extable.o -obj-y += flushtlb.o -obj-$(CONFIG_CRASH_DEBUG) += gdbstub.o -obj-y += hypercall.o -obj-y += i387.o -obj-y += i8259.o -obj-y += io_apic.o -obj-$(CONFIG_LIVEPATCH) += alternative.o livepatch.o -obj-y += msi.o -obj-y += msr.o -obj-$(CONFIG_INDIRECT_THUNK) += indirect-thunk.o -obj-y += ioport_emulate.o -obj-y += irq.o -obj-$(CONFIG_KEXEC) += machine_kexec.o -obj-y += microcode_amd.o -obj-y += microcode_intel.o -obj-y += microcode.o -obj-y += mm.o x86_64/mm.o -obj-$(CONFIG_HVM) += monitor.o -obj-y += mpparse.o -obj-y += nmi.o -obj-y += numa.o -obj-y += pci.o -obj-y += percpu.o -obj-y += physdev.o x86_64/physdev.o -obj-y += platform_hypercall.o x86_64/platform_hypercall.o -obj-y += psr.o -obj-y += setup.o -obj-y += shutdown.o -obj-y += smp.o -obj-y += smpboot.o -obj-y += spec_ctrl.o -obj-y += srat.o -obj-y += string.o -obj-y += sysctl.o -obj-y += time.o -obj-y += trace.o -obj-y += traps.o -obj-y += usercopy.o -obj-y += x86_emulate.o -obj-$(CONFIG_TBOOT) += tboot.o -obj-y += hpet.o -obj-y += vm_event.o -obj-y += xstate.o - -x86_emulate.o: x86_emulate/x86_emulate.c x86_emulate/x86_emulate.h efi-y := $(shell if [ ! -r $(BASEDIR)/include/xen/compile.h -o \ -O $(BASEDIR)/include/xen/compile.h ]; then \ echo '$(TARGET).efi'; fi) -ifneq ($(build_id_linker),) -notes_phdrs = --notes -else -ifeq ($(CONFIG_PVH_GUEST),y) -notes_phdrs = --notes -endif -endif - -ifdef CONFIG_LIVEPATCH -all_symbols = --all-symbols -ifdef CONFIG_FAST_SYMBOL_LOOKUP -all_symbols = --all-symbols --sort-by-name -endif -else -all_symbols = -endif - -syms-warn-dup-y := --warn-dup -syms-warn-dup-$(CONFIG_SUPPRESS_DUPLICATE_SYMBOL_WARNINGS) := - -$(TARGET): TMP = $(@D)/.$(@F).elf32 -$(TARGET): $(TARGET)-syms $(efi-y) boot/mkelf32 - ./boot/mkelf32 $(notes_phdrs) $(TARGET)-syms $(TMP) $(XEN_IMG_OFFSET) \ - `$(NM) $(TARGET)-syms | sed -ne 's/^\([^ ]*\) . __2M_rwdata_end$$/0x\1/p'` - od -t x4 -N 8192 $(TMP) | grep 1badb002 > /dev/null || \ - { echo "No Multiboot1 header found" >&2; false; } - od -t x4 -N 32768 $(TMP) | grep e85250d6 > /dev/null || \ - { echo "No Multiboot2 header found" >&2; false; } - mv $(TMP) $(TARGET) - ALL_OBJS := $(BASEDIR)/arch/x86/boot/built_in.o $(BASEDIR)/arch/x86/efi/built_in.o $(ALL_OBJS) ifeq ($(CONFIG_LTO),y) @@ -127,33 +20,10 @@ prelink.o: $(patsubst %/built_in.o,%/built_in_bin.o,$(ALL_OBJS)) prelink_lto.o prelink-efi.o: $(patsubst %/built_in.o,%/built_in_bin.o,$(ALL_OBJS)) prelink-efi_lto.o efi/boot.init.o $(guard) $(LD) $(LDFLAGS) -r -o $@ $^ else -prelink.o: $(ALL_OBJS) - $(LD) $(LDFLAGS) -r -o $@ $^ - prelink-efi.o: $(ALL_OBJS) efi/boot.init.o efi/runtime.o efi/compat.o $(guard) $(LD) $(LDFLAGS) -r -o $@ $(filter-out %/efi/built_in.o,$^) endif -$(TARGET)-syms: prelink.o xen.lds - $(LD) $(LDFLAGS) -T xen.lds -N prelink.o $(build_id_linker) \ - $(BASEDIR)/common/symbols-dummy.o -o $(@D)/.$(@F).0 - $(NM) -pa --format=sysv $(@D)/.$(@F).0 \ - | $(BASEDIR)/tools/symbols $(all_symbols) --sysv --sort \ - >$(@D)/.$(@F).0.S - $(MAKE) -f $(BASEDIR)/Rules.mk $(@D)/.$(@F).0.o - $(LD) $(LDFLAGS) -T xen.lds -N prelink.o $(build_id_linker) \ - $(@D)/.$(@F).0.o -o $(@D)/.$(@F).1 - $(NM) -pa --format=sysv $(@D)/.$(@F).1 \ - | $(BASEDIR)/tools/symbols $(all_symbols) --sysv --sort $(syms-warn-dup-y) \ - >$(@D)/.$(@F).1.S - $(MAKE) -f $(BASEDIR)/Rules.mk $(@D)/.$(@F).1.o - $(LD) $(LDFLAGS) -T xen.lds -N prelink.o $(build_id_linker) \ - $(@D)/.$(@F).1.o -o $@ - $(NM) -pa --format=sysv $(@D)/$(@F) \ - | $(BASEDIR)/tools/symbols --xensyms --sysv --sort \ - >$(@D)/$(@F).map - rm -f $(@D)/.$(@F).[0-9]* $(@D)/..$(@F).[0-9]* - note.o: $(TARGET)-syms $(OBJCOPY) -O binary --only-section=.note.gnu.build-id $(BASEDIR)/xen-syms $@.bin $(OBJCOPY) -I binary -O elf64-x86-64 -B i386:x86-64 \ @@ -219,11 +89,6 @@ $(TARGET).efi: prelink-efi.o $(note_file) efi.lds efi/relocs-dummy.o efi/mkreloc efi/boot.init.o efi/runtime.o efi/compat.o efi/buildid.o: $(BASEDIR)/arch/x86/efi/built_in.o efi/boot.init.o efi/runtime.o efi/compat.o efi/buildid.o: ; -asm-offsets.s: $(TARGET_SUBARCH)/asm-offsets.c $(BASEDIR)/include/asm-x86/asm-macros.h - $(CC) $(filter-out -Wa$(comma)% -flto,$(CFLAGS)) -S -o $@ $< - -asm-macros.i: CFLAGS += -D__ASSEMBLY__ -P - $(BASEDIR)/include/asm-x86/asm-macros.h: asm-macros.i Makefile echo '#if 0' >$@.new echo '.if 0' >>$@.new @@ -235,19 +100,6 @@ $(BASEDIR)/include/asm-x86/asm-macros.h: asm-macros.i Makefile echo '#endif' >>$@.new $(call move-if-changed,$@.new,$@) -xen.lds: xen.lds.S - $(CC) -P -E -Ui386 $(filter-out -Wa$(comma)%,$(AFLAGS)) -o $@ $< - sed -e 's/.*\.lds\.o:/$(@F):/g' <.$(@F).d >.$(@F).d.new - mv -f .$(@F).d.new .$(@F).d - -efi.lds: xen.lds.S - $(CC) -P -E -Ui386 -DEFI $(filter-out -Wa$(comma)%,$(AFLAGS)) -o $@ $< - sed -e 's/.*\.lds\.o:/$(@F):/g' <.$(@F).d >.$(@F).d.new - mv -f .$(@F).d.new .$(@F).d - -boot/mkelf32: boot/mkelf32.c - $(HOSTCC) $(HOSTCFLAGS) -o $@ $< - efi/mkreloc: efi/mkreloc.c $(HOSTCC) $(HOSTCFLAGS) -g -o $@ $< From patchwork Wed Oct 23 16:48:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 11207257 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 09646112C for ; Wed, 23 Oct 2019 17:11:48 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D9AF92086D for ; Wed, 23 Oct 2019 17:11:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="Aiwjc/L3" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D9AF92086D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNK9d-0002Yg-UC; Wed, 23 Oct 2019 17:10:37 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNK9c-0002Xv-Ih for xen-devel@lists.xenproject.org; Wed, 23 Oct 2019 17:10:36 +0000 X-Inumbo-ID: 070b0d24-f5b8-11e9-bbab-bc764e2007e4 Received: from esa5.hc3370-68.iphmx.com (unknown [216.71.155.168]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 070b0d24-f5b8-11e9-bbab-bc764e2007e4; Wed, 23 Oct 2019 17:10:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1571850635; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CmM17caS9BcmxVqilv9CV864hCkmygyaAx1dtmUJsKE=; b=Aiwjc/L3U591+5AREaFLWNsdA1FoMHTIDNL0t2+q/WytaogoN+4/6FAI Nb2bLeSR9EVRhi2S3ReHa7Qj7jT+yWUSDbFEnYaua64GGycWU8GXtPI/X OQ8wwOq65GL9Acjo5HKNxSQAJdCqLu306Jq5hp5vc5nfQaDJ+eg9MBq0H g=; Authentication-Results: esa5.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=anthony.perard@citrix.com; spf=Pass smtp.mailfrom=anthony.perard@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa5.hc3370-68.iphmx.com: no sender authenticity information available from domain of anthony.perard@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa5.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa5.hc3370-68.iphmx.com: domain of anthony.perard@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa5.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa5.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa5.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: 96h22YvGU1Hv80EMQPFhAJtz51BiZ2aQCqOdCC1wc36zTwRVO/CuWLE4B8Y/zkiJxhRaEO/MCl 6JZHwGy+pyX4uu8LSGNlCG/u2tv61WQ0QK2/MQUxJIe+4Hi6pDZgyL4yq0QpbpQzKAILl8qt8Z 79/z+fzx7Fc3dhI0UXAOXhs4HTJScrsrVmQhJpCYKvHkUmvBu0H0nI9SadSMmyGe95GXbStgJD 6j14BN5WeuR3Q6F8kZeBf29NIbvfycwBLj94kTDUS3TZsI4surHie5HOdrXaC168VEoCjELkQW FfI= X-SBRS: 2.7 X-MesageID: 7642017 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.68,221,1569297600"; d="scan'208";a="7642017" From: Anthony PERARD To: Date: Wed, 23 Oct 2019 17:48:33 +0100 Message-ID: <20191023164837.2700240-20-anthony.perard@citrix.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191023164837.2700240-1-anthony.perard@citrix.com> References: <20191023164837.2700240-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [RFC XEN PATCH 19/23] update *FLAGS for arch/x86/Makefile X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Anthony PERARD Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" --- xen/arch/x86/Makefile | 65 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile index 49b7eb9fd116..41486c512f10 100644 --- a/xen/arch/x86/Makefile +++ b/xen/arch/x86/Makefile @@ -1,3 +1,68 @@ +# select defconfig based on actual architecture +KBUILD_DEFCONFIG := $(ARCH)_defconfig + +export XEN_IMG_OFFSET := 0x200000 + +KBUILD_CFLAGS += -I$(srctree)/include +KBUILD_CFLAGS += -I$(srctree)/include/asm-x86/mach-generic +KBUILD_CFLAGS += -I$(srctree)/include/asm-x86/mach-default +KBUILD_CFLAGS += -DXEN_IMG_OFFSET=$(XEN_IMG_OFFSET) + +# Prevent floating-point variables from creeping into Xen. +KBUILD_CFLAGS += -msoft-float + +KBUILD_CFLAGS += $(foreach o,$(EMBEDDED_EXTRA_CFLAGS),$(call cc-option,$(o))) +KBUILD_CFLAGS += $(call cc-option,-Wnested-externs) +KBUILD_CFLAGS += $(call as-instr,vmcall,-DHAVE_AS_VMX) +KBUILD_CFLAGS += $(call as-instr,crc32 %eax$(comma)%eax,-DHAVE_AS_SSE4_2) +KBUILD_CFLAGS += $(call as-instr,invept (%rax)$(comma)%rax,-DHAVE_AS_EPT) +KBUILD_CFLAGS += $(call as-instr,rdrand %eax,-DHAVE_AS_RDRAND) +KBUILD_CFLAGS += $(call as-instr,rdfsbase %rax,-DHAVE_AS_FSGSBASE) +KBUILD_CFLAGS += $(call as-instr,xsaveopt (%rax),-DHAVE_AS_XSAVEOPT) +KBUILD_CFLAGS += $(call as-instr,rdseed %eax,-DHAVE_AS_RDSEED) +KBUILD_CFLAGS += $(call as-instr,clwb (%rax),-DHAVE_AS_CLWB) +KBUILD_CFLAGS += $(call as-instr,.equ \"x\"$(comma)1,-DHAVE_AS_QUOTED_SYM) +KBUILD_CFLAGS += $(call as-instr,invpcid (%rax)$(comma)%rax,-DHAVE_AS_INVPCID) + +# GAS's idea of true is -1. Clang's idea is 1 +KBUILD_CFLAGS += $(call as-instr,\ + .if ((1 > 0) < 0); .error "";.endif,,-DHAVE_AS_NEGATIVE_TRUE) + +# Check to see whether the assmbler supports the .nop directive. +KBUILD_CFLAGS += $(call as-instr,\ + .L1: .L2: .nops (.L2 - .L1)$(comma)9,-DHAVE_AS_NOPS_DIRECTIVE) + +KBUILD_CFLAGS += -mno-red-zone -fpic -fno-asynchronous-unwind-tables + +# Xen doesn't use SSE interally. If the compiler supports it, also skip the +# SSE setup for variadic function calls. +KBUILD_CFLAGS += -mno-sse $(call cc-option,-mskip-rax-setup) + +# -fvisibility=hidden reduces -fpic cost, if it's available +ifeq ($(call cc-option-yn,-fvisibility=hidden),y) +KBUILD_CFLAGS += -DGCC_HAS_VISIBILITY_ATTRIBUTE +endif + +# Compile with thunk-extern, indirect-branch-register if avaiable. +ifeq ($(call cc-option-yn,-mindirect-branch-register),y) +KBUILD_CFLAGS += -mindirect-branch=thunk-extern -mindirect-branch-register +KBUILD_CFLAGS += -DCONFIG_INDIRECT_THUNK +KBUILD_CFLAGS += -fno-jump-tables +export CONFIG_INDIRECT_THUNK=y +endif + +# If supported by the compiler, reduce stack alignment to 8 bytes. But allow +# this to be overridden elsewhere. +# XXX adding to cflags instead of CFLAGS-stack-boundary +KBUILD_CFLAGS += $(call cc-option,-mpreferred-stack-boundary=3) + +# Set up the assembler include path properly for older toolchains. +KBUILD_CFLAGS += -Wa,-I$(srctree)/include + +# XXX from xen.git/config/x86_64.mk +LDFLAGS_emulation_OpenBSD := _obsd +LDFLAGS_emulation_FreeBSD := _fbsd +KBUILD_LDFLAGS += -melf_x86_64$(LDFLAGS_emulation_$(XEN_OS)) efi-y := $(shell if [ ! -r $(BASEDIR)/include/xen/compile.h -o \ -O $(BASEDIR)/include/xen/compile.h ]; then \ From patchwork Wed Oct 23 16:48:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 11207279 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C381C1747 for ; Wed, 23 Oct 2019 17:12:30 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9FD1C2086D for ; Wed, 23 Oct 2019 17:12:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="AzohAkO6" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9FD1C2086D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNKAI-000354-H8; Wed, 23 Oct 2019 17:11:18 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNKAG-00033T-KA for xen-devel@lists.xenproject.org; Wed, 23 Oct 2019 17:11:16 +0000 X-Inumbo-ID: 1a3f5e22-f5b8-11e9-bbab-bc764e2007e4 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 1a3f5e22-f5b8-11e9-bbab-bc764e2007e4; Wed, 23 Oct 2019 17:11:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1571850668; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CBfQ6dPGVZL/Q6VVNFGebn4qUfglC7w9/n2BUG61lEo=; b=AzohAkO6YQJz84wyStVsjZhR3e8dTnwKxXpqiE5+a2gEixxavNy4KF3s cpp4JeftL5au7nbM7VEVYFTQlgHbsDnJMl2DsGeOHaUESRmR96UOjEizh uTgIIUW6z+25uJs6HpKqaQLdbJsFgZd/A/hxKILs+1S9qEMS0v1qUe158 E=; Authentication-Results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=anthony.perard@citrix.com; spf=Pass smtp.mailfrom=anthony.perard@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa1.hc3370-68.iphmx.com: no sender authenticity information available from domain of anthony.perard@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa1.hc3370-68.iphmx.com: domain of anthony.perard@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa1.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: 7wzMBaLYNteM0K8ie8ehDUssS+qgOPyeJz+XfBM8aIPFPSG90GU/a9dQWNJYWKTYzahwcm2Hlm CpUU6VWFN0m+lmA0SCEbBjBwJxkNAtcDIfD2nqB+DuAkYzhRNhVDxIomhr3lbnRbXCeZzDHIbt TsEfJA0VAHTRHWciGcKWOY86lNT+XrDXkMb3UVpTIA+bjOWNpsKlio3/cj+4GfVJ4M972fBJz9 mnO+8W97nHlp1XtdxCfTSWc+DVE0O/JWiEN5/z452x1o1MHbQjeH1DGy9b5WPQxmzJz6YQagzl V1A= X-SBRS: 2.7 X-MesageID: 7429246 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.68,221,1569297600"; d="scan'208";a="7429246" From: Anthony PERARD To: Date: Wed, 23 Oct 2019 17:48:34 +0100 Message-ID: <20191023164837.2700240-21-anthony.perard@citrix.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191023164837.2700240-1-anthony.perard@citrix.com> References: <20191023164837.2700240-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [RFC XEN PATCH 20/23] update arch/Makefile X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Anthony PERARD Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" archprepare target make asm-offsets.h make asm-macros.[ih] --- xen/Kbuild | 10 ++++++++ xen/arch/x86/Makefile | 54 +++++++++++++++++++++---------------------- 2 files changed, 37 insertions(+), 27 deletions(-) create mode 100644 xen/Kbuild diff --git a/xen/Kbuild b/xen/Kbuild new file mode 100644 index 000000000000..3b36d67226d6 --- /dev/null +++ b/xen/Kbuild @@ -0,0 +1,10 @@ +##### +# Generate asm-offsets.h + +offsets-file := include/asm-$(SRCARCH)/asm-offsets.h + +always += $(offsets-file) + +$(offsets-file): arch/$(SRCARCH)/asm-offsets.s FORCE + $(call filechk,offsets,__ASM_OFFSETS_H__) + diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile index 41486c512f10..9a6a0a595975 100644 --- a/xen/arch/x86/Makefile +++ b/xen/arch/x86/Makefile @@ -64,11 +64,17 @@ LDFLAGS_emulation_OpenBSD := _obsd LDFLAGS_emulation_FreeBSD := _fbsd KBUILD_LDFLAGS += -melf_x86_64$(LDFLAGS_emulation_$(XEN_OS)) +archheaders: $(objtree)/include/asm-x86/asm-macros.h + +archprepare: + $(Q)$(MAKE) $(build)=arch/$(SRCARCH) arch/$(SRCARCH)/asm-offsets.s + efi-y := $(shell if [ ! -r $(BASEDIR)/include/xen/compile.h -o \ -O $(BASEDIR)/include/xen/compile.h ]; then \ echo '$(TARGET).efi'; fi) -ALL_OBJS := $(BASEDIR)/arch/x86/boot/built_in.o $(BASEDIR)/arch/x86/efi/built_in.o $(ALL_OBJS) +head-y := arch/x86/boot/ +head-y += arch/x86/efi/ ifeq ($(CONFIG_LTO),y) # Gather all LTO objects together @@ -104,7 +110,10 @@ EFI_LDFLAGS += --major-os-version=2 --minor-os-version=0 EFI_LDFLAGS += --major-subsystem-version=2 --minor-subsystem-version=0 # Check if the compiler supports the MS ABI. -export XEN_BUILD_EFI := $(shell $(CC) $(filter-out $(CFLAGS-y) .%.d,$(CFLAGS)) -c efi/check.c -o efi/check.o 2>/dev/null && echo y) +#export XEN_BUILD_EFI := $(shell $(CC) $(filter-out $(CFLAGS-y) .%.d,$(CFLAGS)) -c efi/check.c -o efi/check.o 2>/dev/null && echo y) +# XXX FIXME: The subdir efi/ depends on symbolic links of files in common/efi/ +# XXX Disable EFI build for now. +override XEN_BUILD_EFI := # Check if the linker supports PE. XEN_BUILD_PE := $(if $(XEN_BUILD_EFI),$(shell $(LD) -mi386pep --subsystem=10 -o efi/check.efi efi/check.o 2>/dev/null && echo y)) CFLAGS-$(XEN_BUILD_EFI) += -DXEN_BUILD_EFI @@ -154,31 +163,22 @@ $(TARGET).efi: prelink-efi.o $(note_file) efi.lds efi/relocs-dummy.o efi/mkreloc efi/boot.init.o efi/runtime.o efi/compat.o efi/buildid.o: $(BASEDIR)/arch/x86/efi/built_in.o efi/boot.init.o efi/runtime.o efi/compat.o efi/buildid.o: ; -$(BASEDIR)/include/asm-x86/asm-macros.h: asm-macros.i Makefile - echo '#if 0' >$@.new - echo '.if 0' >>$@.new - echo '#endif' >>$@.new - echo 'asm ( ".include \"$@\"" );' >>$@.new - echo '#if 0' >>$@.new - echo '.endif' >>$@.new - cat $< >>$@.new - echo '#endif' >>$@.new - $(call move-if-changed,$@.new,$@) +define filechk_asm-macros.h + echo '#if 0'; \ + echo '.if 0'; \ + echo '#endif'; \ + echo 'asm ( ".include \"$@\"" );'; \ + echo '#if 0'; \ + echo '.endif'; \ + cat $<; \ + echo '#endif' +endef + +$(objtree)/arch/x86/asm-macros.i: FORCE + $(Q)$(MAKE) $(build)=$(@D) $@ + +$(objtree)/include/asm-x86/asm-macros.h: $(objtree)/arch/x86/asm-macros.i Makefile FORCE + $(call filechk,asm-macros.h) efi/mkreloc: efi/mkreloc.c $(HOSTCC) $(HOSTCFLAGS) -g -o $@ $< - -.PHONY: clean -clean:: - rm -f asm-offsets.s *.lds boot/*.o boot/*~ boot/core boot/mkelf32 - rm -f asm-macros.i $(BASEDIR)/include/asm-x86/asm-macros.* - rm -f $(BASEDIR)/.xen-syms.[0-9]* boot/.*.d $(BASEDIR)/.xen.elf32 - rm -f $(BASEDIR)/.xen.efi.[0-9]* efi/*.efi efi/mkreloc - rm -f boot/cmdline.S boot/reloc.S boot/*.lnk boot/*.bin - rm -f note.o - -# Suppress loading of DEPS files for internal, temporary target files. This -# then also suppresses re-generation of the respective .*.d2 files. -ifeq ($(filter-out .xen%.o,$(notdir $(MAKECMDGOALS))),) -DEPS:= -endif From patchwork Wed Oct 23 16:48:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 11207275 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7E11013BD for ; Wed, 23 Oct 2019 17:12:26 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 41E092086D for ; Wed, 23 Oct 2019 17:12:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="GlrFJQpt" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 41E092086D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNK9n-0002eG-4X; Wed, 23 Oct 2019 17:10:47 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNK9l-0002dN-L9 for xen-devel@lists.xenproject.org; Wed, 23 Oct 2019 17:10:45 +0000 X-Inumbo-ID: 09156916-f5b8-11e9-9488-12813bfff9fa Received: from esa2.hc3370-68.iphmx.com (unknown [216.71.145.153]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 09156916-f5b8-11e9-9488-12813bfff9fa; Wed, 23 Oct 2019 17:10:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1571850639; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8lmlO/7p9GznTUOr/iZxDm/tyiPM2BM+XRXLjTUxh9M=; b=GlrFJQptSM/IrT4wGiHTtjIb6bTKz6R4hELjpmrQOul9ic/zUR0Lv921 VvBauHQu6myuCpsnUlo7oVar/dWY3dtPfNVAoXtdbHyHd05JPd+OPyDLI pKQyQjZ8wI23tgt2cl14d2yrJvkqHmf7rbPfEHmcqGxuwTe2a0+VxlEsI 0=; Authentication-Results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=anthony.perard@citrix.com; spf=Pass smtp.mailfrom=anthony.perard@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa2.hc3370-68.iphmx.com: no sender authenticity information available from domain of anthony.perard@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa2.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa2.hc3370-68.iphmx.com: domain of anthony.perard@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa2.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa2.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa2.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: H+yHm6gRSKvWRvyzgoOXTF6FHGC67Zz7ruCz1W1XZCFIhktMtHujALOnWpWyVylRxU+cxG93qo 7XJ0sTH8kpOKtMpRZSZwX9ydon8nL0fZ7LGOiPiDBCIW7dzts7FqWMnsp8JLwA7V4vSG5xNOIO Ie8VtR80dKxKKKHGVBJShTAlGXaxmbIoIBLJBOs+JZpmwb6Jfl0Id6GOcA1WWAqt7n7Wz5EA+a cpPII7+eFFWwbcnraPcU3aGAf9xF0JjTSScIxR5q2TFuRSBr6Lkd6R5lfEGOsXOm9nJgdzZi4a 3bI= X-SBRS: 2.7 X-MesageID: 7335581 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.68,221,1569297600"; d="scan'208";a="7335581" From: Anthony PERARD To: Date: Wed, 23 Oct 2019 17:48:35 +0100 Message-ID: <20191023164837.2700240-22-anthony.perard@citrix.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191023164837.2700240-1-anthony.perard@citrix.com> References: <20191023164837.2700240-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [RFC XEN PATCH 21/23] Import root Makefile from Linux v5.3 X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Anthony PERARD Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Edit a lot of it out, mostly CFLAGS, build of modules. Edit in xenversion. --- xen/Makefile | 1249 ++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 1001 insertions(+), 248 deletions(-) diff --git a/xen/Makefile b/xen/Makefile index b1b60e679082..90645668957c 100644 --- a/xen/Makefile +++ b/xen/Makefile @@ -1,3 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0 # This is the correct place to edit the build version. # All other places this is stored (eg. compile.h) should be autogenerated. export XEN_VERSION = 4 @@ -11,284 +12,1036 @@ export XEN_DOMAIN ?= $(shell ([ -x /bin/dnsdomainname ] && /bin/dnsdomainname) | export XEN_BUILD_DATE ?= $(shell LC_ALL=C date) export XEN_BUILD_TIME ?= $(shell LC_ALL=C date +%T) export XEN_BUILD_HOST ?= $(shell hostname) -export XEN_CONFIG_EXPERT ?= n -export BASEDIR := $(CURDIR) -export XEN_ROOT := $(BASEDIR)/.. +export XEN_ROOT := $(CURDIR)/.. + +# *DOCUMENTATION* +# To see a list of typical targets execute "make help" +# More info can be located in ./README +# Comments in this file are targeted only to the developer, do not +# expect to learn how to build the kernel reading this file. + +# That's our default target when none is given on the command line +PHONY := _all +_all: + +# We are using a recursive build, so we need to do a little thinking +# to get the ordering right. +# +# Most importantly: sub-Makefiles should only ever modify files in +# their own directory. If in some directory we have a dependency on +# a file in another dir (which doesn't happen often, but it's often +# unavoidable when linking the built-in.a targets which finally +# turn into xen), we will call a sub make in that other dir, and +# after that we are sure that everything which is in that other dir +# is now up to date. +# +# The only cases where we need to modify files which have global +# effects are thus separated out and done before the recursive +# descending is started. They are now explicitly listed as the +# prepare rule. + +ifneq ($(sub_make_done),1) # Do not use make's built-in rules and variables +# (this increases performance and avoids hard-to-debug behaviour) MAKEFLAGS += -rR -EFI_MOUNTPOINT ?= $(BOOT_DIR)/efi +# Avoid funny character set dependencies +unexport LC_ALL +LC_COLLATE=C +LC_NUMERIC=C +export LC_COLLATE LC_NUMERIC -ARCH=$(XEN_TARGET_ARCH) -SRCARCH=$(shell echo $(ARCH) | sed -e 's/x86.*/x86/' -e s'/arm\(32\|64\)/arm/g') +# Avoid interference with shell env settings +unexport GREP_OPTIONS -# Don't break if the build process wasn't called from the top level -# we need XEN_TARGET_ARCH to generate the proper config -include $(XEN_ROOT)/Config.mk +# Beautify output +# --------------------------------------------------------------------------- +# +# Normally, we echo the whole command before executing it. By making +# that echo $($(quiet)$(cmd)), we now have the possibility to set +# $(quiet) to choose other forms of output instead, e.g. +# +# quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@ +# cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< +# +# If $(quiet) is empty, the whole command will be printed. +# If it is set to "quiet_", only the short version will be printed. +# If it is set to "silent_", nothing will be printed at all, since +# the variable $(silent_cmd_cc_o_c) doesn't exist. +# +# A simple variant is to prefix commands with $(Q) - that's useful +# for commands that shall be hidden in non-verbose mode. +# +# $(Q)ln $@ :< +# +# If KBUILD_VERBOSE equals 0 then the above command will be hidden. +# If KBUILD_VERBOSE equals 1 then the above command is displayed. +# +# To put more focus on warnings, be less verbose as default +# Use 'make V=1' to see the full commands -# Allow someone to change their config file -export KCONFIG_CONFIG ?= .config +ifeq ("$(origin V)", "command line") + KBUILD_VERBOSE = $(V) +endif +ifndef KBUILD_VERBOSE + KBUILD_VERBOSE = 0 +endif -.PHONY: default -default: build +ifeq ($(KBUILD_VERBOSE),1) + quiet = + Q = +else + quiet=quiet_ + Q = @ +endif + +# If the user is running make -s (silent mode), suppress echoing of +# commands + +ifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),) + quiet=silent_ +endif + +export quiet Q KBUILD_VERBOSE -.PHONY: dist -dist: install +# Kbuild will save output files in the current working directory. +# This does not need to match to the root of the kernel source tree. +# +# For example, you can do this: +# +# cd /dir/to/store/output/files; make -f /dir/to/kernel/source/Makefile +# +# If you want to save output files in a different location, there are +# two syntaxes to specify it. +# +# 1) O= +# Use "make O=dir/to/store/output/files/" +# +# 2) Set KBUILD_OUTPUT +# Set the environment variable KBUILD_OUTPUT to point to the output directory. +# export KBUILD_OUTPUT=dir/to/store/output/files/; make +# +# The O= assignment takes precedence over the KBUILD_OUTPUT environment +# variable. -build install:: include/config/auto.conf +# Do we want to change the working directory? +ifeq ("$(origin O)", "command line") + KBUILD_OUTPUT := $(O) +endif -.PHONY: build install uninstall clean distclean cscope TAGS tags MAP gtags tests -build install uninstall debug clean distclean cscope TAGS tags MAP gtags tests:: -ifneq ($(XEN_TARGET_ARCH),x86_32) - $(MAKE) -f Rules.mk _$@ +ifneq ($(KBUILD_OUTPUT),) +# Make's built-in functions such as $(abspath ...), $(realpath ...) cannot +# expand a shell special character '~'. We use a somewhat tedious way here. +abs_objtree := $(shell mkdir -p $(KBUILD_OUTPUT) && cd $(KBUILD_OUTPUT) && pwd) +$(if $(abs_objtree),, \ + $(error failed to create output directory "$(KBUILD_OUTPUT)")) + +# $(realpath ...) resolves symlinks +abs_objtree := $(realpath $(abs_objtree)) +else +abs_objtree := $(CURDIR) +endif # ifneq ($(KBUILD_OUTPUT),) + +ifeq ($(abs_objtree),$(CURDIR)) +# Suppress "Entering directory ..." unless we are changing the work directory. +MAKEFLAGS += --no-print-directory else - echo "*** Xen x86/32 target no longer supported!" +need-sub-make := 1 +endif + +abs_srctree := $(realpath $(dir $(lastword $(MAKEFILE_LIST)))) + +ifneq ($(words $(subst :, ,$(abs_srctree))), 1) +$(error source directory cannot contain spaces or colons) +endif + +ifneq ($(abs_srctree),$(abs_objtree)) +# Look for make include files relative to root of kernel src +# +# This does not become effective immediately because MAKEFLAGS is re-parsed +# once after the Makefile is read. We need to invoke sub-make. +MAKEFLAGS += --include-dir=$(abs_srctree) +need-sub-make := 1 +endif + +ifneq ($(filter 3.%,$(MAKE_VERSION)),) +# 'MAKEFLAGS += -rR' does not immediately become effective for GNU Make 3.x +# We need to invoke sub-make to avoid implicit rules in the top Makefile. +need-sub-make := 1 +# Cancel implicit rules for this Makefile. +$(lastword $(MAKEFILE_LIST)): ; +endif + +export abs_srctree abs_objtree +export sub_make_done := 1 + +ifeq ($(need-sub-make),1) + +PHONY += $(MAKECMDGOALS) sub-make + +$(filter-out _all sub-make $(lastword $(MAKEFILE_LIST)), $(MAKECMDGOALS)) _all: sub-make + @: + +# Invoke a second make in the output directory, passing relevant variables +sub-make: + $(Q)$(MAKE) -C $(abs_objtree) -f $(abs_srctree)/Makefile $(MAKECMDGOALS) + +endif # need-sub-make +endif # sub_make_done + +# We process the rest of the Makefile if this is the final invocation of make +ifeq ($(need-sub-make),) + +# Do not print "Entering directory ...", +# but we want to display it when entering to the output directory +# so that IDEs/editors are able to understand relative filenames. +MAKEFLAGS += --no-print-directory + +# Call a source code checker (by default, "sparse") as part of the +# C compilation. +# +# Use 'make C=1' to enable checking of only re-compiled files. +# Use 'make C=2' to enable checking of *all* source files, regardless +# of whether they are re-compiled or not. +# +# See the file "Documentation/dev-tools/sparse.rst" for more details, +# including where to get the "sparse" utility. + +ifeq ("$(origin C)", "command line") + KBUILD_CHECKSRC = $(C) +endif +ifndef KBUILD_CHECKSRC + KBUILD_CHECKSRC = 0 +endif + +export KBUILD_CHECKSRC + +ifeq ($(abs_srctree),$(abs_objtree)) + # building in the source tree + srctree := . + building_out_of_srctree := +else + ifeq ($(abs_srctree)/,$(dir $(abs_objtree))) + # building in a subdirectory of the source tree + srctree := .. + else + srctree := $(abs_srctree) + endif + building_out_of_srctree := 1 +endif + +ifneq ($(KBUILD_ABS_SRCTREE),) +srctree := $(abs_srctree) +endif + +objtree := . +VPATH := $(srctree) + +export building_out_of_srctree srctree objtree VPATH + +# To make sure we do not include .config for any of the *config targets +# catch them early, and hand them over to scripts/kconfig/Makefile +# It is allowed to specify more targets when calling make, including +# mixing *config targets and build targets. +# For example 'make oldconfig all'. +# Detect when mixed targets is specified, and make a second invocation +# of make so .config is not included in this case either (for *config). + +version_h := include/xen/compile.h + +clean-targets := %clean mrproper cleandocs +no-dot-config-targets := $(clean-targets) \ + cscope gtags TAGS tags help% %docs check% \ + $(version_h) headers headers_% archheaders \ + xenversion +no-sync-config-targets := $(no-dot-config-targets) install %install + +config-targets := 0 +mixed-targets := 0 +dot-config := 1 +may-sync-config := 1 + +ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),) + ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),) + dot-config := 0 + endif endif -.PHONY: _build -_build: $(TARGET)$(CONFIG_XEN_INSTALL_SUFFIX) - -.PHONY: _install -_install: D=$(DESTDIR) -_install: T=$(notdir $(TARGET)) -_install: Z=$(CONFIG_XEN_INSTALL_SUFFIX) -_install: $(TARGET)$(CONFIG_XEN_INSTALL_SUFFIX) - [ -d $(D)$(BOOT_DIR) ] || $(INSTALL_DIR) $(D)$(BOOT_DIR) - $(INSTALL_DATA) $(TARGET)$(Z) $(D)$(BOOT_DIR)/$(T)-$(XEN_FULLVERSION)$(Z) - ln -f -s $(T)-$(XEN_FULLVERSION)$(Z) $(D)$(BOOT_DIR)/$(T)-$(XEN_VERSION).$(XEN_SUBVERSION)$(Z) - ln -f -s $(T)-$(XEN_FULLVERSION)$(Z) $(D)$(BOOT_DIR)/$(T)-$(XEN_VERSION)$(Z) - ln -f -s $(T)-$(XEN_FULLVERSION)$(Z) $(D)$(BOOT_DIR)/$(T)$(Z) - [ -d "$(D)$(DEBUG_DIR)" ] || $(INSTALL_DIR) $(D)$(DEBUG_DIR) - $(INSTALL_DATA) $(TARGET)-syms $(D)$(DEBUG_DIR)/$(T)-syms-$(XEN_FULLVERSION) - $(INSTALL_DATA) $(TARGET)-syms.map $(D)$(DEBUG_DIR)/$(T)-syms-$(XEN_FULLVERSION).map - $(INSTALL_DATA) $(KCONFIG_CONFIG) $(D)$(BOOT_DIR)/$(T)-$(XEN_FULLVERSION).config - if [ -r $(TARGET).efi -a -n '$(EFI_DIR)' ]; then \ - [ -d $(D)$(EFI_DIR) ] || $(INSTALL_DIR) $(D)$(EFI_DIR); \ - $(INSTALL_DATA) $(TARGET).efi $(D)$(EFI_DIR)/$(T)-$(XEN_FULLVERSION).efi; \ - if [ -e $(TARGET).efi.map ]; then \ - $(INSTALL_DATA) $(TARGET).efi.map $(D)$(DEBUG_DIR)/$(T)-$(XEN_FULLVERSION).efi.map; \ - fi; \ - ln -sf $(T)-$(XEN_FULLVERSION).efi $(D)$(EFI_DIR)/$(T)-$(XEN_VERSION).$(XEN_SUBVERSION).efi; \ - ln -sf $(T)-$(XEN_FULLVERSION).efi $(D)$(EFI_DIR)/$(T)-$(XEN_VERSION).efi; \ - ln -sf $(T)-$(XEN_FULLVERSION).efi $(D)$(EFI_DIR)/$(T).efi; \ - if [ -n '$(EFI_MOUNTPOINT)' -a -n '$(EFI_VENDOR)' ]; then \ - $(INSTALL_DATA) $(TARGET).efi $(D)$(EFI_MOUNTPOINT)/efi/$(EFI_VENDOR)/$(T)-$(XEN_FULLVERSION).efi; \ - elif [ "$(D)" = "$(patsubst $(shell cd $(XEN_ROOT) && pwd)/%,%,$(D))" ]; then \ - echo 'EFI installation only partially done (EFI_VENDOR not set)' >&2; \ - fi; \ - fi - -.PHONY: _tests -_tests: - $(MAKE) -f $(BASEDIR)/Rules.mk -C test tests - -.PHONY: _uninstall -_uninstall: D=$(DESTDIR) -_uninstall: T=$(notdir $(TARGET)) -_uninstall: Z=$(CONFIG_XEN_INSTALL_SUFFIX) -_uninstall: - rm -f $(D)$(BOOT_DIR)/$(T)-$(XEN_FULLVERSION).config - rm -f $(D)$(BOOT_DIR)/$(T)-$(XEN_FULLVERSION)$(Z) - rm -f $(D)$(BOOT_DIR)/$(T)-$(XEN_VERSION).$(XEN_SUBVERSION)$(Z) - rm -f $(D)$(BOOT_DIR)/$(T)-$(XEN_VERSION)$(Z) - rm -f $(D)$(BOOT_DIR)/$(T)$(Z) - rm -f $(D)$(DEBUG_DIR)/$(T)-syms-$(XEN_FULLVERSION) - rm -f $(D)$(DEBUG_DIR)/$(T)-syms-$(XEN_FULLVERSION).map - rm -f $(D)$(EFI_DIR)/$(T)-$(XEN_FULLVERSION).efi - rm -f $(D)$(EFI_DIR)/$(T)-$(XEN_VERSION).$(XEN_SUBVERSION).efi - rm -f $(D)$(DEBUG_DIR)/$(T)-$(XEN_FULLVERSION).efi.map - rm -f $(D)$(EFI_DIR)/$(T)-$(XEN_VERSION).efi - rm -f $(D)$(EFI_DIR)/$(T).efi - rm -f $(D)$(EFI_MOUNTPOINT)/efi/$(EFI_VENDOR)/$(T)-$(XEN_FULLVERSION).efi - -.PHONY: _debug -_debug: - $(OBJDUMP) -D -S $(TARGET)-syms > $(TARGET).s - -.PHONY: _clean -_clean: delete-unfresh-files - $(MAKE) -C tools clean - $(MAKE) -f $(BASEDIR)/Rules.mk -C include clean - $(MAKE) -f $(BASEDIR)/Rules.mk -C common clean - $(MAKE) -f $(BASEDIR)/Rules.mk -C drivers clean - $(MAKE) -f $(BASEDIR)/Rules.mk -C xsm clean - $(MAKE) -f $(BASEDIR)/Rules.mk -C crypto clean - $(MAKE) -f $(BASEDIR)/Rules.mk -C arch/arm clean - $(MAKE) -f $(BASEDIR)/Rules.mk -C arch/x86 clean - $(MAKE) -f $(BASEDIR)/Rules.mk -C test clean - $(MAKE) -f $(BASEDIR)/tools/kconfig/Makefile.kconfig ARCH=$(ARCH) SRCARCH=$(SRCARCH) clean - find . \( -name "*.o" -o -name ".*.d" -o -name ".*.d2" -o -name "*.gcno" \) -exec rm -f {} \; - rm -f include/asm $(TARGET) $(TARGET).gz $(TARGET).efi $(TARGET).efi.map $(TARGET)-syms $(TARGET)-syms.map *~ core - rm -f include/asm-*/asm-offsets.h - rm -f .banner - -.PHONY: _distclean -_distclean: clean - rm -f tags TAGS cscope.files cscope.in.out cscope.out cscope.po.out GTAGS GPATH GRTAGS GSYMS .config - -$(TARGET).gz: $(TARGET) - gzip -n -f -9 < $< > $@.new - mv $@.new $@ - -$(TARGET): delete-unfresh-files - $(MAKE) -C tools - $(MAKE) -f $(BASEDIR)/Rules.mk include/xen/compile.h - [ -e include/asm ] || ln -sf asm-$(TARGET_ARCH) include/asm - [ -e arch/$(TARGET_ARCH)/efi ] && for f in boot.c runtime.c compat.c efi.h;\ - do test -r arch/$(TARGET_ARCH)/efi/$$f || \ - ln -nsf ../../../common/efi/$$f arch/$(TARGET_ARCH)/efi/; \ - done; \ - true - $(MAKE) -f $(BASEDIR)/Rules.mk -C include - $(MAKE) -f $(BASEDIR)/Rules.mk -C arch/$(TARGET_ARCH) asm-offsets.s - $(MAKE) -f $(BASEDIR)/Rules.mk include/asm-$(TARGET_ARCH)/asm-offsets.h - $(MAKE) -f $(BASEDIR)/Rules.mk -C arch/$(TARGET_ARCH) $@ - -# drivers/char/console.o contains static banner/compile info. Blow it away. -# Don't refresh these files during e.g., 'sudo make install' -.PHONY: delete-unfresh-files -delete-unfresh-files: - @if [ ! -r include/xen/compile.h -o -O include/xen/compile.h ]; then \ - rm -f include/xen/compile.h; \ - fi - -.banner: Makefile - @if which figlet >/dev/null 2>&1 ; then \ - echo " Xen $(XEN_FULLVERSION)" | figlet -f tools/xen.flf > $@.tmp; \ - else \ - echo " Xen $(XEN_FULLVERSION)" > $@.tmp; \ - fi - @mv -f $@.tmp $@ - -# compile.h contains dynamic build info. Rebuilt on every 'make' invocation. -include/xen/compile.h: include/xen/compile.h.in .banner - @sed -e 's/@@date@@/$(XEN_BUILD_DATE)/g' \ - -e 's/@@time@@/$(XEN_BUILD_TIME)/g' \ - -e 's/@@whoami@@/$(XEN_WHOAMI)/g' \ - -e 's/@@domain@@/$(XEN_DOMAIN)/g' \ - -e 's/@@hostname@@/$(XEN_BUILD_HOST)/g' \ - -e 's!@@compiler@@!$(shell $(CC) $(CFLAGS) --version 2>&1 | head -1)!g' \ - -e 's/@@version@@/$(XEN_VERSION)/g' \ - -e 's/@@subversion@@/$(XEN_SUBVERSION)/g' \ - -e 's/@@extraversion@@/$(XEN_EXTRAVERSION)/g' \ - -e 's!@@changeset@@!$(shell tools/scmversion $(XEN_ROOT) || echo "unavailable")!g' \ - < include/xen/compile.h.in > $@.new - @cat .banner - @$(PYTHON) tools/fig-to-oct.py < .banner >> $@.new - @mv -f $@.new $@ - -include/asm-$(TARGET_ARCH)/asm-offsets.h: arch/$(TARGET_ARCH)/asm-offsets.s - @(set -e; \ - echo "/*"; \ - echo " * DO NOT MODIFY."; \ - echo " *"; \ - echo " * This file was auto-generated from $<"; \ - echo " *"; \ - echo " */"; \ - echo ""; \ - echo "#ifndef __ASM_OFFSETS_H__"; \ - echo "#define __ASM_OFFSETS_H__"; \ - echo ""; \ - sed -rne "/^[^#].*==>/{s:.*==>(.*)<==.*:\1:; s: [\$$#]: :; p;}"; \ - echo ""; \ - echo "#endif") <$< >$@ - -SUBDIRS = xsm arch/$(TARGET_ARCH) common drivers test -define all_sources - ( find include/asm-$(TARGET_ARCH) -name '*.h' -print; \ - find include -name 'asm-*' -prune -o -name '*.h' -print; \ - find $(SUBDIRS) -name '*.[chS]' -print ) +ifneq ($(filter $(no-sync-config-targets), $(MAKECMDGOALS)),) + ifeq ($(filter-out $(no-sync-config-targets), $(MAKECMDGOALS)),) + may-sync-config := 0 + endif +endif + +ifneq ($(filter config %config,$(MAKECMDGOALS)),) + config-targets := 1 + ifneq ($(words $(MAKECMDGOALS)),1) + mixed-targets := 1 + endif +endif + +# For "make -j clean all", "make -j mrproper defconfig all", etc. +ifneq ($(filter $(clean-targets),$(MAKECMDGOALS)),) + ifneq ($(filter-out $(clean-targets),$(MAKECMDGOALS)),) + mixed-targets := 1 + endif +endif + +# install and modules_install need also be processed one by one +ifneq ($(filter install,$(MAKECMDGOALS)),) + ifneq ($(filter modules_install,$(MAKECMDGOALS)),) + mixed-targets := 1 + endif +endif + +ifeq ($(mixed-targets),1) +# =========================================================================== +# We're called with mixed targets (*config and build targets). +# Handle them one by one. + +PHONY += $(MAKECMDGOALS) __build_one_by_one + +$(filter-out __build_one_by_one, $(MAKECMDGOALS)): __build_one_by_one + @: + +__build_one_by_one: + $(Q)set -e; \ + for i in $(MAKECMDGOALS); do \ + $(MAKE) -f $(srctree)/Makefile $$i; \ + done + +else + +include scripts/Kbuild.include + +# Cross compiling and selecting different set of gcc/bin-utils +# --------------------------------------------------------------------------- +# +# When performing cross compilation for other architectures ARCH shall be set +# to the target architecture. (See arch/* for the possibilities). +# ARCH can be set during invocation of make: +# make ARCH=ia64 +# Another way is to have ARCH set in the environment. +# The default ARCH is the host where make is executed. + +# CROSS_COMPILE specify the prefix used for all executables used +# during compilation. Only gcc and related bin-utils executables +# are prefixed with $(CROSS_COMPILE). +# CROSS_COMPILE can be set on the command line +# make CROSS_COMPILE=ia64-linux- +# Alternatively CROSS_COMPILE can be set in the environment. +# Default value for CROSS_COMPILE is not to prefix executables +# Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile +ARCH ?= $(SUBARCH) +SRCARCH := $(shell echo $(XEN_TARGET_ARCH) | \ + sed -e 's/x86.*/x86/' -e s'/arm\(32\|64\)/arm/g') + +KCONFIG_CONFIG ?= .config +export KCONFIG_CONFIG + +# SHELL used by kbuild +CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \ + else if [ -x /bin/bash ]; then echo /bin/bash; \ + else echo sh; fi ; fi) + +HOST_LFS_CFLAGS := $(shell getconf LFS_CFLAGS 2>/dev/null) +HOST_LFS_LDFLAGS := $(shell getconf LFS_LDFLAGS 2>/dev/null) +HOST_LFS_LIBS := $(shell getconf LFS_LIBS 2>/dev/null) + +HOSTCC = gcc +HOSTCXX = g++ +KBUILD_HOSTCFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 \ + -fomit-frame-pointer -std=gnu89 $(HOST_LFS_CFLAGS) \ + $(HOSTCFLAGS) +KBUILD_HOSTCXXFLAGS := -O2 $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS) +KBUILD_HOSTLDFLAGS := $(HOST_LFS_LDFLAGS) $(HOSTLDFLAGS) +KBUILD_HOSTLDLIBS := $(HOST_LFS_LIBS) $(HOSTLDLIBS) + +# Make variables (CC, etc...) +AS = $(CROSS_COMPILE)as +LD = $(CROSS_COMPILE)ld +CC = $(CROSS_COMPILE)gcc +CPP = $(CC) -E +AR = $(CROSS_COMPILE)ar +NM = $(CROSS_COMPILE)nm +STRIP = $(CROSS_COMPILE)strip +OBJCOPY = $(CROSS_COMPILE)objcopy +OBJDUMP = $(CROSS_COMPILE)objdump +OBJSIZE = $(CROSS_COMPILE)size +PAHOLE = pahole +LEX = flex +YACC = bison +AWK = awk +PERL = perl +PYTHON = python +PYTHON2 = python2 +PYTHON3 = python3 +CHECK = sparse + +CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \ + -Wbitwise -Wno-return-void -Wno-unknown-attribute $(CF) +NOSTDINC_FLAGS := +CFLAGS_KERNEL = +AFLAGS_KERNEL = +LDFLAGS_vmlinux = + +# Use LINUXINCLUDE when you must reference the include/ directory. +# Needed to be compatible with the O= option +LINUXINCLUDE := \ + $(if $(building_out_of_srctree),-I$(srctree)/include) \ + -I$(objtree)/include + +KBUILD_AFLAGS := -D__ASSEMBLY__ -fno-PIE +KBUILD_CFLAGS := +KBUILD_CPPFLAGS := +KBUILD_LDFLAGS := +GCC_PLUGINS_CFLAGS := +CLANG_FLAGS := + +export ARCH SRCARCH CONFIG_SHELL HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE AS LD CC +export CPP AR NM STRIP OBJCOPY OBJDUMP OBJSIZE PAHOLE LEX YACC AWK +export PERL PYTHON PYTHON2 PYTHON3 CHECK CHECKFLAGS MAKE HOSTCXX +export KBUILD_HOSTCXXFLAGS KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS + +export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS KBUILD_LDFLAGS +export KBUILD_CFLAGS CFLAGS_KERNEL +export CFLAGS_KASAN CFLAGS_KASAN_NOSANITIZE CFLAGS_UBSAN +export KBUILD_AFLAGS AFLAGS_KERNEL +export KBUILD_ARFLAGS + +# Files to ignore in find ... statements + +export RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o \ + -name CVS -o -name .pc -o -name .hg -o -name .git \) \ + -prune -o +export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \ + --exclude CVS --exclude .pc --exclude .hg --exclude .git + +# =========================================================================== +# Rules shared between *config targets and build targets + +# Basic helpers built in scripts/basic/ +PHONY += scripts_basic +scripts_basic: + $(Q)$(MAKE) $(build)=scripts/basic + +PHONY += outputmakefile +# outputmakefile generates a Makefile in the output directory, if using a +# separate output directory. This allows convenient use of make in the +# output directory. +# At the same time when output Makefile generated, generate .gitignore to +# ignore whole output directory +outputmakefile: +ifdef building_out_of_srctree + $(Q)ln -fsn $(srctree) source + $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile $(srctree) + $(Q)test -e .gitignore || \ + { echo "# this is build directory, ignore it"; echo "*"; } > .gitignore +endif + +ifneq ($(shell $(CC) --version 2>&1 | head -n 1 | grep clang),) +ifneq ($(CROSS_COMPILE),) +CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%)) +GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit)) +CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR) +GCC_TOOLCHAIN := $(realpath $(GCC_TOOLCHAIN_DIR)/..) +endif +ifneq ($(GCC_TOOLCHAIN),) +CLANG_FLAGS += --gcc-toolchain=$(GCC_TOOLCHAIN) +endif +ifeq ($(shell $(AS) --version 2>&1 | head -n 1 | grep clang),) +CLANG_FLAGS += -no-integrated-as +endif +CLANG_FLAGS += -Werror=unknown-warning-option +KBUILD_CFLAGS += $(CLANG_FLAGS) +KBUILD_AFLAGS += $(CLANG_FLAGS) +export CLANG_FLAGS +endif + +# The expansion should be delayed until arch/$(SRCARCH)/Makefile is included. +# Some architectures define CROSS_COMPILE in arch/$(SRCARCH)/Makefile. +# CC_VERSION_TEXT is referenced from Kconfig (so it needs export), +# and from include/config/auto.conf.cmd to detect the compiler upgrade. +CC_VERSION_TEXT = $(shell $(CC) --version 2>/dev/null | head -n 1) + +ifeq ($(config-targets),1) +# =========================================================================== +# *config targets only - make sure prerequisites are updated, and descend +# in scripts/kconfig to make the *config target + +# Read arch specific Makefile to set KBUILD_DEFCONFIG as needed. +# KBUILD_DEFCONFIG may point out an alternative default configuration +# used for 'make defconfig' +include arch/$(SRCARCH)/Makefile +export KBUILD_DEFCONFIG KBUILD_KCONFIG CC_VERSION_TEXT + +config: scripts_basic outputmakefile FORCE + $(Q)$(MAKE) $(build)=scripts/kconfig $@ + +%config: scripts_basic outputmakefile FORCE + $(Q)$(MAKE) $(build)=scripts/kconfig $@ + +else +# =========================================================================== +# Build targets only - this includes vmlinux, arch specific targets, clean +# targets and others. In general all targets except *config targets. + +PHONY += all +_all: all + +# Just do built-in. + +KBUILD_BUILTIN := 1 + +export KBUILD_BUILTIN + +ifeq ($(dot-config),1) +include include/config/auto.conf +endif + +ifeq ($(KBUILD_EXTMOD),) +# Objects we will link into vmlinux / subdirs we need to visit +init-y := init/ +drivers-y := drivers/ sound/ +drivers-$(CONFIG_SAMPLES) += samples/ +drivers-$(CONFIG_KERNEL_HEADER_TEST) += include/ +net-y := net/ +libs-y := lib/ +core-y := usr/ +virt-y := virt/ +endif # KBUILD_EXTMOD + +# The all: target is the default when no target is given on the +# command line. +# This allow a user to issue only 'make' to build a kernel including modules +# Defaults to vmlinux, but the arch makefile usually adds further targets +all: vmlinux + +CFLAGS_GCOV := -fprofile-arcs -ftest-coverage \ + $(call cc-option,-fno-tree-loop-im) \ + $(call cc-disable-warning,maybe-uninitialized,) +export CFLAGS_GCOV + +# The arch Makefiles can override CC_FLAGS_FTRACE. We may also append it later. +ifdef CONFIG_FUNCTION_TRACER + CC_FLAGS_FTRACE := -pg +endif + +RETPOLINE_CFLAGS_GCC := -mindirect-branch=thunk-extern -mindirect-branch-register +RETPOLINE_VDSO_CFLAGS_GCC := -mindirect-branch=thunk-inline -mindirect-branch-register +RETPOLINE_CFLAGS_CLANG := -mretpoline-external-thunk +RETPOLINE_VDSO_CFLAGS_CLANG := -mretpoline +RETPOLINE_CFLAGS := $(call cc-option,$(RETPOLINE_CFLAGS_GCC),$(call cc-option,$(RETPOLINE_CFLAGS_CLANG))) +RETPOLINE_VDSO_CFLAGS := $(call cc-option,$(RETPOLINE_VDSO_CFLAGS_GCC),$(call cc-option,$(RETPOLINE_VDSO_CFLAGS_CLANG))) +export RETPOLINE_CFLAGS +export RETPOLINE_VDSO_CFLAGS + +# The arch Makefile can set ARCH_{CPP,A,C}FLAGS to override the default +# values of the respective KBUILD_* variables +ARCH_CPPFLAGS := +ARCH_AFLAGS := +ARCH_CFLAGS := +include arch/$(SRCARCH)/Makefile + +ifeq ($(dot-config),1) +ifeq ($(may-sync-config),1) +# Read in dependencies to all Kconfig* files, make sure to run syncconfig if +# changes are detected. This should be included after arch/$(SRCARCH)/Makefile +# because some architectures define CROSS_COMPILE there. +include include/config/auto.conf.cmd + +$(KCONFIG_CONFIG): + @echo >&2 '***' + @echo >&2 '*** Configuration file "$@" not found!' + @echo >&2 '***' + @echo >&2 '*** Please run some configurator (e.g. "make oldconfig" or' + @echo >&2 '*** "make menuconfig" or "make xconfig").' + @echo >&2 '***' + @/bin/false + +# The actual configuration files used during the build are stored in +# include/generated/ and include/config/. Update them if .config is newer than +# include/config/auto.conf (which mirrors .config). +# +# This exploits the 'multi-target pattern rule' trick. +# The syncconfig should be executed only once to make all the targets. +%/auto.conf %/auto.conf.cmd %/tristate.conf: $(KCONFIG_CONFIG) + $(Q)$(MAKE) -f $(srctree)/Makefile syncconfig +else +# External modules and some install targets need include/generated/autoconf.h +# and include/config/auto.conf but do not care if they are up-to-date. +# Use auto.conf to trigger the test +PHONY += include/config/auto.conf + +include/config/auto.conf: + $(Q)test -e include/generated/autoconf.h -a -e $@ || ( \ + echo >&2; \ + echo >&2 " ERROR: Kernel configuration is invalid."; \ + echo >&2 " include/generated/autoconf.h or $@ are missing.";\ + echo >&2 " Run 'make oldconfig && make prepare' on kernel src to fix it."; \ + echo >&2 ; \ + /bin/false) + +endif # may-sync-config +endif # $(dot-config) + + +# arch Makefile may override CC so keep this after arch Makefile is included +NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include) + + + +# use the deterministic mode of AR if available +KBUILD_ARFLAGS := $(call ar-option,D) + +include scripts/Makefile.kasan +include scripts/Makefile.ubsan + +# Add any arch overrides and user supplied CPPFLAGS, AFLAGS and CFLAGS as the +# last assignments +KBUILD_CPPFLAGS += $(ARCH_CPPFLAGS) $(KCPPFLAGS) +KBUILD_AFLAGS += $(ARCH_AFLAGS) $(KAFLAGS) +KBUILD_CFLAGS += $(ARCH_CFLAGS) $(KCFLAGS) + +# insure the checker run with the right endianness +CHECKFLAGS += $(if $(CONFIG_CPU_BIG_ENDIAN),-mbig-endian,-mlittle-endian) + +# the checker needs the correct machine size +CHECKFLAGS += $(if $(CONFIG_64BIT),-m64,-m32) + +# Default kernel image to build when no specific target is given. +# KBUILD_IMAGE may be overruled on the command line or +# set in the environment +# Also any assignments in arch/$(ARCH)/Makefile take precedence over +# this default value +export KBUILD_IMAGE ?= vmlinux + +# +# INSTALL_PATH specifies where to place the updated kernel and system map +# images. Default is /boot, but you can set it to other values +export INSTALL_PATH ?= /boot + +HOST_LIBELF_LIBS = $(shell pkg-config libelf --libs 2>/dev/null || echo -lelf) + +PHONY += prepare0 + +core-y += kernel/ certs/ mm/ fs/ ipc/ security/ crypto/ block/ + +vmlinux-dirs := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \ + $(core-y) $(core-m) $(drivers-y) $(drivers-m) \ + $(net-y) $(net-m) $(libs-y) $(libs-m) $(virt-y))) + +vmlinux-alldirs := $(sort $(vmlinux-dirs) Documentation \ + $(patsubst %/,%,$(filter %/, $(init-) $(core-) \ + $(drivers-) $(net-) $(libs-) $(virt-)))) + +init-y := $(patsubst %/, %/built-in.a, $(init-y)) +core-y := $(patsubst %/, %/built-in.a, $(core-y)) +drivers-y := $(patsubst %/, %/built-in.a, $(drivers-y)) +net-y := $(patsubst %/, %/built-in.a, $(net-y)) +libs-y1 := $(patsubst %/, %/lib.a, $(libs-y)) +libs-y2 := $(patsubst %/, %/built-in.a, $(filter-out %.a, $(libs-y))) +virt-y := $(patsubst %/, %/built-in.a, $(virt-y)) + +# Externally visible symbols (used by link-vmlinux.sh) +export KBUILD_VMLINUX_OBJS := $(head-y) $(init-y) $(core-y) $(libs-y2) \ + $(drivers-y) $(net-y) $(virt-y) +export KBUILD_VMLINUX_LIBS := $(libs-y1) +export KBUILD_LDS := arch/$(SRCARCH)/kernel/vmlinux.lds +export LDFLAGS_vmlinux +# used by scripts/package/Makefile +export KBUILD_ALLDIRS := $(sort $(filter-out arch/%,$(vmlinux-alldirs)) LICENSES arch include scripts tools) + +vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS) + +ARCH_POSTLINK := $(wildcard $(srctree)/arch/$(SRCARCH)/Makefile.postlink) + +# Final link of vmlinux with optional arch pass after final link +cmd_link-vmlinux = \ + $(CONFIG_SHELL) $< $(LD) $(KBUILD_LDFLAGS) $(LDFLAGS_vmlinux) ; \ + $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true) + +vmlinux: scripts/link-vmlinux.sh autoksyms_recursive $(vmlinux-deps) FORCE + +$(call if_changed,link-vmlinux) + +targets := vmlinux + +# The actual objects are generated when descending, +# make sure no implicit rule kicks in +$(sort $(vmlinux-deps)): $(vmlinux-dirs) ; + +# Handle descending into subdirectories listed in $(vmlinux-dirs) +# Preset locale variables to speed up the build process. Limit locale +# tweaks to this spot to avoid wrong language settings when running +# make menuconfig etc. +# Error messages still appears in the original language + +PHONY += $(vmlinux-dirs) +$(vmlinux-dirs): prepare + $(Q)$(MAKE) $(build)=$@ need-builtin=1 need-modorder=1 + +filechk_kernel.release = \ + echo "$(KERNELVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))" + +# Store (new) KERNELRELEASE string in include/config/kernel.release +include/config/kernel.release: FORCE + $(call filechk,kernel.release) + +# Additional helpers built in scripts/ +# Carefully list dependencies so we do not try to build scripts twice +# in parallel +PHONY += scripts +scripts: scripts_basic scripts_dtc + $(Q)$(MAKE) $(build)=$(@) + +# Things we need to do before we recursively start building the kernel +# or the modules are listed in "prepare". +# A multi level approach is used. prepareN is processed before prepareN-1. +# archprepare is used in arch Makefiles and when processed asm symlink, +# version.h and scripts_basic is processed / created. + +PHONY += prepare archprepare prepare3 + +# prepare3 is used to check if we are building in a separate output directory, +# and if so do: +# 1) Check that make has not been executed in the kernel src $(srctree) +prepare3: include/config/kernel.release +ifdef building_out_of_srctree + @$(kecho) ' Using $(srctree) as source for kernel' + $(Q)if [ -f $(srctree)/.config -o \ + -d $(srctree)/include/config -o \ + -d $(srctree)/arch/$(SRCARCH)/include/generated ]; then \ + echo >&2 " $(srctree) is not clean, please run 'make ARCH=$(ARCH) mrproper'"; \ + echo >&2 " in the '$(srctree)' directory.";\ + /bin/false; \ + fi; +endif + +archprepare: archheaders archscripts scripts prepare3 outputmakefile \ + asm-generic $(version_h) $(autoksyms_h) include/generated/utsrelease.h + +prepare0: archprepare + $(Q)$(MAKE) $(build)=scripts/mod + $(Q)$(MAKE) $(build)=. + +# All the preparing.. +prepare: prepare0 + +# Generate some files +# --------------------------------------------------------------------------- + +# KERNELRELEASE can change from a few different places, meaning version.h +# needs to be updated, so this check is forced on all builds + +uts_len := 64 +define filechk_utsrelease.h + if [ `echo -n "$(KERNELRELEASE)" | wc -c ` -gt $(uts_len) ]; then \ + echo '"$(KERNELRELEASE)" exceeds $(uts_len) characters' >&2; \ + exit 1; \ + fi; \ + echo \#define UTS_RELEASE \"$(KERNELRELEASE)\" endef -define set_exuberant_flags - exuberant_flags=`$1 --version 2>/dev/null | (grep -iq exuberant && \ - echo "-I __initdata,__exitdata,__acquires,__releases \ - -I EXPORT_SYMBOL \ - --extra=+f --c-kinds=+px") || true` +define filechk_version.h + echo \#define LINUX_VERSION_CODE $(shell \ + expr $(VERSION) \* 65536 + 0$(PATCHLEVEL) \* 256 + 0$(SUBLEVEL)); \ + echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))' endef -.PHONY: xenversion +$(version_h): FORCE + $(call filechk,version.h) + $(Q)rm -f $(old_version_h) + +### +# Cleaning is done on three levels. +# make clean Delete most generated files +# Leave enough to build external modules +# make mrproper Delete the current configuration, and all generated files +# make distclean Remove editor backup files, patch leftover files and the like + +# Directories & files removed with 'make clean' +CLEAN_DIRS += include/ksym +CLEAN_FILES += modules.builtin.modinfo + +# Directories & files removed with 'make mrproper' +MRPROPER_DIRS += include/config include/generated \ + arch/$(SRCARCH)/include/generated .tmp_objdiff +MRPROPER_FILES += .config .config.old .version \ + Module.symvers \ + signing_key.pem signing_key.priv signing_key.x509 \ + x509.genkey extra_certificates signing_key.x509.keyid \ + signing_key.x509.signer vmlinux-gdb.py + +# Directories & files removed with 'make distclean' +DISTCLEAN_DIRS += +DISTCLEAN_FILES += tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS + +# clean - Delete most, but leave enough to build external modules +# +clean: rm-dirs := $(CLEAN_DIRS) +clean: rm-files := $(CLEAN_FILES) +clean-dirs := $(addprefix _clean_, . $(vmlinux-alldirs)) + +PHONY += $(clean-dirs) clean archclean vmlinuxclean +$(clean-dirs): + $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@) + +vmlinuxclean: + $(Q)$(CONFIG_SHELL) $(srctree)/scripts/link-vmlinux.sh clean + $(Q)$(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) clean) + +clean: archclean vmlinuxclean + +# mrproper - Delete all generated files, including .config +# +mrproper: rm-dirs := $(wildcard $(MRPROPER_DIRS)) +mrproper: rm-files := $(wildcard $(MRPROPER_FILES)) +mrproper-dirs := $(addprefix _mrproper_,scripts) + +PHONY += $(mrproper-dirs) mrproper +$(mrproper-dirs): + $(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@) + +mrproper: clean $(mrproper-dirs) + $(call cmd,rmdirs) + $(call cmd,rmfiles) + +# distclean +# +distclean: rm-dirs := $(wildcard $(DISTCLEAN_DIRS)) +distclean: rm-files := $(wildcard $(DISTCLEAN_FILES)) + +PHONY += distclean + +distclean: mrproper + $(call cmd,rmdirs) + $(call cmd,rmfiles) + @find $(srctree) $(RCS_FIND_IGNORE) \ + \( -name '*.orig' -o -name '*.rej' -o -name '*~' \ + -o -name '*.bak' -o -name '#*#' -o -name '*%' \ + -o -name 'core' \) \ + -type f -print | xargs rm -f + + +# Brief documentation of the typical targets used +# --------------------------------------------------------------------------- + +boards := $(wildcard $(srctree)/arch/$(SRCARCH)/configs/*_defconfig) +boards := $(sort $(notdir $(boards))) +board-dirs := $(dir $(wildcard $(srctree)/arch/$(SRCARCH)/configs/*/*_defconfig)) +board-dirs := $(sort $(notdir $(board-dirs:/=))) + +PHONY += help +help: + @echo 'Cleaning targets:' + @echo ' clean - Remove most generated files but keep the config and' + @echo ' enough build support to build external modules' + @echo ' mrproper - Remove all generated files + config + various backup files' + @echo ' distclean - mrproper + remove editor backup and patch files' + @echo '' + @echo 'Configuration targets:' + @$(MAKE) -f $(srctree)/scripts/kconfig/Makefile help + @echo '' + @echo 'Other generic targets:' + @echo ' all - Build all targets marked with [*]' + @echo '* vmlinux - Build the bare kernel' + @echo '* modules - Build all modules' + @echo ' modules_install - Install all modules to INSTALL_MOD_PATH (default: /)' + @echo ' dir/ - Build all files in dir and below' + @echo ' dir/file.[ois] - Build specified target only' + @echo ' dir/file.ll - Build the LLVM assembly file' + @echo ' (requires compiler support for LLVM assembly generation)' + @echo ' dir/file.lst - Build specified mixed source/assembly target only' + @echo ' (requires a recent binutils and recent build (System.map))' + @echo ' dir/file.ko - Build module including final link' + @echo ' modules_prepare - Set up for building external modules' + @echo ' tags/TAGS - Generate tags file for editors' + @echo ' cscope - Generate cscope index' + @echo ' gtags - Generate GNU GLOBAL index' + @echo ' kernelrelease - Output the release version string (use with make -s)' + @echo ' kernelversion - Output the version stored in Makefile (use with make -s)' + @echo ' image_name - Output the image name (use with make -s)' + @echo ' headers_install - Install sanitised kernel headers to INSTALL_HDR_PATH'; \ + echo ' (default: $(INSTALL_HDR_PATH))'; \ + echo '' + @echo 'Static analysers:' + @echo ' checkstack - Generate a list of stack hogs' + @echo ' namespacecheck - Name space analysis on compiled kernel' + @echo ' versioncheck - Sanity check on version.h usage' + @echo ' includecheck - Check for duplicate included header files' + @echo ' export_report - List the usages of all exported symbols' + @echo ' headers_check - Sanity check on exported headers' + @echo ' headerdep - Detect inclusion cycles in headers' + @echo ' coccicheck - Check with Coccinelle' + @echo '' + @echo 'Kernel selftest:' + @echo ' kselftest - Build and run kernel selftest (run as root)' + @echo ' Build, install, and boot kernel before' + @echo ' running kselftest on it' + @echo ' kselftest-clean - Remove all generated kselftest files' + @echo ' kselftest-merge - Merge all the config dependencies of kselftest to existing' + @echo ' .config.' + @echo '' + @$(if $(dtstree), \ + echo 'Devicetree:'; \ + echo '* dtbs - Build device tree blobs for enabled boards'; \ + echo ' dtbs_install - Install dtbs to $(INSTALL_DTBS_PATH)'; \ + echo '') + + @echo 'Userspace tools targets:' + @echo ' use "make tools/help"' + @echo ' or "cd tools; make help"' + @echo '' + @echo 'Kernel packaging:' + @$(MAKE) $(build)=$(package-dir) help + @echo '' + @echo 'Documentation targets:' + @$(MAKE) -f $(srctree)/Documentation/Makefile dochelp + @echo '' + @echo 'Architecture specific targets ($(SRCARCH)):' + @$(if $(archhelp),$(archhelp),\ + echo ' No architecture specific help defined for $(SRCARCH)') + @echo '' + @$(if $(boards), \ + $(foreach b, $(boards), \ + printf " %-24s - Build for %s\\n" $(b) $(subst _defconfig,,$(b));) \ + echo '') + @$(if $(board-dirs), \ + $(foreach b, $(board-dirs), \ + printf " %-16s - Show %s-specific targets\\n" help-$(b) $(b);) \ + printf " %-16s - Show all of the above\\n" help-boards; \ + echo '') + + @echo ' make V=0|1 [targets] 0 => quiet build (default), 1 => verbose build' + @echo ' make V=2 [targets] 2 => give reason for rebuild of target' + @echo ' make O=dir [targets] Locate all output files in "dir", including .config' + @echo ' make C=1 [targets] Check re-compiled c source with $$CHECK (sparse by default)' + @echo ' make C=2 [targets] Force check of all c source with $$CHECK' + @echo ' make RECORDMCOUNT_WARN=1 [targets] Warn about ignored mcount sections' + @echo ' make W=n [targets] Enable extra gcc checks, n=1,2,3 where' + @echo ' 1: warnings which may be relevant and do not occur too often' + @echo ' 2: warnings which occur quite often but may still be relevant' + @echo ' 3: more obscure warnings, can most likely be ignored' + @echo ' Multiple levels can be combined with W=12 or W=123' + @echo '' + @echo 'Execute "make" or "make all" to build all targets marked with [*] ' + @echo 'For further info see the ./README file' + + +help-board-dirs := $(addprefix help-,$(board-dirs)) + +help-boards: $(help-board-dirs) + +boards-per-dir = $(sort $(notdir $(wildcard $(srctree)/arch/$(SRCARCH)/configs/$*/*_defconfig))) + +$(help-board-dirs): help-%: + @echo 'Architecture specific targets ($(SRCARCH) $*):' + @$(if $(boards-per-dir), \ + $(foreach b, $(boards-per-dir), \ + printf " %-24s - Build for %s\\n" $*/$(b) $(subst _defconfig,,$(b));) \ + echo '') + + +# Misc +# --------------------------------------------------------------------------- + +clean: $(clean-dirs) + $(call cmd,rmdirs) + $(call cmd,rmfiles) + @find $(if $(KBUILD_EXTMOD), $(KBUILD_EXTMOD), .) $(RCS_FIND_IGNORE) \ + \( -name '*.[aios]' -o -name '*.ko' -o -name '.*.cmd' \ + -o -name '*.ko.*' \ + -o -name '*.dtb' -o -name '*.dtb.S' -o -name '*.dt.yaml' \ + -o -name '*.dwo' -o -name '*.lst' \ + -o -name '*.su' -o -name '*.mod' \ + -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \ + -o -name '*.lex.c' -o -name '*.tab.[ch]' \ + -o -name '*.asn1.[ch]' \ + -o -name '*.symtypes' -o -name 'modules.order' \ + -o -name modules.builtin -o -name '.tmp_*.o.*' \ + -o -name '*.c.[012]*.*' \ + -o -name '*.ll' \ + -o -name '*.gcno' \) -type f -print | xargs rm -f + +# Generate tags for editors +# --------------------------------------------------------------------------- +quiet_cmd_tags = GEN $@ + cmd_tags = $(CONFIG_SHELL) $(srctree)/scripts/tags.sh $@ + +tags TAGS cscope gtags: FORCE + $(call cmd,tags) + +# Scripts to check various things for consistency +# --------------------------------------------------------------------------- + +PHONY += includecheck versioncheck + +includecheck: + find $(srctree)/* $(RCS_FIND_IGNORE) \ + -name '*.[hcS]' -type f -print | sort \ + | xargs $(PERL) -w $(srctree)/scripts/checkincludes.pl + +versioncheck: + find $(srctree)/* $(RCS_FIND_IGNORE) \ + -name '*.[hcS]' -type f -print | sort \ + | xargs $(PERL) -w $(srctree)/scripts/checkversion.pl + +PHONY += xenversion image_name + xenversion: @echo $(XEN_FULLVERSION) -.PHONY: _TAGS -_TAGS: - set -e; rm -f TAGS; \ - $(call set_exuberant_flags,etags); \ - $(all_sources) | xargs etags $$exuberant_flags -a - -.PHONY: _tags -_tags: - set -e; rm -f tags; \ - $(call set_exuberant_flags,ctags); \ - $(all_sources) | xargs ctags $$exuberant_flags -a - -.PHONY: _gtags -_gtags: - set -e; rm -f GTAGS GSYMS GPATH GRTAGS - $(all_sources) | gtags -f - - -.PHONY: _cscope -_cscope: - $(all_sources) > cscope.files - cscope -k -b -q - -.PHONY: _MAP -_MAP: - $(NM) -n $(TARGET)-syms | grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' > System.map - -.PHONY: FORCE -FORCE: - -%.o %.i %.s: %.c FORCE - $(MAKE) -f $(BASEDIR)/Rules.mk -C $(*D) $(@F) +image_name: + @echo $(KBUILD_IMAGE) -%.o %.s: %.S FORCE - $(MAKE) -f $(BASEDIR)/Rules.mk -C $(*D) $(@F) +# Single targets +# --------------------------------------------------------------------------- +# Single targets are compatible with: +# - build with mixed source and output +# - build with separate output dir 'make O=...' +# +# target-dir => where to store outputfile +# build-dir => directory in kernel source tree to use -%/: FORCE - $(MAKE) -f $(BASEDIR)/Rules.mk -C $* built_in.o built_in_bin.o +build-target = $@ +build-dir = $(patsubst %/,%,$(dir $(build-target))) -build-intermediate = $(eval $(call build-intermediate-closure,$(1))) -define build-intermediate-closure -$(1): FORCE - $(MAKE) -f $(BASEDIR)/Rules.mk -C $$(@D) $$(@F) -endef +%.i: prepare FORCE + $(Q)$(MAKE) $(build)=$(build-dir) $(build-target) +%.ll: prepare FORCE + $(Q)$(MAKE) $(build)=$(build-dir) $(build-target) +%.lst: prepare FORCE + $(Q)$(MAKE) $(build)=$(build-dir) $(build-target) +%.o: prepare FORCE + $(Q)$(MAKE) $(build)=$(build-dir) $(build-target) +%.s: prepare FORCE + $(Q)$(MAKE) $(build)=$(build-dir) $(build-target) +%.symtypes: prepare FORCE + $(Q)$(MAKE) $(build)=$(build-dir) $(build-target) -$(foreach base,arch/x86/mm/guest_walk_% \ - arch/x86/mm/hap/guest_walk_%level \ - arch/x86/mm/shadow/guest_%, \ - $(foreach ext,o i s,$(call build-intermediate,$(base).$(ext)))) +# FIXME Should go into a make.lib or something +# =========================================================================== -kconfig := oldconfig config menuconfig defconfig \ - nconfig xconfig gconfig savedefconfig listnewconfig olddefconfig \ - randconfig $(notdir $(wildcard arch/$(SRCARCH)/configs/*_defconfig)) -.PHONY: $(kconfig) -$(kconfig): - $(MAKE) -f $(BASEDIR)/tools/kconfig/Makefile.kconfig ARCH=$(ARCH) SRCARCH=$(SRCARCH) HOSTCC="$(HOSTCC)" HOSTCXX="$(HOSTCXX)" $@ +quiet_cmd_rmdirs = $(if $(wildcard $(rm-dirs)),CLEAN $(wildcard $(rm-dirs))) + cmd_rmdirs = rm -rf $(rm-dirs) -include/config/%.conf: include/config/auto.conf.cmd $(KCONFIG_CONFIG) - $(MAKE) -f $(BASEDIR)/tools/kconfig/Makefile.kconfig ARCH=$(ARCH) SRCARCH=$(SRCARCH) HOSTCC="$(HOSTCC)" HOSTCXX="$(HOSTCXX)" syncconfig +quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files))) + cmd_rmfiles = rm -f $(rm-files) -# Allow people to just run `make` as before and not force them to configure -$(KCONFIG_CONFIG): - $(MAKE) -f $(BASEDIR)/tools/kconfig/Makefile.kconfig ARCH=$(ARCH) SRCARCH=$(SRCARCH) HOSTCC="$(HOSTCC)" HOSTCXX="$(HOSTCXX)" defconfig +# read saved command lines for existing targets +existing-targets := $(wildcard $(sort $(targets))) -# Break the dependency chain for the first run -include/config/auto.conf.cmd: ; +-include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd) --include $(BASEDIR)/include/config/auto.conf.cmd +endif # ifeq ($(config-targets),1) +endif # ifeq ($(mixed-targets),1) +endif # need-sub-make -.PHONY: cloc -cloc: - $(eval tmpfile := $(shell mktemp)) - $(foreach f, $(shell find $(BASEDIR) -name *.o.d), \ - $(eval path := $(dir $(f))) \ - $(eval names := $(shell grep -o "[a-zA-Z0-9_/-]*\.[cS]" $(f))) \ - $(foreach sf, $(names), \ - $(shell if test -f $(path)/$(sf) ; then echo $(path)/$(sf) >> $(tmpfile); fi;))) - cloc --list-file=$(tmpfile) - rm $(tmpfile) +PHONY += FORCE +FORCE: +# Declare the contents of the PHONY variable as phony. We keep that +# information in a variable so we can use it in if_changed and friends. +.PHONY: $(PHONY) From patchwork Wed Oct 23 16:48:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 11207265 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4FB5E112C for ; Wed, 23 Oct 2019 17:12:02 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 200912086D for ; Wed, 23 Oct 2019 17:12:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="hf94xfmf" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 200912086D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNK9i-0002aH-6X; Wed, 23 Oct 2019 17:10:42 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNK9g-0002Zt-L5 for xen-devel@lists.xenproject.org; Wed, 23 Oct 2019 17:10:40 +0000 X-Inumbo-ID: 067caf3e-f5b8-11e9-9488-12813bfff9fa Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 067caf3e-f5b8-11e9-9488-12813bfff9fa; Wed, 23 Oct 2019 17:10:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1571850635; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=o9iR+NN3wy+FNjUXt4ByoVwhjsassX4g+IHSZsUVaEc=; b=hf94xfmfIjA0B0of4b9rzbTw7paFx4Bp7/TDgNznMLOzQkJwjyrOZRG0 9A7FWvxbemZH1/gQWW8/qgrd+a8pCUWdZEFDFDHPvvmRFDoofq3gKlwKl ANdF4U6SyVEUvQ1e5nOMPdysHgfwFSamgvy/oq9sfue5f313ZMmK9pZQc Q=; Authentication-Results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=anthony.perard@citrix.com; spf=Pass smtp.mailfrom=anthony.perard@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa1.hc3370-68.iphmx.com: no sender authenticity information available from domain of anthony.perard@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa1.hc3370-68.iphmx.com: domain of anthony.perard@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa1.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: MffVZ1XEehJjAUDDBhM3nQTPpOie2eNmkiyP7zuKPM9EqWxJQzz5VFUv4/Mdm0RtjBvIsVy/CK yBiotQJE3HN3g19HmfcXZgwcLAJarCfNHdySfh1o8XfNTOxqNzDw34SPsVfhuzpZpoFRFACYax fLjOEciAfHJICJdqhhLDK2bZpN25hw1cbCsw/1wRDp6TMC41kXx9DGx8qs6U/Fy0DMyyRuW6KK mxA8podGBuK3t5a4elHGEKEHCMCP2MMu3JdtHAHkG8RAbrYsub8H20QTrvBjaxIlOifJmKJ8bp ao4= X-SBRS: 2.7 X-MesageID: 7429236 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.68,221,1569297600"; d="scan'208";a="7429236" From: Anthony PERARD To: Date: Wed, 23 Oct 2019 17:48:36 +0100 Message-ID: <20191023164837.2700240-23-anthony.perard@citrix.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191023164837.2700240-1-anthony.perard@citrix.com> References: <20191023164837.2700240-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [RFC XEN PATCH 22/23] Changes to root Makefile X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Anthony PERARD Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" - *FLAGS - fix path to Kconfig - List objects to build - generate include/xen/compile.h - make prepare phase - changes to clean - remove build of kernel.version --- xen/Makefile | 263 ++++++++++++++++++++++++++++----------------------- 1 file changed, 143 insertions(+), 120 deletions(-) diff --git a/xen/Makefile b/xen/Makefile index 90645668957c..66448b067eb0 100644 --- a/xen/Makefile +++ b/xen/Makefile @@ -13,8 +13,6 @@ export XEN_BUILD_DATE ?= $(shell LC_ALL=C date) export XEN_BUILD_TIME ?= $(shell LC_ALL=C date +%T) export XEN_BUILD_HOST ?= $(shell hostname) -export XEN_ROOT := $(CURDIR)/.. - # *DOCUMENTATION* # To see a list of typical targets execute "make help" # More info can be located in ./README @@ -238,8 +236,10 @@ endif objtree := . VPATH := $(srctree) +XEN_ROOT := $(abs_srctree)/.. export building_out_of_srctree srctree objtree VPATH +export XEN_ROOT # To make sure we do not include .config for any of the *config targets # catch them early, and hand them over to scripts/kconfig/Makefile @@ -316,6 +316,15 @@ else include scripts/Kbuild.include +# XXX From Config.mk +XEN_COMPILE_ARCH ?= $(shell uname -m | sed -e s/i.86/x86_32/ \ + -e s/i86pc/x86_32/ -e s/amd64/x86_64/ \ + -e s/armv7.*/arm32/ -e s/armv8.*/arm64/ \ + -e s/aarch64/arm64/) +XEN_TARGET_ARCH ?= $(XEN_COMPILE_ARCH) +XEN_OS ?= $(shell uname -s) +export XEN_OS + # Cross compiling and selecting different set of gcc/bin-utils # --------------------------------------------------------------------------- # @@ -334,7 +343,7 @@ include scripts/Kbuild.include # Alternatively CROSS_COMPILE can be set in the environment. # Default value for CROSS_COMPILE is not to prefix executables # Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile -ARCH ?= $(SUBARCH) +ARCH ?= $(XEN_COMPILE_ARCH) SRCARCH := $(shell echo $(XEN_TARGET_ARCH) | \ sed -e 's/x86.*/x86/' -e s'/arm\(32\|64\)/arm/g') @@ -363,6 +372,7 @@ KBUILD_HOSTLDLIBS := $(HOST_LFS_LIBS) $(HOSTLDLIBS) AS = $(CROSS_COMPILE)as LD = $(CROSS_COMPILE)ld CC = $(CROSS_COMPILE)gcc +CXX = $(CROSS_COMPILE)g++ CPP = $(CC) -E AR = $(CROSS_COMPILE)ar NM = $(CROSS_COMPILE)nm @@ -385,7 +395,7 @@ CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \ NOSTDINC_FLAGS := CFLAGS_KERNEL = AFLAGS_KERNEL = -LDFLAGS_vmlinux = +LDFLAGS_xen = # Use LINUXINCLUDE when you must reference the include/ directory. # Needed to be compatible with the O= option @@ -395,13 +405,35 @@ LINUXINCLUDE := \ KBUILD_AFLAGS := -D__ASSEMBLY__ -fno-PIE KBUILD_CFLAGS := + +# XXX CFLAGS found in xen.git/config/$(XEN_TARGET_ARCH).mk +KBUILD_CFLAGS += -m64 +# XXX CFLAGS found in Config.mk +export XEN_HAS_BUILD_ID ?= n +ifeq ($(call ld-option,--build-id),) +build_id_linker := +else +KBUILD_CFLAGS += -DBUILD_ID +export XEN_HAS_BUILD_ID=y +build_id_linker := --build-id=sha1 +# possible improvement: LDFLAGS_xen-syms := --build-id=sha1 +endif +export build_id_linker +KBUILD_CFLAGS += -fno-strict-aliasing -std=gnu99 -Wall -Wstrict-prototypes +KBUILD_CFLAGS += $(call cc-option,-Wdeclaration-after-statement) +KBUILD_CFLAGS += $(call cc-disable-warning,unused-but-set-variable) +KBUILD_CFLAGS += $(call cc-disable-warning,unused-local-typedefs) + +EMBEDDED_EXTRA_CFLAGS := -nopie -fno-stack-protector -fno-stack-protector-all +EMBEDDED_EXTRA_CFLAGS += -fno-exceptions + KBUILD_CPPFLAGS := KBUILD_LDFLAGS := GCC_PLUGINS_CFLAGS := CLANG_FLAGS := export ARCH SRCARCH CONFIG_SHELL HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE AS LD CC -export CPP AR NM STRIP OBJCOPY OBJDUMP OBJSIZE PAHOLE LEX YACC AWK +export CXX CPP AR NM STRIP OBJCOPY OBJDUMP OBJSIZE PAHOLE LEX YACC AWK export PERL PYTHON PYTHON2 PYTHON3 CHECK CHECKFLAGS MAKE HOSTCXX export KBUILD_HOSTCXXFLAGS KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS @@ -469,7 +501,7 @@ CC_VERSION_TEXT = $(shell $(CC) --version 2>/dev/null | head -n 1) ifeq ($(config-targets),1) # =========================================================================== # *config targets only - make sure prerequisites are updated, and descend -# in scripts/kconfig to make the *config target +# in tools/kconfig to make the *config target # Read arch specific Makefile to set KBUILD_DEFCONFIG as needed. # KBUILD_DEFCONFIG may point out an alternative default configuration @@ -478,10 +510,10 @@ include arch/$(SRCARCH)/Makefile export KBUILD_DEFCONFIG KBUILD_KCONFIG CC_VERSION_TEXT config: scripts_basic outputmakefile FORCE - $(Q)$(MAKE) $(build)=scripts/kconfig $@ + $(Q)$(MAKE) $(build)=tools/kconfig $@ %config: scripts_basic outputmakefile FORCE - $(Q)$(MAKE) $(build)=scripts/kconfig $@ + $(Q)$(MAKE) $(build)=tools/kconfig $@ else # =========================================================================== @@ -501,23 +533,18 @@ ifeq ($(dot-config),1) include include/config/auto.conf endif -ifeq ($(KBUILD_EXTMOD),) -# Objects we will link into vmlinux / subdirs we need to visit -init-y := init/ -drivers-y := drivers/ sound/ -drivers-$(CONFIG_SAMPLES) += samples/ -drivers-$(CONFIG_KERNEL_HEADER_TEST) += include/ -net-y := net/ -libs-y := lib/ -core-y := usr/ -virt-y := virt/ -endif # KBUILD_EXTMOD +# Objects we will link into xen / subdirs we need to visit +common-y := common/ +drivers-y := drivers/ +libs-$(CONFIG_X86) := lib/ +xsm-y := xsm/ +arch-y := arch/$(SRCARCH)/ +crypto-$(CONFIG_CRYPTO) := crypto/ # The all: target is the default when no target is given on the # command line. -# This allow a user to issue only 'make' to build a kernel including modules -# Defaults to vmlinux, but the arch makefile usually adds further targets -all: vmlinux +# Defaults to xen, but the arch makefile usually adds further targets +all: xen CFLAGS_GCOV := -fprofile-arcs -ftest-coverage \ $(call cc-option,-fno-tree-loop-im) \ @@ -552,14 +579,9 @@ ifeq ($(may-sync-config),1) # because some architectures define CROSS_COMPILE there. include include/config/auto.conf.cmd +# Allow people to just run `make` as before and not force them to configure $(KCONFIG_CONFIG): - @echo >&2 '***' - @echo >&2 '*** Configuration file "$@" not found!' - @echo >&2 '***' - @echo >&2 '*** Please run some configurator (e.g. "make oldconfig" or' - @echo >&2 '*** "make menuconfig" or "make xconfig").' - @echo >&2 '***' - @/bin/false + $(Q)$(MAKE) -f $(srctree)/Makefile defconfig # The actual configuration files used during the build are stored in # include/generated/ and include/config/. Update them if .config is newer than @@ -587,15 +609,40 @@ include/config/auto.conf: endif # may-sync-config endif # $(dot-config) +# XXX CFLAGS found in Rules.mk +ifeq ($(CONFIG_DEBUG),y) +KBUILD_CFLAGS += -O1 +else +KBUILD_CFLAGS += -O2 +endif -# arch Makefile may override CC so keep this after arch Makefile is included -NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include) +ifeq ($(CONFIG_FRAME_POINTER),y) +KBUILD_CFLAGS += -fno-omit-frame-pointer +else +KBUILD_CFLAGS += -fomit-frame-pointer +endif +KBUILD_CFLAGS += -fno-builtin -fno-common +KBUILD_CFLAGS += -Werror -Wredundant-decls -Wno-pointer-arith +KBUILD_CFLAGS += $(call cc-option,-Wvla) +KBUILD_CFLAGS += -pipe -D__XEN__ -include $(srctree)/include/xen/config.h +ifeq ($(CONFIG_DEBUG_INFO),y) +KBUILD_CFLAGS += -g +endif +KBUILD_CFLAGS += -Wa,--strip-local-absolute + +# arch Makefile may override CC so keep this after arch Makefile is included +NOSTDINC_FLAGS += -nostdinc # use the deterministic mode of AR if available KBUILD_ARFLAGS := $(call ar-option,D) +# Most CFLAGS are safe for assembly files: +# -std=gnu{89,99} gets confused by #-prefixed end-of-line comments +# -flto makes no sense and annoys clang +KBUILD_AFLAGS += $(filter-out -std=gnu% -flto,$(KBUILD_CFLAGS)) + include scripts/Makefile.kasan include scripts/Makefile.ubsan @@ -616,7 +663,7 @@ CHECKFLAGS += $(if $(CONFIG_64BIT),-m64,-m32) # set in the environment # Also any assignments in arch/$(ARCH)/Makefile take precedence over # this default value -export KBUILD_IMAGE ?= vmlinux +export KBUILD_IMAGE ?= xen # # INSTALL_PATH specifies where to place the updated kernel and system map @@ -627,74 +674,59 @@ HOST_LIBELF_LIBS = $(shell pkg-config libelf --libs 2>/dev/null || echo -lelf) PHONY += prepare0 -core-y += kernel/ certs/ mm/ fs/ ipc/ security/ crypto/ block/ +xen-dirs := $(patsubst %/,%,$(filter %/, $(head-y) $(common-y) \ + $(drivers-y) $(libs-y) $(xsm-y) $(arch-y) \ + $(crypto-y))) -vmlinux-dirs := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \ - $(core-y) $(core-m) $(drivers-y) $(drivers-m) \ - $(net-y) $(net-m) $(libs-y) $(libs-m) $(virt-y))) +xen-alldirs := $(sort $(xen-dirs) \ + $(patsubst %/,%,$(filter %/, $(head-y) $(common-) \ + $(drivers-) $(libs-) $(xsm-) $(arch-) $(crypto-)))) +xen-alldirs += include -vmlinux-alldirs := $(sort $(vmlinux-dirs) Documentation \ - $(patsubst %/,%,$(filter %/, $(init-) $(core-) \ - $(drivers-) $(net-) $(libs-) $(virt-)))) - -init-y := $(patsubst %/, %/built-in.a, $(init-y)) -core-y := $(patsubst %/, %/built-in.a, $(core-y)) +head-y := $(patsubst %/, %/built-in.a, $(head-y)) +common-y := $(patsubst %/, %/built-in.a, $(common-y)) drivers-y := $(patsubst %/, %/built-in.a, $(drivers-y)) -net-y := $(patsubst %/, %/built-in.a, $(net-y)) libs-y1 := $(patsubst %/, %/lib.a, $(libs-y)) libs-y2 := $(patsubst %/, %/built-in.a, $(filter-out %.a, $(libs-y))) -virt-y := $(patsubst %/, %/built-in.a, $(virt-y)) +xsm-y := $(patsubst %/, %/built-in.a, $(xsm-y)) +arch-y := $(patsubst %/, %/built-in.a, $(arch-y)) +crypto-y := $(patsubst %/, %/built-in.a, $(crypto-y)) -# Externally visible symbols (used by link-vmlinux.sh) -export KBUILD_VMLINUX_OBJS := $(head-y) $(init-y) $(core-y) $(libs-y2) \ - $(drivers-y) $(net-y) $(virt-y) +# Externally visible symbols +export ALL_OBJS := $(head-y) $(common-y) $(drivers-y) $(libs-y2) \ + $(xsm-y) $(arch-y) $(crypto-y) export KBUILD_VMLINUX_LIBS := $(libs-y1) -export KBUILD_LDS := arch/$(SRCARCH)/kernel/vmlinux.lds -export LDFLAGS_vmlinux -# used by scripts/package/Makefile -export KBUILD_ALLDIRS := $(sort $(filter-out arch/%,$(vmlinux-alldirs)) LICENSES arch include scripts tools) - -vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS) - -ARCH_POSTLINK := $(wildcard $(srctree)/arch/$(SRCARCH)/Makefile.postlink) +export KBUILD_LDS := arch/$(SRCARCH)/xen.lds +export LDFLAGS_xen +export TARGET := xen -# Final link of vmlinux with optional arch pass after final link -cmd_link-vmlinux = \ - $(CONFIG_SHELL) $< $(LD) $(KBUILD_LDFLAGS) $(LDFLAGS_vmlinux) ; \ - $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true) +xen-deps := $(KBUILD_LDS) $(ALL_OBJS) $(KBUILD_VMLINUX_LIBS) -vmlinux: scripts/link-vmlinux.sh autoksyms_recursive $(vmlinux-deps) FORCE - +$(call if_changed,link-vmlinux) +xen: $(xen-deps) FORCE + $(Q)$(MAKE) $(build)=arch/$(SRCARCH) xen -targets := vmlinux +targets := xen # The actual objects are generated when descending, # make sure no implicit rule kicks in -$(sort $(vmlinux-deps)): $(vmlinux-dirs) ; +$(sort $(xen-deps)): $(xen-dirs) ; -# Handle descending into subdirectories listed in $(vmlinux-dirs) +# Handle descending into subdirectories listed in $(xen-dirs) # Preset locale variables to speed up the build process. Limit locale # tweaks to this spot to avoid wrong language settings when running # make menuconfig etc. # Error messages still appears in the original language -PHONY += $(vmlinux-dirs) -$(vmlinux-dirs): prepare +PHONY += $(xen-dirs) +$(xen-dirs): prepare $(Q)$(MAKE) $(build)=$@ need-builtin=1 need-modorder=1 -filechk_kernel.release = \ - echo "$(KERNELVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))" - -# Store (new) KERNELRELEASE string in include/config/kernel.release -include/config/kernel.release: FORCE - $(call filechk,kernel.release) - # Additional helpers built in scripts/ # Carefully list dependencies so we do not try to build scripts twice # in parallel PHONY += scripts -scripts: scripts_basic scripts_dtc - $(Q)$(MAKE) $(build)=$(@) +scripts: scripts_basic + $(Q)$(MAKE) $(build)=tools # Things we need to do before we recursively start building the kernel # or the modules are listed in "prepare". @@ -707,7 +739,7 @@ PHONY += prepare archprepare prepare3 # prepare3 is used to check if we are building in a separate output directory, # and if so do: # 1) Check that make has not been executed in the kernel src $(srctree) -prepare3: include/config/kernel.release +prepare3: ifdef building_out_of_srctree @$(kecho) ' Using $(srctree) as source for kernel' $(Q)if [ -f $(srctree)/.config -o \ @@ -719,11 +751,15 @@ ifdef building_out_of_srctree fi; endif -archprepare: archheaders archscripts scripts prepare3 outputmakefile \ - asm-generic $(version_h) $(autoksyms_h) include/generated/utsrelease.h +PHONY += preprepare +preprepare: + $(Q)[ -e $(objtree)/include/asm ] || ln -sf asm-$(SRCARCH) $(objtree)/include/asm + $(Q)$(MAKE) $(build)=include all + +archprepare: preprepare archheaders scripts prepare3 outputmakefile \ + $(version_h) prepare0: archprepare - $(Q)$(MAKE) $(build)=scripts/mod $(Q)$(MAKE) $(build)=. # All the preparing.. @@ -732,73 +768,63 @@ prepare: prepare0 # Generate some files # --------------------------------------------------------------------------- -# KERNELRELEASE can change from a few different places, meaning version.h +# KERNELRELEASE can change from a few different places, meaning compile.h # needs to be updated, so this check is forced on all builds -uts_len := 64 -define filechk_utsrelease.h - if [ `echo -n "$(KERNELRELEASE)" | wc -c ` -gt $(uts_len) ]; then \ - echo '"$(KERNELRELEASE)" exceeds $(uts_len) characters' >&2; \ - exit 1; \ - fi; \ - echo \#define UTS_RELEASE \"$(KERNELRELEASE)\" -endef - +# compile.h contains dynamic build info. Rebuilt on every 'make' invocation. define filechk_version.h - echo \#define LINUX_VERSION_CODE $(shell \ - expr $(VERSION) \* 65536 + 0$(PATCHLEVEL) \* 256 + 0$(SUBLEVEL)); \ - echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))' + echo '#define XEN_COMPILE_DATE "$(XEN_BUILD_DATE)"'; \ + echo '#define XEN_COMPILE_TIME "$(XEN_BUILD_TIME)"'; \ + echo '#define XEN_COMPILE_BY "$(XEN_WHOAMI)"'; \ + echo '#define XEN_COMPILE_DOMAIN "$(XEN_DOMAIN)"'; \ + echo '#define XEN_COMPILE_HOST "$(XEN_BUILD_HOST)"'; \ + echo '#define XEN_COMPILER "$(shell $(CC) $(KBUILD_CFLAGS) --version 2>&1 | head -1)"'; \ + echo; \ + echo '#define XEN_VERSION $(XEN_VERSION)'; \ + echo '#define XEN_SUBVERSION $(XEN_SUBVERSION)'; \ + echo '#define XEN_EXTRAVERSION "$(XEN_EXTRAVERSION)"'; \ + echo; \ + echo '#define XEN_CHANGESET "$(shell tools/scmversion $(XEN_ROOT) || echo "unavailable")"'; \ + echo '#define XEN_BANNER "Xen $(XEN_FULLVERSION)"' endef $(version_h): FORCE $(call filechk,version.h) - $(Q)rm -f $(old_version_h) ### # Cleaning is done on three levels. # make clean Delete most generated files -# Leave enough to build external modules # make mrproper Delete the current configuration, and all generated files # make distclean Remove editor backup files, patch leftover files and the like # Directories & files removed with 'make clean' -CLEAN_DIRS += include/ksym -CLEAN_FILES += modules.builtin.modinfo # Directories & files removed with 'make mrproper' MRPROPER_DIRS += include/config include/generated \ - arch/$(SRCARCH)/include/generated .tmp_objdiff -MRPROPER_FILES += .config .config.old .version \ - Module.symvers \ - signing_key.pem signing_key.priv signing_key.x509 \ - x509.genkey extra_certificates signing_key.x509.keyid \ - signing_key.x509.signer vmlinux-gdb.py + arch/$(SRCARCH)/include/generated +MRPROPER_FILES += .config .config.old include/asm # Directories & files removed with 'make distclean' DISTCLEAN_DIRS += DISTCLEAN_FILES += tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS -# clean - Delete most, but leave enough to build external modules +# clean - Delete most # clean: rm-dirs := $(CLEAN_DIRS) clean: rm-files := $(CLEAN_FILES) -clean-dirs := $(addprefix _clean_, . $(vmlinux-alldirs)) +clean-dirs := $(addprefix _clean_, . $(xen-alldirs)) -PHONY += $(clean-dirs) clean archclean vmlinuxclean +PHONY += $(clean-dirs) clean archclean $(clean-dirs): $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@) -vmlinuxclean: - $(Q)$(CONFIG_SHELL) $(srctree)/scripts/link-vmlinux.sh clean - $(Q)$(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) clean) - -clean: archclean vmlinuxclean +clean: archclean # mrproper - Delete all generated files, including .config # mrproper: rm-dirs := $(wildcard $(MRPROPER_DIRS)) mrproper: rm-files := $(wildcard $(MRPROPER_FILES)) -mrproper-dirs := $(addprefix _mrproper_,scripts) +mrproper-dirs := $(addprefix _mrproper_,tools) PHONY += $(mrproper-dirs) mrproper $(mrproper-dirs): @@ -842,7 +868,7 @@ help: @echo ' distclean - mrproper + remove editor backup and patch files' @echo '' @echo 'Configuration targets:' - @$(MAKE) -f $(srctree)/scripts/kconfig/Makefile help + @$(MAKE) -f $(srctree)/tools/kconfig/Makefile help @echo '' @echo 'Other generic targets:' @echo ' all - Build all targets marked with [*]' @@ -950,17 +976,14 @@ $(help-board-dirs): help-%: clean: $(clean-dirs) $(call cmd,rmdirs) $(call cmd,rmfiles) - @find $(if $(KBUILD_EXTMOD), $(KBUILD_EXTMOD), .) $(RCS_FIND_IGNORE) \ - \( -name '*.[aios]' -o -name '*.ko' -o -name '.*.cmd' \ - -o -name '*.ko.*' \ - -o -name '*.dtb' -o -name '*.dtb.S' -o -name '*.dt.yaml' \ - -o -name '*.dwo' -o -name '*.lst' \ + @find . $(RCS_FIND_IGNORE) \ + \( -name '*.[aios]' -o -name '.*.cmd' \ + -o -name '*.dwo' \ -o -name '*.su' -o -name '*.mod' \ - -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \ + -o -name '.*.d' -o -name '.*.tmp' \ -o -name '*.lex.c' -o -name '*.tab.[ch]' \ -o -name '*.asn1.[ch]' \ - -o -name '*.symtypes' -o -name 'modules.order' \ - -o -name modules.builtin -o -name '.tmp_*.o.*' \ + -o -name '.tmp_*.o.*' \ -o -name '*.c.[012]*.*' \ -o -name '*.ll' \ -o -name '*.gcno' \) -type f -print | xargs rm -f From patchwork Wed Oct 23 16:48:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 11207267 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0AF8113BD for ; Wed, 23 Oct 2019 17:12:06 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CFEF220640 for ; Wed, 23 Oct 2019 17:12:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="YzFyUOhZ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CFEF220640 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNK9t-0002jH-AC; Wed, 23 Oct 2019 17:10:53 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iNK9r-0002iA-Qo for xen-devel@lists.xenproject.org; Wed, 23 Oct 2019 17:10:51 +0000 X-Inumbo-ID: 0e197a93-f5b8-11e9-9488-12813bfff9fa Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 0e197a93-f5b8-11e9-9488-12813bfff9fa; Wed, 23 Oct 2019 17:10:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1571850647; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9XYbMAa141Vjay5LuVpIV4/K3CYa1fcQfpPhYsRXZRg=; b=YzFyUOhZfWxq/DJxxJHpVWajS6FsUOVre9KsuGsK0jBjPQIJY8cPFYvw dA5+5phFJUXmov7r4iRs88c0/8NBxkltZ6/FBnAh0tFrFpQfve6VnB14D F9QZldwbnn7sywRpX9htJqr/ITatAKFJ/dFVFJXRbUcYIVHN7IK2Pwyvy w=; Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=anthony.perard@citrix.com; spf=Pass smtp.mailfrom=anthony.perard@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa4.hc3370-68.iphmx.com: no sender authenticity information available from domain of anthony.perard@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa4.hc3370-68.iphmx.com: domain of anthony.perard@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa4.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: iwRSXedvfq+0P99ZZhzsPLBKtzvYZNvYErSRsnVAVHuRAKehKf69clTSnECKsv1TikqIsnw13g U3GF/IvuK/TEI+nCyywZqSPOeMRLGJeCog8hK/Bz9/iy0O7SDhmmEVES7YH+5rocDmcFlS79rS xnCVnClZXw+c/pwp2zwFIhk4ub2+xtbZ/0VnA1rHiKFUAfhANxZePE53Le9eVvM5Hryv7phaWx jIADM0DCkGAduW3K83vM3IxHN+obGqOHgBdNdeAhjDzmiYBSvwgWmOKvlkO31PhknkbefmbDla KBM= X-SBRS: 2.7 X-MesageID: 7779494 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.68,221,1569297600"; d="scan'208";a="7779494" From: Anthony PERARD To: Date: Wed, 23 Oct 2019 17:48:37 +0100 Message-ID: <20191023164837.2700240-24-anthony.perard@citrix.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191023164837.2700240-1-anthony.perard@citrix.com> References: <20191023164837.2700240-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [RFC XEN PATCH 23/23] xen/tools/kconfig: Delete duplicate makefiles X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Anthony PERARD Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Makefile.host is now in xen/scripts Makefile.kconfig isn't needed anymore. --- xen/tools/kconfig/Makefile.host | 164 ----------------------------- xen/tools/kconfig/Makefile.kconfig | 126 ---------------------- 2 files changed, 290 deletions(-) delete mode 100644 xen/tools/kconfig/Makefile.host delete mode 100644 xen/tools/kconfig/Makefile.kconfig diff --git a/xen/tools/kconfig/Makefile.host b/xen/tools/kconfig/Makefile.host deleted file mode 100644 index 2208ebbd8c4c..000000000000 --- a/xen/tools/kconfig/Makefile.host +++ /dev/null @@ -1,164 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -# ========================================================================== -# Building binaries on the host system -# Binaries are used during the compilation of the kernel, for example -# to preprocess a data file. -# -# Both C and C++ are supported, but preferred language is C for such utilities. -# -# Sample syntax (see Documentation/kbuild/makefiles.rst for reference) -# hostprogs-y := bin2hex -# Will compile bin2hex.c and create an executable named bin2hex -# -# hostprogs-y := lxdialog -# lxdialog-objs := checklist.o lxdialog.o -# Will compile lxdialog.c and checklist.c, and then link the executable -# lxdialog, based on checklist.o and lxdialog.o -# -# hostprogs-y := qconf -# qconf-cxxobjs := qconf.o -# qconf-objs := menu.o -# Will compile qconf as a C++ program, and menu as a C program. -# They are linked as C++ code to the executable qconf - -__hostprogs := $(sort $(hostprogs-y) $(hostprogs-m)) -host-cshlib := $(sort $(hostlibs-y) $(hostlibs-m)) -host-cxxshlib := $(sort $(hostcxxlibs-y) $(hostcxxlibs-m)) - -# C code -# Executables compiled from a single .c file -host-csingle := $(foreach m,$(__hostprogs), \ - $(if $($(m)-objs)$($(m)-cxxobjs),,$(m))) - -# C executables linked based on several .o files -host-cmulti := $(foreach m,$(__hostprogs),\ - $(if $($(m)-cxxobjs),,$(if $($(m)-objs),$(m)))) - -# Object (.o) files compiled from .c files -host-cobjs := $(sort $(foreach m,$(__hostprogs),$($(m)-objs))) - -# C++ code -# C++ executables compiled from at least one .cc file -# and zero or more .c files -host-cxxmulti := $(foreach m,$(__hostprogs),$(if $($(m)-cxxobjs),$(m))) - -# C++ Object (.o) files compiled from .cc files -host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs))) - -# Object (.o) files used by the shared libaries -host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs)))) -host-cxxshobjs := $(sort $(foreach m,$(host-cxxshlib),$($(m:.so=-objs)))) - -host-csingle := $(addprefix $(obj)/,$(host-csingle)) -host-cmulti := $(addprefix $(obj)/,$(host-cmulti)) -host-cobjs := $(addprefix $(obj)/,$(host-cobjs)) -host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti)) -host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs)) -host-cshlib := $(addprefix $(obj)/,$(host-cshlib)) -host-cxxshlib := $(addprefix $(obj)/,$(host-cxxshlib)) -host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs)) -host-cxxshobjs := $(addprefix $(obj)/,$(host-cxxshobjs)) - -##### -# Handle options to gcc. Support building with separate output directory - -_hostc_flags = $(KBUILD_HOSTCFLAGS) $(HOST_EXTRACFLAGS) \ - $(HOSTCFLAGS_$(basetarget).o) -_hostcxx_flags = $(KBUILD_HOSTCXXFLAGS) $(HOST_EXTRACXXFLAGS) \ - $(HOSTCXXFLAGS_$(basetarget).o) - -# $(objtree)/$(obj) for including generated headers from checkin source files -ifeq ($(KBUILD_EXTMOD),) -ifdef building_out_of_srctree -_hostc_flags += -I $(objtree)/$(obj) -_hostcxx_flags += -I $(objtree)/$(obj) -endif -endif - -hostc_flags = -Wp,-MD,$(depfile) $(_hostc_flags) -hostcxx_flags = -Wp,-MD,$(depfile) $(_hostcxx_flags) - -##### -# Compile programs on the host - -# Create executable from a single .c file -# host-csingle -> Executable -quiet_cmd_host-csingle = HOSTCC $@ - cmd_host-csingle = $(HOSTCC) $(hostc_flags) $(KBUILD_HOSTLDFLAGS) -o $@ $< \ - $(KBUILD_HOSTLDLIBS) $(HOSTLDLIBS_$(@F)) -$(host-csingle): $(obj)/%: $(src)/%.c FORCE - $(call if_changed_dep,host-csingle) - -# Link an executable based on list of .o files, all plain c -# host-cmulti -> executable -quiet_cmd_host-cmulti = HOSTLD $@ - cmd_host-cmulti = $(HOSTCC) $(KBUILD_HOSTLDFLAGS) -o $@ \ - $(addprefix $(obj)/,$($(@F)-objs)) \ - $(KBUILD_HOSTLDLIBS) $(HOSTLDLIBS_$(@F)) -$(host-cmulti): FORCE - $(call if_changed,host-cmulti) -$(call multi_depend, $(host-cmulti), , -objs) - -# Create .o file from a single .c file -# host-cobjs -> .o -quiet_cmd_host-cobjs = HOSTCC $@ - cmd_host-cobjs = $(HOSTCC) $(hostc_flags) -c -o $@ $< -$(host-cobjs): $(obj)/%.o: $(src)/%.c FORCE - $(call if_changed_dep,host-cobjs) - -# Link an executable based on list of .o files, a mixture of .c and .cc -# host-cxxmulti -> executable -quiet_cmd_host-cxxmulti = HOSTLD $@ - cmd_host-cxxmulti = $(HOSTCXX) $(KBUILD_HOSTLDFLAGS) -o $@ \ - $(foreach o,objs cxxobjs,\ - $(addprefix $(obj)/,$($(@F)-$(o)))) \ - $(KBUILD_HOSTLDLIBS) $(HOSTLDLIBS_$(@F)) -$(host-cxxmulti): FORCE - $(call if_changed,host-cxxmulti) -$(call multi_depend, $(host-cxxmulti), , -objs -cxxobjs) - -# Create .o file from a single .cc (C++) file -quiet_cmd_host-cxxobjs = HOSTCXX $@ - cmd_host-cxxobjs = $(HOSTCXX) $(hostcxx_flags) -c -o $@ $< -$(host-cxxobjs): $(obj)/%.o: $(src)/%.cc FORCE - $(call if_changed_dep,host-cxxobjs) - -# Compile .c file, create position independent .o file -# host-cshobjs -> .o -quiet_cmd_host-cshobjs = HOSTCC -fPIC $@ - cmd_host-cshobjs = $(HOSTCC) $(hostc_flags) -fPIC -c -o $@ $< -$(host-cshobjs): $(obj)/%.o: $(src)/%.c FORCE - $(call if_changed_dep,host-cshobjs) - -# Compile .c file, create position independent .o file -# Note that plugin capable gcc versions can be either C or C++ based -# therefore plugin source files have to be compilable in both C and C++ mode. -# This is why a C++ compiler is invoked on a .c file. -# host-cxxshobjs -> .o -quiet_cmd_host-cxxshobjs = HOSTCXX -fPIC $@ - cmd_host-cxxshobjs = $(HOSTCXX) $(hostcxx_flags) -fPIC -c -o $@ $< -$(host-cxxshobjs): $(obj)/%.o: $(src)/%.c FORCE - $(call if_changed_dep,host-cxxshobjs) - -# Link a shared library, based on position independent .o files -# *.o -> .so shared library (host-cshlib) -quiet_cmd_host-cshlib = HOSTLLD -shared $@ - cmd_host-cshlib = $(HOSTCC) $(KBUILD_HOSTLDFLAGS) -shared -o $@ \ - $(addprefix $(obj)/,$($(@F:.so=-objs))) \ - $(KBUILD_HOSTLDLIBS) $(HOSTLDLIBS_$(@F)) -$(host-cshlib): FORCE - $(call if_changed,host-cshlib) -$(call multi_depend, $(host-cshlib), .so, -objs) - -# Link a shared library, based on position independent .o files -# *.o -> .so shared library (host-cxxshlib) -quiet_cmd_host-cxxshlib = HOSTLLD -shared $@ - cmd_host-cxxshlib = $(HOSTCXX) $(KBUILD_HOSTLDFLAGS) -shared -o $@ \ - $(addprefix $(obj)/,$($(@F:.so=-objs))) \ - $(KBUILD_HOSTLDLIBS) $(HOSTLDLIBS_$(@F)) -$(host-cxxshlib): FORCE - $(call if_changed,host-cxxshlib) -$(call multi_depend, $(host-cxxshlib), .so, -objs) - -targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\ - $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs) $(host-cxxshlib) $(host-cxxshobjs) diff --git a/xen/tools/kconfig/Makefile.kconfig b/xen/tools/kconfig/Makefile.kconfig deleted file mode 100644 index 6d2df760ff28..000000000000 --- a/xen/tools/kconfig/Makefile.kconfig +++ /dev/null @@ -1,126 +0,0 @@ -# xen/tools/kconfig - -# default rule to do nothing -all: - -# Xen doesn't have a silent build flag -quiet := -Q := -kecho := : - -# eventually you'll want to do out of tree builds -srctree := $(XEN_ROOT)/xen -objtree := $(srctree) -src := tools/kconfig -obj := $(src) - -# handle functions (most of these lifted from different Linux makefiles -dot-target = $(dir $@).$(notdir $@) -depfile = $(subst $(comma),,$(dot-target).d) -basetarget = $(basename $(notdir $@)) -cmd = $(cmd_$(1)) -if_changed = $(cmd_$(1)) -if_changed_dep = $(cmd_$(1)) - -### -# filechk is used to check if the content of a generated file is updated. -# Sample usage: -# -# filechk_sample = echo $(KERNELRELEASE) -# version.h: FORCE -# $(call filechk,sample) -# -# The rule defined shall write to stdout the content of the new file. -# The existing file will be compared with the new one. -# - If no file exist it is created -# - If the content differ the new file is used -# - If they are equal no change, and no timestamp update -# - stdin is piped in from the first prerequisite ($<) so one has -# to specify a valid file as first prerequisite (often the kbuild file) -define filechk - $(Q)set -e; \ - mkdir -p $(dir $@); \ - { $(filechk_$(1)); } > $@.tmp; \ - if [ -r $@ ] && cmp -s $@ $@.tmp; then \ - rm -f $@.tmp; \ - else \ - $(kecho) ' UPD $@'; \ - mv -f $@.tmp $@; \ - fi -endef - -define multi_depend -$(foreach m, $(notdir $1), \ - $(eval $(obj)/$m: \ - $(addprefix $(obj)/, $(foreach s, $3, $($(m:%$(strip $2)=%$(s))))))) -endef - -# LEX -# --------------------------------------------------------------------------- -quiet_cmd_flex = LEX $@ - cmd_flex = $(LEX) -o$@ -L $< - -$(obj)/%.lex.c: $(src)/%.l FORCE - $(call if_changed,flex) - -# YACC -# --------------------------------------------------------------------------- -quiet_cmd_bison = YACC $@ - cmd_bison = $(YACC) -o$@ -t -l $< - -$(obj)/%.tab.c: $(src)/%.y FORCE - $(call if_changed,bison) - -quiet_cmd_bison_h = YACC $@ - cmd_bison_h = $(YACC) -o/dev/null --defines=$@ -t -l $< - -$(obj)/%.tab.h: $(src)/%.y FORCE - $(call if_changed,bison_h) - -# Set our default defconfig file -KBUILD_DEFCONFIG := $(ARCH)_defconfig - -# provide our shell -CONFIG_SHELL := $(SHELL) - -# provide the host compiler -HOSTCC ?= gcc -HOSTCXX ?= g++ -YACC = $(if $(BISON),$(BISON),bison) -LEX = $(if $(FLEX),$(FLEX),flex) - -# force target -PHONY += FORCE - -FORCE: - -# include the original Makefile and Makefile.host from Linux -include $(src)/Makefile -include $(src)/Makefile.host - -# Add intermediate targets: -# When building objects with specific suffix patterns, add intermediate -# targets that the final targets are derived from. -intermediate_targets = $(foreach sfx, $(2), \ - $(patsubst %$(strip $(1)),%$(sfx), \ - $(filter %$(strip $(1)), $(targets)))) - -# %.lex.o <- %.lex.c <- %.l -# %.tab.o <- %.tab.[ch] <- %.y -targets += $(call intermediate_targets, .lex.o, .lex.c) \ - $(call intermediate_targets, .tab.o, .tab.c .tab.h) - -# clean up rule -clean-deps = $(foreach f,$(host-cobjs) $(host-cxxobjs),$(dir $f).$(notdir $f).d) -clean-shipped = $(patsubst %_shipped,%,$(wildcard $(obj)/*_shipped)) - -clean: - rm -rf $(clean-files) - rm -rf $(clean-deps) - rm -rf $(host-csingle) $(host-cmulti) $(host-cxxmulti) $(host-cobjs) $(host-cxxobjs) - rm -rf $(clean-shipped) - -$(obj)/zconf%: $(src)/zconf%_shipped - cp -f $< $@ - -.PHONY: $(PHONY)