All of lore.kernel.org
 help / color / mirror / Atom feed
From: Valerii Chernous <vchernou@cisco.com>
To: Masahiro Yamada <masahiroy@kernel.org>,
	Nathan Chancellor <nathan@kernel.org>,
	Nicolas Schier <nicolas@fjasle.eu>
Cc: xe-linux-external@cisco.com, linux-kbuild@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH] scripts/Makefile.build: fix ext mod subdirs build with separate src,build dirs
Date: Mon, 15 Apr 2024 03:13:44 -0700	[thread overview]
Message-ID: <20240415101345.3807776-1-vchernou@cisco.com> (raw)

The change allow to build external modules with nested makefiles.
Current unofficial way(using "src" variable) allow to build
external(out of tree) kernel module with separating source and build
artifacts dirs but with nested makefiles it doesn't work properly.
Build system trap to recursion inside makefiles, articafts output dir
path grow with each iteration until exceed max path len and build failed
This fix update "src" var during processing subdirs and resolve
recursion issue
Usage example:
make -C KERNEL_SOURCE_TREE M=BUILD_OUT_DIR src=EXT_MOD_SRC_DIR modules

Cc: Valerii Chernous <vchernou@cisco.com>
Cc: xe-linux-external@cisco.com
Signed-off-by: Valerii Chernous <vchernou@cisco.com>
---
 scripts/Makefile.build | 1 +
 1 file changed, 1 insertion(+)

diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index a293950e2e07..75ea9052ea4a 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -490,6 +490,7 @@ $(single-subdir-goals): $(single-subdirs)
 PHONY += $(subdir-ym)
 $(subdir-ym):
 	$(Q)$(MAKE) $(build)=$@ \
+	$(if $(findstring command line,$(origin src)),src=$(patsubst $(obj)/%,$(src)/%,$@)) \
 	need-builtin=$(if $(filter $@/built-in.a, $(subdir-builtin)),1) \
 	need-modorder=$(if $(filter $@/modules.order, $(subdir-modorder)),1) \
 	$(filter $@/%, $(single-subdir-goals))
-- 
2.35.6


             reply	other threads:[~2024-04-15 10:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-15 10:13 Valerii Chernous [this message]
2024-04-15 10:32 ` [PATCH] scripts/Makefile.build: fix ext mod subdirs build with separate src,build dirs Masahiro Yamada
2024-04-15 10:55   ` Valerii Chernous -X (vchernou - GLOBALLOGIC INC at Cisco)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240415101345.3807776-1-vchernou@cisco.com \
    --to=vchernou@cisco.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masahiroy@kernel.org \
    --cc=nathan@kernel.org \
    --cc=nicolas@fjasle.eu \
    --cc=xe-linux-external@cisco.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.