include: Correctly determine MODULES_DIR for external/git kernels ep93xx
authorFlorian Fainelli <f.fainelli@gmail.com>
Wed, 10 May 2017 02:56:37 +0000 (19:56 -0700)
committerFlorian Fainelli <f.fainelli@gmail.com>
Wed, 10 May 2017 03:57:29 +0000 (20:57 -0700)
insmod will refuse to automatically load any module unless it is
installed in /lib/modules/$(uname -r). When using external or git cloned
kernels, the version is typically different from what is extracted from
KERNEL_BASE.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
include/kernel.mk

index 2314ec73aa1f5fd3259e6c7bad864ad81a69b036..f48e41a3012ae986358ef6c366787e64ca392759 100644 (file)
@@ -51,17 +51,19 @@ else
     LINUX_UNAME_VERSION:=$(LINUX_UNAME_VERSION)-$(strip $(lastword $(subst -, ,$(LINUX_VERSION))))
   endif
 
-  MODULES_SUBDIR:=lib/modules/$(LINUX_UNAME_VERSION)
-  TARGET_MODULES_DIR := $(LINUX_TARGET_DIR)/$(MODULES_SUBDIR)
-
   LINUX_KERNEL:=$(KERNEL_BUILD_DIR)/vmlinux
 
   LINUX_SOURCE:=linux-$(LINUX_VERSION).tar.xz
   TESTING:=$(if $(findstring -rc,$(LINUX_VERSION)),/testing,)
   ifeq ($(call qstrip,$(CONFIG_EXTERNAL_KERNEL_TREE))$(call qstrip,$(CONFIG_KERNEL_GIT_CLONE_URI)),)
       LINUX_SITE:=@KERNEL/linux/kernel/v$(word 1,$(subst ., ,$(KERNEL_BASE))).x$(TESTING)
+  else
+      LINUX_UNAME_VERSION:=$(strip $(shell cat $(LINUX_DIR)/include/config/kernel.release))
   endif
 
+  MODULES_SUBDIR:=lib/modules/$(LINUX_UNAME_VERSION)
+  TARGET_MODULES_DIR := $(LINUX_TARGET_DIR)/$(MODULES_SUBDIR)
+
   ifneq ($(TARGET_BUILD),1)
     PKG_BUILD_DIR ?= $(KERNEL_BUILD_DIR)/$(PKG_NAME)$(if $(PKG_VERSION),-$(PKG_VERSION))
   endif