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>
diff --git a/scripts/depmod.sh b/scripts/depmod.sh
index 3643b4f..2de598d 100755
--- a/scripts/depmod.sh
+++ b/scripts/depmod.sh
@@ -3,14 +3,15 @@
 #
 # A depmod wrapper used by the toplevel Makefile
 
-if test $# -ne 2; then
-	echo "Usage: $0 /sbin/depmod <kernelrelease>" >&2
+if test $# -ne 2 -a $# -ne 3; then
+	echo "Usage: $0 /sbin/depmod <kernelrelease> [System.map folder]" >&2
 	exit 1
 fi
 DEPMOD=$1
 KERNELRELEASE=$2
+KBUILD_MIXED_TREE=$3
 
-if ! test -r System.map ; then
+if ! test -r ${KBUILD_MIXED_TREE}System.map ; then
 	echo "Warning: modules_install: missing 'System.map' file. Skipping depmod." >&2
 	exit 0
 fi
@@ -41,7 +42,7 @@
 	KERNELRELEASE=99.98.$KERNELRELEASE
 fi
 
-set -- -ae -F System.map
+set -- -ae -F ${KBUILD_MIXED_TREE}System.map
 if test -n "$INSTALL_MOD_PATH"; then
 	set -- "$@" -b "$INSTALL_MOD_PATH"
 fi