Makefiles: calculate KVER properly

When deriving the kernel version (KVER) from KDIR, the file
$(KDIR)/include/config/kernel.release should be preferred over
'make kernelversion'.

For example, the Ubuntu 3.2.0-23-generic kernel has a kernel.release
file containing '3.2.0-23-generic', but 'make kernelversion' returns
3.2.14. Since the modules are stored under /lib/modules/3.2.0-23-generic,
the value in kernel.release is the correct one to use.
    
Also:
- Evaluate KVER only once
- All depmod commands must include KVER
    
Signed-off-by: Steven J. Magnani <steve@digidescorp.com>
[bvanassche: Split long lines / removed trailing whitespace]


git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@5286 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Bart Van Assche
2014-02-14 15:52:10 +00:00
parent ff857a394a
commit 79b8ce942e
12 changed files with 160 additions and 65 deletions
+23 -15
View File
@@ -26,19 +26,6 @@
# - install and uninstall must be made as root
#
ifndef PREFIX
PREFIX=/usr/local
endif
ifeq ($(KVER),)
ifeq ($(KDIR),)
KVER = $(shell uname -r)
KDIR := /lib/modules/$(KVER)/build
endif
else
KDIR := /lib/modules/$(KVER)/build
endif
export PWD := $(shell pwd)
export CONFIG_FCST := m
@@ -55,11 +42,30 @@ EXTRA_CFLAGS += -I$(SCST_INC_DIR) $(FCSTFLAGS$(BUILDMODE))
MODULE_NAME = fcst
INSTALL_DIR := /lib/modules/$(KVER)/extra
ifneq ($(KERNELRELEASE),)
include $(SUBDIRS)/Makefile_in-tree
else
######### BEGIN OUT-OF-TREE RULES #########
ifndef PREFIX
PREFIX=/usr/local
endif
ifeq ($(KVER),)
ifeq ($(KDIR),)
KVER := $(shell uname -r)
KDIR := /lib/modules/$(KVER)/build
else
KVER := $(strip $(shell \
cat $(KDIR)/include/config/kernel.release 2>/dev/null || \
make -s -C $(KDIR) kernelversion))
endif
else
KDIR := /lib/modules/$(KVER)/build
endif
INSTALL_DIR := /lib/modules/$(KVER)/extra
SCST_INC_DIR := $(shell if [ -e "$$PWD/../scst" ]; \
then echo "$$PWD/../scst/include"; \
else echo "$(PREFIX)/include/scst"; fi)
@@ -102,6 +108,8 @@ endif
uninstall:
rm -f $(INSTALL_DIR)/$(MODULE_NAME).ko
-/sbin/depmod -a $(KVER)
########## END OUT-OF-TREE RULES ##########
endif
clean: