|
@@ -225,6 +225,20 @@ export KBUILD_CHECKSRC KBUILD_EXTMOD
|
|
|
|
|
|
extmod-prefix = $(if $(KBUILD_EXTMOD),$(KBUILD_EXTMOD)/)
|
|
|
|
|
|
+# ANDROID: set up mixed-build support. mixed-build allows device kernel modules
|
|
|
+# to be compiled against a GKI kernel. This approach still uses the headers and
|
|
|
+# Kbuild from device kernel, so care must be taken to ensure that those headers match.
|
|
|
+ifdef KBUILD_MIXED_TREE
|
|
|
+# Need vmlinux.symvers for modpost and System.map for depmod, check whether they exist in KBUILD_MIXED_TREE
|
|
|
+required_mixed_files=vmlinux.symvers System.map
|
|
|
+$(if $(filter-out $(words $(required_mixed_files)), \
|
|
|
+ $(words $(wildcard $(add-prefix $(KBUILD_MIXED_TREE)/,$(required_mixed_files))))),,\
|
|
|
+ $(error KBUILD_MIXED_TREE=$(KBUILD_MIXED_TREE) doesn't contain $(required_mixed_files)))
|
|
|
+endif
|
|
|
+
|
|
|
+mixed-build-prefix = $(if $(KBUILD_MIXED_TREE),$(KBUILD_MIXED_TREE)/)
|
|
|
+export KBUILD_MIXED_TREE
|
|
|
+
|
|
|
ifeq ($(abs_srctree),$(abs_objtree))
|
|
|
# building in the source tree
|
|
|
srctree := .
|
|
@@ -655,11 +669,13 @@ drivers-y += net/ virt/
|
|
|
libs-y := lib/
|
|
|
endif # KBUILD_EXTMOD
|
|
|
|
|
|
+ifndef KBUILD_MIXED_TREE
|
|
|
# The all: target is the default when no target is given on the
|
|
|
# command line.
|
|
|
# This allow a user to issue only 'make' to build a kernel including modules
|
|
|
# Defaults to vmlinux, but the arch makefile usually adds further targets
|
|
|
all: vmlinux
|
|
|
+endif
|
|
|
|
|
|
CFLAGS_GCOV := -fprofile-arcs -ftest-coverage \
|
|
|
$(call cc-option,-fno-tree-loop-im) \
|
|
@@ -1255,8 +1271,10 @@ cmd_link-vmlinux = \
|
|
|
$(CONFIG_SHELL) $< "$(LD)" "$(KBUILD_LDFLAGS)" "$(LDFLAGS_vmlinux)"; \
|
|
|
$(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true)
|
|
|
|
|
|
+ifndef KBUILD_MIXED_TREE
|
|
|
vmlinux: scripts/link-vmlinux.sh autoksyms_recursive $(vmlinux-deps) FORCE
|
|
|
+$(call if_changed,link-vmlinux)
|
|
|
+endif
|
|
|
|
|
|
targets := vmlinux
|
|
|
|
|
@@ -1472,7 +1490,9 @@ endif
|
|
|
# using awk while concatenating to the final file.
|
|
|
|
|
|
PHONY += modules
|
|
|
-modules: $(if $(KBUILD_BUILTIN),vmlinux) modules_check modules_prepare
|
|
|
+# if KBUILD_BUILTIN && !KBUILD_MIXED_TREE, depend on vmlinux
|
|
|
+modules: $(if $(KBUILD_BUILTIN), $(if $(KBUILD_MIXED_TREE),,vmlinux))
|
|
|
+modules: modules_check modules_prepare
|
|
|
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
|
|
|
|
|
|
PHONY += modules_check
|
|
@@ -1506,8 +1526,8 @@ _modinst_:
|
|
|
ln -s $(CURDIR) $(MODLIB)/build ; \
|
|
|
fi
|
|
|
@sed 's:^:kernel/:' modules.order > $(MODLIB)/modules.order
|
|
|
- @cp -f modules.builtin $(MODLIB)/
|
|
|
- @cp -f $(objtree)/modules.builtin.modinfo $(MODLIB)/
|
|
|
+ @cp -f $(mixed-build-prefix)modules.builtin $(MODLIB)/
|
|
|
+ @cp -f $(or $(mixed-build-prefix),$(objtree)/)modules.builtin.modinfo $(MODLIB)/
|
|
|
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst
|
|
|
|
|
|
# This depmod is only for convenience to give the initial
|
|
@@ -1886,7 +1906,7 @@ descend: $(build-dirs)
|
|
|
$(build-dirs): prepare
|
|
|
$(Q)$(MAKE) $(build)=$@ \
|
|
|
single-build=$(if $(filter-out $@/, $(filter $@/%, $(KBUILD_SINGLE_TARGETS))),1) \
|
|
|
- need-builtin=1 need-modorder=1
|
|
|
+ $(if $(KBUILD_MIXED_TREE),,need-builtin=1) need-modorder=1
|
|
|
|
|
|
clean-dirs := $(addprefix _clean_, $(clean-dirs))
|
|
|
PHONY += $(clean-dirs) clean
|
|
@@ -2020,7 +2040,7 @@ quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files))
|
|
|
# Run depmod only if we have System.map and depmod is executable
|
|
|
quiet_cmd_depmod = DEPMOD $(KERNELRELEASE)
|
|
|
cmd_depmod = $(CONFIG_SHELL) $(srctree)/scripts/depmod.sh $(DEPMOD) \
|
|
|
- $(KERNELRELEASE)
|
|
|
+ $(KERNELRELEASE) $(mixed-build-prefix)
|
|
|
|
|
|
# read saved command lines for existing targets
|
|
|
existing-targets := $(wildcard $(sort $(targets)))
|