[PATCH] Documentation: kbuild: Add note about using (subst m,y)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


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:

This only documents the first one, which seems most common.

Signed-off-by: David Gow <davidgow@xxxxxxxxxx>
 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.
+  #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

[Index of Archives]     [Linux&nblp;USB Development]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite Secrets]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux