From patchwork Sat Feb 4 00:26:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1737408 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=HtpSx4z9; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4P7tzT28r7z23hh for ; Sat, 4 Feb 2023 11:43:01 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2BDAA85C4D; Sat, 4 Feb 2023 01:41:53 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="HtpSx4z9"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 967FE85CC9; Sat, 4 Feb 2023 01:31:17 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x12c.google.com (mail-il1-x12c.google.com [IPv6:2607:f8b0:4864:20::12c]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 4F7718601E for ; Sat, 4 Feb 2023 01:28:50 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x12c.google.com with SMTP id l7so2793952ilf.0 for ; Fri, 03 Feb 2023 16:28:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HukEI2W3wd8E3uimYIg49GGSZRlL3xvGX22YE6ihKos=; b=HtpSx4z9jYQHS+DBO/m0n7KSS4t0h35gRT+ohfWf77iTgOCzmGyk2EmUDEx0K6+pDT ryCAYCiVRvwGyQzaBgPmOHrqS3HGcxpgPBCIyuJEVDjC6wiCdpKxoze0KvRQvLjEWx5R AEtqEKNkgROno3vwVGYKqmi/GXDTakZbjf8nM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HukEI2W3wd8E3uimYIg49GGSZRlL3xvGX22YE6ihKos=; b=oZKSB2sncl4Ar9CIl1MWB4u/24HoH7J0x9DAqi25nio3EcGmiUBHmvREMy+C1h8pV1 LKYGT7id2oGG0FEEdv8BfLFoJPYJ9le/tyiLhlfKsqzLY+Mfq/ZSxMYDuD1/esmN/lg4 CiVoHWb11KT5GkG7XNuZ4SOhk42RYq+pC7svPDgS6NFK4O9z7lP50MQbCxKgGXFsGzeI DWIZEX8XNcyfeYactHViR1ZD3XRzuzTg+mGENv5Z2KtdHiehQ7LehROn7zz2Q1EbHVJD JIwm6nqSgUWMUlwaYUx+WIR0Aeupj6VYPcuKCdN6Hk/cLxZ6UcZSVYMwO7SWIIxJCMLr Gi5w== X-Gm-Message-State: AO0yUKV0JuMlx0x6dK669rc3OhflnZNbeV6++pJXb4wbYDpjoWyURn2R 1yfhvt8/AYLWv9ZTFfzh+WTyqT4Xfa/4x+Qr X-Google-Smtp-Source: AK7set87PnzU6Yr39hY3h/4cbbBKhQlCSCl336ewCYHU5CO9FWSIwd3wJ/duvvJOdPQbHbGczmWJ6g== X-Received: by 2002:a05:6e02:2167:b0:310:e71b:208f with SMTP id s7-20020a056e02216700b00310e71b208fmr10900917ilv.17.1675470520453; Fri, 03 Feb 2023 16:28:40 -0800 (PST) Received: from kea.bld.corp.google.com ([2620:15c:183:200:5b65:12f1:51b7:8157]) by smtp.gmail.com with ESMTPSA id j12-20020a02cc6c000000b003adab954c5asm1270255jaq.153.2023.02.03.16.28.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Feb 2023 16:28:40 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Masahiro Yamada Subject: [RFC PATCH v2 46/56] Makefile: Include the config for the phase being built Date: Fri, 3 Feb 2023 17:26:09 -0700 Message-Id: <20230204002619.938387-47-sjg@chromium.org> X-Mailer: git-send-email 2.39.1.519.gcb327c4b5f-goog In-Reply-To: <20230204002619.938387-1-sjg@chromium.org> References: <20230204002619.938387-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean At present there is only a single auto.conf file used within the makefiles. Update them to use the correct one for each phase. Also update kconfig.h to include the correct autoconf.h or autoconf_spl.h file for each phase. This allows the macros to be simplified. With this, CONFIG_IS_ENABLED() is the same as IS_ENABLED() apart from a migration detail. Both changes are made in the same patch to avoid build errors. Signed-off-by: Simon Glass --- Changes in v2: - Include code from 'Update CONFIG_IS_ENABLED() for split files' too Makefile | 11 +++- include/linux/kconfig.h | 74 +++++++++----------------- scripts/Makefile.build | 12 ++++- scripts/Makefile.spl | 10 +++- tools/binman/test/generated/autoconf.h | 4 +- 5 files changed, 58 insertions(+), 53 deletions(-) diff --git a/Makefile b/Makefile index 4d6f71037ff..1eea78a2d7e 100644 --- a/Makefile +++ b/Makefile @@ -587,8 +587,17 @@ scripts: scripts_basic scripts_dtc include/config/auto.conf $(Q)$(MAKE) $(build)=$(@) ifeq ($(dot-config),1) -# Read in config + +# Read in the config for this phase +ifdef CONFIG_TPL_BUILD +-include include/config/auto_tpl.conf +else ifdef CONFIG_VPL_BUILD +-include include/config/auto_vpl.conf +else ifdef CONFIG_SPL_BUILD +-include include/config/auto_spl.conf +else -include include/config/auto.conf +endif # Read in dependencies to all Kconfig* files, make sure to run # oldconfig if changes are detected. diff --git a/include/linux/kconfig.h b/include/linux/kconfig.h index 2bc704e1104..f00686eb3e1 100644 --- a/include/linux/kconfig.h +++ b/include/linux/kconfig.h @@ -1,7 +1,17 @@ #ifndef __LINUX_KCONFIG_H #define __LINUX_KCONFIG_H +#ifdef USE_HOSTCC +#include +#elif defined(CONFIG_TPL_BUILD) +#include +#elif defined(CONFIG_VPL_BUILD) +#include +#elif defined(CONFIG_SPL_BUILD) +#include +#else #include +#endif /* * Helper macros to use CONFIG_ options in C/CPP expressions. Note that @@ -28,37 +38,9 @@ */ #define IS_ENABLED(option) config_enabled(option, 0) -/* - * U-Boot add-on: Helper macros to reference to different macros (prefixed by - * CONFIG_, CONFIG_SPL_, CONFIG_TPL_ or CONFIG_TOOLS_), depending on the build - * context. - */ +#define __config_val(cfg) CONFIG_ ## cfg -#ifdef USE_HOSTCC -#define _CONFIG_PREFIX TOOLS_ -#elif defined(CONFIG_TPL_BUILD) -#define _CONFIG_PREFIX TPL_ -#elif defined(CONFIG_VPL_BUILD) -#define _CONFIG_PREFIX VPL_ -#elif defined(CONFIG_SPL_BUILD) -#define _CONFIG_PREFIX SPL_ -#else -#define _CONFIG_PREFIX -#endif - -#define config_val(cfg) _config_val(_CONFIG_PREFIX, cfg) -#define _config_val(pfx, cfg) __config_val(pfx, cfg) -#define __config_val(pfx, cfg) CONFIG_ ## pfx ## cfg - -/* - * CONFIG_VAL(FOO) evaluates to the value of - * CONFIG_TOOLS_FOO if USE_HOSTCC is defined, - * CONFIG_FOO if CONFIG_SPL_BUILD is undefined, - * CONFIG_SPL_FOO if CONFIG_SPL_BUILD is defined. - * CONFIG_TPL_FOO if CONFIG_TPL_BUILD is defined. - * CONFIG_VPL_FOO if CONFIG_VPL_BUILD is defined. - */ -#define CONFIG_VAL(option) config_val(option) +#define CONFIG_VAL(option) __config_val(option) /* * This uses a similar mechanism to config_enabled() above. If cfg is enabled, @@ -104,26 +86,17 @@ long invalid_use_of_IF_ENABLED_INT(void); __concat(__unwrap, config_enabled(CONFIG_VAL(option), 0)) (case1, case0) /* - * CONFIG_IS_ENABLED(FOO) expands to - * 1 if USE_HOSTCC is defined and CONFIG_TOOLS_FOO is set to 'y', - * 1 if CONFIG_SPL_BUILD is undefined and CONFIG_FOO is set to 'y', - * 1 if CONFIG_SPL_BUILD is defined and CONFIG_SPL_FOO is set to 'y', - * 1 if CONFIG_TPL_BUILD is defined and CONFIG_TPL_FOO is set to 'y', - * 0 otherwise. + * CONFIG_IS_ENABLED(FOO) returns 1 if CONFIG_FOO is enabled for the phase being + * built, else 0. Note that CONFIG_FOO corresponds to CONFIG_SPL_FOO (in + * Kconfig) for the SPL phase, CONFIG_TPL_FOO for the TPL phase, etc. * - * CONFIG_IS_ENABLED(FOO, (abc)) expands to - * abc if USE_HOSTCC is defined and CONFIG_TOOLS_FOO is set to 'y', - * abc if CONFIG_SPL_BUILD is undefined and CONFIG_FOO is set to 'y', - * abc if CONFIG_SPL_BUILD is defined and CONFIG_SPL_FOO is set to 'y', - * abc if CONFIG_TPL_BUILD is defined and CONFIG_TPL_FOO is set to 'y', - * nothing otherwise. + * The _nospl version of a CONFIG is emitted by kconfig when an option has no + * SPL equivalent. So in that case there is a CONFIG_xxx for example, but not a + * CONFIG_SPL_xxx * - * CONFIG_IS_ENABLED(FOO, (abc), (def)) expands to - * abc if USE_HOSTCC is defined and CONFIG_TOOLS_FOO is set to 'y', - * abc if CONFIG_SPL_BUILD is undefined and CONFIG_FOO is set to 'y', - * abc if CONFIG_SPL_BUILD is defined and CONFIG_SPL_FOO is set to 'y', - * abc if CONFIG_TPL_BUILD is defined and CONFIG_TPL_FOO is set to 'y', - * def otherwise. + * This is needed as a transition measure while CONFIG_IS_ENABLED() is used on + * options without SPL equivalent, since in that case it should always return + * zero. Once we add SPL equivalents, this clause can be dropped. * * The optional second and third arguments must be parenthesized; that * allows one to include a trailing comma, e.g. for use in @@ -135,7 +108,7 @@ long invalid_use_of_IF_ENABLED_INT(void); * set, and nothing otherwise. */ -#define CONFIG_IS_ENABLED(option, ...) \ +#define CONFIG_IS_ENABLED(option, ...) \ __concat(__CONFIG_IS_ENABLED_, __count_args(option, ##__VA_ARGS__)) (option, ##__VA_ARGS__) #ifndef __ASSEMBLY__ @@ -155,4 +128,7 @@ long invalid_use_of_CONFIG_IF_ENABLED_INT(void); CONFIG_IS_ENABLED(option, (CONFIG_VAL(int_option)), \ (invalid_use_of_CONFIG_IF_ENABLED_INT())) +#define CONFIG_IF_INT(option, int_option) \ + CONFIG_IF_ENABLED_INT(option, int_option) + #endif /* __LINUX_KCONFIG_H */ diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 97dd4a64f6e..093392b430f 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -44,9 +44,19 @@ ldflags-y := subdir-asflags-y := subdir-ccflags-y := -# Read auto.conf if it exists, otherwise ignore +# Read appropriate auto.conf if it exists, otherwise ignore # Modified for U-Boot + +ifeq ($(SPL_NAME),tpl) +-include include/config/auto_tpl.conf +else ifeq ($(SPL_NAME),vpl) +-include include/config/auto_vpl.conf +else ifeq ($(SPL_NAME),spl) +-include include/config/auto_spl.conf +else -include include/config/auto.conf +endif + -include $(prefix)/include/autoconf.mk include scripts/Kbuild.include diff --git a/scripts/Makefile.spl b/scripts/Makefile.spl index 15ac87286d5..41528f32307 100644 --- a/scripts/Makefile.spl +++ b/scripts/Makefile.spl @@ -19,9 +19,17 @@ _dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj)) include $(srctree)/scripts/Kbuild.include --include include/config/auto.conf -include $(obj)/include/autoconf.mk +# Read in the config for this SPL phase +ifdef CONFIG_TPL_BUILD +-include include/config/auto_tpl.conf +else ifdef CONFIG_VPL_BUILD +-include include/config/auto_vpl.conf +else +-include include/config/auto_spl.conf +endif + UBOOTINCLUDE := -I$(obj)/include $(UBOOTINCLUDE) KBUILD_CPPFLAGS += -DCONFIG_SPL_BUILD diff --git a/tools/binman/test/generated/autoconf.h b/tools/binman/test/generated/autoconf.h index 6a23039f469..88dc762c423 100644 --- a/tools/binman/test/generated/autoconf.h +++ b/tools/binman/test/generated/autoconf.h @@ -1,3 +1,5 @@ #define CONFIG_BINMAN 1 #define CONFIG_SPL_BUILD 1 -#define CONFIG_SPL_BINMAN_SYMBOLS 1 + +/* Don't include the SPL_ here since we are using separate autoconf files */ +#define CONFIG_BINMAN_SYMBOLS 1