public inbox for linux-kbuild@vger.kernel.org
 help / color / mirror / Atom feed
From: 袁建鹏 <yuanjianpeng@xiaomi.com>
To: masahiroy <masahiroy@kernel.org>, nathan <nathan@kernel.org>,
	ndesaulniers <ndesaulniers@google.com>,
	nicolas <nicolas@fjasle.eu>,
	linux-kbuild <linux-kbuild@vger.kernel.org>
Cc: linux-kernel <linux-kernel@vger.kernel.org>
Subject: [PATCH] kbuild: support external module out-of-tree build
Date: Sat, 25 Mar 2023 06:25:19 +0000	[thread overview]
Message-ID: <e58cba84c90c40108ac678500f33655e@xiaomi.com> (raw)

From 205af45582ad0cb1293839a95ee01d383f1cfbf1 Mon Sep 17 00:00:00 2001
From: Yuan Jianpeng <yuanjianpeng@xiaomi.com>
Date: Sat, 25 Mar 2023 10:24:38 +0800
Subject: [PATCH] kbuild: support external module out-of-tree build

A new module build variable KBUILD_EXTMOD_SRC is added which
specifying the external module source path.

Build like this:
make -C $KDIR M=<output dir> KBUILD_EXTMOD_SRC=<module source dir>

Signed-off-by: Yuan Jianpeng <yuanjianpeng@xiaomi.com>
---
 scripts/Makefile.build   | 2 +-
 scripts/Makefile.clean   | 2 +-
 scripts/Makefile.modpost | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 76323201232a..971a2161d502 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -3,7 +3,7 @@
 # Building
 # ==========================================================================

-src := $(obj)
+src := $(if $(KBUILD_EXTMOD_SRC),$(KBUILD_EXTMOD_SRC)$(patsubst $(KBUILD_EXTMOD)%,%,$(obj)),$(obj))

 PHONY := $(obj)/
 $(obj)/:
diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
index 3649900696dd..5232a0b6e139 100644
--- a/scripts/Makefile.clean
+++ b/scripts/Makefile.clean
@@ -3,7 +3,7 @@
 # Cleaning up
 # ==========================================================================

-src := $(obj)
+src := $(if $(KBUILD_EXTMOD_SRC),$(KBUILD_EXTMOD_SRC)$(patsubst $(KBUILD_EXTMOD)%,%,$(obj)),$(obj))

 PHONY := __clean
 __clean:
diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost
index 0980c58d8afc..3f0b23157c68 100644
--- a/scripts/Makefile.modpost
+++ b/scripts/Makefile.modpost
@@ -103,7 +103,7 @@ else

 # set src + obj - they may be used in the modules's Makefile
 obj := $(KBUILD_EXTMOD)
-src := $(obj)
+src := $(if $(KBUILD_EXTMOD_SRC),$(KBUILD_EXTMOD_SRC)$(patsubst $(KBUILD_EXTMOD)%,%,$(obj)),$(obj))

 # Include the module's Makefile to find KBUILD_EXTRA_SYMBOLS
 include $(kbuild-file)
--
2.38.1

#/******本邮件及其附件含有小米公司的保密信息,仅限于发送给上面地址中列出的个人或群组。禁止任何其他人以任何形式使用(包括但不限于全部或部分地泄露、复制、或散发)本邮件中的信息。如果您错收了本邮件,请您立即电话或邮件通知发件人并删除本邮件! This e-mail and its attachments contain confidential information from XIAOMI, which is intended only for the person or entity whose address is listed above. Any use of the information contained herein in any way (including, but not limited to, total or partial disclosure, reproduction, or dissemination) by persons other than the intended recipient(s) is prohibited. If you receive this e-mail in error, please notify the sender by phone or email immediately and delete it!******/#

                 reply	other threads:[~2023-03-25  6:26 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=e58cba84c90c40108ac678500f33655e@xiaomi.com \
    --to=yuanjianpeng@xiaomi.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masahiroy@kernel.org \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=nicolas@fjasle.eu \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox