From: David Gow <davidgow@google.com>
To: Masahiro Yamada <masahiroy@kernel.org>,
Nathan Chancellor <nathan@kernel.org>,
Nick Desaulniers <ndesaulniers@google.com>,
Nicolas Schier <nicolas@fjasle.eu>,
Jonathan Corbet <corbet@lwn.net>
Cc: Sadiya Kazi <sadiyakazi@google.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
Brendan Higgins <brendanhiggins@google.com>,
linux-kbuild@vger.kernel.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org, David Gow <davidgow@google.com>
Subject: [PATCH] Documentation: kbuild: Add note about using (subst m,y)
Date: Tue, 28 Feb 2023 11:13:18 +0800 [thread overview]
Message-ID: <20230228031317.3415484-1-davidgow@google.com> (raw)
THe kbuild documentation already notes that, where there's an obj-y
target in a subdirectory, it will be orphaned if the subdirectory uses
obj-m. Suggest a way of forcing the directory to obj-y when it's based
on a config option which could be 'm'.
Linus made several suggestions as to how this is usually done here:
https://lore.kernel.org/linux-kselftest/CAHk-=wgK07PQ_DBBbAbSJ41t__6de1xZ6q7RRu-JS=2SU0wqLQ@mail.gmail.com/
This only documents the first one, which seems most common.
Signed-off-by: David Gow <davidgow@google.com>
---
Documentation/kbuild/makefiles.rst | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/Documentation/kbuild/makefiles.rst b/Documentation/kbuild/makefiles.rst
index e67eb261c9b0..d9eb24799f52 100644
--- a/Documentation/kbuild/makefiles.rst
+++ b/Documentation/kbuild/makefiles.rst
@@ -254,6 +254,17 @@ from that directory will be linked into vmlinux. If the Makefile in
that directory specifies obj-y, those objects will be left orphan.
It is very likely a bug of the Makefile or of dependencies in Kconfig.
+This means that, if a directory contains both obj-y and obj-m targets,
+it should be added with obj-y. If this directory nevertheless should
+only be built when a config option is enabled (typically to support
+a module which requires one or two files to nevertheless be built-in),
+'subst m,y' can be used to ensure obj-y is used.
+
+Example::
+
+ #drivers/Makefile
+ obj-$(subst m,y,$(CONFIG_HYPERV)) += hv/
+
Kbuild also supports dedicated syntax, subdir-y and subdir-m, for
descending into subdirectories. It is a good fit when you know they
do not contain kernel-space objects at all. A typical usage is to let
--
2.39.2.722.g9855ee24e9-goog
next reply other threads:[~2023-02-28 3:13 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-28 3:13 David Gow [this message]
2023-02-28 8:30 ` [PATCH] Documentation: kbuild: Add note about using (subst m,y) Masahiro Yamada
2023-02-28 15:15 ` Alexander Lobakin
2023-02-28 16:25 ` Masahiro Yamada
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=20230228031317.3415484-1-davidgow@google.com \
--to=davidgow@google.com \
--cc=brendanhiggins@google.com \
--cc=corbet@lwn.net \
--cc=linux-doc@vger.kernel.org \
--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 \
--cc=sadiyakazi@google.com \
--cc=torvalds@linux-foundation.org \
/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