ANDROID: Kbuild: Add support for KBUILD_MIXED_TREE
When KBUILD_MIXED_TREE points to the output folder of another kernel's
build output, Kbuild can compile a complete kernel tree's modules
against that other kernel tree's vmlinux. This is useful when two
kernel trees exist: a "Generic Kernel Image" tree and a "device kernel"
tree. Both trees are complete kernel source trees, and the "Generic
Kernel Image" should provide the kernel Image and device kernel tree
provides device driver modules.
To accomplish this, references to vmlinux.symvers in the device kernel
should point to the generic kernel's vmlinux.symvers and the device
kernel should skip compilation of built-in files.
Bug: 178469391
Change-Id: I614f3e87519236c4e2c5da74937cb0ecd98a278a
Signed-off-by: Elliot Berman <eberman@codeaurora.org>
Signed-off-by: Giuliano Procida <gprocida@google.com>
diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost
index e8bac75..6f63779 100644
--- a/scripts/Makefile.modpost
+++ b/scripts/Makefile.modpost
@@ -46,6 +46,8 @@
# for ld_flags
include scripts/Makefile.lib
+mixed-build-prefix = $(if $(KBUILD_MIXED_TREE),$(KBUILD_MIXED_TREE)/)
+
MODPOST = scripts/mod/modpost \
$(if $(CONFIG_MODVERSIONS),-m) \
$(if $(CONFIG_MODULE_SRCVERSION_ALL),-a) \
@@ -67,7 +69,7 @@
ifeq ($(KBUILD_EXTMOD),)
-input-symdump := vmlinux.symvers
+input-symdump := $(mixed-build-prefix)vmlinux.symvers
output-symdump := Module.symvers
module_srcpath := $(srctree)