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
+10 -4
View File
@@ -15,13 +15,19 @@ SUBDIRS := $(shell pwd)
ifeq ($(KVER),)
ifeq ($(KDIR),)
KVER = $(shell uname -r)
KDIR ?= /lib/modules/$(KVER)/build
KVER := $(shell uname -r)
KDIR := /lib/modules/$(KVER)/build
else
KVER = $$KERNELRELEASE
ifeq ($(KERNELRELEASE),)
KVER := $(strip $(shell \
cat $(KDIR)/include/config/kernel.release 2>/dev/null || \
make -s -C $(KDIR) kernelversion))
else
KVER := $(KERNELRELEASE)
endif
endif
else
KDIR ?= /lib/modules/$(KVER)/build
KDIR := /lib/modules/$(KVER)/build
endif
# Set variable $(2) to value $(3) in file $(1).