mirror of
https://github.com/SCST-project/scst.git
synced 2026-05-14 09:11:27 +00:00
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:
14
Makefile
14
Makefile
@@ -20,18 +20,20 @@ SHELL = /bin/bash
|
||||
|
||||
# Define the location to the kernel src. Can be defined here or on
|
||||
# the command line during the build process. If KDIR is defined,
|
||||
# we will set an appropriate value for KVER by running "make
|
||||
# kernelversion" in the kernel source tree. KVER can still be
|
||||
# overrode by the user via the command line or by defining it in
|
||||
# this Makefile. If KDIR and KVER are not defined by the user,
|
||||
# the current running kernel version is used to define KVER.
|
||||
# we will determine an appropriate value for KVER from the kernel
|
||||
# source tree. KVER can still be overridden by the user via the
|
||||
# command line or by defining it in this Makefile. If KDIR and KVER
|
||||
# are not defined by the user, the current running kernel version is
|
||||
# used to define KVER.
|
||||
|
||||
#export KDIR=/usr/src/linux-2.6
|
||||
#export KVER=2.6.x
|
||||
|
||||
ifdef KDIR
|
||||
ifndef KVER
|
||||
export KVER = $(strip $(shell make -s -C $(KDIR) kernelversion))
|
||||
export KVER = $(strip $(shell \
|
||||
cat $(KDIR)/include/config/kernel.release 2>/dev/null || \
|
||||
make -s -C $(KDIR) kernelversion))
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -7,13 +7,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
|
||||
|
||||
# The file Modules.symvers has been renamed in the 2.6.18 kernel to
|
||||
|
||||
@@ -27,13 +27,19 @@ INCDIR := $(shell pwd)/include
|
||||
|
||||
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
|
||||
|
||||
all: include/iscsi_scst_itf_ver.h progs mods
|
||||
|
||||
16
mpt/Makefile
16
mpt/Makefile
@@ -38,7 +38,16 @@ EXTRA_CFLAGS += -DCONFIG_SCST_DEBUG
|
||||
|
||||
ifeq ($(KVER),)
|
||||
ifeq ($(KDIR),)
|
||||
KDIR := /lib/modules/$(shell uname -r)/build
|
||||
KVER := $(shell uname -r)
|
||||
KDIR := /lib/modules/$(KVER)/build
|
||||
else
|
||||
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
|
||||
@@ -50,6 +59,7 @@ EXTRA_CFLAGS += -I$(LSI_INC_DIR)
|
||||
ifneq ($(PATCHLEVEL),)
|
||||
obj-m += mpt_scst.o
|
||||
else
|
||||
######### BEGIN OUT-OF-TREE RULES #########
|
||||
|
||||
all: Modules.symvers Module.symvers
|
||||
$(MAKE) -C $(KDIR) SUBDIRS=$(shell pwd) BUILD_INI=m
|
||||
@@ -80,7 +90,9 @@ endif
|
||||
|
||||
uninstall:
|
||||
rm -f $(INSTALL_DIR)/mpt_scst.ko
|
||||
-/sbin/depmod -a
|
||||
-/sbin/depmod -a $(KVER)
|
||||
|
||||
########## END OUT-OF-TREE RULES ##########
|
||||
endif
|
||||
|
||||
clean:
|
||||
|
||||
@@ -31,13 +31,25 @@ endif
|
||||
|
||||
ifeq ($(KVER),)
|
||||
ifeq ($(KDIR),)
|
||||
KVER = $(shell uname -r)
|
||||
KVER := $(shell uname -r)
|
||||
KDIR := /lib/modules/$(KVER)/build
|
||||
else
|
||||
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
|
||||
endif
|
||||
|
||||
ifeq ($(INSTALL_MOD_PATH),)
|
||||
export INSTALL_MOD_PATH := $(DESTDIR)
|
||||
endif
|
||||
|
||||
export PWD := $(shell pwd)
|
||||
export LIBSAS := m
|
||||
|
||||
@@ -53,7 +65,7 @@ MODULE_NAME = mvsas_tgt
|
||||
|
||||
EXTRA_CFLAGS += -DMV_DEBUG
|
||||
|
||||
INSTALL_DIR := /lib/modules/$(shell uname -r)/extra
|
||||
INSTALL_DIR := $(INSTALL_MOD_PATH)/lib/modules/$(KVER)/extra
|
||||
|
||||
#EXTRA_CFLAGS += -DCONFIG_SCST_TRACING
|
||||
#EXTRA_CFLAGS += -DDEBUG_WORK_IN_THREAD
|
||||
@@ -68,6 +80,8 @@ mvsas-y := mv_init.o \
|
||||
mv_94xx.o \
|
||||
mv_spi.o
|
||||
else
|
||||
######### BEGIN OUT-OF-TREE RULES #########
|
||||
|
||||
all: Modules.symvers Module.symvers
|
||||
$(MAKE) -C $(KDIR) SUBDIRS=$(shell pwd) BUILD_INI=m
|
||||
|
||||
@@ -102,6 +116,8 @@ endif
|
||||
uninstall:
|
||||
rm -f $(INSTALL_DIR)/$(MODULE_NAME).ko
|
||||
-/sbin/depmod -a $(KVER)
|
||||
|
||||
########## END OUT-OF-TREE RULES ##########
|
||||
endif
|
||||
|
||||
clean:
|
||||
|
||||
@@ -16,6 +16,7 @@ extraclean: clean
|
||||
.PHONY: clean extraclean
|
||||
|
||||
else
|
||||
######### BEGIN OUT-OF-TREE RULES #########
|
||||
|
||||
SHELL=/bin/bash
|
||||
|
||||
@@ -32,7 +33,12 @@ endif
|
||||
|
||||
ifeq ($(KVER),)
|
||||
ifeq ($(KDIR),)
|
||||
KDIR := /lib/modules/$(shell uname -r)/build
|
||||
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
|
||||
@@ -54,6 +60,8 @@ install: all
|
||||
uninstall:
|
||||
rm -f $(INSTALL_DIR)/qla2xxxt.ko
|
||||
-/sbin/depmod -a $(KVER)
|
||||
|
||||
########## END OUT-OF-TREE RULES ##########
|
||||
endif
|
||||
|
||||
clean:
|
||||
|
||||
@@ -27,16 +27,10 @@
|
||||
# - install and uninstall must be made as root
|
||||
#
|
||||
|
||||
ifndef PREFIX
|
||||
PREFIX=/usr/local
|
||||
endif
|
||||
|
||||
SHELL=/bin/bash
|
||||
|
||||
EXTRA_CFLAGS += -I$(SCST_INC_DIR)
|
||||
|
||||
INSTALL_DIR := /lib/modules/$(shell uname -r)/extra
|
||||
|
||||
EXTRA_CFLAGS += -W -Wno-unused-parameter -Wno-missing-field-initializers
|
||||
|
||||
EXTRA_CFLAGS += -DCONFIG_SCST_EXTRACHECKS
|
||||
@@ -47,8 +41,16 @@ EXTRA_CFLAGS += -DCONFIG_SCST_DEBUG -g -fno-inline -fno-inline-functions
|
||||
|
||||
ifeq ($(KVER),)
|
||||
ifeq ($(KDIR),)
|
||||
KVER = $(shell uname -r)
|
||||
KVER := $(shell uname -r)
|
||||
KDIR := /lib/modules/$(KVER)/build
|
||||
else
|
||||
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
|
||||
@@ -69,6 +71,13 @@ ifneq ($(PATCHLEVEL),)
|
||||
obj-m := qla2x00tgt.o
|
||||
qla2x00tgt-objs := qla2x00t.o
|
||||
else
|
||||
######### BEGIN OUT-OF-TREE RULES #########
|
||||
|
||||
ifndef PREFIX
|
||||
PREFIX=/usr/local
|
||||
endif
|
||||
|
||||
INSTALL_DIR := /lib/modules/$(KVER)/extra
|
||||
|
||||
SCST_INC_DIR := $(shell if [ -e "$$PWD/../../scst" ]; \
|
||||
then echo "$$PWD/../../scst/include"; \
|
||||
@@ -130,6 +139,7 @@ else
|
||||
.PHONY: Module.symvers
|
||||
endif
|
||||
|
||||
########## END OUT-OF-TREE RULES ##########
|
||||
endif
|
||||
|
||||
clean:
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -2,10 +2,6 @@
|
||||
# A Makefile for the scst-local ...
|
||||
#
|
||||
|
||||
ifndef PREFIX
|
||||
PREFIX=/usr/local
|
||||
endif
|
||||
|
||||
SHELL=/bin/bash
|
||||
|
||||
KMOD := $(shell pwd)/kernel
|
||||
@@ -24,17 +20,28 @@ EXTRA_CFLAGS += -DCONFIG_SCST_EXTRACHECKS
|
||||
|
||||
EXTRA_CFLAGS += -DCONFIG_SCST_DEBUG -g -fno-inline -fno-inline-functions
|
||||
|
||||
ifneq ($(PATCHLEVEL),)
|
||||
obj-m := scst_local.o
|
||||
else
|
||||
######### BEGIN OUT-OF-TREE RULES #########
|
||||
|
||||
ifndef PREFIX
|
||||
PREFIX=/usr/local
|
||||
endif
|
||||
|
||||
ifeq ($(KVER),)
|
||||
ifeq ($(KDIR),)
|
||||
KDIR := /lib/modules/$(shell uname -r)/build
|
||||
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
|
||||
|
||||
ifneq ($(PATCHLEVEL),)
|
||||
obj-m := scst_local.o
|
||||
else
|
||||
|
||||
SCST_INC_DIR := $(shell if [ -e "$$PWD/../scst" ]; \
|
||||
then echo "$$PWD/../scst/include"; \
|
||||
@@ -71,6 +78,8 @@ endif
|
||||
uninstall:
|
||||
rm -f $(INSTALL_DIR)/scst_local.ko
|
||||
-/sbin/depmod -a $(KVER)
|
||||
|
||||
########## END OUT-OF-TREE RULES ##########
|
||||
endif
|
||||
|
||||
clean:
|
||||
|
||||
@@ -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).
|
||||
|
||||
Reference in New Issue
Block a user