From patchwork Fri Nov 18 19:15:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 22484 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp370790wrr; Fri, 18 Nov 2022 11:28:15 -0800 (PST) X-Google-Smtp-Source: AA0mqf5ldvPxK8VVfRN32tYoDWAWQTZo7O//t2lJmT9AXA1qZeBvaf5S6i34vTO6imWrq8itPKkz X-Received: by 2002:a17:902:ca04:b0:188:f993:724a with SMTP id w4-20020a170902ca0400b00188f993724amr932128pld.77.1668799694965; Fri, 18 Nov 2022 11:28:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668799694; cv=none; d=google.com; s=arc-20160816; b=hlMJHJtzVz2hwTelEvjbjE9Tij/P8+AgUu0Waq/Ale/3fPZx7QX4zSMJ3TBS2bgjWl oxmAyGLVen2myVk3OJ6G+0u2PMnZj3ZodhcMfMSuijfZr/pJVAR3bFC8EcllnOc/b5vK bqpj+s5WAvN9wPHvIj2w7jGQHA74VW6kHvyZZRgnqOS+FvXj5mtUB+peu+L570Dx26+g IgCQs5k7Olw18C556CtinFgyELm2MyrEdNFGQXzOfscVp6C8ZEsYHhkXLiai6ugK2zQ0 sRTkFKvjWdroTO0pGtiqhFkrZ1ud4PUU1YF7jjUIJMArQ9/dEC5TlQea98f9+E1hEDT1 5BNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=9r9+jCctFU5qS0XLnEo62MR+EOkW17dVZ5LhS7CAoWc=; b=UIqJ8g705F1ioLzdG8JBhiUe5gAbmSEHvrHWqAWNb76lnbIRSiX9Mwo84q6/CEAqq+ XQOJpPC9mkZ0spwDEtonfF1bMJyTbiIG6moY7pjChSP30Q0Usgw2kMl1LFzPrv757aNh X02Z7NiML0H8Cvqn0QWH5H/13cla+cEbfxFf6e6TVDeVHossVRHWfcf0rE/TJ/i2lE/T XQRkFlhkoOsMw9WRfSkPh1rb8xwckPggueg3XbOpn2iX7Tzh9xoiomfpJXriUcryuP9W nDrafGJLvubVDVhRamULhTkfh/b/HyYMZg2qvyfOuVvGIIOZRI8NUir7Y1e9bDpBmVhI 3ZNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MtEsJp7A; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 190-20020a6300c7000000b00476f43ccfa8si4738777pga.849.2022.11.18.11.28.01; Fri, 18 Nov 2022 11:28:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MtEsJp7A; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235537AbiKRTQE (ORCPT + 99 others); Fri, 18 Nov 2022 14:16:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234828AbiKRTQB (ORCPT ); Fri, 18 Nov 2022 14:16:01 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5347B48774; Fri, 18 Nov 2022 11:16:01 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A897C62736; Fri, 18 Nov 2022 19:16:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D7496C433C1; Fri, 18 Nov 2022 19:15:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1668798960; bh=M4K5ScH+pC6MglCf1f3gYi4X+V904FTpAtCEzBIDp+Y=; h=From:To:Cc:Subject:Date:From; b=MtEsJp7A1l+j9iieOiRuDRXqsy6i11Nh7z9lvWJ4gWmPoc8u0IPwMeC9kKei4+YoC X+6i+r3b2LRkyTbt7oY1N3FYMNoc6Ebi9hfofD39po8qnq5ytwP/bX0y+WpEKexz7c tbsihnlLMZtIzwcjnvBG5kNWG/3D8ThP1gcOumaC9qh2FvC4dnPkjVcwUo63nol+TH XG5x8mnP5DOMNbCjlZtXDoekT+AkwtqY99rDeq9DkVIqtYfGidA7XJO19auJImJA5G vGv9/ntx5mZPGmxUIHeZBVAtVvDSa5mu1YxbNHvxHctMNAjw8GNwNy3LFelH8EASg2 I4y0VVQxGgjxg== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada , Nicolas Schier , Nathan Chancellor , Nick Desaulniers , linux-kernel@vger.kernel.org Subject: [PATCH v2 1/2] kbuild: add kbuild-file macro Date: Sat, 19 Nov 2022 04:15:50 +0900 Message-Id: <20221118191551.66448-1-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749863309074507933?= X-GMAIL-MSGID: =?utf-8?q?1749863309074507933?= While building, installing, cleaning, Kbuild visits sub-directories and includes 'Kbuild' or 'Makefile' that exists there. Add 'kbuild-file' macro, and reuse it from scripts/Makefie.* Signed-off-by: Masahiro Yamada Reviewed-by: Nicolas Schier --- Changes in v2: - Change scripts/Makefile.modpost scripts/Kbuild.include | 5 +++++ scripts/Makefile.asm-generic | 6 +++--- scripts/Makefile.build | 6 +----- scripts/Makefile.clean | 5 +---- scripts/Makefile.dtbinst | 2 +- scripts/Makefile.modpost | 2 +- 6 files changed, 12 insertions(+), 14 deletions(-) diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index 2bc08ace38a3..cbe28744637b 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -40,6 +40,11 @@ escsq = $(subst $(squote),'\$(squote)',$1) # Quote a string to pass it to C files. foo => '"foo"' stringify = $(squote)$(quote)$1$(quote)$(squote) +### +# The path to Kbuild or Makefile. Kbuild has precedence over Makefile. +kbuild-dir = $(if $(filter /%,$(src)),$(src),$(srctree)/$(src)) +kbuild-file = $(or $(wildcard $(kbuild-dir)/Kbuild),$(kbuild-dir)/Makefile) + ### # Easy method for doing a status message kecho := : diff --git a/scripts/Makefile.asm-generic b/scripts/Makefile.asm-generic index 1d501c57f9ef..8d01b37b7677 100644 --- a/scripts/Makefile.asm-generic +++ b/scripts/Makefile.asm-generic @@ -10,15 +10,15 @@ PHONY := all all: src := $(subst /generated,,$(obj)) --include $(src)/Kbuild + +include $(srctree)/scripts/Kbuild.include +-include $(kbuild-file) # $(generic)/Kbuild lists mandatory-y. Exclude um since it is a special case. ifneq ($(SRCARCH),um) include $(srctree)/$(generic)/Kbuild endif -include $(srctree)/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)) diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 41f3602fc8de..37cf88d076e8 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -38,11 +38,7 @@ subdir-ccflags-y := include $(srctree)/scripts/Kbuild.include include $(srctree)/scripts/Makefile.compiler - -# The filename Kbuild has precedence over Makefile -kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src)) -include $(or $(wildcard $(kbuild-dir)/Kbuild),$(kbuild-dir)/Makefile) - +include $(kbuild-file) include $(srctree)/scripts/Makefile.lib # Do not include hostprogs rules unless needed. diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean index 878cec648959..3649900696dd 100644 --- a/scripts/Makefile.clean +++ b/scripts/Makefile.clean @@ -9,10 +9,7 @@ PHONY := __clean __clean: include $(srctree)/scripts/Kbuild.include - -# The filename Kbuild has precedence over Makefile -kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src)) -include $(or $(wildcard $(kbuild-dir)/Kbuild),$(kbuild-dir)/Makefile) +include $(kbuild-file) # Figure out what we need to build from the various variables # ========================================================================== diff --git a/scripts/Makefile.dtbinst b/scripts/Makefile.dtbinst index 190d781e84f4..2ab936e4179d 100644 --- a/scripts/Makefile.dtbinst +++ b/scripts/Makefile.dtbinst @@ -15,7 +15,7 @@ __dtbs_install: include include/config/auto.conf include $(srctree)/scripts/Kbuild.include -include $(src)/Makefile +include $(kbuild-file) dtbs := $(addprefix $(dst)/, $(dtb-y) $(if $(CONFIG_OF_ALL_DTBS),$(dtb-))) subdirs := $(addprefix $(obj)/, $(subdir-y) $(subdir-m)) diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index e41dee64d429..55a72f5eb76d 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost @@ -93,7 +93,7 @@ obj := $(KBUILD_EXTMOD) src := $(obj) # Include the module's Makefile to find KBUILD_EXTRA_SYMBOLS -include $(or $(wildcard $(src)/Kbuild), $(src)/Makefile) +include $(kbuild-file) module.symvers-if-present := $(wildcard Module.symvers) output-symdump := $(KBUILD_EXTMOD)/Module.symvers