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
+9 -5
View File
@@ -54,10 +54,16 @@ obj-$(CONFIG_SCST) += scst.o dev_handlers/
obj-$(BUILD_DEV) += $(DEV_HANDLERS_DIR)/
else
######### BEGIN OUT-OF-TREE RULES #########
ifeq ($(KVER),)
ifeq ($(KDIR),)
KVER = $(shell uname -r)
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
@@ -118,13 +124,11 @@ uninstall:
-rmdir $(INSTALL_DIR) 2>/dev/null
-/sbin/depmod -a $(KVER)
rm -rf $(INSTALL_DIR_H)
########## END OUT-OF-TREE RULES ##########
endif
ifeq ($(KVER),)
INSTALL_DIR := $(DESTDIR)/lib/modules/$(shell uname -r)/extra
else
INSTALL_DIR := $(DESTDIR)/lib/modules/$(KVER)/extra
endif
INSTALL_DIR_H := $(DESTDIR)$(PREFIX)/include/scst
enable-Wextra = $(shell uname_r="$$(uname -r)"; if [ "$${uname_r%.el5}" = "$${uname_r}" ]; then echo "$(1)"; fi)
+15 -7
View File
@@ -46,11 +46,23 @@ obj-$(CONFIG_SCST_VDISK) += scst_vdisk.o
obj-$(CONFIG_SCST_USER) += scst_user.o
else
ifeq ($(KDIR),)
KVER = $(shell uname -r)
######### BEGIN OUT-OF-TREE RULES #########
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
all:
$(MAKE) -C $(KDIR) SUBDIRS=$(shell pwd)
@@ -60,12 +72,8 @@ install: all
uninstall:
rm -f $(INSTALL_DIR)/dev_handlers/scst_*.ko
endif
ifeq ($(KVER),)
INSTALL_DIR := /lib/modules/$(shell uname -r)/extra
else
INSTALL_DIR := /lib/modules/$(KVER)/extra
########## END OUT-OF-TREE RULES ##########
endif
enable-Wextra = $(shell uname_r="$$(uname -r)"; if [ "$${uname_r%.el5}" = "$${uname_r}" ]; then echo "$(1)"; fi)