ANDROID: modpost: Support relative paths for module_srcpath

If a relative path is used for EXT_MODULES and -O is defined, then we
need to set the module_srcpath as relative to $(srctree) vs $(objtree).
Refer to [1] for more details.

[1] https://lore.kernel.org/lkml/20210120193100.3414664-1-masahiroy@kernel.org/

Bug: 180027765
Signed-off-by: Will McVicker <willmcvicker@google.com>
Change-Id: I17065f2dc7d5c3297f88500390a6f45aceea7229
This commit is contained in:
Will McVicker
2021-02-11 11:40:05 -08:00
parent da2089a28a
commit cca2b40a78

View File

@@ -86,7 +86,17 @@ MODPOST += -e
input-symdump := Module.symvers $(KBUILD_EXTRA_SYMBOLS)
output-symdump := $(KBUILD_EXTMOD)/Module.symvers
module_srcpath := $(KBUILD_EXTMOD)
# Get the external module's source path. KBUILD_EXTMOD could either be an
# absolute path or relative path from $(srctree). This makes sure that we
# aren't using a relative path from a separate working directory (O= or
# KBUILD_OUTPUT) since that may not be the actual module's SCM project path. So
# check the path relative to $(srctree) first.
ifneq ($(realpath $(srctree)/$(KBUILD_EXTMOD) 2>/dev/null),)
module_srcpath := $(srctree)/$(KBUILD_EXTMOD)
else
module_srcpath := $(KBUILD_EXTMOD)
endif
endif